diff options
Diffstat (limited to 'js/panels/properties.reel/properties.js')
-rwxr-xr-x | js/panels/properties.reel/properties.js | 205 |
1 files changed, 62 insertions, 143 deletions
diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 507770f6..7f8197ea 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js | |||
@@ -46,17 +46,15 @@ exports.Properties = Montage.create(Component, { | |||
46 | 46 | ||
47 | prepareForDraw: { | 47 | prepareForDraw: { |
48 | value : function() { | 48 | value : function() { |
49 | 49 | this.eventManager.addEventListener("openDocument", this, false); | |
50 | this.eventManager.addEventListener("selectionChange", this, false); | 50 | this.eventManager.addEventListener("selectionChange", this, false); |
51 | this.eventManager.addEventListener("closeDocument", this, false); | ||
51 | 52 | ||
52 | // This will be a toggle option | 53 | // This will be a toggle option |
53 | if(this.application.ninja.appData.PILiveUpdate) { | 54 | if(this.application.ninja.appData.PILiveUpdate) { |
54 | this.eventManager.addEventListener( "elementChanging", this, false); | 55 | this.eventManager.addEventListener( "elementChanging", this, false); |
55 | } | 56 | } |
56 | 57 | ||
57 | this.eventManager.addEventListener("openDocument", this, false); | ||
58 | this.eventManager.addEventListener("switchDocument", this, false); | ||
59 | |||
60 | this.elementId.element.addEventListener("blur", this, false); | 58 | this.elementId.element.addEventListener("blur", this, false); |
61 | this.elementId.element.addEventListener("focus", this, false); | 59 | this.elementId.element.addEventListener("focus", this, false); |
62 | this.elementId.element.addEventListener("keyup", this, false); | 60 | this.elementId.element.addEventListener("keyup", this, false); |
@@ -67,32 +65,21 @@ exports.Properties = Montage.create(Component, { | |||
67 | } | 65 | } |
68 | }, | 66 | }, |
69 | 67 | ||
70 | // Document is opened - Display the current selection | ||
71 | handleOpenDocument: { | 68 | handleOpenDocument: { |
72 | value: function() { | 69 | value: function() { |
73 | |||
74 | this.eventManager.addEventListener( "elementChange", this, false); | 70 | this.eventManager.addEventListener( "elementChange", this, false); |
75 | 71 | ||
76 | // For now always assume that the stage is selected by default when opening the old template | 72 | // Save a reference of the pi inside the document view to be able to clear |
77 | // TODO: Remove marker for old template: NINJA-STAGE-REWORK | 73 | this.application.ninja.currentDocument.model.views.design.propertiesPanel = this; |
78 | if(this.application.ninja.selectedElements.length === 0 && this.application.ninja.currentDocument.documentRoot.nodeName.toLowerCase() !== "body") { | 74 | |
79 | this.displayStageProperties(); | 75 | // Display the default document root PI |
80 | } | 76 | this.displayElementProperties(this.application.ninja.currentDocument.model.documentRoot); |
81 | } | 77 | } |
82 | }, | 78 | }, |
83 | 79 | ||
84 | handleSwitchDocument: { | 80 | handleCloseDocument: { |
85 | value: function(){ | 81 | value: function(){ |
86 | // For now always assume that the stage is selected by default | 82 | this.clear(); |
87 | if(this.application.ninja.selectedElements.length === 0) { | ||
88 | this.displayStageProperties(); | ||
89 | } else { | ||
90 | if(this.application.ninja.selectedElements.length === 1) { | ||
91 | this.displayElementProperties(this.application.ninja.selectedElements[0]); | ||
92 | } else { | ||
93 | this.displayGroupProperties(this.application.ninja.selectedElements); | ||
94 | } | ||
95 | } | ||
96 | } | 83 | } |
97 | }, | 84 | }, |
98 | 85 | ||
@@ -101,13 +88,14 @@ exports.Properties = Montage.create(Component, { | |||
101 | */ | 88 | */ |
102 | handleBlur: { | 89 | handleBlur: { |
103 | value: function(event) { | 90 | value: function(event) { |
104 | if(event.target.id === "elementId") { | 91 | |
92 | if(event.target === this.elementId.element) { | ||
105 | 93 | ||
106 | // Remove all white spaces from the id | 94 | // Remove all white spaces from the id |
107 | this.elementId.value = this.elementId.value.replace(/\s/g, ''); | 95 | this.elementId.value = this.elementId.value.replace(/\s/g, ''); |
108 | 96 | ||
109 | // Check if that id is in use | 97 | // Check if that id is in use |
110 | if(this.application.ninja.currentDocument._document.getElementById(this.elementId.value) !== null) { | 98 | if(this.application.ninja.currentDocument.model.views.design.document.getElementById(this.elementId.value) !== null) { |
111 | // TODO: Replace with Ninja Alert | 99 | // TODO: Replace with Ninja Alert |
112 | alert("The following ID: " + this.elementId.value + " is already in use"); | 100 | alert("The following ID: " + this.elementId.value + " is already in use"); |
113 | } | 101 | } |
@@ -116,13 +104,13 @@ exports.Properties = Montage.create(Component, { | |||
116 | // ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, "Change", "pi"); | 104 | // ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, "Change", "pi"); |
117 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, this.application.ninja.selectedElements[0].id, "pi"); | 105 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, this.application.ninja.selectedElements[0].id, "pi"); |
118 | } else { | 106 | } else { |
119 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.documentRoot, "id", this.elementId.value, "Change", "pi", this.application.ninja.currentDocument.documentRoot.elementModel.id); | 107 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.model.documentRoot, "id", this.elementId.value, "Change", "pi", this.application.ninja.currentDocument.model.documentRoot.elementModel.id); |
120 | } | 108 | } |
121 | } else if(event.target.id === "elementClass") { | 109 | } else if(event.target === this.elementClass.element) { |
122 | if(this.application.ninja.selectedElements.length) { | 110 | if(this.application.ninja.selectedElements.length) { |
123 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "class", this.elementClass.value, this.application.ninja.selectedElements[0].className, "pi"); | 111 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "class", this.elementClass.value, this.application.ninja.selectedElements[0].className, "pi"); |
124 | } else { | 112 | } else { |
125 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.documentRoot, "class", this.elementClass.value, "Change", "pi", this.application.ninja.currentDocument.documentRoot.elementModel.elementClass); | 113 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.model.documentRoot, "class", this.elementClass.value, "Change", "pi", this.application.ninja.currentDocument.model.documentRoot.elementModel.elementClass); |
126 | } | 114 | } |
127 | } | 115 | } |
128 | NJevent("updatedID",this.application.ninja.selectedElements[0]); | 116 | NJevent("updatedID",this.application.ninja.selectedElements[0]); |
@@ -148,7 +136,7 @@ exports.Properties = Montage.create(Component, { | |||
148 | value: function(event) { | 136 | value: function(event) { |
149 | // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update | 137 | // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update |
150 | if(event.detail.source && event.detail.source !== "pi") { | 138 | if(event.detail.source && event.detail.source !== "pi") { |
151 | var el = this.application.ninja.currentDocument.documentRoot; | 139 | var el = this.application.ninja.currentDocument.model.documentRoot; |
152 | if(this.application.ninja.selectedElements.length) { | 140 | if(this.application.ninja.selectedElements.length) { |
153 | el = this.application.ninja.selectedElements[0]; | 141 | el = this.application.ninja.selectedElements[0]; |
154 | } | 142 | } |
@@ -174,8 +162,7 @@ exports.Properties = Montage.create(Component, { | |||
174 | handleSelectionChange: { | 162 | handleSelectionChange: { |
175 | value: function(event) { | 163 | value: function(event) { |
176 | if(event.detail.isDocument) { | 164 | if(event.detail.isDocument) { |
177 | if(this.application.ninja.currentDocument.documentRoot.nodeName.toLowerCase() === "body") return; | 165 | this.displayElementProperties(this.application.ninja.currentDocument.model.documentRoot); |
178 | this.displayStageProperties(); | ||
179 | } else { | 166 | } else { |
180 | if(this.application.ninja.selectedElements.length === 1) { | 167 | if(this.application.ninja.selectedElements.length === 1) { |
181 | this.displayElementProperties(this.application.ninja.selectedElements[0]); | 168 | this.displayElementProperties(this.application.ninja.selectedElements[0]); |
@@ -187,98 +174,33 @@ exports.Properties = Montage.create(Component, { | |||
187 | } | 174 | } |
188 | }, | 175 | }, |
189 | 176 | ||
190 | displayStageProperties: { | 177 | clear: { |
191 | value: function() { | 178 | value: function() { |
192 | var stage = this.application.ninja.currentDocument.documentRoot; | 179 | this.elementName.value = ""; |
193 | //this is test code please remove | 180 | this.elementId.value = ""; |
194 | this.elementName.value = "Stage"; | ||
195 | this.elementId.value = stage.elementModel.id; | ||
196 | this.elementClass.value = ""; | 181 | this.elementClass.value = ""; |
197 | 182 | this.customPi = null; | |
198 | this.positionSize.disablePosition = true; | 183 | this.customSections = []; |
199 | this.threeD.disableTranslation = true; | ||
200 | |||
201 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(stage, "height")); | ||
202 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(stage, "width")); | ||
203 | |||
204 | if(this.threeD.inGlobalMode) | ||
205 | { | ||
206 | this.threeD.xAngle = ElementsMediator.get3DProperty(stage, "xAngle"); | ||
207 | this.threeD.yAngle = ElementsMediator.get3DProperty(stage, "yAngle"); | ||
208 | this.threeD.zAngle = ElementsMediator.get3DProperty(stage, "zAngle"); | ||
209 | } | ||
210 | |||
211 | this.threeD.flatten = ElementsMediator.getProperty(stage, "-webkit-transform-style") !== "preserve-3d"; | ||
212 | |||
213 | if(this.customPi !== stage.elementModel.pi) { | ||
214 | // We need to unregister color chips from the previous selection from the Color Model | ||
215 | var len = this.customSections.length; | ||
216 | for(var n = 0, controls; n < len; n++) { | ||
217 | controls = this.customSections[n].content.controls; | ||
218 | if(controls["colorSelect"]) { | ||
219 | controls["colorSelect"].destroy(); | ||
220 | } else if(controls["stageBackground"]) { | ||
221 | controls["stageBackground"].destroy(); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | this.customPi = stage.elementModel.pi; | ||
226 | this.displayCustomProperties(stage, stage.elementModel.pi); | ||
227 | } | ||
228 | |||
229 | // For now hardcode the background since it is the only custom property | ||
230 | // No need to loop through all the properties. | ||
231 | var backgroundChip = this.customSections[0].content.controls["background"]; | ||
232 | backgroundChip.color = ElementsMediator.getProperty(stage, "background"); | ||
233 | |||
234 | /* | ||
235 | var customPI = PiData[this.customPi]; | ||
236 | // Get all the custom section for the custom PI | ||
237 | for(var i = 0, customSec; customSec = customPI[i]; i++) { | ||
238 | |||
239 | // Now set the Fields for the custom PI | ||
240 | for(var j = 0, fields; fields = customSec.Section[j]; j++) { | ||
241 | for(var k = 0, control; control = fields[k]; k++) { | ||
242 | |||
243 | var colorChipEl = this.customSections[i].content.controls[control.id]; | ||
244 | this.foo = colorChipEl; | ||
245 | colorChipEl.addEventListener("firstDraw", this, false); | ||