X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/66aae866400efc99684f51486f8ce1ebb7f59404..b5a1f98a2118706355925314bfe3027ba45464e8:/modules/visualEditor.js?ds=inline diff --git a/modules/visualEditor.js b/modules/visualEditor.js index 1c61ef0..65de452 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -1,5 +1,6 @@ -rng.modules.visualEditor = function(sandbox) { - var transformations = rng.modules.visualEditor.transformations; +define(['./visualEditor.transformations'], function(transformations) { + +return function(sandbox) { var view = { node: $(sandbox.getTemplate('main')()), @@ -277,6 +278,7 @@ rng.modules.visualEditor = function(sandbox) { var view = this; this.node.find('#rng-visualEditor-sidebarButtons a').click(function(e) { e.preventDefault(); + e.stopPropagation(); var target = $(e.currentTarget); if(!target.attr('data-content-id')) return; @@ -315,16 +317,18 @@ rng.modules.visualEditor = function(sandbox) { }, updateEditPane: function(node) { var pane = this.node.find('#rng-visualEditor-edit'); + var parentClass = node.parent().attr('wlxml-class'); pane.html( $(sandbox.getTemplate('editPane')({tag: node.attr('wlxml-tag'), klass: node.attr('wlxml-class')}))); var parent = node.parent('[wlxml-tag]').length ? { - repr: node.parent().attr('wlxml-tag') + ' / ' + (node.parent().attr('wlxml-class') || '[[no class]]'), + repr: node.parent().attr('wlxml-tag') + (parentClass ? ' / ' + parentClass : ''), id: node.parent().attr('id') } : undefined; var children = []; node.children('[wlxml-tag]').each(function() { var child = $(this); - children.push({repr: child.attr('wlxml-tag') + ' / ' + (child.attr('wlxml-class') || '[[no class]]'), id: child.attr('id')}); + var childClass = child.attr('wlxml-class'); + children.push({repr: child.attr('wlxml-tag') + (childClass ? ' / ' + childClass : ''), id: child.attr('id')}); }); var naviTemplate = sandbox.getTemplate('editPaneNavigation')({parent: parent, children: children}); pane.find('.rng-visualEditor-editPaneSurrouding > div').html($(naviTemplate)); @@ -351,7 +355,7 @@ rng.modules.visualEditor = function(sandbox) { mediator.toolbarButtonToggled(btn.attr('data-btn'), btn.hasClass('active')); } if(btn.attr('data-btn-type') === 'cmd') { - mediator.toolbarButtonCmd(btn.attr('data-btn')); + mediator.toolbarButtonCmd(btn.attr('data-btn'), btn.attr('data-meta')); } }); }, @@ -423,12 +427,19 @@ rng.modules.visualEditor = function(sandbox) { if(btn === 'tags') view.toggleTags(toggle); }, - toolbarButtonCmd: function(btn) { + toolbarButtonCmd: function(btn, meta) { if(btn === 'new-node') { + var wlxmlTag = toolbarView.getOption('newTag-tag'); + var wlxmlClass = toolbarView.getOption('newTag-class'); + if(meta) { + var split = meta.split('/'); + wlxmlTag = split[0]; + wlxmlClass = split[1]; + } if(window.getSelection().isCollapsed) - view.insertNewNode(toolbarView.getOption('newTag-tag'), toolbarView.getOption('newTag-class')); + view.insertNewNode(wlxmlTag, wlxmlClass); else { - this.wrapWithNodeRequest(toolbarView.getOption('newTag-tag'), toolbarView.getOption('newTag-class')); + this.wrapWithNodeRequest(wlxmlTag, wlxmlClass); } @@ -484,4 +495,6 @@ rng.modules.visualEditor = function(sandbox) { } } -}; \ No newline at end of file +}; + +}); \ No newline at end of file