לדלג לתוכן

מדיה ויקי:Gadget-Collapsetables.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
מאין תקציר עריכה
(אין הבדלים)

גרסה מ־16:56, 4 באפריל 2019

/** Collapsible tables *********************************************************
 *
 *  Description: Allows tables to be collapsed - using $.makeCollapsible
 */

var autoCollapse = 2;

mw.hook( 'wikipage.content' ).add( function ( $content ) {
	var $tables = $content
					.find( 'table.collapsible:not(.mw-collapsible)' )
					.addClass( 'mw-collapsible' );
	$.each( $tables, function( index, table ) {
		if( $( table ).hasClass( 'collapsed') ) {
			$( table ).addClass( 'mw-collapsed' );
			
		}
	} );
	if( $tables.length > 0 ) {
		mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
			$tables.makeCollapsible();
			mw.hook( 'he.wikipedia.collapsetables.loaded' ).fire();
		} );
	}

	if ( ( $content.find( 'table.collapsible' ).length + $content.find( 'table.mw-collapsible' ).length ) > autoCollapse ) {
		mw.loader.using( 'jquery.makeCollapsible' ).then( function() {
			$content.find( 'table.collapsible.autocollapse' ).addClass( 'mw-collapsed' ).makeCollapsible();
		} );
	}
} );