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