aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-28 16:02:37 -0800
committerValerio Virgillito2012-02-28 16:02:37 -0800
commit20d4f1d703c004dd7f869576b6c471b3fb5b5d3e (patch)
tree7a6cf1e52e1aea55f4bc2112e11a790fc35f839c
parentee52f197d1eb53a5ff30b54b8df1d2b53014eb0e (diff)
parent557c4d3100ccde51b925b71f0650b2c783a4a042 (diff)
downloadninja-20d4f1d703c004dd7f869576b6c471b3fb5b5d3e.tar.gz
Merge pull request #81 from ananyasen/integration-candidate
persist selections while switching documents
-rwxr-xr-xjs/controllers/selection-controller.js13
-rwxr-xr-xjs/document/html-document.js6
-rwxr-xr-xjs/panels/properties/content.reel/content.js16
3 files changed, 32 insertions, 3 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index f50762f3..c4623d3f 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -47,6 +47,7 @@ exports.SelectionController = Montage.create(Component, {
47 this.eventManager.addEventListener("elementDeleted", this, false); 47 this.eventManager.addEventListener("elementDeleted", this, false);
48 this.eventManager.addEventListener("selectAll", this, false); 48 this.eventManager.addEventListener("selectAll", this, false);
49 this.eventManager.addEventListener("deleteSelection", this, false); 49 this.eventManager.addEventListener("deleteSelection", this, false);
50 this.eventManager.addEventListener("switchDocument", this, false);
50// defaultEventManager.addEventListener( "undo", this, false); 51// defaultEventManager.addEventListener( "undo", this, false);
51// defaultEventManager.addEventListener( "redo", this, false); 52// defaultEventManager.addEventListener( "redo", this, false);
52 } 53 }
@@ -88,6 +89,18 @@ exports.SelectionController = Montage.create(Component, {
88 } 89 }
89 }, 90 },
90 91
92 handleSwitchDocument: {
93 value: function() {
94 this._selectedItems = this.application.ninja.selectedElements.slice(0);
95 if(this._selectedItems.length === 0 ){
96 this._isDocument = true;
97 }else{
98 this._isDocument = false;
99 }
100 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
101 }
102 },
103
91 handleElementAdded: { 104 handleElementAdded: {
92 value: function(event) { 105 value: function(event) {
93 this.executeSelectElement(event.detail); 106 this.executeSelectElement(event.detail);
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 6853f4d7..826a59c0 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -710,7 +710,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
710 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; 710 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
711 711
712 if(typeof this.application.ninja.selectedElements !== 'undefined'){ 712 if(typeof this.application.ninja.selectedElements !== 'undefined'){
713 this.selectionModel = this.application.ninja.selectedElements; 713 this.selectionModel = this.application.ninja.selectedElements.slice(0);
714 } 714 }
715 715
716 this.draw3DGrid = this.application.ninja.appModel.show3dGrid; 716 this.draw3DGrid = this.application.ninja.appModel.show3dGrid;
@@ -724,8 +724,8 @@ exports.HTMLDocument = Montage.create(TextDocument, {
724 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; 724 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing;
725 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; 725 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
726 726
727 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ 727 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null)){
728 this.application.ninja.selectionController.initWithDocument(this.selectionModel); 728 this.application.ninja.selectedElements = this.selectionModel.slice(0);
729 } 729 }
730 730
731 if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){ 731 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..cc9ec96a 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, {
55 } 55 }
56 56
57 this.eventManager.addEventListener("openDocument", this, false); 57 this.eventManager.addEventListener("openDocument", this, false);
58 this.eventManager.addEventListener("switchDocument", this, false);
58 } 59 }
59 }, 60 },
60 61
@@ -74,6 +75,21 @@ exports.Content = Montage.create(Component, {
74 } 75 }
75 }, 76 },
76 77
78 handleSwitchDocument: {
79 value: function(){
80 // For now always assume that the stage is selected by default
81 if(this.application.ninja.selectedElements.length === 0) {
82 this.displayStageProperties();
83 }else {
84 if(this.application.ninja.selectedElements.length === 1) {
85 this.displayElementProperties(this.application.ninja.selectedElements[0]._element);
86 } else {
87 this.displayGroupProperties(this.application.ninja.selectedElements);
88 }
89 }
90 }
91 },
92
77 /** 93 /**
78 * Blur and Key up to handle change in the Element ID field. 94 * Blur and Key up to handle change in the Element ID field.
79 */ 95 */