User:Essjay/editbuttons.js

// //============================================================ // en: ADD SOME EXTRA BUTTONS TO THE EDITPANEL // de: FÜGE NEUE BUTTON IN DIE WERKZEUGLEISTE //============================================================ // Vorschläge für neue Buttons werden gerne entgegengenommen // Die Reihenfolge und Anzahl der Buttons ist über die (alphabetische) Variable XEBOrder wählbar.

//fills the variable mwCustomEditButtons (s. function in /wikibits.js), with buttons for the Toolbar function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText){ mwCustomEditButtons.push({ "imageFile": imageFile,  "speedTip": speedTip,  "tagOpen": tagOpen,  "tagClose": tagClose,  "sampleText": sampleText}); }

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

// English Wikipedia creates 11 extra buttons which are stored in mwCustomEditButtons // rather than mwEditButtons. However, there is no guarantee it will always be 11 // so we count them here. var enExtraButtons=mwCustomEditButtons.length;

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',,,'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',' ','<\/code>','Code'], 'P':['3/3c/Button_pre.png','Pre formatted Text',' ','<\/pre>','Pre formatted text'], 'P1':['9/93/Button_sub_link.png','Insert link to sub-page','','/Sub_Page','Page'], 'Q':['d/d3/Button_definition_list.png','Insert definition list','\n; ','\n: Item 1\n: Item 2','Definition'], 'R':['7/79/Button_reflink.png','Insert a reference',' ','Reference material'], 'R3':['1/1a/Button_reflink_advanced_3.png','No reference material',,'"/>',], 'R4':['9/9a/Button_references.png','Reference footer',"\n==Notes==\n\n\n \n ",,], 'S':['c/c9/Button_strike.png','Strikeout',' ','<\/s>','Struck out text'], 'T':['e/eb/Button_plantilla.png','Template',,'Template name'], 'TS':['a/a4/TableStart.png','Start a table','{|',,], 'TC':['7/71/TableCell.png','Table cell','|',,], 'TE':['0/06/TableEnd.png','End a table',,'|}',], 'TR':['4/4c/TableRow.png','Start a table row','|-',,], 'T1':['3/30/Tt_icon.png','Teletype text','','<\/tt>','Teletype Text'], 'TL':['3/37/Button_tl_template.png','Template link',"",,'Template name'], 'U':['f/fd/Button_underline.png','Underlined'," ","<\/u>",'Underlined text'], 'V':['c/c8/Button_redirect.png','Redirect',"#REDIRECT ","",'Article Name'], 'W':['8/88/Btn_toolbar_enum.png','Numbering',"\n# ","\n# Element 2\n# Element 3",'Element 1'], 'X':['1/11/Btn_toolbar_liste.png','List',"\n* ","\n* Element B\n* Element C",'Element A'], 'Y1':['c/ce/Button_no_include.png','No Include'," ","<\/noinclude>",'Text'], 'Y2':['7/79/Button_include.png','Include only'," ","<\/includeonly>",'Text'], 'Z':['3/35/Button_substitute.png','Substitute',"",'Template'], 'AI': };

var XEBOrder2=[]; if (typeof XEBOrder!='string') // can be modified XEBOrder2="A,B,D,C,D1,F,U,S,I1,I2,J1,E,G,Q,W,X,K,L,M,H,O,R,T,V".split(","); else if (XEBOrder.toLowerCase=='all') for (b in BDict) XEBOrder2.push(b); else XEBOrder2=XEBOrder.toUpperCase.split(",");

function initButtons{

var bc,d;

for (b in BDict) BDict[b][0] = Isrc+BDict[b][0]; // // Add the start of the URL (Isrc) to the XEB buttons // If the user has defined any buttons then add them into the available button lists

if (typeof myButtons=='object') for (b in myButtons) BDict[b] = myButtons[b];	// custom user buttons // Add the media wiki standard buttons into the available buttons

for (b in mwEditButtons) { // add standard buttons for full XEB order changing BDict[b]=[]; for (d in mwEditButtons[b]) BDict[b].push(mwEditButtons[b][d]); }

// Build the new buttons

for (i=0;i<XEBOrder2.length;i++) {

bc = BDict[XEBOrder2[i]]; //Check if bc is an object (its not if just viewing the page, in which case IE might display an error) if(typeof bc!='object')return; addCustomButton(bc[0],bc[1],bc[2],bc[3],bc[4]); }

// Remove the default buttons (if requested by the user) eraseButtons; }

addOnloadHook(initButtons);

/** en: Removes arbitrary standard buttons from the toolbar * @author: de:User:Olliminatore * @version: 0.1 (01.10.2006) **/

function eraseButtons{

//Remove the buttons the user doesn't want

if(typeof rmEditButtons!='object') return;

if (typeof rmEditButtons[0] == 'string' && rmEditButtons[0].toLowerCase == 'all') {		mwEditButtons=[]; for(i=0;i=0 && n=n) mwEditButtons[x] = mwEditButtons[x+1]; }		mwEditButtons.pop; }		//Extra buttons in English Wikipedia n=n-mwEditButtons.length; if(n>0 && n=n) mwCustomEditButtons[x] = mwCustomEditButtons[x+1]; }		mwCustomEditButtons.pop; }	} };

//Function: //	sortit //Purpose: //	Used to sort the rmEditButtons array into descending order function sortit(a,b){ return(b-a) }

//