Difference between revisions of "MediaWiki:Common.js/edit.js"

m
m
Line 79: Line 79:
  
 
var symbols = new Array();
 
var symbols = new Array();
symbol["text"] = "Insert a symbol";
+
symbols["text"] = "Insert a symbol";
  
 
symbols["nonstandard"] = new Array();
 
symbols["nonstandard"] = new Array();

Revision as of 14:55, 16 July 2009

/* Any JavaScript here will be loaded for all users on all edit pages. */
//<source lang="javascript">
 
/***********************************************************
 *  Extra toolbar options
 *
 *  Description: Adds extra buttons to the editing toolbar.
 ***********************************************************/
if (mwCustomEditButtons) {
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/c/c8/Button_redirect.png",
        "speedTip": "Redirect",
        "tagOpen": "#REDIRECT[[",
        "tagClose": "]]",
        "sampleText": "Target page name"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/1/13/Button_enter.png",
        "speedTip": "Line break",
        "tagOpen": "<br />",
        "tagClose": "",
        "sampleText": ""
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/6/6a/Button_sup_letter.png",
        "speedTip": "Superscript",
        "tagOpen": "<sup>",
        "tagClose": "</sup>",
        "sampleText": "Superscript text"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/a/aa/Button_sub_letter.png",
        "speedTip": "Subscript",
        "tagOpen": "<sub>",
        "tagClose": "</sub>",
        "sampleText": "Subscript text"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/1/17/Button_small_2.png",
        "speedTip": "Small text",
        "tagOpen": "<small>",
        "tagClose": "</small>",
        "sampleText": "Small text"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/1/12/Button_gallery.png",
        "speedTip": "Insert a picture gallery",
        "tagOpen": "\n<gallery>\n",
        "tagClose": "\n</gallery>",
        "sampleText": "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/6/60/Button_insert_table.png",
        "speedTip": "Insert a table",
        "tagOpen": '{| class="wikitable" border="1"\n|',
        "tagClose": "\n|}",
        "sampleText": "-\n! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"
    });
 
    mwCustomEditButtons.push({
        "imageFile": "http://sarna.net/wiki/images/7/79/Button_reflink.png",
        "speedTip": "Insert a reference",
        "tagOpen": "<ref>",
        "tagClose": "</ref>",
        "sampleText": "Insert footnote text here"
    });

    if (isTesting) {
        addOnloadHook(insertToolbarMenus);
    }
}


var symbols = new Array();
symbols["text"] = "Insert a symbol";

symbols["nonstandard"] = new Array();
symbols["nonstandard"]["vowels"] = new Array();
symbols["nonstandard"]["vowels"]["title"] = "Vowels: "
symbols["nonstandard"]["vowels"]["items"] = new Array("Á", "á", "À", "à", "Ã", "ã", "É", "é", "È", "è", "Ẽ", "ẽ", "Í", "í", "Ì", "ì", "Ĩ", "ĩ", "Ó", "ó", "Ò", "ò", "Õ", "õ", "Ú", "ú", "Ù", "ù", "Ũ", "ũ");

symbols["sections"] = new Array();
symbols["sections"]["vowels"] = new Array();
symbols["sections"]["vowels"]["title"] = "Vowels: "
symbols["sections"]["vowels"]["items"] = new Array("Á", "á", "À", "à", "Ã", "ã", "É", "é", "È", "è", "Ẽ", "ẽ", "Í", "í", "Ì", "ì", "Ĩ", "ĩ", "Ó", "ó", "Ò", "ò", "Õ", "õ", "Ú", "ú", "Ù", "ù", "Ũ", "ũ");

symbols["sections"]["consonants"] = new Array();
symbols["sections"]["consonants"]["title"] = "Consonants: "
symbols["sections"]["consonants"]["items"] = new Array("Ć", "ć", "Ç", "ç", "Ģ", "ģ", "Ķ", "ķ", "Ĺ", "ĺ", "Ļ", "ļ", "Ń", "ń", "Ñ", "ñ", "Ņ", "ņ", "Ŕ", "ŕ", "Ŗ", "ŗ", "Ś", "ś", "Ş", "ş", "Ţ", "ţ", "Ý", "ý", "Ỹ", "ỹ", "Ź", "ź", "ß", "Đ", "đ");


var stubs = new Array("{{stub}}", "{{sectionstub}}");
var notices = new Array("{{Citation needed}}", "{{Update Needed}}", "{{Cleanup}}", "{{Verify}}", "{{NonCanon}}", "{{Moratorium}}");
var misc = new Array("{{disambig}}", "{{quote| }}", "{{yearlist}}", "{{otheruses| | | }}");

/***********************************************************
 *  insertToolbarMenus()
 *
 *  Description: 
 ***********************************************************/
function insertToolbarMenus() {
    var insert = '<div><strong>' + symbols['text'] + ':</strong><br />';

    for (var i in symbols['sections']) {
        insert += symbols['sections'][i]['title'] + "<br />";

        for (var j=0; j < symbols['sections'][i]['items'].length; j++) {
            insert += wrapToolbarCharacter(symbols['sections'][i]['items'][j]);
        }
        insert += "<hr />";
    }

    insert += "</div>";

    $("#editform").prepend(insert);
};

/***********************************************************
 *  wrapToolbarCharacter()
 *
 *  Description: 
 ***********************************************************/
function wrapToolbarCharacter(char) {
    return '<a title="Click on the character or tag to insert it into the edit window" href="javascript:insertTags(\'' + char + '\',\'\',\'\'); return false">' + char + '</a> &nbsp;';
};

//</source>