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/controllers/selection-controller.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index f50762f3..62313960 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -47,6 +47,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementDeleted", this, false); this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("deleteSelection", this, false); + this.eventManager.addEventListener("switchDocument", this, false); // defaultEventManager.addEventListener( "undo", this, false); // defaultEventManager.addEventListener( "redo", this, false); } @@ -88,6 +89,14 @@ exports.SelectionController = Montage.create(Component, { } }, + handleSwitchDocument: { + value: function() { + this._selectedItems = this.application.ninja.selectedElements.slice(0); + this._isDocument = false; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + } + }, + handleElementAdded: { value: function(event) { this.executeSelectElement(event.detail); -- cgit v1.2.3 From 7a9c2a91dfbbdd0cd7c79d81be5aeecd7887e7f1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 29 Feb 2012 10:12:38 -0800 Subject: handle selections for switching documents Signed-off-by: Ananya Sen --- js/controllers/selection-controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 62313960..0f2a16e0 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -92,7 +92,11 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { this._selectedItems = this.application.ninja.selectedElements.slice(0); - this._isDocument = false; + if(this._selectedItems.length === 0){ + this._isDocument = true; + }else{ + this._isDocument = false; + } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); } }, -- 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/controllers/selection-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 0f2a16e0..184c4899 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -92,12 +92,14 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { this._selectedItems = this.application.ninja.selectedElements.slice(0); - if(this._selectedItems.length === 0){ + if(this._selectedItems.length === 0 ){ this._isDocument = true; }else{ this._isDocument = false; } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + + this._selectionContainer = this.application.ninja.currentSelectedContainer; } }, -- cgit v1.2.3