aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/selection-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/selection-controller.js')
-rwxr-xr-xjs/controllers/selection-controller.js37
1 files changed, 31 insertions, 6 deletions
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 833e6f04..fed9affd 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -20,6 +20,27 @@ exports.SelectionController = Montage.create(Component, {
20 } 20 }
21 }, 21 },
22 22
23 /*
24 * Bound property to the ninja currentSelectedContainer
25 */
26 _selectionContainer: {
27 value: null
28 },
29
30 selectionContainer: {
31 get: function() {
32 return this._selectionContainer
33 },
34 set: function(value) {
35 if(this._selectionContainer && this._selectionContainer !== value) {
36 console.log("setting container in the selection tool");
37 this.executeSelectElement();
38 }
39
40 this._selectionContainer = value;
41 }
42 },
43
23 deserializedFromTemplate: { 44 deserializedFromTemplate: {
24 value: function() { 45 value: function() {
25 this.eventManager.addEventListener("openDocument", this, false); 46 this.eventManager.addEventListener("openDocument", this, false);
@@ -53,7 +74,9 @@ exports.SelectionController = Montage.create(Component, {
53 } 74 }
54 } 75 }
55 76
56 this.dispatchEvent(selectionEvent.event); 77 //
78 this._selectionContainer = this.application.ninja.currentSelectedContainer;
79
57 } 80 }
58 }, 81 },
59 82
@@ -66,13 +89,10 @@ exports.SelectionController = Montage.create(Component, {
66 handleElementDeleted: { 89 handleElementDeleted: {
67 value: function(event) { 90 value: function(event) {
68 if(!this._isDocument) { 91 if(!this._isDocument) {
69
70 if(this.findSelectedElement(event.detail) !== -1) { 92 if(this.findSelectedElement(event.detail) !== -1) {
71 this.executeSelectElement(); 93 this.executeSelectElement();
72 } 94 }
73
74 } 95 }
75
76 } 96 }
77 }, 97 },
78 98
@@ -130,12 +150,17 @@ exports.SelectionController = Montage.create(Component, {
130 this.executeSelectElement(); // Else execute selection with no item 150 this.executeSelectElement(); // Else execute selection with no item
131 } else { 151 } else {
132 152
133 if(item.parentNode.id == "UserContent") { 153// if(item.parentNode.id === "UserContent") {
154 if(item.parentNode.uuid === this.selectionContainer.uuid) {
134 this.executeSelectElement(item); 155 this.executeSelectElement(item);
135 } else { 156 } else {
136 var outerElement = item.parentNode; 157 var outerElement = item.parentNode;
137 158
138 while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { 159 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) {
160 //while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") {
161 // If element is higher up than current container then return
162 if(outerElement.id === "UserContent") return;
163 // else keep going up the chain
139 outerElement = outerElement.parentNode; 164 outerElement = outerElement.parentNode;
140 } 165 }
141 166