User:Tommy Jantarek/common.js

mw.loader.load('//en.wikisource.org/w/index.php?title=User:Samwilson/FullScreenEditing.js&action=raw&ctype=text/javascript'); mw.loader.load('//pl.wikipedia.org/w/index.php?title=User:Nux/hideSidebar.js&action=raw&ctype=text/javascript'); mw.loader.load('//pl.wikisource.org/w/index.php?title=MediaWiki:Gadget-lib-shortcuts.js&action=raw&ctype=text/javascript');

window.shortcutsGadget = { version: 3, pageLoaded: false, queue: [],

addTextShortcut: function( keystroke, tagOpen, tagClose, sampleText ) { if ( tagClose === null ) { tagClose = ''; }

if ( sampleText === null ) { sampleText = ''; }

var callback = function { $( ':focus' ).textSelection(					'encapsulateSelection', {						pre: tagOpen,						peri: sampleText,						post: tagClose					}				); return false; };

var item = { keystroke: keystroke, callback: callback };

if ( this.pageLoaded ) { this.addTextShortcutNow( item ); } else { this.queue.push( item ); }	},

addTextShortcutNow: function( item ) { shortcut.add( item.keystroke, item.callback, {			target: document		} ); },

removeAll: function { this.queue = []; },

bindShortcuts: function { for ( var i = 0; i < this.queue.length; i++ ) { this.addTextShortcutNow( this.queue[i] ); }		this.removeAll; },

init: function { this.pageLoaded = true; this.bindShortcuts; } };

jQuery( document ).ready( function {	shortcutsGadget.init; } );

setTimeout( function {   shortcutsGadget.addTextShortcut('alt+q', '—', , );    shortcutsGadget.addTextShortcut('alt+t', 'ë', , );    shortcutsGadget.addTextShortcut('alt+y', 'Ë', , );    shortcutsGadget.addTextShortcut('alt+w', ' ', , ); }, 1000 );