From 2edcdd88ffc2f6ff0ea836e4da3e1fd2cb3e856f Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 27 Feb 2012 17:39:26 -0800 Subject: persist undo/redo stack per html document Signed-off-by: Ananya Sen --- js/document/html-document.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 75628731..111c491d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -59,6 +59,27 @@ exports.HTMLDocument = Montage.create(TextDocument, { _gridVerticalSpacing: {value:0}, //end - drawUtils state + _undoStack: { value: [] }, + undoStack: { + get: function() { + return this._undoStack; + }, + set:function(value){ + this._undoStack = value; + } + }, + + _redoStack: { value: [], enumerable: false }, + + redoStack: { + get: function() { + return this._redoStack; + }, + set:function(value){ + this._redoStack = value; + } + }, + // GETTERS / SETTERS @@ -681,6 +702,11 @@ exports.HTMLDocument = Montage.create(TextDocument, { } this.draw3DGrid = this.application.ninja.appModel.show3dGrid; + + //persist a clone of history per document + this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); + this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); + this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start } }, @@ -704,6 +730,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.handleScroll(); this.application.ninja.appModel.show3dGrid = this.draw3DGrid; + + this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); + this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 1766c6b17e2311fcd21c2be6608c7dcdc0a9b23a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 15:07:49 -0800 Subject: persist selections while switching documents Signed-off-by: Ananya Sen --- js/document/html-document.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 111c491d..aac03606 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -698,7 +698,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; if(typeof this.application.ninja.selectedElements !== 'undefined'){ - this.selectionModel = this.application.ninja.selectedElements; + this.selectionModel = this.application.ninja.selectedElements.slice(0); } this.draw3DGrid = this.application.ninja.appModel.show3dGrid; @@ -717,8 +717,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ - this.application.ninja.selectionController.initWithDocument(this.selectionModel); + if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + this.application.ninja.selectedElements = this.selectionModel.slice(0); } if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ -- cgit v1.2.3 From 03ea76700cb8bee3f4f58acf3e3503b0642d13fb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 11:46:19 -0800 Subject: fixed selection which click after switching to a document Signed-off-by: Ananya Sen --- js/document/html-document.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index aac03606..9e3f0cdd 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -717,9 +717,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ - this.application.ninja.selectedElements = this.selectionModel.slice(0); - } + if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; @@ -727,12 +725,17 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; this.application.ninja.stage._scrollLeft = this.savedTopScroll; } - this.application.ninja.stage.handleScroll(); + + if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + this.application.ninja.selectedElements = this.selectionModel.slice(0); + } this.application.ninja.appModel.show3dGrid = this.draw3DGrid; this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); + + this.application.ninja.currentSelectedContainer = this.documentRoot; } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 4e21db069b28c79236c8c7fd19dcc7810d28c5cb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 12:18:09 -0800 Subject: set selectionContainer before restoring selected elements Signed-off-by: Ananya Sen --- js/document/html-document.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9e3f0cdd..9dcea8cb 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -726,6 +726,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.stage._scrollLeft = this.savedTopScroll; } + this.application.ninja.currentSelectedContainer = this.documentRoot; if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } @@ -735,7 +736,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.application.ninja.undocontroller.undoQueue = this.undoStack.slice(0); this.application.ninja.undocontroller.redoQueue = this.redoStack.slice(0); - this.application.ninja.currentSelectedContainer = this.documentRoot; + } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 0cd17b6cf9231e60083958d85759d4796f505342 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 29 Feb 2012 13:48:11 -0800 Subject: Fix for selection bug due to bad scrollLeft and scrollTop values when switching between documents. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 9dcea8cb..581bbc08 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -719,15 +719,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { - if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ + if((this.savedLeftScroll !== null) && (this.savedTopScroll !== null)){ this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll; - this.application.ninja.stage._scrollLeft = this.savedLeftScroll; this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll; - this.application.ninja.stage._scrollLeft = this.savedTopScroll; + this.application.ninja.stage.handleScroll(); } this.application.ninja.currentSelectedContainer = this.documentRoot; - if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){ + if(!this.selectionModel){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } -- cgit v1.2.3 From 84d6f6f5518e5ef8fc3d68be7e41c510f57b597a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 29 Feb 2012 13:53:45 -0800 Subject: Fixing typo. Signed-off-by: Nivesh Rajbhandari --- js/document/html-document.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/html-document.js') diff --git a/js/document/html-document.js b/js/document/html-document.js index 581bbc08..544c0ad5 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -726,7 +726,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } this.application.ninja.currentSelectedContainer = this.documentRoot; - if(!this.selectionModel){ + if(this.selectionModel){ this.application.ninja.selectedElements = this.selectionModel.slice(0); } -- cgit v1.2.3