X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/88f8eb498d9fbc99d768bbbabdebaa593746bb47..24e73bdbeb5e83ff18d2f9b359e7b41fe8230c1a:/src/smartxml/smartxml.js?ds=inline diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index b7fc3f1..43e3041 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -29,7 +29,21 @@ $.extend(DocumentNode.prototype, { sameNode: function(otherNode) { return this.nativeNode === otherNode.nativeNode; - } + }, + + parent: function() { + return this.nativeNode.parentNode ? new ElementNode(this.nativeNode.parentNode) : null; + }, + + before: function(node) { + this._$.before(node.nativeNode); + }, + + wrapWith: function(node) { + if(this.parent()) + this.before(node); + node.append(this); + }, }); var ElementNode = function(nativeNode) { @@ -58,16 +72,16 @@ $.extend(ElementNode.prototype, DocumentNode.prototype, { return this._$.contents().index(node._$); }, - parent: function() { - return new ElementNode(this._$.parent()); + getAttr: function(name) { + return this._$.attr(name); }, - append: function(documentNode) { - this._$.append(documentNode.nativeNode); + setAttr: function(name, value) { + this._$.attr(name, value); }, - before: function(node) { - this._$.before(node.nativeNode); + append: function(documentNode) { + this._$.append(documentNode.nativeNode); }, unwrapContent: function() {