aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/elements/body-controller.js2
-rwxr-xr-xjs/controllers/elements/element-controller.js4
-rwxr-xr-xjs/controllers/selection-controller.js32
3 files changed, 9 insertions, 29 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 0dc11b82..27989c65 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -37,7 +37,7 @@ exports.BodyController = Montage.create(ElementController, {
37 case "height": 37 case "height":
38 case "width": 38 case "width":
39 case "-webkit-transform-style": 39 case "-webkit-transform-style":
40 return this.application.ninja.stylesController.getElementStyle(el, p, true, true); 40 return this.application.ninja.stylesController.getElementStyle(el, p);
41 default: 41 default:
42 return ElementController.getProperty(el, p, true, true); 42 return ElementController.getProperty(el, p, true, true);
43 //console.log("Undefined Stage property ", p); 43 //console.log("Undefined Stage property ", p);
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index 3d71c52d..a474961a 100755
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -38,13 +38,13 @@ exports.ElementController = Montage.create(Component, {
38 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); 38 var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID);
39 39
40 if(selectedLayerIndex === 0) { 40 if(selectedLayerIndex === 0) {
41 this.application.ninja.currentSelectedContainer.appendChild(el); 41 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
42 } else { 42 } else {
43 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.stageElement; 43 var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.stageElement;
44 element.parentNode.insertBefore(el, element.nextSibling); 44 element.parentNode.insertBefore(el, element.nextSibling);
45 } 45 }
46 } else { 46 } else {
47 this.application.ninja.currentSelectedContainer.appendChild(el); 47 this.application.ninja.currentDocument.model.domContainer.appendChild(el);
48 } 48 }
49 49
50 if(styles) { 50 if(styles) {
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 4bca0755..b327bea4 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -35,11 +35,13 @@ 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;
39 } 38 }
40 39
41 this._currentDocument = value; 40 this._currentDocument = value;
42 41
42 if(this._currentDocument && this._currentDocument.currentView === "design") {
43 this.selectedElements = this._currentDocument.model.selection;
44 }
43 /* 45 /*
44 if(!value) { 46 if(!value) {
45 } else if(this._currentDocument.currentView === "design") { 47 } else if(this._currentDocument.currentView === "design") {
@@ -59,43 +61,21 @@ exports.SelectionController = Montage.create(Component, {
59 return this._selectedElements; 61 return this._selectedElements;
60 }, 62 },
61 set: function(value) { 63 set: function(value) {
62 if(this.currentDocument && this.currentDocument.currentView === "code") return;
63 64
64 if(value) { 65 if(value) {
65 this._selectedElements = value; 66 this._selectedElements = value;
66 67
67 this.application.ninja.selectedElements = this._selectedElements; 68 this.application.ninja.selectedElements = this._selectedElements;
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();
72 } else { 72 } else {
73 this.executeSelectElement(this._selectedElements); 73 this.executeSelectElement(this._selectedElements);
74 } 74 }
75
76
77 } 75 }
78 } 76 }
79 }, 77 },
80 78
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: { 79 deserializedFromTemplate: {
100 value: function() { 80 value: function() {
101 this.eventManager.addEventListener("elementAdded", this, false); 81 this.eventManager.addEventListener("elementAdded", this, false);
@@ -131,7 +111,7 @@ exports.SelectionController = Montage.create(Component, {
131 value: function(event) { 111 value: function(event) {
132 var selected = [], childNodes = [], self = this; 112 var selected = [], childNodes = [], self = this;
133 113
134 childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes; 114 childNodes = this.currentDocument.model.domContainer.childNodes;
135 childNodes = Array.prototype.slice.call(childNodes, 0); 115 childNodes = Array.prototype.slice.call(childNodes, 0);
136 childNodes.forEach(function(item) { 116 childNodes.forEach(function(item) {
137 if(self.isNodeTraversable(item)) { 117 if(self.isNodeTraversable(item)) {
@@ -175,12 +155,12 @@ exports.SelectionController = Montage.create(Component, {
175 if(this.isDocument) return; // If the stage is already selected do nothing. 155 if(this.isDocument) return; // If the stage is already selected do nothing.
176 this.executeSelectElement(); // Else execute selection with no element 156 this.executeSelectElement(); // Else execute selection with no element
177 } else { 157 } else {
178 if(element.parentNode.uuid === this.selectionContainer.uuid) { 158 if(element.parentNode.uuid === this.currentDocument.model.domContainer.uuid) {
179 this.executeSelectElement(element); 159 this.executeSelectElement(element);
180 } else { 160 } else {
181 var outerElement = element.parentNode; 161 var outerElement = element.parentNode;
182 162
183 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { 163 while(outerElement.parentNode && outerElement.parentNode.uuid !== this.currentDocument.model.domContainer.uuid) {
184 // If element is higher up than current container then return 164 // If element is higher up than current container then return
185 if(outerElement.nodeName === "BODY") return; 165 if(outerElement.nodeName === "BODY") return;
186 // else keep going up the chain 166 // else keep going up the chain