Difference between revisions of "MediaWiki:Common.js"

From SCI Wiki
Jump to navigationJump to search
 
(46 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: ""
 +
});
  
jQuery.getScript('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript', function () {
 
 
// Comment
 
// Comment
mw.toolbar.addButton({ // OLD WAY - "classic toolbar"
+
mw.toolbar.addButton({
         imageId: 'mw-customeditbutton-myspecialbutton',
+
         imageId: 'mw-customeditbutton-Comment',
         imageFile: '//upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png',
+
         imageFile: '/buttons/Comment.png',
 
         speedTip: "Comment",
 
         speedTip: "Comment",
 
         tagOpen: "<!-- ",
 
         tagOpen: "<!-- ",
Line 14: Line 210:
 
});
 
});
  
krInsertWikiEditorButton({ // NEW WAY - "WikiEditor"
+
// Non-breaking space
         id: 'mw-customeditbutton-myspecialbutton',
+
mw.toolbar.addButton({
         icon: '//upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png',
+
         imageId: 'mw-customeditbutton-NoBreak',
         label: 'Comment',
+
         imageFile: '/buttons/NoBreak.png',
         insertBefore: '<!-- ',
+
         speedTip: "Non-breaking Space",
         insertAfter: ' -->',
+
         tagOpen: "&nbsp;",
         sampleText: 'Insert comment here'
+
         tagClose: "",
 +
         sampleText: ""
 
});
 
});
  
 
+
// New Line
// Comment
+
mw.toolbar.addButton({
mw.toolbar.addButton({ // OLD WAY - "classic toolbar"
+
         imageId: 'mw-customeditbutton-NewLine',
         imageId: 'mw-customeditbutton-myspecialbutton',
+
         imageFile: '/buttons/NewLine.png',
         imageFile: '//upload.wikimedia.org/wikipedia/en/3/34/Button-br.png',
 
 
         speedTip: "New Line",
 
         speedTip: "New Line",
         tagOpen: "<",
+
         tagOpen: "",
         tagClose: "<br />",
+
         tagClose: "<br />\n",
         sampleText: "Insert comment here"
+
         sampleText: ""
 
});
 
});
  
krInsertWikiEditorButton({ // NEW WAY - "WikiEditor"
+
// Table
         id: 'mw-customeditbutton-myspecialbutton',
+
mw.toolbar.addButton({
         icon: '//upload.wikimedia.org/wikipedia/en/3/34/Button-br.png',
+
         imageId: 'mw-customeditbutton-Table',
         label: 'New Line',
+
         imageFile: '/buttons/Table.png',
         insertBefore: '',
+
         speedTip: "Table",
         insertAfter: '<br />',
+
         tagOpen: "{| cellpadding=\"10\" align=\"center\" width=\"85%\"\n|- \n|align=\"center\"| ",
         sampleText: 'Insert comment here'
+
         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',
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . .
+
        speedTip: "Clear",
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
+
        tagOpen: "<div>",
         mw.loader.using( 'user.options', function () {
+
        tagClose: "</div>",
                if ( mw.user.options.get('usebetatoolbar') ) {
+
         sampleText: "Text here"
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
+
});
                                $(document).ready( customizeToolbar );
 
                        } );
 
                }
 
         } );
 
}*/
 

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"
});