MediaWiki

Gadget-InsertTranslate.js

From Joomla! Documentation

Revision as of 10:51, 26 June 2014 by Tom Hutchison (talk | contribs) (new gadget)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* wikiEditor extra group and icons for developers allowing for easy tags of code insertion into articles*/

var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'groups': {
                'lang': {
                        'label': 'Tags' // or use labelMsg for a localized label, see above
                }
        }
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
       section: 'advanced',
       group: 'lang',
       tools: {
              "atrans": {
                         label: 'Insert translate tags',
                         type: 'button',
                         icon: '/images/2/29/Translate_button.png',
                         action: {
                                 type: 'encapsulate',
                                 options: {
                                          pre: '\u003ctranslate>',
                                          peri: "Text to translate",
                                          post: '\u003c\u002ftranslate>'
                                 }
                         }
               }
       }
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
       section: 'advanced',
       group: 'lang',
       tools: {
              "alangs": {
                         label: 'Insert language tags',
                         type: 'button',
                         icon: '/images/1/1e/Language_button.png',
                         action: {
                                 type: 'encapsulate',
                                 options: {
                                          pre: '\u003cnoinclude>',
                                          peri: "\u003clanguages \u002f>",
                                          post: '\u003c\u002fnoinclude>'
                                 }
                         }
               }
       }
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'lang',
	tools: {
		"comment": {
			label: 'Comment',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<!-- ",
					post: " -->"
				}
			}
		}
	}
} );
 
};
 
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
}