aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/selection-controller.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-08 16:59:59 -0700
committerValerio Virgillito2012-06-08 16:59:59 -0700
commit806974142d44afdd23534bf2d18eff0a8e701e0c (patch)
tree811acab38c063ca4fb594bcab0a6dc5e143f29a2 /js/controllers/selection-controller.js
parentd14249dd2d76e9eb8d14733c10393d36bd2ea8ee (diff)
downloadninja-806974142d44afdd23534bf2d18eff0a8e701e0c.tar.gz
rewrite: currentSelectedContainer -> domContainer
Fixed the currentSelectedContainer by removing bindings and using property change on the current document added the red outline back. Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/controllers/selection-controller.js')
-rwxr-xr-xjs/controllers/selection-controller.js38
1 files changed, 16 insertions, 22 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 4bca0755..9ae1cfc9 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -35,7 +35,7 @@ exports.SelectionController = Montage.create(Component, {
35 35
36 if(this._currentDocument && this._currentDocument.currentView === "design") { 36 if(this._currentDocument && this._currentDocument.currentView === "design") {
37 this._currentDocument.model._selection = this.application.ninja.selectedElements; 37 this._currentDocument.model._selection = this.application.ninja.selectedElements;
38 this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; 38// this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer;
39 } 39 }
40 40
41 this._currentDocument = value; 41 this._currentDocument = value;
@@ -65,7 +65,7 @@ exports.SelectionController = Montage.create(Component, {
65 this._selectedElements = value; 65 this._selectedElements = value;
66 66
67 this.application.ninja.selectedElements = this._selectedElements; 67 this.application.ninja.selectedElements = this._selectedElements;
68 this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot; 68// this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot;
69 69
70 if(this._selectedElements.length === 0) { 70 if(this._selectedElements.length === 0) {
71 this.executeSelectElement(); 71 this.executeSelectElement();
@@ -78,30 +78,24 @@ exports.SelectionController = Montage.create(Component, {
78 } 78 }
79 }, 79 },
80 80
81 // Bound property to the ninja currentSelectedContainer
82 _selectionContainer: {
83 value: null
84 },
85
86 selectionContainer: {
87 get: function() {
88 return this._selectionContainer
89 },
90 set: function(value) {
91 if(this._selectionContainer && this._selectionContainer !== value) {
92 this.executeSelectElement();
93 }
94
95 this._selectionContainer = value;
96 }
97 },
98
99 deserializedFromTemplate: { 81 deserializedFromTemplate: {
100 value: function() { 82 value: function() {
101 this.eventManager.addEventListener("elementAdded", this, false); 83 this.eventManager.addEventListener("elementAdded", this, false);
102 this.eventManager.addEventListener("elementsRemoved", this, false); 84 this.eventManager.addEventListener("elementsRemoved", this, false);
103 this.eventManager.addEventListener("elementReplaced", this, false); 85 this.eventManager.addEventListener("elementReplaced", this, false);
104 this.eventManager.addEventListener("selectAll", this, false); 86 this.eventManager.addEventListener("selectAll", this, false);
87
88 this.addPropertyChangeListener("currentDocument.model.domContainer", this);
89 }
90 },
91
92 handleChange: {
93 value: function() {
94 if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) {
95 if(this.currentDocument.model.getProperty("domContainer") !== null) {
96 this.executeSelectElement();
97 }
98 }
105 } 99 }
106 }, 100 },
107 101
@@ -175,12 +169,12 @@ exports.SelectionController = Montage.create(Component, {
175 if(this.isDocument) return; // If the stage is already selected do nothing. 169 if(this.isDocument) return; // If the stage is already selected do nothing.
176 this.executeSelectElement(); // Else execute selection with no element 170 this.executeSelectElement(); // Else execute selection with no element
177 } else { 171 } else {
178 if(element.parentNode.uuid === this.selectionContainer.uuid) { 172 if(element.parentNode.uuid === this.currentDocument.model.domContainer.uuid) {
179 this.executeSelectElement(element); 173 this.executeSelectElement(element);
180 } else { 174 } else {
181 var outerElement = element.parentNode; 175 var outerElement = element.parentNode;
182 176
183 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { 177 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.currentDocument.model.domContainer.uuid) {
184 // If element is higher up than current container then return 178 // If element is higher up than current container then return
185 if(outerElement.nodeName === "BODY") return; 179 if(outerElement.nodeName === "BODY") return;
186 // else keep going up the chain 180 // else keep going up the chain