X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/df1aaa5ae8434788bb67662782fe7e5324ac9786..4b866f317d1e2e774e55127ba6bf598d61b363d8:/src/smartxml/smartxml.js diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index d87ec54..102a506 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -66,7 +66,7 @@ $.extend(DocumentNode.prototype, { } }); - if(idx !== 'undefined') { + if(idx !== undefined) { nodePath = nodePath.slice(0, idx); } toret = nodePath.map(function(node) {return node.getIndex(); }); @@ -123,6 +123,9 @@ $.extend(DocumentNode.prototype, { var node = (metaData && metaData.node) ? metaData.node : this, event = new events.ChangeEvent(type, $.extend({node: node}, metaData || {})); if(type === 'nodeDetached' || this.document.containsNode(event.meta.node)) { + if(type === 'nodeMoved') { + event.meta.parent = origParent; + } this.document.trigger('change', event); } if((type === 'nodeAdded' || type === 'nodeMoved') && !this.document.containsNode(this) && nodeWasContained) { @@ -574,6 +577,12 @@ $.extend(Document.prototype, Backbone.Events, { } }, + transaction: function(callback, context) { + this.startTransaction(); + callback.call(context); + this.endTransaction(); + }, + getNodeByPath: function(path) { var toret = this.root; path.forEach(function(idx) {