User:MarkS/XEB/dev.js

/* Version: 3.1 * ============================================================ * en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL * de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE * pt: ACRESCENTA ALGUNS BOTÕES EXTRAS AO PAINEL DE EDIÇÃO * ============================================================ * Vorschläge für neue Buttons werden gerne entgegengenommen * Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar. * * ================================ * Control Variables * * window.rmEditButtons - Removes standard toolbar buttons * window.XEBOrder - The order in which the buttons are displayed * window.myButtons - Add user defined buttons * */

mw.loader.load( '//en.wikipedia.org/w/index.php?title=User:MarkS/XEB/live.css&action=raw&ctype=text/css', 'text/css' );

if (typeof XEBPopups === 'undefined') { XEBPopups = true; } if (typeof XEBHideDelay === 'undefined') { // Time before the popup disappears after the mouse moves out window.XEBHideDelay = 0.5; } if (typeof XEBExtendEditSummary === 'undefined') { // Is the edit summary extended after a popup window.XEBExtendEditSummary = true; }

if (typeof usersignature === 'undefined') { var usersignature = '-- ' + ''; }

var Isrc = '//upload.wikimedia.org/wikipedia/commons/';

var BDict = { 'A': ['e/e9/Button_headline2.png', 'Secondary headline', '\n===', '===', 'Secondary headline'], 'B': ['1/13/Button_enter.png', 'Line break', ' ', , ],	'C': ['5/5f/Button_center.png', 'Center', ' \n', '\n<\/div>', 'Centred text'], 'D': ['e/ea/Button_align_left.png', 'Left-Align', ' \n', '\n<\/div>', 'Left-aligned text'], 'D1': ['a/a5/Button_align_right.png', 'Right-Align', ' \n', '\n<\/div>', 'Right-aligned text'], 'E': ['0/04/Button_array.png', 'Table', '\n{| class="wikitable" \n|- \n| 1 || 2\n|- \n| 3 || 4', '\n|}\n', ''], 'F': ['1/1e/Button_font_color.png', 'Insert coloured text', 'Coloured text<\/span>', 'ColourName'], 'FS': ['1/1b/Button_miss_signature.png', 'Unsigned post', ' — Preceding unsigned comment added by ', ' (talk • contribs) date ', 'user name or IP'], 'G': , 'H': ['7/74/Button_comment.png', 'Comment', "", 'Comment'], 'I1': ['6/6a/Button_sup_letter.png', 'Superscript', ' ', '<\/sup>', 'Superscript text'], 'I2': ['a/aa/Button_sub_letter.png', 'Subscript', ' ', '<\/sub>', 'Subscript text'], 'J1': ['5/58/Button_small.png', 'Small', ' ', '<\/small>', 'Small Text'], 'J2': ['5/56/Button_big.png', 'Big text', ' ', '<\/big>', 'Big text'], 'K': ['b/b4/Button_category03.png', 'Category', "", 'Category name'], 'L': ['8/8e/Button_shifting.png', 'Insert tab(s)', ':', '', ':'], 'M': ['f/fd/Button_blockquote.png', 'Insert block of quoted text', '\n', '\n<\/blockquote>', 'Block quote'], 'N': ['4/4b/Button_nbsp.png', 'nonbreaking space', ' ', , ], 'O': ['2/23/Button_code.png', 'Insert code', ' ' + 'Size:' + 'small' + '[Normal]' + 'big' + ' <\/td><\/tr>' + '<\/form>' + 'Sample:' + ' Text "' +		' Insert ' +		'Cancel ';

curPopup.setInnerHTML(mt);

return true; }

function XEBUpdateSampleText { var f = document.XEBPopupImageForm; }

//====================

function XEBMenuMouseOut(e) { var targ; if (!e) { e = window.event; }	if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; }

targ.style.color = 'black'; }

function XEBMenuMouseOver(e) { var targ; if (!e) { e = window.event; }	if (e.target) { targ = e.target; } else if (e.srcElement) { targ = e.srcElement; }

targ.style.color = 'red'; }

//======================================================================= // Other functions //=======================================================================

function XEBgetElementsByClassName(parent, clsName, htmltag) { var arr = [], elem; var elems = parent.getElementsByTagName(htmltag); for (var cls, i = 0;	(elem = elems[i]); i++) { if (elem.className === clsName) { arr[arr.length] = elem; }	}	return arr; }

function extendSummary(newText) { if (!XEBExtendEditSummary) { return; }	var s = document.editform.elements.wpSummary.value; s += (s === '') ? newText : ' +' + newText; document.editform.elements.wpSummary.value = s; }

function bug(msg) { if (mw.config.get( 'wgUserName' ) === 'MarkS') { alert(msg); } } /* */