Utente:Titore/defaultsummaries.js
Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.
Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.
/* _____________________________________________________________________________
* | |
* | === WARNING: GLOBAL GADGET FILE === |
* | Changes to this page affect many users. |
* | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. |
* |_____________________________________________________________________________|
*
* Imported as of 09/06/2011 from [[User:ErrantX/defaultsummaries.js]]
* Edited version from [[User:MC10/defaultsummaries.js]]
* Implements default edit summary dropdown boxes
*/
/* global mediaWiki, ve */
( function ( $, mw ) { // Wrap with anonymous function
var $summaryBox = $( '#wpSummary' ),
minorSummaries = [
'corretta ortografia/grammatica/punteggiatura',
'refuso',
'formattazione',
'correzioni minori',
'modifica di prova o impropria',
'rimozione ingiustificata di contenuti',
'rimosso vandalismo',
'wikilink',
'smistamento lavoro sporco'
],
articleSummaries = [
'rimossa [[WP:STAGIONI FUTURE|stagione futura]]',
'[[Wikipedia:Convenzioni di stile/Televisione/Fiction|convenzioni]]',
'rimosso testo in [[WP:C|violazione di copyright]]',
'fonti',
'ridotto [[WP:OVERLINKING|overlinking]]',
'rimosso contenuto senza [[WP:FONTI|fonti]]',
'revisione',
'voce ampliata',
'aggiunti collegamenti esterni',
'rimosso [[WP:SPAM|spam]] come da [[WP:CE]]',
],
nonArticleSummaries = [
'+1',
'+1 recidivo',
'risposta',
'commento',
'mio parere',
'suggerimento',
'favorevole',
'contrario'
],
talkPageSummaries = [
'segnalo discussione',
'avviso'
];
function addOptionsToDropdown( dropdown, optionTexts ) {
dropdown.menu.addItems( optionTexts.map( function ( optionText ) {
return new OO.ui.MenuOptionWidget( { label: optionText } );
} ) );
}
function onSummarySelect( option ) {
// Save the original value of the edit summary field
var editsummOriginalSummary = $summaryBox.val(),
canned = option.getLabel(),
newSummary = editsummOriginalSummary;
// Append old edit summary with space, if exists,
// and last character != space
if ( newSummary.length !== 0 && newSummary.charAt( newSummary.length - 1 ) !== ' ' ) {
newSummary += ' ';
}
newSummary += canned;
$summaryBox.val( newSummary ).trigger( 'change' );
}
function insertSummaryOptions( $insertBeforeThis, dropdownWidth ) {
// For convenience, add a dropdown box with some canned edit
// summaries to the form.
var namespace = mw.config.get( 'wgNamespaceNumber' ),
dropdown = new OO.ui.DropdownWidget( {
label: 'Modifiche frequenti – click to use'
} ),
minorDropdown = new OO.ui.DropdownWidget( {
label: 'Modifiche minori frequenti – click to use'
} );
dropdown.$element.css( 'width', dropdownWidth );
dropdown.menu.on( 'select', onSummarySelect );
minorDropdown.$element.css( 'width', dropdownWidth );
minorDropdown.menu.on( 'select', onSummarySelect );
addOptionsToDropdown( minorDropdown, minorSummaries );
if ( namespace === 0 || namespace === 118 ) {
addOptionsToDropdown( dropdown, articleSummaries );
} else {
addOptionsToDropdown( dropdown, nonArticleSummaries );
if ( namespace % 2 !== 0 && namespace !== 3 ) {
addOptionsToDropdown( dropdown, talkPageSummaries );
}
}
$insertBeforeThis.before( dropdown.$element );
$insertBeforeThis.before( minorDropdown.$element );
}
// VisualEditor
mw.hook( 've.saveDialog.stateChanged' ).add( function () {
var target, $saveOptions;
// .ve-init-mw-viewPageTarget-saveDialog-checkboxes
if ( $( 'body' ).data( 'wppresent' ) ) { return; }
$( 'body' ).data( 'wppresent', 'true' );
target = ve.init.target;
$saveOptions = target.saveDialog.$saveOptions;
$summaryBox = target.saveDialog.editSummaryInput.$input;
if ( !$saveOptions.length ) {
return;
}
insertSummaryOptions( $saveOptions );
} );
// WikiEditor
$.when( mw.loader.using( 'oojs-ui-core' ), $.ready ).then( function () {
var $editCheckboxes = $( '.editCheckboxes' );
// If we failed to find the editCheckboxes class
if ( !$editCheckboxes.length ) {
return;
}
insertSummaryOptions( $editCheckboxes, '48%' );
} );
}( jQuery, mediaWiki ) ); // End wrap with anonymous function