diff --git a/bin/Editor.js b/bin/Editor.js index c5fb9d3f1d3d4ed799b69914a0da0fa7267e9c55..f4d6990d7d4a517f4de21a01e74c92c4c58e000c 100644 --- a/bin/Editor.js +++ b/bin/Editor.js @@ -247,23 +247,23 @@ define('package/quiqqer/ckeditor4/bin/Editor', [ } window.CKEDITOR.replace(instance, { - skinName : 'moono-lisa', - customConfig : '', - language : Locale.getCurrent(), - baseHref : URL_DIR, - basePath : URL_DIR, - height : height, - width : width, - toolbar : toolbar, - allowedContent : true, - extraAllowedContent : 'iframe(*)[*]{*}; img(*)[*]{*}; script(*)[*]{*}; ins(*)[*]{*}', - protectedSource : [/<ins[\s|\S]+?<\/ins>/g], - stylesSet : styles, - contentsCss : data.cssFiles || [], - bodyClass : data.bodyClass, + skinName : 'moono-lisa', + customConfig : '', + language : Locale.getCurrent(), + baseHref : URL_DIR, + basePath : URL_DIR, + height : height, + width : width, + toolbar : toolbar, + allowedContent : true, + extraAllowedContent: 'iframe(*)[*]{*}; img(*)[*]{*}; script(*)[*]{*}; ins(*)[*]{*}', + protectedSource : [/<ins[\s|\S]+?<\/ins>/g], + stylesSet : styles, + contentsCss : data.cssFiles || [], + bodyClass : data.bodyClass, // templates_files : [URL_OPT_DIR +'base/bin/pcsgEditorPlugins/templates.php'], - baseFloatZIndex : zIndex, - extraPlugins : extraPlugins, + baseFloatZIndex: zIndex, + extraPlugins : extraPlugins, //removePlugins : 'scayt', disableNativeSpellChecker: config.disableNativeSpellChecker, autoGrow_onStartup : false, @@ -484,7 +484,7 @@ define('package/quiqqer/ckeditor4/bin/Editor', [ var extra = [], buttonList = []; - if (typeOf(toolbar) == 'array') { + if (typeOf(toolbar) === 'array') { buttonList = toolbar.flatten(); } diff --git a/plugins/quiqqer/quiqqerBricks/images/icon.jpg b/plugins/quiqqer/quiqqerBricks/images/icon.jpg new file mode 100644 index 0000000000000000000000000000000000000000..514edafb04edd14b7926738c66ebef4a2a5d6bc0 Binary files /dev/null and b/plugins/quiqqer/quiqqerBricks/images/icon.jpg differ diff --git a/plugins/quiqqer/quiqqerBricks/lang/de.js b/plugins/quiqqer/quiqqerBricks/lang/de.js new file mode 100644 index 0000000000000000000000000000000000000000..8f879f944a86c790e1240d1a8c69cc8eb2544332 --- /dev/null +++ b/plugins/quiqqer/quiqqerBricks/lang/de.js @@ -0,0 +1,3 @@ +CKEDITOR.plugins.setLang('quiqqerBricks', 'de', { + button: 'QUIQQER Bausteine' +}); diff --git a/plugins/quiqqer/quiqqerBricks/lang/en.js b/plugins/quiqqer/quiqqerBricks/lang/en.js new file mode 100644 index 0000000000000000000000000000000000000000..10dcdb959662a340b81a52d5a198c57468c43721 --- /dev/null +++ b/plugins/quiqqer/quiqqerBricks/lang/en.js @@ -0,0 +1,3 @@ +CKEDITOR.plugins.setLang('quiqqerBricks', 'en', { + button: 'QUIQQER Bricks' +}); diff --git a/plugins/quiqqer/quiqqerBricks/plugin.js b/plugins/quiqqer/quiqqerBricks/plugin.js new file mode 100644 index 0000000000000000000000000000000000000000..d610860b79621f9a2b43e207b210c9c22c86109b --- /dev/null +++ b/plugins/quiqqer/quiqqerBricks/plugin.js @@ -0,0 +1,149 @@ +(function () { + "use strict"; + + CKEDITOR.plugins.add('quiqqerBricks', { + icons: "icon", + lang : ['en', 'de'], + + onLoad: function () { + // Register styles for placeholder widget frame. + CKEDITOR.addCss( + '.quiqqer_bricks_placeholder{' + + ' display: inline-block;' + + ' background-color:#dedede;' + + ' height: 200px;' + + ' margin-bottom: 10px;' + + ' width: 100%;' + + '}' + ); + }, + + init: function (editor) { + var self = this; + + this.$Editor = editor; + + editor.ui.addButton('QuiqqerBricks', { + label : editor.lang.quiqqerBricks.button, + toolbar: 'insert', + command: 'insert-quiqqer-brick', + icon : this.path + 'images/icon.jpg' + }); + + editor.on('getData', function (evt) { + var Ghost = new Element('div', { + html: evt.data.dataValue + }); + + var placeholders = Ghost.getElements('.quiqqer_bricks_placeholder'); + var lang, project, brickid, textNode, PH; + + for (var i = 0, len = placeholders.length; i < len; i++) { + PH = placeholders[i]; + brickid = PH.get('data-brickid'); + + if (!brickid) { + continue; + } + + textNode = document.createTextNode("{{brick id=" + brickid + "}}"); + + PH.parentNode.insertBefore(textNode, PH); + PH.parentNode.removeChild(PH); + } + + evt.data.dataValue = Ghost.get('html'); + }); + + + editor.on('setData', function (evt) { + var result; + var data = evt.data.dataValue; + + if (data.indexOf('{{brick ') === -1) { + return; + } + + result = data.replace( + /{{brick ([^}}]*)}}/g, + function (match, contents, offset, input_string) { + match = match.replace('{{brick ', '') + match = match.replace('}}', ''); + match = match.trim(); + match = match.split(' '); + + var parts; + var attributes = []; + + for (var m = 0, len = match.length; m < len; m++) { + parts = match[m].trim().split('='); + + attributes[parts[0]] = parts[1]; + } + + if ("id" in attributes) { + return '<div class="quiqqer_bricks_placeholder" ' + + 'data-brickid="' + attributes.id + '"' + + '> </div>'; + } + + return ""; + } + ); + + evt.data.dataValue = result; + }); + + + editor.addCommand('insert-quiqqer-brick', { + exec: function (editor) { + require([ + 'package/quiqqer/bricks/bin/Controls/backend/BrickSelectWindow' + ], function (BrickSelectWindow) { + // get project, if editor is in panel + var Node = editor.ui.contentsElement.$; + var project = ''; + var lang = ''; + + if (Node.getParent('.qui-panel')) { + var Panel = QUI.Controls.getById( + Node.getParent('.qui-panel').get('data-quiid') + ); + + if (Panel && Panel.getType() === 'controls/projects/project/site/Panel') { + var Site = Panel.getSite(); + + project = Site.getProject().getName(); + lang = Site.getProject().getLang(); + } + } + + new BrickSelectWindow({ + project : project, + lang : lang, + area : 'content', + multiple: false, + events : { + onSubmit: function (Instance, bricks) { + self.insertBrick( + bricks[0].id, + bricks[0].project, + bricks[0].lang + ); + } + } + }).open(); + }); + } + }); + }, + + insertBrick: function (brickId, project, lang) { + this.$Editor.insertHtml( + '<div class="quiqqer_bricks_placeholder" ' + + ' data-brickid="' + brickId + '"' + + '> </div>' + ); + } + }); +})();