- this.node.on('mouseover', '[wlxml-tag]', function(e) { sandbox.publish('nodeHovered', $(e.target)); });\r
- this.node.on('mouseout', '[wlxml-tag]', function(e) { sandbox.publish('nodeBlured', $(e.target)); });\r
- this.node.on('click', '[wlxml-tag]', function(e) {\r
- console.log('clicked node type: '+e.target.nodeType);\r
- view._markSelected($(e.target));\r
- });\r
-\r
- this.node.on('keyup', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
- var anchor = $(window.getSelection().anchorNode);\r
- if(anchor[0].nodeType === Node.TEXT_NODE)\r
- anchor = anchor.parent();\r
- if(!anchor.is('[wlxml-tag]'))\r
- return;\r
- view._markSelected(anchor);\r
- });\r
- \r
- this.node.on('keydown', '#rng-module-documentCanvas-contentWrapper', function(e) {\r
- if(e.which === 13) { \r
- e.preventDefault();\r
- view.insertNewNode(null, null);\r
- }\r
- });\r
- \r
- \r
- var observer = new MutationObserver(function(mutations) {\r
- mutations.forEach(function(mutation) {\r
- _.each(mutation.addedNodes, function(node) {\r
- node = $(node);\r
- node.parent().find('[wlxml-tag]').each(function() {\r
- tag = $(this);\r
- if(!tag.attr('id'))\r
- tag.attr('id', 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);}));\r
- });\r
- });\r
- }); \r
- });\r
- var config = { attributes: true, childList: true, characterData: true, subtree: true };\r
- observer.observe(this.node.find('#rng-module-documentCanvas-contentWrapper')[0], config);\r
- \r
- this.gridToggled = false;\r
- },\r
- _createNode: function(wlxmlTag, wlxmlClass) {\r
- var toBlock = ['div', 'document', 'section', 'header'];\r
- var htmlTag = _.contains(toBlock, wlxmlTag) ? 'div' : 'span';\r
- var toret = $('<' + htmlTag + '>');\r
- toret.attr('wlxml-tag', wlxmlTag);\r
- if(wlxmlClass)\r
- toret.attr('wlxml-class', wlxmlClass);\r
- return toret;\r