summaryrefslogtreecommitdiff
path: root/extensions/Vector/modules/jquery.footerCollapsibleList.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/Vector/modules/jquery.footerCollapsibleList.js')
-rw-r--r--extensions/Vector/modules/jquery.footerCollapsibleList.js70
1 files changed, 34 insertions, 36 deletions
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 ) );