X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/02ea7eed98a6826504c4472a9309010277026a03..9ce300f6e7b27995b982c14b79785e8ca4bed4f0:/src/smartxml/smartxml.js?ds=sidebyside diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index b469068..18664c7 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -27,7 +27,9 @@ $.extend(DocumentNode.prototype, { }, detach: function() { + var parent = this.parent(); this._$.detach(); + this.triggerChangeEvent('nodeDetached', {parent: parent}); return this; }, @@ -78,6 +80,10 @@ $.extend(DocumentNode.prototype, { insertion.insertsNew = true; } return insertion; + }, + + getIndex: function() { + return this.parent().indexOf(this); } }); @@ -315,7 +321,13 @@ $.extend(Document.prototype, Backbone.Events, { from = node[0]; } } - return new this.ElementNodeFactory(from, this); + var Factory; + if(from.nodeType === Node.TEXT_NODE) { + Factory = this.TextNodeFactory; + } else if(from.nodeType === Node.ELEMENT_NODE) { + Factory = this.ElementNodeFactory; + } + return new Factory(from, this); }, createTextNode: function(nativeNode) {