Utente:Ricordisamoa/PDC.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
fix autoRfd per Template:E
fallback per maggiorContributore(), evento select di autocomplete, wgArticleId > 0
(2 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1:
//<nowiki>
/* jshint browser:true, devel:true, smarttabs:true */
/* global mediaWiki, jQuery, OO */
( function ( mw, $ ) {
'use strict';
var namespaces = mw.config.get( 'wgFormattedNamespaces' );,
window.PDC = {
api: new mw.Api(),
 
Riga 26:
*/
dialog: [
'oojs-ui',
'jquery.spinner',
'jquery.ui.autocomplete',
'jquery.ui.dialog'
]
 
Riga 91:
'dialog-button-cancel': 'Annulla',
'dialog-button-proceed': 'Procedi',
'dialog-button-final': 'Richiedi la cancellazione',
'error-msg': '$1: $2',
'process-init': 'Benvenuto/a!<br>Sarai guidato/a nella richiesta di cancellazione per la pagina "<b>$1</b>".<br><br>Se invece desideri effettuare la procedura manualmente, consulta $2.',
Line 178 ⟶ 179:
*/
dialogo: function ( contenuto ) {
this.dialog.description.setLabel( $( '#PDC-dialog<p>' ).empty().append( contenuto ) );
},
 
Line 189 ⟶ 190:
messaggio = this.msg( messaggio );
console.info( messaggio );
varif $d = $( '#PDC-this.dialog' ); {
var $l = this.dialog.$element.find( '.PDC-spinner-label' );
if ( $d.length === 1 ) {
var $l = $d.find( '.PDC-spinner-label' );
if ( $l.length === 1 ) {
$l.empty().append( messaggio );
Riga 237:
}
console.error( messaggio );
if ( $( '#PDC-dialog' )this.length === 1dialog ) {
this.dialogo(
$( '<p>' )
Riga 376:
return ( ( t[a] > t[b] ) ? -1 : ( ( t[a] < t[b] ) ? 1 : 0 ) );
} ),
r = x[0] || null;
$.each( t, function ( k, v ) {
if ( k != x[0] && v == t[x[0]] ) {
Riga 723:
},
 
/**
opzione: function ( nome ) {
* Configura jquery.ui.autocomplete per un TextInputWidget.
var params = Array.prototype.slice.call( arguments );
* @param {OO.ui.TextInputWidget} widget - Il widget per il quale configurare i suggerimenti
params[0] = 'option-' + nome;
*/
return $( '<label>' )
autocompletaArgomento: function ( widget ) {
.append(
widget
$( '<input>' )
.attr( {$input
.autocomplete( {
type: 'checkbox',
source: this.scegliArgomento.bind( this ),
id: 'PDC-option-' + nome
select: widget.onEdit.bind( widget )
} )
} );
.append( this.msg.apply( this, params ) );
},
 
Line 762 ⟶ 761:
mw.loader.using( self.dependencies.dialog )
.done( function () {
PDC.Dialog = function ( config ) {
var cancelButton = {
PDC.Dialog.super.call( this, config );
text: self.msg( 'dialog-button-cancel' ),
specialButton: 'cancel',
click: function () {
$( this ).dialog( 'destroy' ).remove();
}
};
OO.inheritClass( PDC.Dialog, OO.ui.ProcessDialog );
$( '<div>' )
PDC.Dialog.static.attr(title 'id',= 'PDC-dialog.js' );
PDC.Dialog.static.size = 'large';
.append(
PDC.Dialog.static.actions = [
self.msg( 'process-init', titolo, '<a href="' + mw.util.getUrl( self.config.help ) + '">' + self.config.help + '</a>' )
) {
.dialog( action: {'proceed',
title label: self.msg( 'dialog-titlebutton-proceed' ),
flags: [ 'primary', 'progressive' ]
modal: true,
width: 'auto',
close: function () {
$( this ).dialog( 'destroy' ).remove();
},
buttons: [{
cancelButtonaction: 'cancel',
label: self.msg( 'dialog-button-cancel' ),
{
textflags: self.msg( 'dialog-button-proceedsafe' ),
}
specialButton: 'proceed',
];
click: function () {
PDC.Dialog.prototype.initialize = function () {
var dialog = $( this );
PDC.Dialog.super.prototype.initialize.apply( this, arguments );
self.progresso( 'process-loading-contributors' );
this.content = new OO.ui.PanelLayout( { padded: true } );
self.ottieniContributori( titolo )
this.fieldset = new OO.ui.FieldsetLayout( {
.done( function ( contributori ) {
label: self.msg( 'dialog-title' ), icon: 'alert'
var opzioni = [
} );
self.msg( 'process-confirm', titolo ),
this.description = new OO.ui.LabelWidget( {
$( '<textarea>' )
padded: true,
.addClass( 'mw-ui-input' )
.csslabel: $( 'background', '#fff<p>' )
.attrappend( {
id: 'PDC-option-reason',self.msg(
placeholder: self.msg( 'optionprocess-reasoninit' ),
} )titolo,
'<a href="' + mw.util.getUrl( self.config.help ) + '">' + self.config.help + '</a>'
],
)
creatore = contributori[contributori.length - 1],
)
magg = self.maggiorContributore( contributori );
} );
if ( creatore.anon === undefined && creatore.user !== mw.config.get( 'wgUserName' ) ) {
this.fieldset.addItems( [ this.description ] );
opzioni.push( self.opzione( 'notify-creator', creatore.user ) );
this.content.$element.append( this.fieldset.$element );
this.$body.append( this.content.$element );
this.starting = true;
this.options = {};
};
PDC.Dialog.prototype.proceed = function () {
var dialog = this;
self.ottieniContributori( titolo )
.done( function ( contributori ) {
dialog.options.reason = new OO.ui.TextInputWidget( {
multiline: true,
autosize: true,
validate: /\S/
} );
dialog.fieldset.addItems( [
new OO.ui.FieldLayout(
dialog.options.reason,
{
label: self.msg( 'option-reason' ),
align: 'top'
}
)
] );
dialog.description.setLabel(
$( '<p>' )
.append(
self.msg( 'process-confirm', titolo )
)
);
dialog.creatore = contributori[contributori.length - 1];
dialog.maggiore = self.maggiorContributore( contributori );
if (
dialog.creatore.anon === undefined &&
dialog.creatore.user !== mw.config.get( 'wgUserName' )
) {
dialog.options.notifyCreator = new OO.ui.CheckboxInputWidget( {} );
dialog.fieldset.addItems( [
new OO.ui.FieldLayout(
dialog.options.notifyCreator,
{
align: 'inline',
label: self.msg( 'option-notify-creator', dialog.creatore.user )
}
)
if ( magg !== null && magg !== creatore.user && magg !== mw.config.get( 'wgUserName' ) ) {
] );
opzioni.push( self.opzione( 'notify-biggest', magg ) );
}
if (
dialog.maggiore !== null &&
dialog.maggiore !== dialog.creatore.user &&
dialog.maggiore !== mw.config.get( 'wgUserName' )
) {
dialog.options.notifyBiggest = new OO.ui.CheckboxInputWidget( {} );
dialog.fieldset.addItems( [
new OO.ui.FieldLayout(
dialog.options.notifyBiggest,
{
align: 'inline',
label: self.msg( 'option-notify-biggest', dialog.maggiore )
}
)
for ( var i = 1; i < opzioni.length; i = i + 2 ) {
opzioni.splice( i, 0, '<br>'] );
}
dialog.options.notifyTopic1 = new OO.ui.TextInputWidget();
opzioni.push( '<br>' );
self.autocompletaArgomento( dialog.options.notifyTopic1 );
opzioni.push(
dialog.fieldset.addItems( [
$( '<label>' )
new OO.ui.FieldLayout(
.attr( 'for', 'PDC-option-topic1' )
dialog.options.notifyTopic1,
.append( self.msg( 'option-notify-topics' ) )
);{
opzioni.push(align: 'left',
$label: self.msg( '<input>option-notify-topics' )
}
.attr( 'id', 'PDC-option-topic1' )
.autocomplete( {)
] );
source: function ( request, response ) {
dialog.options.notifyTopic2 = new OO.ui.TextInputWidget();
self.scegliArgomento( request, response );
self.autocompletaArgomento( dialog.options.notifyTopic2 );
}
}dialog.fieldset.addItems( )[
);new OO.ui.FieldLayout(
opzionidialog.push(options.notifyTopic2,
$( '<label>' ){
.attr(align: 'forleft', 'PDC-option-topic2' )
.append(label: '+' )
);}
opzioni.push()
$( '<input>'] );
// namespace "Discussioni progetto"
.attr( 'id', 'PDC-option-topic2' )
dialog.pTalk = self.config.wikiprojectNamespace + 1;
.autocomplete( {
dialog.options.notifyWikiprojects = new OO.ui.CheckboxInputWidget( {
source: function ( request, response ) {
disabled: self.scegliArgomento( request,namespaces[dialog.pTalk] response=== );undefined
} );
}dialog.fieldset.addItems( )[
);new OO.ui.FieldLayout(
opzionidialog.push( '<br>' );options.notifyWikiprojects,
{
opzioni.push( self.opzione( 'notify-wikiprojects' ) );
var form = $(align: '<form>inline' ),
label: self.appendmsg( opzioni'option-notify-wikiprojects' )
.submit( function ( event ) {}
event.preventDefault();
}] );
// Forza il ridimensionamento della finestra
self.dialogo( form );
dialog.manager.updateWindowSize( dialog );
// ricrea i pulsanti per cambiare la funzione di "Procedi"
// Reimposta il pulsante 'procedi'
dialog.dialog( 'option', 'buttons', [
cancelButton,dialog.actions
.get( { actions: 'proceed' } )[0]
{
.clearFlags()
text: self.msg( 'dialog-button-proceed' ),
.setFlags( [ 'primary', 'constructive' ] )
specialButton: 'proceed',
.setLabel( self.msg( 'dialog-button-final' ) );
click: function () {
} );
var $motivazione = $( '#PDC-option-reason' ),
};
motivazione = $motivazione.val().trim().replace( /\s*(\-\-)?\~{4}$/, '' );
PDC.Dialog.prototype.final = function () {
if ( motivazione.length === 0 ) {
var dialog = this,
$motivazione.get( 0 ).setCustomValidity( self.msg( 'option-reason-missing' ) );
$motivazione.parents( 'form'= dialog.options.reason.getValue().submittrim();,
argomenti = $.map( [ 'notifyTopic1', 'notifyTopic2' ], function ( opt ) {
} else {
return dialog.options[opt].getValue().trim();
$motivazione.get( 0 ).setCustomValidity( '' );
} )
var argomenti = $.map( [1, 2], function ( n ) {
.filter( function ( el, i, arr ) {
return $( '#PDC-option-topic' + n ).val().trim();
}// )Elimina i duplicati
.filter(return functionel (!== el,'' i,&& arr.indexOf( el ) {=== i;
} ),
return el !== '' && arr.indexOf( el ) === i;
}daNotificare );= $.map( {
notifyCreator: dialog.creatore.user,
var daNotificare = $.map( {
creatornotifyBiggest: creatoredialog.user,maggiore
}, function ( user, opt ) {
biggest: magg
if (
}, function ( user, opt ) {
dialog.options[opt] !== undefined &&
if ( $( '#PDC-option-notify-' + opt ).prop( 'checked' ) === true ) {
dialog.options[opt].isSelected()
return self.namespaces[3] + ':' + user;
}) {
return self.namespaces[3] + ':' + user;
} );
}
var pTalk = self.config.wikiprojectNamespace + 1;
} );
if ( $( '#PDC-option-notify-wikiprojects' ).prop( 'checked' ) === true && pTalk in self.namespaces ) {
if (
pTalk = self.namespaces[pTalk] + ':';
!dialog.options.notifyWikiprojects.isDisabled() &&
daNotificare = daNotificare.concat( $.map( argomenti, function ( arg ) {
dialog.options.notifyWikiprojects.isSelected()
return pTalk + arg;
} ) );{
daNotificare = daNotificare.concat(
}
self$.creaProceduramap( titoloargomenti, motivazionefunction ( argomento ) {
return self.namespaces[dialog.pTalk] + ':' + argomento;
.done( function ( procedura, numero ) {
} )
self.avvisoVoce( titolo, numero, argomenti )
.done( function () {;
}
self.progresso( 'notify-wait' );
self.notificaProceduracreaProcedura( titolo, daNotificaremotivazione )
.done( function ( procedura, numero ) {
self.avvisoVoce( titolo, numero, argomenti )
window.location = mw.util.getUrl( procedura );
}.done( function () {
self.failprogresso( function'notify-wait' () {;
self.errorenotificaProcedura( 'notify-error'titolo, daNotificare );
}.done( function (); {
window.location = mw.util.getUrl( procedura );
} )
} )
.fail( function () {
self.errore( 'nominatenotify-error' );
} );
} );
self.progressofail( 'nominate-wait'function (); {
}self.errore( 'nominate-error' );
.fail(} function () {;
self.erroreprogresso( 'newnominate-nomination-errorwait' );
} );
.fail( function () {
self.progresso( 'new-nomination-wait' );
self.errore( 'new-nomination-error' );
}
} );
self.progresso( 'new-nomination-wait' );
};
PDC.Dialog.prototype.getActionProcess = function ( action ) {
return PDC.Dialog.super.prototype.getActionProcess.call( this, action )
.next( function () {
var dialog = this;
if ( action === 'proceed' ) {
if ( dialog.starting === true ) {
dialog.starting = false;
dialog.proceed();
} else {
dialog.options.reason.isValid()
.done( function ( isValid ) {
if ( isValid ) {
dialog.final();
}
]} );
} );
} else {
return this.close();
}
}, this );
]};
var windowManager = new OO.ui.WindowManager();
} );
$( 'body' ).append( windowManager.$element );
self.dialog = new PDC.Dialog();
windowManager.addWindows( [ self.dialog ] );
windowManager.openWindow( self.dialog );
} );
},
Line 1 092 ⟶ 1 162:
preInit: function () {
if (
// pagina esistente
mw.config.get( 'wgArticleId' ) > 0 &&
// in modalità di visualizzazione
mw.config.get( 'wgAction' ) === 'view' &&
Line 1 401 ⟶ 1 473:
}
};
window.PDC.preInit();
window.PDC = PDC;
}( mediaWiki, jQuery ) );