From: Aleksander Ɓukasz Date: Sun, 4 Aug 2013 20:44:28 +0000 (+0200) Subject: internal container wip: refactoring X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/3d5a3556cac5639b18e41ad5c96d4d4573101e00 internal container wip: refactoring --- diff --git a/modules/documentCanvas/canvas/canvas.js b/modules/documentCanvas/canvas/canvas.js index a89a148..f96e62e 100644 --- a/modules/documentCanvas/canvas/canvas.js +++ b/modules/documentCanvas/canvas/canvas.js @@ -206,7 +206,7 @@ $.extend(Canvas.prototype, { } }); - this.wrapper.on('click', '[wlxml-tag], [wlxml-text]', function(e) { + this.wrapper.on('click', '[wlxml-tag], [document-text-element]', function(e) { e.stopPropagation(); canvas.setCurrentElement(canvas.getDocumentElement(e.target), {caretTo: false}); }); @@ -220,7 +220,8 @@ $.extend(Canvas.prototype, { var config = { attributes: false, childList: false, characterData: true, subtree: true, characterDataOldValue: true}; observer.observe(this.d[0], config); - this.wrapper.on('mouseover', '[wlxml-tag], [wlxml-text]', function(e) { + + this.wrapper.on('mouseover', '[wlxml-tag], [document-text-element]', function(e) { var el = canvas.getDocumentElement(e.target); if(!el) return; @@ -229,7 +230,7 @@ $.extend(Canvas.prototype, { el = el.parent(); el.toggleLabel(true); }); - this.wrapper.on('mouseout', '[wlxml-tag], [wlxml-text]', function(e) { + this.wrapper.on('mouseout', '[wlxml-tag], [document-text-element]', function(e) { var el = canvas.getDocumentElement(e.target); if(!el) return; diff --git a/modules/documentCanvas/canvas/canvas.test3.js b/modules/documentCanvas/canvas/canvas.test3.js index 3b14b19..fc390ec 100644 --- a/modules/documentCanvas/canvas/canvas.test3.js +++ b/modules/documentCanvas/canvas/canvas.test3.js @@ -30,10 +30,10 @@ describe('Canvas', function() { }); describe('Internal HTML representation of a DocumentTextElement', function() { - it('is text node wrapped in a div with wlxml-text attribute set', function() { + it('is text node wrapped in a div with document-text-element attribute set', function() { var dom = canvas.fromXML('
Alice
').doc().children()[0].dom(); expect(dom.prop('tagName')).to.equal('DIV'); - expect(dom.attr('wlxml-text')).to.equal(''); + expect(dom.attr('document-text-element')).to.equal(''); expect(dom.contents().length).to.equal(1); expect(dom.contents()[0].nodeType).to.equal(Node.TEXT_NODE); expect($(dom.contents()[0]).text()).to.equal('Alice'); diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 1354a84..f03719e 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -34,7 +34,7 @@ $.extend(DocumentElement, { var $element = $(htmlElement); if(htmlElement.nodeType === Node.ELEMENT_NODE && $element.attr('document-node-element') !== undefined) return DocumentNodeElement.fromHTMLElement(htmlElement, canvas); - if($element.attr('wlxml-text') !== undefined || (htmlElement.nodeType === Node.TEXT_NODE && $element.parent().attr('wlxml-text') !== undefined)) + if($element.attr('document-text-element') !== undefined || (htmlElement.nodeType === Node.TEXT_NODE && $element.parent().attr('document-text-element') !== undefined)) return DocumentTextElement.fromHTMLElement(htmlElement, canvas); return undefined; } @@ -353,7 +353,7 @@ var DocumentTextElement = function(htmlElement, canvas) { $.extend(DocumentTextElement, { createDOM: function(params) { return $('
') - .attr('wlxml-text', '') + .attr('document-text-element', '') .text(params.text || utils.unicode.ZWS); }, @@ -365,7 +365,7 @@ $.extend(DocumentTextElement, { return new this(htmlElement, canvas); }, isContentContainer: function(htmlElement) { - return htmlElement.nodeType === Node.TEXT_NODE && $(htmlElement).parent().is('[wlxml-text]'); + return htmlElement.nodeType === Node.TEXT_NODE && $(htmlElement).parent().is('[document-text-element]'); } }); diff --git a/modules/documentCanvas/nodes.less b/modules/documentCanvas/nodes.less index 1b325d6..cf1df16 100644 --- a/modules/documentCanvas/nodes.less +++ b/modules/documentCanvas/nodes.less @@ -1,4 +1,4 @@ -[wlxml-text] { +[document-text-element] { display: inline; margin: 0 1px; border: 1px solid white;