this.node.on('click', '[wlxml-tag]', function(e) {\r
e.stopPropagation();\r
console.log('clicked node type: '+e.target.nodeType);\r
- view._markSelected(new wlxmlNode.Node($(e.target)));\r
+ view.selectNode(new wlxmlNode.Node($(e.target)));\r
});\r
\r
this.node.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
anchor = anchor.parent();\r
if(!anchor.is('[wlxml-tag]'))\r
return;\r
- view._markSelected(new wlxmlNode.Node(anchor));\r
+ view.selectNode(new wlxmlNode.Node(anchor));\r
});\r
\r
this.node.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
getBody: function() {\r
return this.node.find('#rng-module-documentCanvas-content').html();\r
}, \r
- _markSelected: function(node) {\r
+ selectNode: function(node, options) {\r
+ options = options || {};\r
this.dimNode(node);\r
\r
- \r
this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');\r
- \r
this.getNodeElement(node).addClass('rng-module-documentCanvas-currentNode');\r
-\r
this.currentNode = node;\r
- sandbox.publish('nodeSelected', node);\r
\r
- },\r
- selectNode: function(node) {\r
- view._markSelected(node);\r
- var range = document.createRange();\r
- range.selectNodeContents(this.getNodeElement(node)[0]);\r
- range.collapse(false);\r
+ if(options.doFocus) {\r
+ var range = document.createRange();\r
+ range.selectNodeContents(this.getNodeElement(node)[0]);\r
+ range.collapse(false);\r
\r
- var selection = document.getSelection();\r
- selection.removeAllRanges()\r
- selection.addRange(range);\r
+ var selection = document.getSelection();\r
+ selection.removeAllRanges()\r
+ selection.addRange(range);\r
+ }\r
+ \r
+ sandbox.publish('nodeSelected', node);\r
},\r
highlightNode: function(node) {\r
node = this.getNodeElement(node);\r
view.dimNode(wlxmlNode);\r
},\r
selectNode: function(wlxmlNode) {\r
- view.selectNode(wlxmlNode);\r
+ view.selectNode(wlxmlNode, {doFocus: true});\r
},\r
toggleGrid: function(toggle) {\r
view.toggleGrid(toggle);\r