From 5ab7efb9949e486395659c383064a08821febdae Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 28 Feb 2012 15:15:27 -0800 Subject: persist selections while switching documents Signed-off-by: Ananya Sen --- js/controllers/selection-controller.js | 9 +++++++++ js/document/html-document.js | 6 +++--- js/panels/properties/content.reel/content.js | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) (limited to '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); diff --git a/js/document/html-document.js b/js/document/html-document.js index 75628731..0e74914a 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -677,7 +677,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; @@ -691,8 +691,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)){ diff --git a/js/panels/properties/content.reel/content.js b/js/panels/properties/content.reel/content.js index 8fa33a75..9b9b7108 100755 --- a/js/panels/properties/content.reel/content.js +++ b/js/panels/properties/content.reel/content.js @@ -55,6 +55,7 @@ exports.Content = Montage.create(Component, { } this.eventManager.addEventListener("openDocument", this, false); + this.eventManager.addEventListener("switchDocument", this, false); } }, @@ -74,6 +75,15 @@ exports.Content = Montage.create(Component, { } }, + handleSwitchDocument: { + value: function(){ + // For now always assume that the stage is selected by default + if(this.application.ninja.selectedElements.length === 0) { + this.displayStageProperties(); + } + } + }, + /** * Blur and Key up to handle change in the Element ID field. */ -- cgit v1.2.3