MediaWiki:Gadget-SureSureSure.js: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Contenuto cancellato Contenuto aggiunto
m fix _yetConfirmed |
Rendo locale la variabile di opzioni. Adesso specificando window.sureSureSure = ... viene usato il default per i valori mancanti. |
||
Riga 12: | Riga 12: | ||
* @see https://phabricator.wikimedia.org/T49782 |
* @see https://phabricator.wikimedia.org/T49782 |
||
*/ |
*/ |
||
const defaultOpts = { |
|||
window.sureSureSure = window.sureSureSure || { |
|||
confirm: 'sicuro sicuro sicuro?', |
confirm: 'sicuro sicuro sicuro?', |
||
disablePatrolAjax: false, |
disablePatrolAjax: false, |
||
}; |
}; |
||
var opts = $.extend( defaultOps, window.sureSureSure ); |
|||
$( function () { |
$( function () { |
||
$( '.mw-rollback-link a' ).click( function ( event ) { |
$( '.mw-rollback-link a' ).click( function ( event ) { |
||
Riga 21: | Riga 22: | ||
if( ! $(this).hasClass(yes) && ! window.sureSureSure._yetConfirmed ) { |
if( ! $(this).hasClass(yes) && ! window.sureSureSure._yetConfirmed ) { |
||
var $t = $(this); |
var $t = $(this); |
||
$t.addClass(yes).text( $t.text() + ": " + |
$t.addClass(yes).text( $t.text() + ": " + opts.confirm ); |
||
event.preventDefault(); |
event.preventDefault(); |
||
window.sureSureSure._yetConfirmed = true; |
window.sureSureSure._yetConfirmed = true; |
||
Riga 29: | Riga 30: | ||
// actually this is the simpler way to prevent automatic patrol action |
// actually this is the simpler way to prevent automatic patrol action |
||
// @see mediwiki.page.patrol.ajax ResourceLoader module |
// @see mediwiki.page.patrol.ajax ResourceLoader module |
||
if( |
if( opts.disablePatrolAjax ) { |
||
$( '.patrollink[data-mw="interface"] a' ).off( 'click' ); |
$( '.patrollink[data-mw="interface"] a' ).off( 'click' ); |
||
} |
} |
Versione delle 11:17, 17 feb 2019
/**
* Questo gadget è per te se non sai come mai MediaWiki chieda conferma
* per ringraziare qualcuno, mentre per rollbackare no. asd
*
* This gadget is for you if you don't know why MediaWiki asks for confirmation
* to thank someone, but it doesn't for rollbacking. asd
*
* TODO: this snippet should coexist with the 'mediawiki.page.patrol.ajax' ResourceLoader module somehow.
*
* @license [[WTFPL]] or [[GNU GPL]] or [[CC BY SA 3.0]] at your opinion
* @author [[w:User:Valerio Bozzolan]] and contributors
* @see https://phabricator.wikimedia.org/T49782
*/
const defaultOpts = {
confirm: 'sicuro sicuro sicuro?',
disablePatrolAjax: false,
};
var opts = $.extend( defaultOps, window.sureSureSure );
$( function () {
$( '.mw-rollback-link a' ).click( function ( event ) {
var yes = 'ok-guy-im-not-accidetally-clicking-this';
if( ! $(this).hasClass(yes) && ! window.sureSureSure._yetConfirmed ) {
var $t = $(this);
$t.addClass(yes).text( $t.text() + ": " + opts.confirm );
event.preventDefault();
window.sureSureSure._yetConfirmed = true;
}
} );
// actually this is the simpler way to prevent automatic patrol action
// @see mediwiki.page.patrol.ajax ResourceLoader module
if( opts.disablePatrolAjax ) {
$( '.patrollink[data-mw="interface"] a' ).off( 'click' );
}
} );