- },\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
- selectNode: function(wlxmlNode, options) {\r
- options = options || {};\r
- var nodeElement = this.getNodeElement(wlxmlNode)\r
- \r
- this.dimNode(wlxmlNode);\r
- \r
- this.node.find('.rng-module-documentCanvas-currentNode').removeClass('rng-module-documentCanvas-currentNode');\r
- nodeElement.addClass('rng-module-documentCanvas-currentNode');\r
- \r
- if(options.moveCarret) {\r
- var range = document.createRange();\r
- range.selectNodeContents(nodeElement[0]);\r
- range.collapse(false);\r
- var selection = document.getSelection();\r
- selection.removeAllRanges()\r
- selection.addRange(range);\r
- }\r
- \r
- this.currentNode = wlxmlNode;\r
- sandbox.publish('nodeSelected', wlxmlNode);\r
- },\r
- highlightNode: function(wlxmlNode) {\r
- var nodeElement = this.getNodeElement(wlxmlNode);\r
- if(!this.gridToggled) {\r
- nodeElement.addClass('rng-common-hoveredNode');\r
- var label = nodeElement.attr('wlxml-tag');\r
- if(nodeElement.attr('wlxml-class'))\r
- label += ' / ' + nodeElement.attr('wlxml-class');\r
- var tag = $('<div>').addClass('rng-module-documentCanvas-hoveredNodeTag').text(label);\r
- nodeElement.append(tag);\r
- }\r
- },\r
- dimNode: function(wlxmlNode) {\r
- var nodeElement = this.getNodeElement(wlxmlNode);\r
- if(!this.gridToggled) {\r
- nodeElement.removeClass('rng-common-hoveredNode');\r
- nodeElement.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