Difference between revisions of "MediaWiki:Common.js"

From SCI Wiki
Jump to navigationJump to search
 
(62 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
 +
// Underscore
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Underscore',
 +
        imageFile: '/buttons/FormatUnderscore.png',
 +
        speedTip: "Underscore",
 +
        tagOpen: "<u>",
 +
        tagClose: "</u>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Strikethrough
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Strikethrough',
 +
        imageFile: '/buttons/FormatStrike.png',
 +
        speedTip: "Strikethrough",
 +
        tagOpen: "<strike>",
 +
        tagClose: "</strike>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Align Left
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-AlignLeft',
 +
        imageFile: '/buttons/AlignLeft.png',
 +
        speedTip: "Align Left",
 +
        tagOpen: "<div align=\"left\">",
 +
        tagClose: "</div>",
 +
        sampleText: "content here"
 +
});
 +
 +
// Align Center
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-AlignCenter',
 +
        imageFile: '/buttons/AlignCenter.png',
 +
        speedTip: "Align Center",
 +
        tagOpen: "<div align=\"center\">",
 +
        tagClose: "</div>",
 +
        sampleText: "content here"
 +
});
 +
 +
// Align Right
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-AlignRight',
 +
        imageFile: '/buttons/AlignRight.png',
 +
        speedTip: "Align Right",
 +
        tagOpen: "<div align=\"right\">",
 +
        tagClose: "</div>",
 +
        sampleText: "content here"
 +
});
 +
 +
// Justify
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Justify',
 +
        imageFile: '/buttons/AlignJustify.png',
 +
        speedTip: "Justify",
 +
        tagOpen: "<div align=\"justify\">",
 +
        tagClose: "</div>",
 +
        sampleText: ""
 +
});
 +
 +
// Indent
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Indent',
 +
        imageFile: '/buttons/Indent.png',
 +
        speedTip: "Indent",
 +
        tagOpen: "<blockquote>",
 +
        tagClose: "</blockquote>",
 +
        sampleText: "Insert comment here"
 +
});
 +
 +
// Offset
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Offset',
 +
        imageFile: '/buttons/Offset.png',
 +
        speedTip: "Offset",
 +
        tagOpen: "<blockquote class=\"offset\">",
 +
        tagClose: "</blockquote>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Quote
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Quote',
 +
        imageFile: 'http://wiki.sierrahelp.com/buttons/Quote.png',
 +
        speedTip: "Quote",
 +
        tagOpen: "<div class=\"Quote\">\n{{Quote|Attrib = \n}}\n",
 +
        tagClose: "\n</div>",
 +
        sampleText: "Quoted text here"
 +
});
 +
 +
// Alert
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Alert',
 +
        imageFile: '/buttons/Red.png',
 +
        speedTip: "Alert",
 +
        tagOpen: "<span class=\"Alert\">",
 +
        tagClose: "</span>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Inactive
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Inactive',
 +
        imageFile: '/buttons/Gray.png',
 +
        speedTip: "Inactive",
 +
        tagOpen: "<span class=\"Inactive\">",
 +
        tagClose: "</span>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Add Reference
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Reference',
 +
        imageFile: '/buttons/Reference.png',
 +
        speedTip: "Add Reference",
 +
        tagOpen: "<ref>",
 +
        tagClose: "</ref>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Add Citation Required Notice
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-CitationWarning',
 +
        imageFile: '/buttons/CitationWarning.png',
 +
        speedTip: "Add Reference",
 +
        tagOpen: "{{CitationReq}}"
 +
});
 +
 +
// Wikipedia Link
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Wikipedia',
 +
        imageFile: '/buttons/Wikipedia.png',
 +
        speedTip: "Wikipedia Link",
 +
        tagOpen: "[[w:|",
 +
        tagClose: "]]",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Redirect
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Redirect',
 +
        imageFile: '/buttons/Redirect.png',
 +
        speedTip: "Redirect",
 +
        tagOpen: "#REDIRECT [[",
 +
        tagClose: "]]",
 +
        sampleText: "code here"
 +
});
 +
 +
// Superscript
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Superscript',
 +
        imageFile: '/buttons/Superscript.png',
 +
        speedTip: "Superscript",
 +
        tagOpen: "<sup>",
 +
        tagClose: "</sup>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Subscript
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Subscript',
 +
        imageFile: '/buttons/Subscript.png',
 +
        speedTip: "Subscript",
 +
        tagOpen: "<sub>",
 +
        tagClose: "</sub>",
 +
        sampleText: "Text here"
 +
});
 +
 +
// Half
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Half',
 +
        imageFile: '/buttons/Half.png',
 +
        speedTip: "Half",
 +
        tagOpen: "½",
 +
        tagClose: "",
 +
        sampleText: ""
 +
});
 +
 +
// Quarter
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Quarter',
 +
        imageFile: '/buttons/Quarter.png',
 +
        speedTip: "Quarter",
 +
        tagOpen: "¼",
 +
        tagClose: "",
 +
        sampleText: ""
 +
});
 +
 +
// Copyright
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Copyright',
 +
        imageFile: '/buttons/Copyright.png',
 +
        speedTip: "Copyright",
 +
        tagOpen: "©",
 +
        tagClose: "",
 +
        sampleText: ""
 +
});
  
// OLD WAY - "classic toolbar":
+
// Comment
 
mw.toolbar.addButton({
 
mw.toolbar.addButton({
         imageId: 'mw-customeditbutton-myspecialbutton',
+
         imageId: 'mw-customeditbutton-Comment',
         imageFile: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
+
         imageFile: '/buttons/Comment.png',
         speedTip: "Title label",
+
        speedTip: "Comment",
         tagOpen: "Smile (",
+
        tagOpen: "<!-- ",
         tagClose: ")",
+
        tagClose: " -->",
         sampleText: "sample"
+
        sampleText: "Insert comment here"
 +
});
 +
 
 +
// Non-breaking space
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-NoBreak',
 +
        imageFile: '/buttons/NoBreak.png',
 +
        speedTip: "Non-breaking Space",
 +
        tagOpen: "&nbsp;",
 +
        tagClose: "",
 +
        sampleText: ""
 +
});
 +
 
 +
// New Line
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-NewLine',
 +
        imageFile: '/buttons/NewLine.png',
 +
        speedTip: "New Line",
 +
        tagOpen: "",
 +
        tagClose: "<br />\n",
 +
        sampleText: ""
 +
});
 +
 
 +
// Table
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-Table',
 +
        imageFile: '/buttons/Table.png',
 +
        speedTip: "Table",
 +
        tagOpen: "{| cellpadding=\"10\" align=\"center\" width=\"85%\"\n|- \n|align=\"center\"| ",
 +
        tagClose: "\n|}",
 +
        sampleText: "Insert content here"
 +
});
 +
 
 +
// Add template
 +
mw.toolbar.addButton({
 +
        imageId: 'mw-customeditbutton-NewTemplate',
 +
        imageFile: '/buttons/Template.png',
 +
         speedTip: "Add template",
 +
         tagOpen: "{{",
 +
         tagClose: "}}",
 +
         sampleText: "Template Name"
 
});
 
});
 
   
 
   
// NEW WAY - "WikiEditor":
+
// AGI Code
krInsertWikiEditorButton({
+
mw.toolbar.addButton({
         id: 'mw-customeditbutton-myspecialbutton',
+
         imageId: 'mw-customeditbutton-AGI',
         icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png',
+
         imageFile: '/buttons/AGI.png',
         label: 'Title label',
+
         speedTip: "AGI Code",
         insertBefore: 'Smile (',
+
         tagOpen: "<div class=\"CodeBlockHeader\">AGI Code:</div>\n<syntaxhighlight lang=\"agi\">\n",
         insertAfter: ')',
+
         tagClose: "</syntaxhighlight>",
         sampleText: 'sample'
+
         sampleText: "code here"
 
});
 
});
  
/**
+
// SCI Code
* Extra buttons in toolbar
+
mw.toolbar.addButton({
* @stats [[File:Krinkle_InsertWikiEditorButton.js]]
+
        imageId: 'mw-customeditbutton-SCI',
*/
+
        imageFile: '/buttons/SCI.png',
jQuery.getScript('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript', function () {
+
        speedTip: "SCI Code",
+
        tagOpen: "<div class=\"CodeBlockHeader\">SCI Code:</div>\n<syntaxhighlight lang=\"sci\">\n",
        // Happy face
+
        tagClose: "</syntaxhighlight>",
        krInsertWikiEditorButton({
+
        sampleText: "code here"
                id: "mw-customeditbutton-myspecialbutton",
+
});
                icon: "//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png",
+
 
                label: 'Insert happy face',
+
// Code
                insertBefore: '[[File:Gnome-face-smile.svg|21px|',
+
mw.toolbar.addButton({
                insertAfter: ']]',
+
        imageId: 'mw-customeditbutton-Code',
                sampleText: 'Happy face'
+
        imageFile: '/buttons/code.png',
        });
+
        speedTip: "Code",
+
        tagOpen: "<code>",
        // Monkey
+
        tagClose: "</code>",
        krInsertWikiEditorButton({
+
        sampleText: "code here"
                id: 'mw-customeditbutton-anotherspecialbutton',
+
});
                icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1b/Gnome-face-monkey.svg/22px-Gnome-face-monkey.svg.png',
+
 
                label: 'Insert monkey',
+
// Preformatted
                insertBefore: '[[File:Gnome-face-monkey.svg|21px|',
+
mw.toolbar.addButton({
                insertAfter: ']]',
+
        imageId: 'mw-customeditbutton-Pre',
                sampleText: 'Happy face'
+
        imageFile: '/buttons/pre.png',
        });
+
        speedTip: "Preformatted",
+
        tagOpen: "<pre>",
}); /* */
+
        tagClose: "</pre>",
 +
        sampleText: "code here"
 +
});
  
var addExtraButtons = function(){
+
// Clear
        mw.toolbar.addButtons( {
+
mw.toolbar.addButton({
                imageFile: '//upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png',
+
        imageId: 'mw-customeditbutton-Clear',
                speedTip: 'Comment visible only for editors',
+
        imageFile: '/buttons/Clear.png',
                tagOpen: '<!-- ',
+
        speedTip: "Clear",
                tagClose: ' -->',
+
        tagOpen: "<div>",
                sampleText: 'Insert comment here',
+
        tagClose: "</div>",
                imageId: 'button-comment'
+
        sampleText: "Text here"
        } );
+
});
};
 
 
if( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
 
        mw.loader.using( 'user.options', function () {
 
                if ( ! mw.user.options.get( 'usebetatoolbar' ) ) {
 
                        mw.loader.using( 'mediawiki.action.edit', function(){
 
                                $( addExtraButtons );
 
                        } );
 
                }
 
        } );
 
}
 

Latest revision as of 13:28, 8 September 2020

/* Any JavaScript here will be loaded for all users on every page load. */

// Underscore
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Underscore',
        imageFile: '/buttons/FormatUnderscore.png',
        speedTip: "Underscore",
        tagOpen: "<u>",
        tagClose: "</u>",
        sampleText: "Text here"
});

// Strikethrough
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Strikethrough',
        imageFile: '/buttons/FormatStrike.png',
        speedTip: "Strikethrough",
        tagOpen: "<strike>",
        tagClose: "</strike>",
        sampleText: "Text here"
});

// Align Left
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-AlignLeft',
        imageFile: '/buttons/AlignLeft.png',
        speedTip: "Align Left",
        tagOpen: "<div align=\"left\">",
        tagClose: "</div>",
        sampleText: "content here"
});

// Align Center
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-AlignCenter',
        imageFile: '/buttons/AlignCenter.png',
        speedTip: "Align Center",
        tagOpen: "<div align=\"center\">",
        tagClose: "</div>",
        sampleText: "content here"
});

// Align Right
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-AlignRight',
        imageFile: '/buttons/AlignRight.png',
        speedTip: "Align Right",
        tagOpen: "<div align=\"right\">",
        tagClose: "</div>",
        sampleText: "content here"
});

// Justify
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Justify',
        imageFile: '/buttons/AlignJustify.png',
        speedTip: "Justify",
        tagOpen: "<div align=\"justify\">",
        tagClose: "</div>",
        sampleText: ""
});

// Indent
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Indent',
        imageFile: '/buttons/Indent.png',
        speedTip: "Indent",
        tagOpen: "<blockquote>",
        tagClose: "</blockquote>",
        sampleText: "Insert comment here"
});

// Offset
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Offset',
        imageFile: '/buttons/Offset.png',
        speedTip: "Offset",
        tagOpen: "<blockquote class=\"offset\">",
        tagClose: "</blockquote>",
        sampleText: "Text here"
});

// Quote
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Quote',
        imageFile: 'http://wiki.sierrahelp.com/buttons/Quote.png',
        speedTip: "Quote",
        tagOpen: "<div class=\"Quote\">\n{{Quote|Attrib = \n}}\n",
        tagClose: "\n</div>",
        sampleText: "Quoted text here"
});

// Alert
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Alert',
        imageFile: '/buttons/Red.png',
        speedTip: "Alert",
        tagOpen: "<span class=\"Alert\">",
        tagClose: "</span>",
        sampleText: "Text here"
});

// Inactive
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Inactive',
        imageFile: '/buttons/Gray.png',
        speedTip: "Inactive",
        tagOpen: "<span class=\"Inactive\">",
        tagClose: "</span>",
        sampleText: "Text here"
});

// Add Reference
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Reference',
        imageFile: '/buttons/Reference.png',
        speedTip: "Add Reference",
        tagOpen: "<ref>",
        tagClose: "</ref>",
        sampleText: "Text here"
});

// Add Citation Required Notice
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-CitationWarning',
        imageFile: '/buttons/CitationWarning.png',
        speedTip: "Add Reference",
        tagOpen: "{{CitationReq}}"
});

// Wikipedia Link
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Wikipedia',
        imageFile: '/buttons/Wikipedia.png',
        speedTip: "Wikipedia Link",
        tagOpen: "[[w:|",
        tagClose: "]]",
        sampleText: "Text here"
});

// Redirect
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Redirect',
        imageFile: '/buttons/Redirect.png',
        speedTip: "Redirect",
        tagOpen: "#REDIRECT [[",
        tagClose: "]]",
        sampleText: "code here"
});

// Superscript
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Superscript',
        imageFile: '/buttons/Superscript.png',
        speedTip: "Superscript",
        tagOpen: "<sup>",
        tagClose: "</sup>",
        sampleText: "Text here"
});

// Subscript
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Subscript',
        imageFile: '/buttons/Subscript.png',
        speedTip: "Subscript",
        tagOpen: "<sub>",
        tagClose: "</sub>",
        sampleText: "Text here"
});

// Half
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Half',
        imageFile: '/buttons/Half.png',
        speedTip: "Half",
        tagOpen: "½",
        tagClose: "",
        sampleText: ""
});

// Quarter
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Quarter',
        imageFile: '/buttons/Quarter.png',
        speedTip: "Quarter",
        tagOpen: "¼",
        tagClose: "",
        sampleText: ""
});

// Copyright
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Copyright',
        imageFile: '/buttons/Copyright.png',
        speedTip: "Copyright",
        tagOpen: "©",
        tagClose: "",
        sampleText: ""
});

// Comment
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Comment',
        imageFile: '/buttons/Comment.png',
        speedTip: "Comment",
        tagOpen: "<!-- ",
        tagClose: " -->",
        sampleText: "Insert comment here"
});

// Non-breaking space
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-NoBreak',
        imageFile: '/buttons/NoBreak.png',
        speedTip: "Non-breaking Space",
        tagOpen: "&nbsp;",
        tagClose: "",
        sampleText: ""
});

// New Line
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-NewLine',
        imageFile: '/buttons/NewLine.png',
        speedTip: "New Line",
        tagOpen: "",
        tagClose: "<br />\n",
        sampleText: ""
});

// Table
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Table',
        imageFile: '/buttons/Table.png',
        speedTip: "Table",
        tagOpen: "{| cellpadding=\"10\" align=\"center\" width=\"85%\"\n|- \n|align=\"center\"| ",
        tagClose: "\n|}",
        sampleText: "Insert content here"
});

// Add template
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-NewTemplate',
        imageFile: '/buttons/Template.png',
        speedTip: "Add template",
        tagOpen: "{{",
        tagClose: "}}",
        sampleText: "Template Name"
});
 
// AGI Code
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-AGI',
        imageFile: '/buttons/AGI.png',
        speedTip: "AGI Code",
        tagOpen: "<div class=\"CodeBlockHeader\">AGI Code:</div>\n<syntaxhighlight lang=\"agi\">\n",
        tagClose: "</syntaxhighlight>",
        sampleText: "code here"
});

// SCI Code
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-SCI',
        imageFile: '/buttons/SCI.png',
        speedTip: "SCI Code",
        tagOpen: "<div class=\"CodeBlockHeader\">SCI Code:</div>\n<syntaxhighlight lang=\"sci\">\n",
        tagClose: "</syntaxhighlight>",
        sampleText: "code here"
});

// Code
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Code',
        imageFile: '/buttons/code.png',
        speedTip: "Code",
        tagOpen: "<code>",
        tagClose: "</code>",
        sampleText: "code here"
});

// Preformatted
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Pre',
        imageFile: '/buttons/pre.png',
        speedTip: "Preformatted",
        tagOpen: "<pre>",
        tagClose: "</pre>",
        sampleText: "code here"
});

// Clear
mw.toolbar.addButton({
        imageId: 'mw-customeditbutton-Clear',
        imageFile: '/buttons/Clear.png',
        speedTip: "Clear",
        tagOpen: "<div>",
        tagClose: "</div>",
        sampleText: "Text here"
});