MediaWiki:Common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
riscrittura da zero della funzionalità galleria immagini
Rimosse "Collapsible tables" per passaggio alla nuova classe mw-collapsible, come da discussione
Riga 136:
$( comboboxSearch );
}
 
/**
* Collapsible tables
* Taken from //en.wikipedia.org/wiki/MediaWiki:Common.js
* Allows tables to be collapsed, showing only the header. See Wikipedia:NavFrame.
* Maintainers: User:R. Koot
*/
 
var autoCollapse = 2;
var collapseCaption = 'nascondi';
var expandCaption = 'mostra';
 
function collapseTable( tableIndex ) {
var Button = document.getElementById( 'collapseButton' + tableIndex );
var Table = document.getElementById( 'collapsibleTable' + tableIndex );
var i;
 
if ( !Table || !Button ) {
return false;
}
 
var Rows = Table.getElementsByTagName( 'tr' );
 
if ( Button.firstChild.data == collapseCaption ) {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = 'none';
}
Button.firstChild.data = expandCaption;
} else {
for ( i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
 
function buttonLinkClickHandler( event ) {
event.preventDefault();
collapseTable( event.data );
}
 
function createCollapseButtons() {
var tableIndex = 0;
var NavigationBoxes = {};
var Tables = document.getElementsByTagName( 'table' );
var i;
 
for ( i = 0; i < Tables.length; i++ ) {
if ( $( Tables[i] ).hasClass( 'collapsible' ) ) {
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( 'id', 'collapsibleTable' + tableIndex );
 
var Button = document.createElement( 'span' );
var ButtonLink = document.createElement( 'a' );
var ButtonText = document.createTextNode( collapseCaption );
 
Button.style.styleFloat = 'right';
Button.style.cssFloat = 'right';
Button.style.fontWeight = 'normal';
Button.style.textAlign = 'right';
Button.style.width = '7em';
 
ButtonLink.setAttribute( 'id', 'collapseButton' + tableIndex );
$( ButtonLink ).attr( 'href', '#' ).click( tableIndex, buttonLinkClickHandler );
ButtonLink.appendChild( ButtonText );
 
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
 
var Header = Tables[i].getElementsByTagName( 'tr' )[0].getElementsByTagName( 'th' )[0];
/* only add button and increment count if there is a header row to work with */
if ( Header ) {
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
}
 
var cTables = tableIndex + $( 'table.navbox.mw-collapsible' ).length;
for ( i = 0; i < tableIndex; i++ ) {
if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) ||
( cTables >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
collapseTable( i );
}
}
}
 
$( createCollapseButtons );
 
/**
Riga 450 ⟶ 361:
 
/**
* Classe autocollapse con mw-collapsible: se presente più di una table con classe mw-collapsible o collapsible,
* quelle con anche la classe autocollapse si chiudono da sole. Deve essere presente anche la classe navbox.
*/
$( function () {
if ( $( 'table.navbox.mw-collapsible' ).length + $( 'table.navbox.collapsible' ).length > 1) {
$( 'table.navbox.mw-collapsible.autocollapse' ).each( function ( i, el ) {
if ( !$( el ).hasClass( 'mw-collapsed' ) ) {