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

Contenuto cancellato Contenuto aggiunto
aggiunta nota documentativa e rimosso .off()
m namo bene
Etichetta: Annulla
 
(19 versioni intermedie di 4 utenti non mostrate)
Riga 1:
/**
* PerAggiunge ringraziareuna chiederichiesta di conferma, mentreal primo click di perun rollbackarerollback no.nella BENE.pagina asde
* consente a tutti i rollback successivi di partire all'istante come di consueto.
* L'uso è configurabile a seconda di touch screen e dimensioni della finestra.
*
* @license [[WTFPL]] or [[GNU GPL]] or [[CC BY SA 3.0]] at your opinion
* To thank it asks for confirmation. To rollback no. GOOD. asd
* @author [[Utentew:User:Valerio Bozzolan]] and contributors
*
* Note that this snippets should be executed after
* the 'mediawiki.page.patrol.ajax' ResourceLoader module in order
* to prevent its default action.
*
* @license [[WTFPL]]
* @author [[Utente:Valerio Bozzolan]] and contributors
* @see https://phabricator.wikimedia.org/T49782
*/
 
window.sureSureSure = window.sureSureSure || {};
window.sureSureSure.opts = window.sureSureSure.opts || {
confirm: 'sicuro sicuro sicuro?'
};
$( function () {
var defaultOpts = {
$( '.mw-rollback-link a, .patrollink a' ).click( function ( event ) {
confirm: 'sicuro sicuro sicuro?',
var yes = 'ok-guy-im-not-accidetally-clicking-this';
disablePatrolAjax: false,
if( ! $(this).hasClass(yes) && ! window.sureSureSure.opts._yetConfirmed ) {
hasTouchScreen: undefined,
var $t = $(this);
maxScreenWidth: Infinity
$t.addClass(yes).text( $t.text() + ": " + window.sureSureSure.opts.confirm );
};
event.preventDefault();
 
window.sureSureSure.opts._yetConfirmed = true;
window.sureSureSure = window.sureSureSure || {};
}
 
var opts = $.extend( defaultOpts, window.sureSureSure );
var isIOS = /iPad|iPhone|iPod/.test( navigator.platform ); // Safari iOS pre 13
 
if (
opts.maxScreenWidth < window.innerWidth ||
opts.hasTouchScreen !== undefined &&
opts.hasTouchScreen !== ( isIOS ? isIOS : navigator.maxTouchPoints > 0 )
) {
return;
*}
 
mw.hook( 'wikipage.content' ).add( function () {
$( '.mw-rollback-link a, .patrollink a' ).click( function ( event ) {
var yes = 'ok-guy-im-not-accidetallyaccidentally-clicking-this';
if( ! $( this ).hasClass( yes ) && ! window.sureSureSure.opts._yetConfirmed ) {
var $t = $( this );
$t.addClass( yes ).text( $t.text() + ": " + window.sureSureSure.opts.confirm );
event.preventDefault();
window.sureSureSure.opts._yetConfirmed = true;
}
} );
} );
 
if ( opts.disablePatrolAjax ) {
mw.loader.using( 'mediawiki.misc-authed-curate' ).then( function () {
$( '.patrollink[data-mw="interface"] a' ).off( 'click' );
} );
*}
} );