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
This commit is contained in:
Samuel Georges 2016-05-27 05:21:50 +10:00
parent ef5f89fb65
commit 47d0a2677c
8 changed files with 36 additions and 20 deletions

View File

@ -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');
}
}

View File

@ -1,3 +1,7 @@
# ===================================
# Dashboard Config
# ===================================
defaultWidgets:
systemStatus:
class: System\ReportWidgets\Status

View File

@ -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<check_inputs.length;i++){$input=$(check_inputs[i]);$input.prop('checked',$input.data('checked')==link[$input.attr('name')]);}}
function insertLink(){richeditorPageLinksPlugin=this
editor.$el.popup({handler:'onLoadPageLinksForm'})}
editor.$el.popup({handler:editor.opts.pageLinksHandler})}
function _init(){}
return{_init:_init,setLinkValueFromPopup:setLinkValueFromPopup,setLinkValue:setLinkValue,insertLink:insertLink}}
$.FE.DEFAULTS.audioInsertButtons.push('mmAudioManager');$.FE.DEFAULTS.linkInsertButtons=['linkBack','|','linkPageLinks']
$.FE.DEFAULTS.linkInsertButtons=['linkBack','|','linkPageLinks']
$.FE.RegisterCommand('linkPageLinks',{title:'Choose Link',undo:false,focus:false,callback:function(){this.pageLinks.insertLink()},plugin:'pageLinks'})
$.FE.DefineIcon('linkPageLinks',{NAME:'search'});})(jQuery);(function($){$.FroalaEditor.PLUGINS.figures=function(editor){function insertElement($el){var html=$('<div />').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('&nbsp;')
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=$('<div>'+html+'</div>')
$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'}

View File

@ -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('&nbsp;')
this.contentEditable = false
})
}
@ -211,7 +216,9 @@
var $domTree = $('<div>' + html + '</div>')
$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()

View File

@ -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', {

View File

@ -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) {

View File

@ -17,7 +17,7 @@
<?php if ($paragraphStyles): ?>data-paragraph-styles="<?= e(json_encode($paragraphStyles)) ?>"<?php endif ?>
<?php if ($tableStyles): ?>data-table-styles="<?= e(json_encode($tableStyles)) ?>"<?php endif ?>
<?php if ($tableCellStyles): ?>data-table-cell-styles="<?= e(json_encode($tableCellStyles)) ?>"<?php endif ?>
data-links-handler="<?= $this->getEventHandler('onGetPageLinks') ?>"
data-links-handler="<?= $this->getEventHandler('onLoadPageLinksForm') ?>"
placeholder="<?= e(trans($field->placeholder)) ?>"
data-control="richeditor">
<textarea name="<?= $name ?>" id="<?= $this->getId('textarea') ?>"><?= e($value) ?></textarea>

View File

@ -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