From 47d0a2677cfdc3697341f4e75611469c41ec2df2 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Fri, 27 May 2016 05:21:50 +1000 Subject: [PATCH] UI Blocks can now be moved by dragging Page links handler is now strict definition Use more explicit naming for config_dashboard config We have to use the codeeditor for mail templates for now, since froala is not playing nicely with twig --- modules/backend/controllers/Index.php | 2 +- ...ort_container.yaml => config_dashboard.yaml} | 4 ++++ .../richeditor/assets/js/build-min.js | 12 ++++++------ .../richeditor/assets/js/plugins/figures.js | 17 ++++++++++++----- .../richeditor/assets/js/plugins/pagelinks.js | 10 +++++++--- .../richeditor/assets/js/richeditor.js | 3 ++- .../richeditor/partials/_richeditor.htm | 2 +- modules/system/models/mailtemplate/fields.yaml | 6 +++--- 8 files changed, 36 insertions(+), 20 deletions(-) rename modules/backend/controllers/index/{config_report_container.yaml => config_dashboard.yaml} (60%) diff --git a/modules/backend/controllers/Index.php b/modules/backend/controllers/Index.php index d0b80450d..4b449c56d 100644 --- a/modules/backend/controllers/Index.php +++ b/modules/backend/controllers/Index.php @@ -34,7 +34,7 @@ class Index extends Controller $this->addCss('/modules/backend/assets/css/dashboard/dashboard.css', 'core'); if (BackendAuth::check()) { - new ReportContainer($this); + new ReportContainer($this, 'config_dashboard.yaml'); } } diff --git a/modules/backend/controllers/index/config_report_container.yaml b/modules/backend/controllers/index/config_dashboard.yaml similarity index 60% rename from modules/backend/controllers/index/config_report_container.yaml rename to modules/backend/controllers/index/config_dashboard.yaml index bd3462224..1f1b781a2 100644 --- a/modules/backend/controllers/index/config_report_container.yaml +++ b/modules/backend/controllers/index/config_dashboard.yaml @@ -1,3 +1,7 @@ +# =================================== +# Dashboard Config +# =================================== + defaultWidgets: systemStatus: class: System\ReportWidgets\Status diff --git a/modules/backend/formwidgets/richeditor/assets/js/build-min.js b/modules/backend/formwidgets/richeditor/assets/js/build-min.js index d0af9ce2a..f2edcf8dc 100755 --- a/modules/backend/formwidgets/richeditor/assets/js/build-min.js +++ b/modules/backend/formwidgets/richeditor/assets/js/build-min.js @@ -380,7 +380,7 @@ $.FE.DefineIcon('mmFileManager',{NAME:'folder'});$.FE.DEFAULTS.videoInsertButton $.FE.DefineIcon('mmVideoManager',{NAME:'folder'});$.FE.DEFAULTS.audioInsertButtons.push('mmAudioManager');$.FE.RegisterCommand('mmAudioManager',{title:'Browse',undo:false,focus:false,callback:function(){this.mediaManager.insertAudio();},plugin:'mediaManager'}) $.FE.DefineIcon('mmAudioManager',{NAME:'folder'});})(jQuery);var richeditorPageLinksPlugin function richeditorPageLinksSelectPage($form){richeditorPageLinksPlugin.setLinkValueFromPopup($form)} -(function($){$.FroalaEditor.PLUGINS.pageLinks=function(editor){function setLinkValueFromPopup($form){var $select=$('select[name=pagelink]',$form) +$.FroalaEditor.DEFAULTS=$.extend($.FroalaEditor.DEFAULTS,{pageLinksHandler:'onLoadPageLinksForm'});$.FroalaEditor.DEFAULTS.key='HHMDUGENKACTMXQL==';(function($){$.FroalaEditor.PLUGINS.pageLinks=function(editor){function setLinkValueFromPopup($form){var $select=$('select[name=pagelink]',$form) var link={text:$('option:selected',$select).text().trim(),href:$select.val()} setTimeout(function(){editor.popups.show('link.insert') setLinkValue(link)},300)} @@ -388,10 +388,10 @@ function setLinkValue(link){var $popup=editor.popups.get('link.insert');var text else if($input.attr('name')!='text'){$input.val('');}} for(i=0;i').append($el.clone()).remove().html() editor.events.focus(true) @@ -413,7 +413,7 @@ function insertAudio(url,text){var $node=_makeUiBlockElement() $node.attr('data-audio',url) $node.attr('data-label',text) insertElement($node)} -function _initUiBlocks(){$('[data-video], [data-audio]',editor.$el).each(function(){$(this).attr({'data-ui-block':true,'tabindex':'0'}) +function _initUiBlocks(){$('[data-video], [data-audio]',editor.$el).each(function(){$(this).addClass('fr-draggable').attr({'data-ui-block':'true','draggable':'true','tabindex':'0'}).html(' ') this.contentEditable=false})} function _handleUiBlocksKeydown(ev){if(ev.which==40||ev.which==38||ev.which==8||ev.which==46){var $block=$(editor.selection.element()) if($block.is('br')){$block=$block.parent()} @@ -459,7 +459,7 @@ if(ev.isDefaultPrevented()){return false}} function _onFigureKeydown(ev){if(ev.target&&$(ev.target).attr('data-ui-block')!==undefined){_uiBlockKeyDown(ev,ev.target)} if(ev.isDefaultPrevented()){return false}} function _onSync(html){var $domTree=$('
'+html+'
') -$domTree.find('[data-video], [data-audio]').each(function(){$(this).removeAttr('contenteditable data-ui-block tabindex')}) +$domTree.find('[data-video], [data-audio]').each(function(){$(this).removeAttr('contenteditable data-ui-block tabindex draggable').removeClass('fr-draggable fr-dragging')}) return $domTree.html()} function _init(){editor.events.on('initialized',_initUiBlocks) editor.events.on('html.set',_initUiBlocks) @@ -483,7 +483,7 @@ RichEditor.DEFAULTS={linksHandler:null,stylesheet:null,fullpage:false,editorLang RichEditor.prototype.init=function(){var self=this;this.$el.one('dispose-control',this.proxy(this.dispose)) if(!this.$textarea.attr('id')){this.$textarea.attr('id','element-'+Math.random().toString(36).substring(7))} this.initFroala()} -RichEditor.prototype.initFroala=function(){var froalaOptions={editorClass:'control-richeditor',language:this.options.editorLang,fullPage:this.options.fullpage} +RichEditor.prototype.initFroala=function(){var froalaOptions={editorClass:'control-richeditor',language:this.options.editorLang,fullPage:this.options.fullpage,pageLinksHandler:this.options.linksHandler} if(this.options.toolbarButtons){froalaOptions.toolbarButtons=this.options.toolbarButtons.split(',')} else{froalaOptions.toolbarButtons=['paragraphFormat','paragraphStyle','quote','bold','italic','align','formatOL','formatUL','insertTable','insertLink','insertImage','insertVideo','insertAudio','insertFile','insertHR','fullscreen','html']} froalaOptions.imageStyles=this.options.imageStyles?this.options.imageStyles:{'oc-img-rounded':'Rounded','oc-img-bordered':'Bordered'} diff --git a/modules/backend/formwidgets/richeditor/assets/js/plugins/figures.js b/modules/backend/formwidgets/richeditor/assets/js/plugins/figures.js index 4251f6044..a82ca02e2 100644 --- a/modules/backend/formwidgets/richeditor/assets/js/plugins/figures.js +++ b/modules/backend/formwidgets/richeditor/assets/js/plugins/figures.js @@ -71,10 +71,15 @@ */ function _initUiBlocks () { $('[data-video], [data-audio]', editor.$el).each(function() { - $(this).attr({ - 'data-ui-block': true, - 'tabindex': '0' - }) + $(this) + .addClass('fr-draggable') + .attr({ + 'data-ui-block': 'true', + 'draggable': 'true', + 'tabindex': '0' + }) + .html(' ') + this.contentEditable = false }) } @@ -211,7 +216,9 @@ var $domTree = $('
' + html + '
') $domTree.find('[data-video], [data-audio]').each(function(){ - $(this).removeAttr('contenteditable data-ui-block tabindex') + $(this) + .removeAttr('contenteditable data-ui-block tabindex draggable') + .removeClass('fr-draggable fr-dragging') }) return $domTree.html() diff --git a/modules/backend/formwidgets/richeditor/assets/js/plugins/pagelinks.js b/modules/backend/formwidgets/richeditor/assets/js/plugins/pagelinks.js index af6608b66..c3004f1ed 100644 --- a/modules/backend/formwidgets/richeditor/assets/js/plugins/pagelinks.js +++ b/modules/backend/formwidgets/richeditor/assets/js/plugins/pagelinks.js @@ -8,6 +8,12 @@ function richeditorPageLinksSelectPage($form) { richeditorPageLinksPlugin.setLinkValueFromPopup($form) } +$.FroalaEditor.DEFAULTS = $.extend($.FroalaEditor.DEFAULTS, { + pageLinksHandler: 'onLoadPageLinksForm' +}); + +$.FroalaEditor.DEFAULTS.key = 'HHMDUGENKACTMXQL=='; + (function ($) { $.FroalaEditor.PLUGINS.pageLinks = function (editor) { @@ -54,7 +60,7 @@ function richeditorPageLinksSelectPage($form) { richeditorPageLinksPlugin = this editor.$el.popup({ - handler: 'onLoadPageLinksForm' + handler: editor.opts.pageLinksHandler }) } @@ -72,8 +78,6 @@ function richeditorPageLinksSelectPage($form) { } } - $.FE.DEFAULTS.audioInsertButtons.push('mmAudioManager'); - $.FE.DEFAULTS.linkInsertButtons = ['linkBack', '|', 'linkPageLinks'] $.FE.RegisterCommand('linkPageLinks', { diff --git a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js index ce5992f09..511545c25 100755 --- a/modules/backend/formwidgets/richeditor/assets/js/richeditor.js +++ b/modules/backend/formwidgets/richeditor/assets/js/richeditor.js @@ -73,7 +73,8 @@ var froalaOptions = { editorClass: 'control-richeditor', language: this.options.editorLang, - fullPage: this.options.fullpage + fullPage: this.options.fullpage, + pageLinksHandler: this.options.linksHandler } if (this.options.toolbarButtons) { diff --git a/modules/backend/formwidgets/richeditor/partials/_richeditor.htm b/modules/backend/formwidgets/richeditor/partials/_richeditor.htm index 4c73c7697..09b1933d5 100755 --- a/modules/backend/formwidgets/richeditor/partials/_richeditor.htm +++ b/modules/backend/formwidgets/richeditor/partials/_richeditor.htm @@ -17,7 +17,7 @@ data-paragraph-styles="" data-table-styles="" data-table-cell-styles="" - data-links-handler="getEventHandler('onGetPageLinks') ?>" + data-links-handler="getEventHandler('onLoadPageLinksForm') ?>" placeholder="placeholder)) ?>" data-control="richeditor"> diff --git a/modules/system/models/mailtemplate/fields.yaml b/modules/system/models/mailtemplate/fields.yaml index b484dc772..81a316d77 100644 --- a/modules/system/models/mailtemplate/fields.yaml +++ b/modules/system/models/mailtemplate/fields.yaml @@ -32,11 +32,11 @@ secondaryTabs: fields: content_html: - type: richeditor - size: huge + type: codeeditor + size: giant tab: system::lang.mail_templates.content_html content_text: type: textarea - size: huge + size: giant tab: system::lang.mail_templates.content_text