Gadget-InsertCode.js: Difference between revisions
From Joomla! Documentation
moving editor code insert group to a gadget, will only load js for logged in editors now not every wiki visitor, on by default |
m making insert tag spacing friendly on new code |
||
| Line 22: | Line 22: | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: '<source lang="php">', | pre: '<source lang="php">\r', | ||
peri: "Insert php code here", | peri: "Insert php code here\r", | ||
post: "</source>" | post: "</source>" | ||
} | } | ||
| Line 43: | Line 43: | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: '<source lang="javascript">', | pre: '<source lang="javascript">\r', | ||
peri: "Insert javascript code here", | peri: "Insert javascript code here\r", | ||
post: "</source>" | post: "</source>" | ||
} | } | ||
| Line 64: | Line 64: | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: '<source lang="xml">', | pre: '<source lang="xml">\r', | ||
peri: "Insert XML code here", | peri: "Insert XML code here\r", | ||
post: "</source>" | post: "</source>" | ||
} | } | ||
Revision as of 11:37, 28 April 2013
/* 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 );
} );
}
} );
}