MediaWiki

Gadget-sandbox.js

From Dogcraft Wiki

(preventing middle click mousedown default too)
m (quick test)
Tag: Reverted
Line 33: Line 33:
$( '#mw-content-text' ).append( button.$element );*/
$( '#mw-content-text' ).append( button.$element );*/
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);
/*$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, confirmDialog);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, confirmDialog);
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', function( event ){
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', function( event ){
if (event.originalEvent.which != 2) return;
if (event.originalEvent.which != 2) return;
event.preventDefault();
event.preventDefault();
});*/
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, function ( event ) {
return OO.ui.confirm( 'Are you sure?' ).then( function ( confirmed ) {
    if ( confirmed ) {
    return true;
        /*switch(event.data.clickType) {
        case "click":
        window.location.href = event.target.href;
        break;
        case "middle":
        window.open(event.target.href, "_blank");
        break;
        }*/
        }
    });
});
});

Revision as of 00:41, 17 December 2021

$(document).ready(function() {
	
	if (mw.config.get('wgPageName') === 'User:Domino/Sandbox') {
		
		mw.loader.using( ['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows'] ).done( function () {
			
			function confirmDialog( event ) {
						if (event.data.clickType == "middle")
							if (event.originalEvent.which != 2) return;
							
						event.preventDefault();
					    
						OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
	    					if ( confirmed ) {
	        					switch(event.data.clickType) {
	        						case "click":
	        							window.location.href = event.target.href;
	        							break;
        							case "middle":
        								window.open(event.target.href, "_blank");
        								break;
	        					}
	        				}
	        					
	    				});
					}
			
			$( function () {
				/*var button = new OO.ui.ButtonWidget( {
					label: 'Click me!',
					classes: [ 'confirm-sandbox' ]
				});
				$( '#mw-content-text' ).append( button.$element );*/
				
				/*$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, confirmDialog);
				$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mouseup', {clickType: "middle"}, confirmDialog);
				$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('mousedown', function( event ){
					if (event.originalEvent.which != 2) return;
					event.preventDefault();
				});*/
				
				$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', {clickType: "click"}, function ( event ) {
					return OO.ui.confirm( 'Are you sure?' ).then( function ( confirmed ) {
	    					if ( confirmed ) {
	    						return true;
	        					/*switch(event.data.clickType) {
	        						case "click":
	        							window.location.href = event.target.href;
	        							break;
        							case "middle":
        								window.open(event.target.href, "_blank");
        								break;
	        					}*/
	        				}
    				});
				});
				
				
				
				
			});
		});
		
	}
	
});
This page was last modified on 17 December 2021, at 00:41. (2 years ago)