From 87e029e74fe3bc64c7859490988da52e84d538e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Sat, 7 Dec 2013 22:41:36 +0100 Subject: [PATCH] smartxml: Don't preprare for undo if it's obvious it will never come In current implementation nested transformations are never directly undone. --- src/smartxml/smartxml.js | 6 ++++-- src/smartxml/transformations.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js index eb97ea9..bf64c27 100644 --- a/src/smartxml/smartxml.js +++ b/src/smartxml/smartxml.js @@ -420,6 +420,7 @@ $.extend(Document.prototype, Backbone.Events, { transform: function(Transformation, args) { //console.log('transform'); var toret, transformation; + //debugger; // ref: odrebnie przygotowanie transformacji, odrebnie jej wykonanie (to pierwsze to analog transform z node) @@ -430,7 +431,7 @@ $.extend(Document.prototype, Backbone.Events, { } if(transformation) { this._transformationLevel++; - toret = transformation.run(); + toret = transformation.run({beUndoable:this._transformationLevel === 1}); if(this._transformationLevel === 1 && !this._undoInProgress) { this.undoStack.push(transformation); } @@ -457,9 +458,10 @@ $.extend(Document.prototype, Backbone.Events, { var transformation = this.redoStack.pop(); if(transformation) { this._transformationLevel++; - transformation.run(); + transformation.run({beUndoable: true}); this._transformationLevel--; this.undoStack.push(transformation); + } }, diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index f0b89f1..5e461ee 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -87,9 +87,9 @@ toret.createGenericTransformation = function(desc, name) { }; _.extend(GenericTransformation.prototype, { name: name, - run: function() { + run: function(options) { var changeRoot; - if(!desc.undo) { + if(!desc.undo && options.beUndoable) { changeRoot = desc.getChangeRoot ? desc.getChangeRoot.call(this) : this.document.root; this.snapshot = changeRoot.clone(); this.changeRootPath = changeRoot.getPath(); -- 2.20.1