MediaWiki:Gadget-SureSureSure.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
rimuovo, visto il miglioramento senza la dipendenza |
|||
Riga 1:
/**
* Aggiunge una richiesta di conferma al primo click di un rollback nella pagina
* e lascia che i successivi rollback partano come di consueto all'istante.
* 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
* @author [[w:User:Valerio Bozzolan]] and contributors
*/
const defaultOpts = {▼
confirm: 'sicuro sicuro sicuro?',▼
disablePatrolAjax: false,▼
};▼
var opts = $.extend( defaultOpts, window.sureSureSure );▼
$( function () {
mw.hook( 'wikipage.content' ).add( function () {▼
$( '.mw-rollback-link a' ).click( function ( event ) {▼
var yes = 'ok-guy-im-not-accidetally-clicking-this';▼
hasTouchScreen: undefined,
if( ! $(this).hasClass(yes) && ! window.sureSureSure._yetConfirmed ) {▼
maxScreenWidth: Infinity
var $t = $(this);▼
▲ };
$t.addClass(yes).text( $t.text() + ": " + opts.confirm );▼
event.preventDefault();▼
}▼
▲ var opts = $.extend( defaultOpts, window.sureSureSure );
if (
opts.maxScreenWidth >= window.innerWidth &&
( opts.hasTouchScreen === undefined || opts.hasTouchScreen === navigator.maxTouchPoints > 0 )
) {
▲ $( '.mw-rollback-link a' ).click( function ( event ) {
▲ var $t = $( this );
▲ $t.addClass( yes ).text( $t.text() + ": " + opts.confirm );
▲ event.preventDefault();
window.sureSureSure._yetConfirmed = true;
▲ }
} );
} );
}
if ( opts.disablePatrolAjax ) {▼
▲ if( opts.disablePatrolAjax ) {
▲ mw.loader.using( 'mediawiki.misc-authed-curate' ).catch( function () {
$( '.patrollink[data-mw="interface"] a' ).off( 'click' );
} );
|