MediaWiki:Gadget-InsertCode.js
From Joomla! Documentation
Note: After publishing, 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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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': {
'code': {
'label': 'Insert Code' // or use labelMsg for a localized label, see above
}
}
} );
jQuery(document).ready(function ($) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'code',
tools: {
buttonId: {
label: 'Insert PHP code tags',
type: 'button',
icon: '/images/5/5d/PHP_Icon.png',
action: {
type: 'encapsulate',
options: {
pre: '<source lang="php">\r',
peri: "Insert php code here\r",
post: "</source>"
}
}
}
}
});
});
jQuery(document).ready(function ($) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'code',
tools: {
buttonId: {
label: 'Insert JavaScript code tags',
type: 'button',
icon: '/images/f/f0/JS_editor_toolbar_icon.png',
action: {
type: 'encapsulate',
options: {
pre: '<source lang="javascript">\r',
peri: "Insert javascript code here\r",
post: "</source>"
}
}
}
}
});
});
jQuery(document).ready(function ($) {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'code',
tools: {
buttonId: {
label: 'Insert XML code tags',
type: 'button',
icon: '/images/1/10/XML_toolbar_icon.png',
action: {
type: 'encapsulate',
options: {
pre: '<source lang="xml">\r',
peri: "Insert XML code here\r",
post: "</source>"
}
}
}
}
});
});
};
/* 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 );
} );
}
} );
}