MediaWiki:Common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m fix toolserver url, spezzate righe troppo lunghe
+utilizzo dei tab e di mw:Manual:Coding conventions/JavaScript dove già rivisto
Riga 31:
* Collegamento diretto alla pagina di upload di Commons nel portlet Strumenti
*/
$( function () {
mw.util.addPortletLink( 'p-tb', '//commons.wikimedia.org/wiki/Commons:Upload/it', 'Carica su Commons',
'Carica su Commons', 't-uploadcommons', 'Carica file multimediali su Wikimedia Commons', 'm', '#t-specialpages' );
} );
 
/**
Riga 40:
*/
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === "Discussione:Pagina_principale" ) {
$( function () {
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Lista_di_Wikipedie',
'Lista completa', 'interwiki-completelist', 'Lista completa delle Wikipedie' );
Riga 92:
*/
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' );
 
/**
Riga 159:
 
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 );
}
}
}
}
}
 
Riga 283:
*/
$( function () {
if (mw.config.get( 'wgAction' ) === " 'edit"' ) {
/* Allarga l'edittools a tutta pagina */
$( '#Standard' ).css( 'width', '100%' );
}
} );
 
/**
Riga 382:
* Toglie "Soggetto/Intestazione" nelle creazioni delle discussioni al Bar
*/
if ( mw.config.get( 'wgNamespaceNumber') === 4 &&
mw.config.get( 'wgPageName').indexOf(" 'Wikipedia:Bar/"' ) === 0 &&
mw.config.get( 'wgAction') === "'edit"' &&
document.___URL.indexOf(" '&section=new&preload="') !== -1) {
$( function () {
document.getElementById( 'wpSummaryLabel' ).style.display = "'none"';
document.getElementById( 'wpSummary' ).style.display = "'none"';
} );
}
 
 
Riga 396 ⟶ 397:
* Fatto in Common.css, questo è un fix per IE7
*/
if ( $.client.profile().name === 'msie' && $.client.profile().versionNumber < 8 ) {
$( function () {
$( '.editsection' ).each( function( i, e ) {
$( e ).parent().append( e)} );
} );
} );
}
 
Riga 540 ⟶ 543:
* 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' ) ) {
// makeCollapsible a volte è eseguita prima, a volte successivamente al Common.js,
// se è già stata eseguita, non resta che simulare un click.
if ( $( el ).data( 'mw-made-collapsible' ) ) {
// hide() chiude la tabella più velocemente di fadeOut
$( el ).find( 'tr:not(:first)' ).hide();
$( el ).find( '.mw-collapsible-toggle > a' ).click();
} else {
$( el ).addClass( 'mw-collapsed' );
}
}
}
}
} });
}
}
} );
 
/**