Gadget-InsertCode.js: Difference between revisions
From Joomla! Documentation
m making insert tag spacing friendly on new code |
Fixes for new version |
||
| Line 77: | Line 77: | ||
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */ | /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */ | ||
if ( | 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 ); | |||
} | |||
} ); | |||
} | } | ||
Latest revision as of 01:07, 6 March 2022
/* 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 );
}
} );
}