From 3892eb4ed993ba60f53f3daa35110ed1c99f8fe1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 18 Jun 2013 12:08:54 +0200 Subject: [PATCH] documentCanvas: Fixing missing carret on initially selected ndoe --- modules/documentCanvas/documentCanvas.js | 12 ++++++++++-- views/tabs/tabs.js | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) 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'); -- 2.20.1