MediaWiki:Gadget-cambusa.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
salta le sezioni transcluse (vedi segnalazione); non prova più a chiudere la finestra quando la finestra ancora non esiste
cerca un link diverso a seconda che il VE sia attivo
 
(4 versioni intermedie di 2 utenti non mostrate)
Riga 24:
// La finestra di dialogo per configurare lo spostamento della discussione
var cambusaDialog;
// Nome dell'opzione nelle preferenze che controlla l'attivazione del VisualEditor
var veOptionName = 'visualeditor-betatempdisable';
// Chiavi dei messaggi che possono apparire come testo dei link di modifica sezione
var editLinkMsgKeys = {
0: 'visualeditor-ca-editsource-section', // VisualEditor attivo
1: 'editsection' // VisualEditor disattivo
};
 
/**
Riga 126 ⟶ 133:
extraPages[ formData.destNamespaceNum ].join( ', ' );
}
 
cambusaDialog.close();
 
if ( error ) {
OO.ui.alert( error );
} else {
cambusaDialog.close();
formData.destTitle = formData.destNamespace + ':' + formData.destTitle;
from = mw.config.get( 'wgPageName' ).replace( /_/g, ' ' );
Riga 139 ⟶ 147:
addSection( formData.destTitle, formData.destSectionTitle, text, function ( newrevid ) {
getSectionAnchor( newrevid, function ( anchor ) {
text = '==' + formData.destSectionTitlesourceSectionTitle + '==\n\n' +
'{{Cambusa|' + formData.destIncipit + '|' + formData.destTitle + '#' + anchor + '|firma=~~\~~}}';
setSection( formData.sourceSection, text, 'cambusata discussione in [[' + formData.destTitle + ']]' );
Riga 206 ⟶ 214:
} ),
new OO.ui.FieldLayout( this.sectionTitleInput, {
label: 'Titolo nuova discussione di destinazione:',
align: 'top'
} ),
Riga 228 ⟶ 236:
CambusaDialog.prototype.setSourceSection = function ( sourceSection, sourceSectionTitle, sourceText ) {
this.sourceSection = sourceSection;
this.sourceSectionTitle = sourceSectionTitle;
this.sectionTitleInput.setValue( sourceSectionTitle );
this.sourceText = sourceText;
Riga 241 ⟶ 250:
destNamespaceNum: this.namespaceDropdown.getMenu().findSelectedItem().getData(),
sourceSection: this.sourceSection,
sourceSectionTitle: this.sourceSectionTitle,
sourceText: this.sourceText
};
Riga 252 ⟶ 262:
* Aggiunge il link "Cambusa" a ogni sezione della pagina corrente.
*/
async function addCambusaLinks() {
await mw.loader.load( [ 'mediawiki.jqueryMsg', 'user.options' ] );
const editLinkMsgKey = editLinkMsgKeys[ mw.user.options.get( veOptionName ) ];
await api.loadMessagesIfMissing( [ editLinkMsgKey ] );
var windowManager;
$( '`span.mw-editsection > a:last-of-type'contains(${ mw.msg( editLinkMsgKey ) })` ).each( function ( i, el ) => {
var href = $( el ).attr( 'href' );
ifvar (pageTitle = mw.util.getParamValue( 'title', href );
if ( pageTitle !== mw.config.get( 'wgPageName' ) ) {
$( el ).after(
return; // è una sezione transclusa
'<span> | </span>',
$( '<span>' )
.css( 'color', '#54595d' )
}.attr(
} );'title',
'Sezione della pagina ' + pageTitle.replace( /_/g, ' ' )
} )
return; // è una .text( 'sezione transclusa' )
} );
} )return;
}
var sectionTitle = $( el ).attr( 'title' ).replace( /^(Modifica|Cancella) la sezione /g, '' );
Riga 264 ⟶ 288:
.attr( 'title', 'Cambusa la discussione ' + sectionTitle )
.text( 'cambusa' )
.click( functionasync ( event ) => {
event.preventDefault();
await mw.loader.usingload( [ 'mediawiki.api', 'oojs-ui-core', 'oojs-ui-widgets',
'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows', 'mediawiki.widgets' ]
] );
getSection( mw.util.getParamValue( 'section', href ), function ( text ) => {
.done( function () {
apivar match = newtext.match( mw/==\s*(.Api*?)\s*==\s*\n([\s\S]*)/ );
if ( !cambusaDialog ) {
getSection( mw.util.getParamValue( 'section', href ), function ( text ) {
cambusaDialog = buildCambusaDialog();
var match = text.match( /==\s*(.*?)\s*==\s*\n([\s\S]*)/ );
windowManager = new OO.ui.WindowManager();
if ( !cambusaDialog ) {
$( 'body' ).append( windowManager.$element );
cambusaDialog = buildCambusaDialog();
windowManager.addWindows( =[ newcambusaDialog ] OO.ui.WindowManager();
}
$( 'body' ).append( windowManager.$element );
windowManagercambusaDialog.addWindowssetSourceSection( i + 1, match[ cambusaDialog1 ], match[ 2 ] );
windowManager.openWindow( cambusaDialog );
}
} );
cambusaDialog.setSourceSection( i + 1, match[ 1 ], match[ 2 ] );
windowManager.openWindow( cambusaDialog );
} );
} )
.fail( function () {
console.error( 'Impossibile avviare l\'accessorio cambusa.' );
} );
} );
$( el ).after( '<span> | </span>', $link );
Riga 303 ⟶ 321:
}
 
$( async function () {
if ( !cambusaLinksAllowed() ) {
return;
var portletLink = mw.util.addPortletLink( 'p-tb', '#', 'Cambusa', 't-cambusa', 'Aggiunge il link cambusa a ogni discussione' );
$( portletLink ).click( function ( event ) {
event.preventDefault();
if ( !inited ) {
addCambusaLinks();
inited = true;
}
} );
}
 
await mw.loader.load( 'mediawiki.util' );
 
var portletLink = mw.util.addPortletLink(
var portletLink = mw.util.addPortletLink( 'p-tb', '#', 'Cambusa', 't-cambusa', 'Aggiunge il link cambusa a ogni discussione' );
 
$( portletLink ).click( functionasync ( event ) => {
event.preventDefault();
 
if ( !inited ) {
await mw.loader.load( 'mediawiki.api' );
api = new mw.Api();
addCambusaLinks();
inited = true;
}
} );
} );
}( mediaWiki, jQuery ) );