2734
правки
Изменения
/**
* Collapsible elementstables
*
* Add the "collapsible" class to an element and the child element with class "collapsible-content" * (or everything but the header row if a table) will be hidden when the element is collapsedBased on http://www. * * * Add the class "collapsed" to the element to make it start out collapsedmediawiki. * * Add either "collapsetoggle-left" or "collapsetoggle-inline" to the element to choose the collapse * toggle alignment (defaults to right)org/wiki/Manual:Collapsible_tables#Common. * * Add an ID in the format of "collapsible-<x>" to the element to make any element with the class * "collapsetoggle-custom" and a matching class in the format of "collapsible-<x>-toggle" control * the collapsing instead of the standard buttonjs_script_. * If the custom toggle contains an element with the "jslink" class, only that will be clickable28before_1.18.29
*/
( function() {
var $collapsibles tables = $wikipageContentcontent.find( 'table.collapsible' ); if ( !$collapsiblestables || !$tables.length ) { returnfalse;
}
var $toggleTemplate buttonText = $( '<spanclass="collapsible-button">[<span class="jslink">' )+ mcw.addClass( 'collapsetoggle' )i18n.append( '[', $( hideText + '</span>' ).addClass( 'jslink' ), ']</span> '; ); $collapsiblestables.each( function() { var $collapsible table = $( this ), $header, $collapseButton, firstWidth, secondWidth; // This table is already collapsible if ( $collapsibletable.data( 'made-collapsible' ) ) {
return true;
}
// If there No header or the table body is no content area, add itempty if ( !$collapsibleheader.is( 'table' ) && length || !$childrentable.filterfind( '.collapsible-contenttr:not(tr:first)' ).length html() { if ( $collapsible.istrim( 'tr' ) .length ) { $children.addClass( 'collapsible-content' ); } else { $collapsible.wrapInner( '<div class="collapsible-content">' )return true; }
}
}
// Create Find max button size, and insert the toggle button if there is no custom oneset its min-width to it if ( !$toggle || !collapseButton = $toggletable.find( '.length collapsible-button' ) { var $toggleContainer; if ( firstWidth = $collapsiblecollapseButton.iswidth( 'table' ) ) {; var $rows = $childrencollapseButton.filterfind( 'thead> .jslink' ).childrentext(mcw.i18n.showText ); if ( !$rows.length ) { $rows secondWidth = $children.filter( 'tbody' ).first()collapseButton.childrenwidth(); if ( firstWidth !$rows.length = secondWidth ) { $rows = $children.filter if ( 'tr' firstWidth < secondWidth ); } }{ $toggleContainer = $rowscollapseButton.first().children().lastcss('min-width', secondWidth );
} else {
$toggleContainer = $childrencollapseButton.first(); if ( $toggleContainer.hasClasscss( 'collapsiblemin-contentwidth' ) ) { $toggleContainer = $collapsible; } } $toggle = $toggleTemplate.clone(); if ( $collapsible.hasClass( 'collapsetoggle-inline' ) || $collapsible.hasClass( 'collapse-button-none' ) ) { $toggleContainer.append( $toggle ); } else { $toggleContainer.prepend( $toggle , firstWidth );
}
}
// Set the text back to hide if it's not collapsed to begin with
if ( !$table.hasClass( 'collapsed' ) ) {
$collapseButton.find( '> .jslink' ).text( mcw.i18n.hideText );
}
// Find max toggle size, and set its min-width to itStop table sorting activating when clicking the link var hideWidth = $togglee.widthstopPropagation(); $toggleLink.text( showText ); var showWidth = $toggle.width(); if ( hideWidth !== showWidth ) { $toggle.css( 'min-width', hideWidth > showWidth ? hideWidth : showWidth ); }
}
} );
}() );