- },\r
- setBody: function(HTMLTree) {\r
- this.node.find('#rng-module-documentCanvas-content').html(HTMLTree);\r
- },\r
- getBody: function() {\r
- return this.node.find('#rng-module-documentCanvas-content').html();\r
- }, \r
- _markSelected: function(node) {\r
- this.dimNode(node);\r
- \r
- this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');\r
- \r
- node.addClass('rng-module-documentCanvas-currentNode');\r
-\r
- this.currentNode = node;\r
- sandbox.publish('nodeSelected', new wlxmlNode.Node(node));\r
- \r
- },\r
- selectNode: function(node) {\r
- node = this.getNodeElement(node);\r
- view._markSelected(node);\r
- var range = document.createRange();\r
- range.selectNodeContents(node[0]);\r
- range.collapse(false);\r
-\r
- var selection = document.getSelection();\r
- selection.removeAllRanges()\r
- selection.addRange(range);\r
- },\r
- highlightNode: function(node) {\r
- node = this.getNodeElement(node);\r
- if(!this.gridToggled) {\r
- node.addClass('rng-common-hoveredNode');\r
- var label = node.attr('wlxml-tag');\r
- if(node.attr('wlxml-class'))\r
- label += ' / ' + node.attr('wlxml-class');\r
- var tag = $('<div>').addClass('rng-module-documentCanvas-hoveredNodeTag').text(label);\r
- node.append(tag);\r
- }\r
- },\r
- dimNode: function(node) {\r
- node = this.getNodeElement(node);\r
- if(!this.gridToggled) {\r
- node.removeClass('rng-common-hoveredNode');\r
- node.find('.rng-module-documentCanvas-hoveredNodeTag').remove();\r
- }\r
- },\r
- selectFirstNode: function() {\r
- var firstNodeWithText = this.node.find('[wlxml-tag]').filter(function() {\r
- return $(this).clone().children().remove().end().text().trim() !== '';\r
- }).first();\r
- var node;\r
- if(firstNodeWithText.length)\r
- node = $(firstNodeWithText[0])\r
- else {\r
- node = this.node.find('[wlxml-class|="p"]')\r
- }\r
- this.selectNode(new wlxmlNode.Node(node));\r
- },\r
- toggleGrid: function(toggle) {\r
- this.node.find('[wlxml-tag]').toggleClass('rng-common-hoveredNode', toggle);\r
- this.gridToggled = toggle;\r
- },\r
- getNodeElement: function(wlxmlNode) {\r
- return this.node.find('#'+wlxmlNode.id);\r