X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6479f1b730495626b2d97c3be2fc903ff34e3a5b..9a93c89991001d4ed088bee3b20cea374aa91d37:/src/smartxml/smartxml.js?ds=sidebyside diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index f4aa9fe..6e00a7d 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -209,12 +209,24 @@ $.extend(TextNode.prototype, DocumentNode.prototype, { return this.nativeNode.data; }, + setText: function(text) { + this.nativeNode.data = text; + this.triggerTextChangeEvent(); + }, + appendText: function(text) { this.nativeNode.data = this.nativeNode.data + text; + this.triggerTextChangeEvent(); }, prependText: function(text) { this.nativeNode.data = text + this.nativeNode.data; + this.triggerTextChangeEvent(); + }, + + triggerTextChangeEvent: function() { + var event = new events.ChangeEvent('nodeTextChange', {node: this}); + this.document.trigger('change', event); } }); @@ -242,10 +254,12 @@ $.extend(Document.prototype, Backbone.Events, { return new this.TextNodeFactory(nativeNode, this); }, - loadXML: function(xml) { + loadXML: function(xml, options) { + options = options || {}; defineDocumentProperties(this, $(parseXML(xml))); - - this.trigger('contentSet'); + if(!options.silent) { + this.trigger('contentSet'); + } }, toXML: function() {