}
}));
+ElementNode.prototype.transformations.register(transformations.createContextTransformation({
+ name: 'smartxml.setAttr2',
+ impl: function(args) {
+ this.prevAttr = this.getAttr(args.name);
+ this.setAttr(args.name, args.value);
+ },
+ undo: function(args) {
+ this.setAttr(args.name, this.prevAttr);
+ }
+}));
+
DocumentNode.prototype.transformations.register(transformations.createContextTransformation({
name: 'smartxml.wrapWith',
getChangeRoot: function() {
},
getChangeRoot: function() {
return this.context.parent().parent();
+ },
+ isAllowed: function(args) {
+ var parent = this.parent();
+ return !!(parent && parent.parent());
}
}));
this.loadXML(xml);
this.undoStack = [];
this.redoStack = [];
+ this._transformationLevel = 0;
};
$.extend(Document.prototype, Backbone.Events, {
}
}
if(transformation) {
+ this._transformationLevel++;
toret = transformation.run();
- this.undoStack.push(transformation);
+ if(this._transformationLevel === 1) {
+ this.undoStack.push(transformation);
+ }
+ this._transformationLevel--;
console.log('clearing redo stack');
this.redoStack = [];
return toret;