X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/153ea475b5d188797738c961411ca8d019101b9a..b193de5bbfb1c96da0bb9a5398eb2a11b094017a:/modules/visualEditor.js?ds=sidebyside diff --git a/modules/visualEditor.js b/modules/visualEditor.js index d152acd..8d77302 100644 --- a/modules/visualEditor.js +++ b/modules/visualEditor.js @@ -89,6 +89,14 @@ rng.modules.visualEditor = function(sandbox) { _markSelected: function(node) { this.node.find('.rng-current').removeClass('rng-current'); node.addClass('rng-current'); + mediator.nodeSelected(node); + }, + markFirstSelected: function() { + var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() { + return $(this).clone().children().remove().end().text().trim() !== ''; + }).first(); + if(firstNodeWithText.length) + $(firstNodeWithText[0]).click().focus(); }, _addMetaRow: function(key, value) { var newRow = $(sandbox.getTemplate('metaItem')({key: key || '', value: value || ''})); @@ -117,14 +125,24 @@ rng.modules.visualEditor = function(sandbox) { this.node.find('#rng-visualEditor-sidebarButtons li').removeClass('active'); this.node.find('#rng-visualEditor-sidebarButtons li a[data-content-id=' + id + ']').parent().addClass('active'); + }, + updateEditPane: function(node) { + var pane = this.node.find('#rng-visualEditor-edit'); + pane.html( $(sandbox.getTemplate('editPane')({tag: node.attr('wlxml-tag'), klass: node.attr('wlxml-class')}))); } - } view.setup(); sideBarView.setup(); + var mediator = { + nodeSelected: function(node) { + sideBarView.updateEditPane(node); + } + } + var isDirty = false; + var wasShownAlready = false; return { @@ -148,6 +166,12 @@ rng.modules.visualEditor = function(sandbox) { }, setDirty: function(dirty) { isDirty = dirty; + }, + onShowed: function() { + if(!wasShownAlready) { + wasShownAlready = true; + view.markFirstSelected(); + } } }