aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/elements/element-controller.js4
-rwxr-xr-xjs/controllers/selection-controller.js38
2 files changed, 18 insertions, 24 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 4a02e9a3..e40a646a 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -19,13 +19,13 @@ exports.ElementController = Montage.create(Component, {
19 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); 19 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
20 20
21 if(selectedLayerIndex === 0) { 21 if(selectedLayerIndex === 0) {
22 this.application.ninja.currentSelectedContainer.appendChild(el); 22 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
23 } else { 23 } else {
24 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; 24 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0];
25 element.parentNode.insertBefore(el, element.nextSibling); 25 element.parentNode.insertBefore(el, element.nextSibling);
26 } 26 }
27 } else { 27 } else {
28 this.application.ninja.currentSelectedContainer.appendChild(el); 28 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
29 } 29 }
30 30
31 if(styles) { 31 if(styles) {
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