documentCanvas: Fixing missing carret on initially selected ndoe
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 18 Jun 2013 10:08:54 +0000 (12:08 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 18 Jun 2013 10:08:54 +0000 (12:08 +0200)
modules/documentCanvas/documentCanvas.js
views/tabs/tabs.js

index 51acbf3..2c31ce0 100644 (file)
@@ -13,6 +13,7 @@ return function(sandbox) {
     var view = {\r
         node: $(_.template(template)()),\r
         currentNode: null,\r
     var view = {\r
         node: $(_.template(template)()),\r
         currentNode: null,\r
+        shownAlready: false,\r
         setup: function() {\r
             var view = this;\r
 \r
         setup: function() {\r
             var view = this;\r
 \r
@@ -50,6 +51,14 @@ return function(sandbox) {
                     view.insertNewNode(null, null);\r
                 }\r
             });\r
                     view.insertNewNode(null, null);\r
                 }\r
             });\r
+                      \r
+            this.node.onShow = function() {\r
+                if(!view.shownAlready) {\r
+                    view.shownAlready = true;\r
+                    view.selectFirstNode();\r
+                }\r
+            };\r
+                      \r
             this.gridToggled = false;\r
         },\r
         _createNode: function(wlxmlTag, wlxmlClass) {\r
             this.gridToggled = false;\r
         },\r
         _createNode: function(wlxmlTag, wlxmlClass) {\r
@@ -195,7 +204,7 @@ return function(sandbox) {
             else {\r
                 node = this.node.find('[wlxml-class|="p"]')\r
             }\r
             else {\r
                 node = this.node.find('[wlxml-class|="p"]')\r
             }\r
-            this.selectNode(new wlxmlNode.Node(node));\r
+            this.selectNode(new wlxmlNode.Node(node), {moveCarret: true});\r
         },\r
         toggleGrid: function(toggle) {\r
             this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);\r
         },\r
         toggleGrid: function(toggle) {\r
             this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);\r
@@ -215,7 +224,6 @@ return function(sandbox) {
         setDocument: function(xml) {\r
             var transformed = transformations.fromXML.getDocumentDescription(xml);\r
             view.setBody(transformed.HTMLTree);\r
         setDocument: function(xml) {\r
             var transformed = transformations.fromXML.getDocumentDescription(xml);\r
             view.setBody(transformed.HTMLTree);\r
-            view.selectFirstNode();\r
             sandbox.publish('documentSet');\r
         },\r
         getDocument: function() {\r
             sandbox.publish('documentSet');\r
         },\r
         getDocument: function() {\r
index 7c94938..7298d4e 100644 (file)
@@ -60,6 +60,9 @@ define([
                 if(this.selectedTab)\r
                     this.contents[this.selectedTab].detach();\r
                 this.nodes.content.append(this.contents[slug]);\r
                 if(this.selectedTab)\r
                     this.contents[this.selectedTab].detach();\r
                 this.nodes.content.append(this.contents[slug]);\r
+                if(this.contents[slug].onShow) {\r
+                    this.contents[slug].onShow();\r
+                }\r
                 this.nodes.tabBar.find('.active').removeClass('active');\r
                 this.nodes.tabBar.find('a[href="#'+slug+'"]').parent().addClass('active');\r
                 \r
                 this.nodes.tabBar.find('.active').removeClass('active');\r
                 this.nodes.tabBar.find('a[href="#'+slug+'"]').parent().addClass('active');\r
                 \r