MediaWiki:Common.js
From Eco-Bible 1
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
The following javascript code was added to MediaWiki:Vector.js in the TNG Wiki with the upgrade to MediaWiki 1.16.2 Return to [[Adding Buttons to WikiEditor]] <syntaxhighlight lang="javascript" enclose="div"> /* Any JavaScript here will be loaded for users using the Vector skin */ // Check that the toolbar is available if ( typeof $j !== 'undefined' && typeof $j.fn.wikiEditor !== 'undefined' ) { // Execute on load $j( function() { // To add a group to an existing toolbar section: // Added hdr = Page group on Main toolbar for TNG Wiki $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'groups': { 'hdr': { 'labelMsg': 'wikieditor-toolbar-group-page' // or 'label': 'Text' when localized label no needed } } } ); // To add a group to an existing toolbar section: // Added style = Style group on Main toolbar for TNG Wiki $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'groups': { 'style': { 'labelMsg': 'wikieditor-toolbar-group-style' // or use labelMsg for a localized label, see above } } } ); // To add a group to an existing toolbar section: // Added code = Code group on Advanced toolbar for TNG Wiki $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'groups': { 'code': { 'labelMsg': 'wikieditor-toolbar-group-code' // or use labelMsg for a localized label, see above } } } ); // To add a button to an existing toolbar group: // Added Strikethrough button to WikiEditor main toolbar format group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'format', 'tools': { 'strikethrough': { labelMsg: 'wikieditor-toolbar-tool-strike', type: 'button', icon: 'Button-strike.png', action: { type: 'encapsulate', options: { pre: "<s>", periMsg: 'wikieditor-toolbar-tool-strike-example', post: "</s>" } } } } } ); // To add a button to an existing toolbar group: // Added ZipFile button to WikiEditor main toolbar insert group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'insert', 'tools': { 'zipfile': { labelMsg: 'wikieditor-toolbar-tool-zipfile', type: 'button', icon: 'Button-zipfile.png', action: { type: 'encapsulate', options: { preMsg: [ 'wikieditor-toolbar-tool-zipfile-pre', '[[Media:' ], periMsg: 'wikieditor-toolbar-tool-zipfile-example', post: "]]" } } } } } ); // To add a button to an existing toolbar group: // Added ZipFile button to WikiEditor main toolbar insert group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'insert', 'tools': { 'image': { labelMsg: 'wikieditor-toolbar-tool-imagefile', type: 'button', icon: 'Button-add-media.png', action: { type: 'encapsulate', options: { preMsg: [ 'wikieditor-toolbar-tool-imagefile-pre', '[[Image:' ], periMsg: 'wikieditor-toolbar-tool-imagefile-example', post: "]]" } } } } } ); // To add a button to an existing toolbar group: // Added Definition List button to WikiEditor advanced toolbar format group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'format', 'tools': { 'definition': { labelMsg: 'wikieditor-toolbar-tool-definition', type: 'button', icon: 'Button-list-definition.png', action: { type: 'encapsulate', options: { pre: "\n; Definition\n: Item 1\n: Item 2", post: "\n" } } } } } ); // To add a button to an existing toolbar group: // Added BlockQuote button to TNG main toolbar style group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'style', 'tools': { 'blockquote': { labelMsg: 'wikieditor-toolbar-tool-blockquote', type: 'button', icon: 'Button-blockquote.png', action: { type: 'encapsulate', options: { pre: "<blockquote>\n", periMsg: 'wikieditor-toolbar-tool-blockquote-example', post: "\n</blockquote>" } } } } } ); // To add a button to an existing toolbar group: // Added Font Color button to TNG main toolbar style group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'style', 'tools': { 'fontcolor': { labelMsg: 'wikieditor-toolbar-tool-fontcolor', type: 'button', icon: 'Button-font-color.png', action: { type: 'encapsulate', options: { pre: "<span style=\"color: ColourName\">", periMsg: 'wikieditor-toolbar-tool-fontcolor-example', post: "</span>" } } } } } ); // To add a button to an existing toolbar group: // Added RightTOC button to TNG main toolbar hdr group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'hdr', 'tools': { 'RightTOC': { labelMsg: 'wikieditor-toolbar-tool-rightTOC', type: 'button', icon: 'Button-toc.png', action: { type: 'encapsulate', options: { pre: "{| style=\"margin-right:0.5 em;\" align=\"right\" \n| __TOC__\n", post: "|}\n" } } } } } ); // To add a button to an existing toolbar group: // Added Language Templage button to TNG main toolbar hdr group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'hdr', 'tools': { 'language': { labelMsg: 'wikieditor-toolbar-tool-langtemplate', type: 'button', icon: 'Button-lang-template.png', action: { type: 'encapsulate', options: { pre: "\n{{Languages", periMsg: 'wikieditor-toolbar-tool-langtemplate-example', post: "}}\n" } } } } } ); // To add a button to an existing toolbar group: // Added Language Templage button to TNG main toolbar hdr group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'hdr', 'tools': { 'language': { labelMsg: 'wikieditor-toolbar-tool-toggle', type: 'button', icon: 'Button-Toggle.png', action: { type: 'encapsulate', options: { preMsg: 'wikieditor-toolbar-tool-toggle-pre', periMsg: 'wikieditor-toolbar-tool-toggle-example', post: "</toggledisplay>\n" } } } } } ); // To add a button to an existing toolbar group: // Added Category button to TNG main toolbar hdr group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'main', 'group': 'hdr', 'tools': { 'category': { labelMsg: 'wikieditor-toolbar-tool-category', type: 'button', icon: 'Button-category.png', action: { type: 'encapsulate', options: { pre: "\n[[Category:", periMsg: 'wikieditor-toolbar-tool-category-example', post: "]]\n" } } } } } ); // To add a button to an existing toolbar group: // Added Pre-Formatted Text button to TNG advanced toolbar code group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'code', 'tools': { 'preformat': { labelMsg: 'wikieditor-toolbar-tool-preformat', type: 'button', icon: 'Button-pre.png', action: { type: 'encapsulate', options: { pre: "\n<pre>\n", periMsg: 'wikieditor-toolbar-tool-preformat-example', post: "</pre>\n" } } } } } ); // To add a button to an existing toolbar group: // Added Code button to TNG advanced toolbar code group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'code', 'tools': { 'codesnippet': { labelMsg: 'wikieditor-toolbar-tool-codesnippet', type: 'button', icon: 'Button-code.png', action: { type: 'encapsulate', options: { pre: "\n<code>", periMsg: 'wikieditor-toolbar-tool-codesnippet-example', post: "</code>\n" } } } } } ); // To add a button to an existing toolbar group: // Added Syntax Highlight button to TNG advanced toolbar code group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'code', 'tools': { 'syntaxhighlight': { labelMsg: 'wikieditor-toolbar-tool-highlight', type: 'button', icon: 'Button-source.png', action: { type: 'encapsulate', options: { pre: "\n<syntaxhighlight lang=\"html4strict\" line start=\"100\" highlight=\"5\" enclose=\"div\">", periMsg: 'wikieditor-toolbar-tool-highlight-example', post: "</syntaxhighlight>\n" } } } } } ); // To add a button to an existing toolbar group: // Added Comment button to TNG advanced toolbar code group: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'code', 'tools': { 'comments': { labelMsg: 'wikieditor-toolbar-tool-comments', type: 'button', icon: 'Button-hide-comment.png', action: { type: 'encapsulate', options: { pre: "<!-- ", periMsg: 'wikieditor-toolbar-tool-comments-example', post: " -->\n" } } } } } ); // Terminate onLoad action - Buttons or sections must be added before this line } ); } </syntaxhighlight> See [http://commons.wikimedia.org/wiki/MediaWiki_edit_toolbar MediaWiki edit toolbar] for extra buttons. Return to [[Adding Buttons to WikiEditor]] [[Category:Toolbar Buttons]]