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 ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
}
} );
}