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

Contenuto cancellato Contenuto aggiunto
Maintenance: Move wait for 'mediawiki.page.patrol.ajax' from MediaWiki:Gadgets-definition to here (will load faster for rollback case, and needed for the next edit)
m namo bene
Etichetta: Annulla
 
(6 versioni intermedie di 2 utenti non mostrate)
Riga 1:
/**
* Aggiunge una richiesta di conferma al primo click di un rollback nella pagina e
* Questo gadget è per te se non sai come mai MediaWiki chieda conferma
* consente a tutti i rollback successivi di partire all'istante come di consueto.
* per ringraziare qualcuno, mentre per rollbackare no. asd
* L'uso è configurabile a seconda di touch screen e dimensioni della finestra.
*
* 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
*
* This snippet coexists with the MediaWiki core patrol.js code by making
* sure its code runs first, and then our code calls off('click') afterward.
*
* @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,
};
window.sureSureSure = window.sureSureSure || {};
var opts = $.extend( defaultOpts, window.sureSureSure );
$( function () {
const var defaultOpts = {
confirm: 'sicuro sicuro sicuro?',
disablePatrolAjax: false,
hasTouchScreen: undefined,
maxScreenWidth: Infinity
};
 
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' ).click( function ( event ) {
var yes = 'ok-guy-im-not-accidetallyaccidentally-clicking-this';
.click( function ( event ) {
if( ! $( this ).hasClass( yes ) && ! window.sureSureSure._yetConfirmed ) {
var yes = 'ok-guy-im-not-accidetally-clicking-this';
var $t = $( this );
if( ! $(this).hasClass(yes) && ! window.sureSureSure._yetConfirmed ) {
$t.addClass( yes ).text( $t.text() + ": " + opts.confirm );
var $t = $(this);
event.preventDefault();
$t.addClass(yes).text( $t.text() + ": " + opts.confirm );
window.sureSureSure._yetConfirmed = true;
event.preventDefault();
} )
window.sureSureSure._yetConfirmed = true;
} );
} )
.css( 'pointer-events', 'auto' ); // ready
} );
 
if ( opts.disablePatrolAjax ) {
// actually this is the simpler way to prevent automatic patrol action
mw.loader.using( 'mediawiki.page.patrol.ajaxmisc-authed-curate' ).then( function () {
// @see mediawiki.page.patrol.ajax ResourceLoader module
if( opts.disablePatrolAjax ) {
mw.loader.using( 'mediawiki.page.patrol.ajax' ).then( function () {
$( '.patrollink[data-mw="interface"] a' ).off( 'click' );
} );