Utente:Valcio/Script/WatchUsers-MenuDialog.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.
function MenuDialog( config ) {
MenuDialog.super.call( this, config );
}
OO.inheritClass( MenuDialog, OO.ui.ProcessDialog );
MenuDialog.static.name = 'menuDialog';
//Actions
MenuDialog.static.actions = [
{
flags: 'primary',
label: 'Salva',
action: 'save'
},
{
flags: 'safe',
label: 'Annulla'
}
];
// Layout
MenuDialog.prototype.initialize = function () {
MenuDialog.super.prototype.initialize.call( this );
this.panel = new OO.ui.PanelLayout( {
padded: true,
expanded: false
} );
this.content = new OO.ui.FieldsetLayout();
this.userInput = new OO.ui.TagMultiselectWidget( {
placeholder: 'Aggiungi utenti da osservare',
allowArbitrary: true,
inputPosition: 'outline'
} );
this.field = new OO.ui.FieldLayout( this.userInput, {
label: 'Utenti osservati',
help: "Tutte le modifiche degli utenti che inserisci in questa lista verranno mostarte nei tuoi Osservati Speciali. Per inserire un nuovo utente, digita il suo nome (senza 'Utente:') e premi 'invio'.",
warnings:["Questa lista è privata, altri utenti non potranno visualizzarla", "Ricordati di premere il pulsante 'Salva'"],
align: 'top'
} );
this.content.addItems( [ this.field ] );
this.panel.$element.append( this.content.$element );
this.$body.append( this.panel.$element );
};
MenuDialog.prototype.getBodyHeight = function () {
return this.panel.$element.outerHeight( true );
};
MenuDialog.prototype.getSetupProcess = function ( data ) {
data = data || {};
return MenuDialog.super.prototype.getSetupProcess.call( this, data )
.next( function () {
if ( mw.user.options.exists( 'userjs-gadget-watch-users' ) )
this.userInput.setValue( mw.user.options.get( 'userjs-gadget-watch-users' ).split("|") );
}, this );
};
//Handle actions
MenuDialog.prototype.getActionProcess = function ( action ) {
var dialog = this;
if ( action === 'save' ) {
return new OO.ui.Process( function () {
new mw.Api().postWithToken( 'csrf', {
action: 'options',
optionname: 'userjs-gadget-watch-users',
optionvalue: this.userInput.getValue()
} ).done(function(){dialog.close(); location.reload();});
}, this );
}
return MenuDialog.super.prototype.getActionProcess.call( this, action );
};
module.exports = MenuDialog;