X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.makeCollapsible.js;h=20bd405038e6f145fbe867c864601fd11aee25d9;hp=09306f634cb5b50e197211a6168f1fde7a630310;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=952c3b0aaa0cfbefac76158d3890af705c232013 diff --git a/resources/src/jquery/jquery.makeCollapsible.js b/resources/src/jquery/jquery.makeCollapsible.js index 09306f634c..20bd405038 100644 --- a/resources/src/jquery/jquery.makeCollapsible.js +++ b/resources/src/jquery/jquery.makeCollapsible.js @@ -5,7 +5,7 @@ * familiarise yourself with that CSS before making any changes to this code. * * Dual licensed: - * - CC BY 3.0 + * - CC BY 3.0 * - GPL2 * * @class jQuery.plugin.makeCollapsible @@ -122,6 +122,7 @@ if ( options.wasCollapsed !== undefined ) { wasCollapsed = options.wasCollapsed; } else { + // eslint-disable-next-line no-jquery/no-class-state wasCollapsed = $collapsible.hasClass( 'mw-collapsed' ); } @@ -270,7 +271,7 @@ } } else { // The toggle-link will be in one of the cells (td or th) of the first row - $firstItem = $collapsible.find( 'tr:first th, tr:first td' ); + $firstItem = $collapsible.find( 'tr' ).first().find( 'th, td' ); $toggle = $firstItem.find( '> .mw-collapsible-toggle' ); // If theres no toggle link, add it to the last cell @@ -288,7 +289,7 @@ $collapsible.before( $toggle ); } else if ( $collapsible.is( 'ul' ) || $collapsible.is( 'ol' ) ) { // The toggle-link will be in the first list-item - $firstItem = $collapsible.find( 'li:first' ); + $firstItem = $collapsible.find( 'li' ).first(); $toggle = $firstItem.find( '> .mw-collapsible-toggle' ); // If theres no toggle link, add it @@ -338,6 +339,7 @@ } ); // Initial state + // eslint-disable-next-line no-jquery/no-class-state if ( options.collapsed || $collapsible.hasClass( 'mw-collapsed' ) ) { // One toggler can hook to multiple elements, and one element can have // multiple togglers. This is the sanest way to handle that.