1 CKEDITOR.plugins.add( 'widgettemplatemenu', {
11 init: function( editor ) {
13 // Set the default button info based on installed plugins
15 // @todo: make these if statement work
16 if (editor.plugins.widgetcommon != undefined) {
17 buttonData.widgetcommonBox = 'Insert box';
18 buttonData.widgetcommonQuotebox = 'Insert quote box';
20 if (editor.plugins.widgetbootstrap != undefined) {
21 buttonData.widgetbootstrapLeftCol = 'Insert left column template';
22 buttonData.widgetbootstrapRightCol = 'Insert right column template';
23 buttonData.widgetbootstrapTwoCol = 'Insert two column template';
24 buttonData.widgetbootstrapThreeCol = 'Insert three column template';
25 buttonData.widgetbootstrapAlert = 'Insert Alert box';
27 if (editor.commands.oembed != undefined) {
28 buttonData.oembed = 'Insert media';
30 if (editor.commands.codeSnippet != undefined) {
31 buttonData.codeSnippet = 'Insert code snippet';
33 if (editor.commands.leaflet != undefined) {
34 buttonData.leaflet = 'Insert map';
37 // Get the enabled menu items from editor.config
38 if (editor.config.widgettemplatemenuButtons != undefined) {
39 var config = editor.config.widgettemplatemenuButtons.split(',');
41 for (var i = 0; i < config.length; i++) {
42 buttons[config[i]] = buttonData[config[i]];
46 var buttons = buttonData;
49 // Build the list of menu items
51 for(var key in buttons) {
55 group: 'widgettemplatemenu',
60 // Items must belong to a group.
61 editor.addMenuGroup( 'widgettemplatemenu' );
62 editor.addMenuItems( items );
64 editor.ui.add( 'WidgetTemplateMenu', CKEDITOR.UI_MENUBUTTON, {
65 label: 'Insert Template',
66 icon: this.path + 'icons/widgettemplatemenu.png' ,
68 // You can control the state of your commands live, every time
69 // the menu is opened.
71 widgetcommonBox: editor.commands.widgetcommonBox == undefined ? false : editor.commands.widgetcommonBox.state,
72 widgetcommonQuotebox: editor.commands.widgetcommonQuotebox == undefined ? false : editor.commands.widgetbootstrapLeftCol.state,
73 widgetbootstrapLeftCol: editor.commands.widgetbootstrapLeftCol == undefined ? false : editor.commands.widgetbootstrapLeftCol.state,
74 widgetbootstrapRightCol: editor.commands.widgetbootstrapRightCol == undefined ? false : editor.commands.widgetbootstrapRightCol.state,
75 widgetbootstrapTwoCol: editor.commands.widgetbootstrapTwoCol == undefined ? false : editor.commands.widgetbootstrapTwoCol.state,
76 widgetbootstrapThreeCol: editor.commands.widgetbootstrapThreeCol == undefined ? false : editor.commands.widgetbootstrapThreeCol.state,
77 widgetbootstrapAlert: editor.commands.widgetbootstrapAlert == undefined ? false : editor.commands.widgetbootstrapAlert.state,
78 widgetbootstrapAccordion: editor.commands.widgetbootstrapAccordion == undefined ? false : editor.commands.widgetbootstrapAccordion.state,
79 oembed: editor.commands.oembed == undefined ? false : editor.commands.oembed.state,
80 codeSnippet: editor.commands.codeSnippet == undefined ? false : editor.commands.codeSnippet.state,
81 leaflet: editor.commands.leaflet == undefined ? false : editor.commands.leaflet.state,
82 FontAwesome: editor.commands.FontAwesome == undefined ? false : editor.commands.FontAwesome.state