diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-08-12 09:28:15 +0200 |
commit | 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 (patch) | |
tree | 577a29fb579188d16003a209ce2a2e9c5b0aa2bd /extensions/Vector/modules | |
parent | cacc939b34e315b85e2d72997811eb6677996cc1 (diff) |
Update to MediaWiki 1.21.1
Diffstat (limited to 'extensions/Vector/modules')
9 files changed, 295 insertions, 251 deletions
diff --git a/extensions/Vector/modules/ext.vector.collapsibleNav.css b/extensions/Vector/modules/ext.vector.collapsibleNav.css index fc9246b0..b9c27355 100644 --- a/extensions/Vector/modules/ext.vector.collapsibleNav.css +++ b/extensions/Vector/modules/ext.vector.collapsibleNav.css @@ -1,5 +1,7 @@ /** * Stylesheet for collapsible nav + * NOTE: Please remove all the h5 selectors at some point as they are only for + * backwards-compatibility due to html caching. --2012-11-28 */ #mw-panel.collapsible-nav .portal { @@ -9,6 +11,7 @@ margin: -11px 9px 10px 11px; } +#mw-panel.collapsible-nav .portal h3, #mw-panel.collapsible-nav .portal h5 { color: #4D4D4D; font-weight: normal; @@ -18,11 +21,13 @@ margin-bottom: 0; } +#mw-panel.collapsible-nav .portal h3:hover, #mw-panel.collapsible-nav .portal h5:hover { cursor: pointer; text-decoration: none; } +#mw-panel.collapsible-nav .portal h3 a, #mw-panel.collapsible-nav .portal h5 a { color: #4D4D4D; text-decoration: none; @@ -39,7 +44,7 @@ } /* First */ - +#mw-panel.collapsible-nav .portal.first h3, #mw-panel.collapsible-nav .portal.first h5 { display: none; } @@ -55,6 +60,7 @@ display: block; } +#mw-panel.collapsible-nav .portal.persistent h3, #mw-panel.collapsible-nav .portal.persistent h5 { background: none !important; padding-left: 0.7em; @@ -67,6 +73,7 @@ /* Collapsed */ +#mw-panel.collapsible-nav .portal.collapsed h3, #mw-panel.collapsible-nav .portal.collapsed h5 { color: #0645AD; /* @embed */ @@ -74,10 +81,12 @@ margin-bottom: 0; } +#mw-panel.collapsible-nav .portal.collapsed h3 a, #mw-panel.collapsible-nav .portal.collapsed h5 a { color: #0645AD; } +#mw-panel.collapsible-nav .portal.collapsed h3:hover, #mw-panel.collapsible-nav .portal.collapsed h5:hover { text-decoration: underline; } diff --git a/extensions/Vector/modules/ext.vector.collapsibleNav.js b/extensions/Vector/modules/ext.vector.collapsibleNav.js index 85143014..28a85676 100644 --- a/extensions/Vector/modules/ext.vector.collapsibleNav.js +++ b/extensions/Vector/modules/ext.vector.collapsibleNav.js @@ -174,8 +174,8 @@ if ( $secondary.children().length === 0 ) { $secondary.remove(); } else { - $( '#p-lang' ).after( '<div id="p-lang-more" class="portal"><h5></h5><div class="body"></div></div>' ); - $( '#p-lang-more h5' ).text( mw.msg( 'vector-collapsiblenav-more' ) ); + $( '#p-lang' ).after( '<div id="p-lang-more" class="portal"><h3></h3><div class="body"></div></div>' ); + $( '#p-lang-more h3' ).text( mw.msg( 'vector-collapsiblenav-more' ) ); $secondary.appendTo( $( '#p-lang-more .body' ) ); } // Always show the primary interwiki language portal @@ -194,7 +194,7 @@ var id = $(this).attr( 'id' ), state = $.cookie( 'vector-nav-' + id ); // Add anchor tag to heading for better accessibility - $( this ).find( 'h5' ).wrapInner( $( '<a href="#"></a>' ).click( false ) ); + $( this ).find( 'h3, h5' ).wrapInner( $( '<a href="#"></a>' ).click( false ) ); // In the case that we are not showing the new version, let's show the languages by default if ( state === 'true' || @@ -220,7 +220,7 @@ /* Tab Indexing */ - $headings = $( '#mw-panel > .portal:not(.persistent) > h5' ); + $headings = $( '#mw-panel > .portal:not(.persistent) > h3, #mw-panel > .portal:not(.persistent) > h5' ); // Get the highest tab index tabIndex = $( document ).lastTabIndex() + 1; @@ -235,13 +235,13 @@ // Toggle the selected menu's class and expand or collapse the menu $( '#mw-panel' ) - .delegate( '.portal:not(.persistent) > h5', 'keydown', function ( e ) { + .delegate( '.portal:not(.persistent) > h3, .portal:not(.persistent) > h5', 'keydown', function ( e ) { // Make the space and enter keys act as a click if ( e.which === 13 /* Enter */ || e.which === 32 /* Space */ ) { toggle( $(this) ); } } ) - .delegate( '.portal:not(.persistent) > h5', 'mousedown', function ( e ) { + .delegate( '.portal:not(.persistent) > h3, .portal:not(.persistent) > h5', 'mousedown', function ( e ) { if ( e.which !== 3 ) { // Right mouse click toggle( $(this) ); $(this).blur(); diff --git a/extensions/Vector/modules/ext.vector.collapsibleTabs.js b/extensions/Vector/modules/ext.vector.collapsibleTabs.js index 31f91cbb..439a1995 100644 --- a/extensions/Vector/modules/ext.vector.collapsibleTabs.js +++ b/extensions/Vector/modules/ext.vector.collapsibleTabs.js @@ -2,124 +2,28 @@ * Collapsible tabs for Vector */ jQuery( function ( $ ) { - var rtl = $( 'body' ).is( '.rtl' ); - - // Overloading the moveToCollapsed function to animate the transition - $.collapsibleTabs.moveToCollapsed = function ( ele ) { - var $moving = $( ele ); - - //$.collapsibleTabs.getSettings( $( $.collapsibleTabs.getSettings( $moving ).expandedContainer ) ).shifting = true; - // Do the above, except with guards for JS errors - var data = $.collapsibleTabs.getSettings( $moving ); - if ( !data ) { - return; - } - var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); - if ( !expContainerSettings ) { - return; - } - expContainerSettings.shifting = true; + var $cactions = $( '#p-cactions' ); - // Remove the element from where it's at and put it in the dropdown menu - var target = data.collapsedContainer; - $moving.css( 'position', 'relative' ) - .css( ( rtl ? 'left' : 'right' ), 0 ) - .animate( { width: '1px' }, 'normal', function () { - var data; - $( this ).hide(); - // add the placeholder - $( '<span class="placeholder" style="display: none;"></span>' ).insertAfter( this ); - // XXX: 'data' is undefined here, should the 'data' from the outer scope have - // a different name? - $( this ).detach().prependTo( target ).data( 'collapsibleTabsSettings', data ); - $( this ).attr( 'style', 'display: list-item;' ); - // $.collapsibleTabs.getSettings( $( $.collapsibleTabs.getSettings( $( ele ) ).expandedContainer ) ) - // .shifting = false; - // Do the above, except with guards for accessing properties of undefined. - data = $.collapsibleTabs.getSettings( $( ele ) ); - if ( data ) { - var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); - if ( expContainerSettings ) { - expContainerSettings.shifting = false; - $.collapsibleTabs.handleResize(); - } - } - } ); - }; - - // Overloading the moveToExpanded function to animate the transition - $.collapsibleTabs.moveToExpanded = function ( ele ) { - var $moving = $( ele ); - //$.collapsibleTabs.getSettings( $( $.collapsibleTabs.getSettings( $moving ).expandedContainer ) ).shifting = true; - // Do the above, except with guards for accessing properties of undefined. - var data = $.collapsibleTabs.getSettings( $moving ); - if ( !data ) { - return; - } - var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); - if ( !expContainerSettings ) { - return; - } - expContainerSettings.shifting = true; - - // grab the next appearing placeholder so we can use it for replacing - var $target = $( data.expandedContainer ).find( 'span.placeholder:first' ); - var expandedWidth = data.expandedWidth; - $moving.css( 'position', 'relative' ).css( ( rtl ? 'right' : 'left' ), 0 ).css( 'width', '1px' ); - $target.replaceWith( - $moving - .detach() - .css( 'width', '1px' ) - .data( 'collapsibleTabsSettings', data ) - .animate( { width: expandedWidth + 'px' }, 'normal', function () { - $( this ).attr( 'style', 'display: block;' ); - //$.collapsibleTabs.getSettings( $( $.collapsibleTabs.getSettings( $( ele ) ).expandedContainer ) ) - // .shifting = false; - // Do the above, except with guards for accessing properties of undefined. - var data = $.collapsibleTabs.getSettings( $( this ) ); - if ( data ) { - var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); - if ( expContainerSettings ) { - expContainerSettings.shifting = false; - $.collapsibleTabs.handleResize(); - } - } - } ) - ); - }; - // Bind callback functions to animate our drop down menu in and out - // and then call the collapsibleTabs function on the menu - $( '#p-views ul' ).bind( 'beforeTabCollapse', function () { - if ( $( '#p-cactions' ).css( 'display' ) === 'none' ) { - $( '#p-cactions' ) - .addClass( 'filledPortlet' ).removeClass( 'emptyPortlet' ) - .find( 'h5' ) - .css( 'width','1px' ).animate( { 'width':'26px' }, 390 ); - } - } ).bind( 'beforeTabExpand', function () { - if ( $( '#p-cactions li' ).length === 1 ) { - $( '#p-cactions h5' ).animate( { 'width':'1px' }, 370, function () { - $( this ).attr( 'style', '' ) - .parent().addClass( 'emptyPortlet' ).removeClass( 'filledPortlet' ); - }); - } - } ).collapsibleTabs( { - expandCondition: function ( eleWidth ) { - if ( rtl ) { - return ( $( '#right-navigation' ).position().left + $( '#right-navigation' ).width() + 1 ) - < ( $( '#left-navigation' ).position().left - eleWidth ); + // and then call the collapsibleTabs function on the menu + $( '#p-views ul' ) + .bind( 'beforeTabCollapse', function () { + // If the dropdown was hidden, show it + if ( $cactions.hasClass( 'emptyPortlet' ) ) { + $cactions + .removeClass( 'emptyPortlet' ) + .find( 'h3, h5' ) + .css( 'width', '1px' ).animate( { 'width': '24px' }, 390 ); } - return ( $( '#left-navigation' ).position().left + $( '#left-navigation' ).width() + 1 ) - < ( $( '#right-navigation' ).position().left - eleWidth ); - }, - collapseCondition: function () { - if ( rtl ) { - return ( $( '#right-navigation' ).position().left + $( '#right-navigation' ).width() ) - > $( '#left-navigation' ).position().left; + } ) + .bind( 'beforeTabExpand', function () { + // If we're removing the last child node right now, hide the dropdown + if ( $cactions.find( 'li' ).length === 1 ) { + $cactions.find( 'h3, h5' ).animate( { 'width': '1px' }, 390, function () { + $( this ).attr( 'style', '' ) + .parent().addClass( 'emptyPortlet' ); + }); } - return ( $( '#left-navigation' ).position().left + $( '#left-navigation' ).width() ) - > $( '#right-navigation' ).position().left; - } - } ); + } ) + .collapsibleTabs(); } ); diff --git a/extensions/Vector/modules/ext.vector.editWarning.js b/extensions/Vector/modules/ext.vector.editWarning.js deleted file mode 100644 index e128fd45..00000000 --- a/extensions/Vector/modules/ext.vector.editWarning.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Edit warning for Vector - */ -( function ( mw, $ ) { - $(document).ready( function () { - // Check if EditWarning is enabled and if we need it - if ( $( '#wpTextbox1' ).length === 0 ) { - return true; - } - // Get the original values of some form elements - $( '#wpTextbox1, #wpSummary' ).each( function () { - $(this).data( 'origtext', $(this).val() ); - }); - var savedWindowOnBeforeUnload; - $( window ) - .on( 'beforeunload.editwarning', function () { - var retval; - - // Check if the current values of some form elements are the same as - // the original values - if ( - mw.config.get( 'wgAction' ) == 'submit' || - $( '#wpTextbox1' ).data( 'origtext' ) != $( '#wpTextbox1' ).val() || - $( '#wpSummary' ).data( 'origtext' ) != $( '#wpSummary' ).val() - ) { - // Return our message - retval = mw.msg( 'vector-editwarning-warning' ); - } - - // Unset the onbeforeunload handler so we don't break page caching in Firefox - savedWindowOnBeforeUnload = window.onbeforeunload; - window.onbeforeunload = null; - if ( retval !== undefined ) { - // ...but if the user chooses not to leave the page, we need to rebind it - setTimeout( function () { - window.onbeforeunload = savedWindowOnBeforeUnload; - }, 1 ); - return retval; - } - } ) - .on( 'pageshow.editwarning', function () { - // Re-add onbeforeunload handler - if ( window.onbeforeunload == null ) { - window.onbeforeunload = savedWindowOnBeforeUnload; - } - } ); - - // Add form submission handler - $( '#editform' ).submit( function () { - // Unbind our handlers - $( window ).off( '.editwarning' ); - }); - }); - -}( mediaWiki, jQuery ) ); diff --git a/extensions/Vector/modules/ext.vector.footerCleanup.css b/extensions/Vector/modules/ext.vector.footerCleanup.css index b935aed6..a361346b 100644 --- a/extensions/Vector/modules/ext.vector.footerCleanup.css +++ b/extensions/Vector/modules/ext.vector.footerCleanup.css @@ -2,6 +2,7 @@ * Footer cleanup */ +/* General layout */ #wpTextbox1 { margin: 0; display: block; @@ -15,15 +16,17 @@ margin-bottom: 2em; } +/* Styles for collapsible lists of templates used and hidden categories */ .collapsible-list { display: inline; cursor: pointer; min-width: 400px; } -.collapsible-list > span { + +.collapsible-list span { float: left; /* @embed */ - background: url(./images/open.png); + background-image: url(./images/open.png); background-repeat: no-repeat; background-position: 50% 50%; display: block; @@ -31,46 +34,39 @@ width: 16px; } -.collapsible-list > span.collapsed { +.collapsible-list span.collapsed { /* @embed */ - background: url(./images/closed-ltr.png); - background-repeat: no-repeat; - background-position: 50% 50%; + background-image: url(./images/closed-ltr.png); } -.hiddencats > ul, .templatesUsed > ul { - margin: 1em 2.5em; +.hiddencats ul, .templatesUsed ul { + margin-bottom: 1em; + margin-left: 2.5em; } +/* Adjustments to edit form elements */ .editCheckboxes { margin-bottom: 1em; } -.editCheckboxes input[type='checkbox']:first-child { +.editCheckboxes input:first-child { margin-left: 0; } .cancelLink { - margin: 0 0.5em; -} - -.cancelLinkPipeSpace { - display: inline-block; - width: 0.5em; - height: 0.5em; + margin-left: 0.5em; } #editpage-copywarn { font-size: 0.9em; } -input#wpSummary { +#wpSummary { display: block; margin-top: 0; margin-bottom: 0.5em; } -.editButtons > input[type='submit']:first-child { +.editButtons input:first-child { margin-left: .1em; } - diff --git a/extensions/Vector/modules/ext.vector.footerCleanup.js b/extensions/Vector/modules/ext.vector.footerCleanup.js index 7c4b6898..5881014d 100644 --- a/extensions/Vector/modules/ext.vector.footerCleanup.js +++ b/extensions/Vector/modules/ext.vector.footerCleanup.js @@ -3,7 +3,7 @@ */ ( function ( $ ) { // Wait for onload to remove edit help and "|" after cancel link. - window.onload = function () { + $( window ).load( function () { // Only if advanced editor is found. if ( 'wikiEditor' in $ ) { $( '.editButtons' ).find( '.editHelp' ).remove(); @@ -13,17 +13,17 @@ // Adjustment for proper right side alignment with WikiEditor. $( '.editOptions, #editpage-specialchars' ).css( 'margin-right', '-2px' ); } - }; + } ); // Waiting until dom ready as the module is loaded in the head. $( document ).ready( function () { // Make "Templates used" a collapsible list. - $( '.templatesUsed ul' ).footerCollapsibleList( { + $( '.templatesUsed' ).footerCollapsibleList( { name: 'templates-used-list', title: mw.msg( 'vector-footercleanup-templates' ) } ); // Make "Hidden categories" a collapsible list. - $( '.hiddencats ul' ).footerCollapsibleList( { + $( '.hiddencats' ).footerCollapsibleList( { name: 'hidden-categories-list', title: mw.msg( 'vector-footercleanup-categories' ) } ); diff --git a/extensions/Vector/modules/ext.vector.sectionEditLinks.js b/extensions/Vector/modules/ext.vector.sectionEditLinks.js index 2a3301bf..62bde9e6 100644 --- a/extensions/Vector/modules/ext.vector.sectionEditLinks.js +++ b/extensions/Vector/modules/ext.vector.sectionEditLinks.js @@ -38,20 +38,6 @@ if ( bucket <= 0 ) { } $(document).ready( function () { - // Transform the targets of section edit links to route through the click tracking API - var session = $.cookie( 'clicktracking-session' ); - $( 'span.editsection a, #ca-edit a' ).each( function () { - var event = eventBase + bucket + '@' + experiment; - if ( $(this).is( '#ca-edit a' ) ) { - event += '-tab'; - } - var href = $( this ).attr( 'href' ); - var editUrl = href + ( href.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( { - 'clicktrackingsession': session, - 'clicktrackingevent': event + '-save' - } ); - $(this).attr( 'href', $.trackActionURL( editUrl, event + '-click' ) ); - } ); if ( bucket == 2 ) { // Move the link over to be next to the heading text and style it with an icon $( 'span.mw-headline' ).each( function () { diff --git a/extensions/Vector/modules/jquery.collapsibleTabs.js b/extensions/Vector/modules/jquery.collapsibleTabs.js new file mode 100644 index 00000000..1e6b7af5 --- /dev/null +++ b/extensions/Vector/modules/jquery.collapsibleTabs.js @@ -0,0 +1,206 @@ +/** + * Collapsible tabs jQuery Plugin + */ +( function ( $ ) { + var rtl = $( 'body' ).is( '.rtl' ); + $.fn.collapsibleTabs = function ( options ) { + // return if the function is called on an empty jquery object + if ( !this.length ) { + return this; + } + // Merge options into the defaults + var $settings = $.extend( {}, $.collapsibleTabs.defaults, options ); + + this.each( function () { + var $el = $( this ); + // add the element to our array of collapsible managers + $.collapsibleTabs.instances = ( $.collapsibleTabs.instances.length === 0 ? + $el : $.collapsibleTabs.instances.add( $el ) ); + // attach the settings to the elements + $el.data( 'collapsibleTabsSettings', $settings ); + // attach data to our collapsible elements + $el.children( $settings.collapsible ).each( function () { + $.collapsibleTabs.addData( $( this ) ); + } ); + } ); + + // if we haven't already bound our resize hanlder, bind it now + if ( !$.collapsibleTabs.boundEvent ) { + $( window ) + .delayedBind( '500', 'resize', function ( ) { + $.collapsibleTabs.handleResize(); + } ); + } + // call our resize handler to setup the page + $.collapsibleTabs.handleResize(); + return this; + }; + /** + * Returns the amount of horizontal distance between the two tabs groups + * (#left-navigation and #right-navigation), in pixels. If negative, this + * means that the tabs overlap, and the value is the width of overlapping + * parts. + * + * Used in default expandCondition and collapseCondition. + * + * @return {Numeric} distance/overlap in pixels + */ + function calculateTabDistance() { + var $tabsArray, $leftTab, $rightTab, leftEnd, rightStart; + + // In RTL, #right-navigation is actually on the left and vice versa. + // Hooray for descriptive naming. + if ( !rtl ) { + $leftTab = $( '#left-navigation' ); + $rightTab = $( '#right-navigation' ); + } else { + $leftTab = $( '#right-navigation' ); + $rightTab = $( '#left-navigation' ); + } + + leftEnd = $leftTab.offset().left + $leftTab.width(); + rightStart = $rightTab.offset().left; + + return rightStart - leftEnd; + } + $.collapsibleTabs = { + instances: [], + boundEvent: null, + defaults: { + expandedContainer: '#p-views ul', + collapsedContainer: '#p-cactions ul', + collapsible: 'li.collapsible', + shifting: false, + expandCondition: function ( eleWidth ) { + // If there's at least eleWidth pixels free space, expand. + return calculateTabDistance() >= eleWidth; + }, + collapseCondition: function () { + // If there's an overlap, collapse. + return calculateTabDistance() < 0; + } + }, + addData: function ( $collapsible ) { + var $settings = $collapsible.parent().data( 'collapsibleTabsSettings' ); + if ( $settings !== null ) { + $collapsible.data( 'collapsibleTabsSettings', { + expandedContainer: $settings.expandedContainer, + collapsedContainer: $settings.collapsedContainer, + expandedWidth: $collapsible.width(), + prevElement: $collapsible.prev() + } ); + } + }, + getSettings: function ( $collapsible ) { + var $settings = $collapsible.data( 'collapsibleTabsSettings' ); + if ( $settings === undefined ) { + $.collapsibleTabs.addData( $collapsible ); + $settings = $collapsible.data( 'collapsibleTabsSettings' ); + } + return $settings; + }, + /** + * @param {jQuery.Event} e + */ + handleResize: function () { + $.collapsibleTabs.instances.each( function () { + var $el = $( this ), + data = $.collapsibleTabs.getSettings( $el ); + + if ( data.shifting ) { + return; + } + + // if the two navigations are colliding + if ( $el.children( data.collapsible ).length > 0 && data.collapseCondition() ) { + + $el.trigger( 'beforeTabCollapse' ); + // move the element to the dropdown menu + $.collapsibleTabs.moveToCollapsed( $el.children( data.collapsible + ':last' ) ); + } + + // if there are still moveable items in the dropdown menu, + // and there is sufficient space to place them in the tab container + if ( $( data.collapsedContainer + ' ' + data.collapsible ).length > 0 + && data.expandCondition( $.collapsibleTabs.getSettings( $( data.collapsedContainer ).children( + data.collapsible + ':first' ) ).expandedWidth ) ) { + //move the element from the dropdown to the tab + $el.trigger( 'beforeTabExpand' ); + $.collapsibleTabs + .moveToExpanded( data.collapsedContainer + ' ' + data.collapsible + ':first' ); + } + }); + }, + moveToCollapsed: function ( ele ) { + var $moving = $( ele ); + + var data = $.collapsibleTabs.getSettings( $moving ); + if ( !data ) { + return; + } + var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); + if ( !expContainerSettings ) { + return; + } + expContainerSettings.shifting = true; + + // Remove the element from where it's at and put it in the dropdown menu + var target = data.collapsedContainer; + $moving.css( 'position', 'relative' ) + .css( ( rtl ? 'left' : 'right' ), 0 ) + .animate( { width: '1px' }, 'normal', function () { + var data; + $( this ).hide(); + // add the placeholder + $( '<span class="placeholder" style="display: none;"></span>' ).insertAfter( this ); + // XXX: 'data' is undefined here, should the 'data' from the outer scope have + // a different name? + $( this ).detach().prependTo( target ).data( 'collapsibleTabsSettings', data ); + $( this ).attr( 'style', 'display: list-item;' ); + data = $.collapsibleTabs.getSettings( $( ele ) ); + if ( data ) { + var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); + if ( expContainerSettings ) { + expContainerSettings.shifting = false; + $.collapsibleTabs.handleResize(); + } + } + } ); + }, + moveToExpanded: function ( ele ) { + var $moving = $( ele ); + var data = $.collapsibleTabs.getSettings( $moving ); + if ( !data ) { + return; + } + var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); + if ( !expContainerSettings ) { + return; + } + expContainerSettings.shifting = true; + + // grab the next appearing placeholder so we can use it for replacing + var $target = $( data.expandedContainer ).find( 'span.placeholder:first' ); + var expandedWidth = data.expandedWidth; + $moving.css( 'position', 'relative' ).css( ( rtl ? 'right' : 'left' ), 0 ).css( 'width', '1px' ); + $target.replaceWith( + $moving + .detach() + .css( 'width', '1px' ) + .data( 'collapsibleTabsSettings', data ) + .animate( { width: expandedWidth + 'px' }, 'normal', function () { + $( this ).attr( 'style', 'display: block;' ); + var data = $.collapsibleTabs.getSettings( $( this ) ); + if ( data ) { + var expContainerSettings = $.collapsibleTabs.getSettings( $( data.expandedContainer ) ); + if ( expContainerSettings ) { + expContainerSettings.shifting = false; + $.collapsibleTabs.handleResize(); + } + } + } ) + ); + } + }; + +}( jQuery ) ); diff --git a/extensions/Vector/modules/jquery.footerCollapsibleList.js b/extensions/Vector/modules/jquery.footerCollapsibleList.js index 2915ce29..7b9b5bcb 100644 --- a/extensions/Vector/modules/jquery.footerCollapsibleList.js +++ b/extensions/Vector/modules/jquery.footerCollapsibleList.js @@ -2,45 +2,43 @@ // Small jQuery plugin to handle the toggle function & cookie for state // For collapsible items in the footer $.fn.footerCollapsibleList = function( config ) { - if ( - ! ( 'title' in config ) || - ! ( 'name' in config ) - ) { + if ( !( 'title' in config ) || !( 'name' in config ) ) { return; } + return this.each( function () { - // Setup - $( this ) - .parent() - .prepend( - $( '<a>' ) - .addClass( 'collapsible-list' ) - .text( config.title ) - .on( 'click', function( e ) { - e.preventDefault(); - // Modify state cookie. - var state = ( $.cookie( config.name ) !== 'expanded' ) ? - 'expanded' : 'collapsed'; - $.cookie( config.name, state ); - // Modify DOM. - $( this ).next().toggle(); - $( this ).find( 'span' ).toggleClass( 'collapsed' ); - } ) - .append( $( '<span>' ) ) - ) - .end() - .prev() - .remove(); - // Check cookie and collapse. - if( - $.cookie( config.name ) === null || - $.cookie( config.name ) === 'collapsed' - ) { - $( this ) - .slideUp() - .prev() - .find( 'span' ).addClass( 'collapsed' ); - } + var $container, $ul, $explanation, $icon; + + $container = $( this ); + $ul = $container.find( 'ul' ); + $explanation = $container.find( '.mw-templatesUsedExplanation, .mw-hiddenCategoriesExplanation' ); + + $icon = $( '<span>' ); + $ul.before( + $( '<a>' ) + .addClass( 'collapsible-list' ) + .text( config.title ) + .append( $icon ) + .on( 'click', function( e ) { + // Modify state cookie. + var state = ( $.cookie( config.name ) !== 'expanded' ) ? 'expanded' : 'collapsed'; + $.cookie( config.name, state ); + + // Modify DOM. + $ul.slideToggle(); + $icon.toggleClass( 'collapsed' ); + + e.preventDefault(); + } ) + ); + + $explanation.remove(); + + // Check cookie and collapse. + if( $.cookie( config.name ) === null || $.cookie( config.name ) === 'collapsed' ) { + $ul.hide(); + $icon.addClass( 'collapsed' ); + } } ); }; }( jQuery ) ); |