From: Aleksander Ɓukasz Date: Tue, 18 Jun 2013 10:08:54 +0000 (+0200) Subject: documentCanvas: Fixing missing carret on initially selected ndoe X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/3892eb4ed993ba60f53f3daa35110ed1c99f8fe1?ds=sidebyside documentCanvas: Fixing missing carret on initially selected ndoe --- diff --git a/modules/documentCanvas/documentCanvas.js b/modules/documentCanvas/documentCanvas.js index 51acbf3..2c31ce0 100644 --- a/modules/documentCanvas/documentCanvas.js +++ b/modules/documentCanvas/documentCanvas.js @@ -13,6 +13,7 @@ return function(sandbox) { var view = { node: $(_.template(template)()), currentNode: null, + shownAlready: false, setup: function() { var view = this; @@ -50,6 +51,14 @@ return function(sandbox) { view.insertNewNode(null, null); } }); + + this.node.onShow = function() { + if(!view.shownAlready) { + view.shownAlready = true; + view.selectFirstNode(); + } + }; + this.gridToggled = false; }, _createNode: function(wlxmlTag, wlxmlClass) { @@ -195,7 +204,7 @@ return function(sandbox) { else { node = this.node.find('[wlxml-class|="p"]') } - this.selectNode(new wlxmlNode.Node(node)); + this.selectNode(new wlxmlNode.Node(node), {moveCarret: true}); }, toggleGrid: function(toggle) { this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle); @@ -215,7 +224,6 @@ return function(sandbox) { setDocument: function(xml) { var transformed = transformations.fromXML.getDocumentDescription(xml); view.setBody(transformed.HTMLTree); - view.selectFirstNode(); sandbox.publish('documentSet'); }, getDocument: function() { diff --git a/views/tabs/tabs.js b/views/tabs/tabs.js index 7c94938..7298d4e 100644 --- a/views/tabs/tabs.js +++ b/views/tabs/tabs.js @@ -60,6 +60,9 @@ define([ if(this.selectedTab) this.contents[this.selectedTab].detach(); this.nodes.content.append(this.contents[slug]); + if(this.contents[slug].onShow) { + this.contents[slug].onShow(); + } this.nodes.tabBar.find('.active').removeClass('active'); this.nodes.tabBar.find('a[href="#'+slug+'"]').parent().addClass('active');