Cambios

Saltar a: navegación, buscar

MediaWiki:Common.js

2579 bytes eliminados, 20:44 17 abr 2014
sin resumen de edición
mcw.baseURL = '/';
mcw.wikiURL = '/';
 
 
/* Variables for interface text used throughout the script, for ease of translating */
mcw.i18n = {
// Collapsible tables and page loader
hideText: 'ocultar',
showText: 'mostrar',
// Page loader
}
} );
} );
 
 
mcw.makeCollapsible = function( $content ) {
if ( $content === undefined ) {
$content = $( 'table.collapsible' );
} else {
$content = $content.find( 'table.collapsible' );
}
if ( !$content.length ) {
return false;
}
var buttonText = ' <span class="collapsible-button">[<span class="jslink">' + mcw.i18n.hideText + '</span>]</span> ';
$content.each( function() {
var $table = $( this ), $header, $collapseButton, firstWidth, secondWidth;
// This table is already collapsible
if ( $table.data( 'collapsible' ) ) {
return true;
}
// Use the collapse-button if specified otherwise the first header cell of the first row
$header = $table.find( 'tr:first .collapse-button' );
if ( !$header.length ) {
$header = $table.find( 'tr:first > th:first' );
}
// No header or the table body is empty
if ( !$header.length || !$table.find( 'tr:not(tr:first)' ).text().replace( /\n/g, '' ).length ) {
return true;
}
// For the button to float properly, it has to be /before/ the cell text
if ( $table.hasClass( 'collapse-button-none' ) ) {
$header.append( buttonText );
} else {
$header.prepend( buttonText );
}
// Find max button size, and set its min-width to it
$collapseButton = $table.find( '.collapsible-button' );
firstWidth = $collapseButton.width();
$collapseButton.find( '> .jslink' ).text( mcw.i18n.showText );
secondWidth = $collapseButton.width();
if ( firstWidth != secondWidth ) {
if ( firstWidth < secondWidth ) {
$collapseButton.css( 'min-width', secondWidth );
} else {
$collapseButton.css( 'min-width', 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 );
}
$table.data( 'collapsible', true );
} );
};
 
$( '#mw-content-text' ).on( 'click', 'table.collapsible .collapsible-button .jslink', function( e ) {
var $table = $( this ).closest( 'table.collapsible' );
// Stop table sorting activating when clicking the link
e.stopPropagation();
if ( $table.hasClass( 'collapsed' ) ) {
$table.removeClass( 'collapsed' ).addClass( 'expanded' );
$( this ).text( mcw.i18n.hideText );
} else {
$table.removeClass( 'expanded' ).addClass( 'collapsed' );
$( this ).text( mcw.i18n.showText );
}
} );
mcw.makeCollapsible();
 
/**
2712
ediciones

Menú de navegación