diff options
author | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
commit | c253192a08b499ea7be46fa5438d273e51f7ec5a (patch) | |
tree | 18a1f0e3679c0eb993a9dedb537035d3861f49ac /js/panels/properties.reel/properties.js | |
parent | e19376c54eedd1f1c457ba405b2f110be376a559 (diff) | |
parent | 4b900ea5cd6bb77eb30cec8c03b9ec9fa662c1e9 (diff) | |
download | ninja-c253192a08b499ea7be46fa5438d273e51f7ec5a.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/panels/properties.reel/properties.js')
-rwxr-xr-x | js/panels/properties.reel/properties.js | 129 |
1 files changed, 90 insertions, 39 deletions
diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 947d7937..625e3eb6 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js | |||
@@ -17,15 +17,11 @@ exports.Properties = Montage.create(Component, { | |||
17 | value: null | 17 | value: null |
18 | }, | 18 | }, |
19 | 19 | ||
20 | elementID: { | 20 | elementId: { |
21 | value: null | 21 | value: null |
22 | }, | 22 | }, |
23 | 23 | ||
24 | elementClassName: { | 24 | elementClass: { |
25 | value: null | ||
26 | }, | ||
27 | |||
28 | nameAttribute: { | ||
29 | value: null | 25 | value: null |
30 | }, | 26 | }, |
31 | 27 | ||
@@ -60,6 +56,14 @@ exports.Properties = Montage.create(Component, { | |||
60 | 56 | ||
61 | this.eventManager.addEventListener("openDocument", this, false); | 57 | this.eventManager.addEventListener("openDocument", this, false); |
62 | this.eventManager.addEventListener("switchDocument", this, false); | 58 | this.eventManager.addEventListener("switchDocument", this, false); |
59 | |||
60 | this.elementId.element.addEventListener("blur", this, false); | ||
61 | this.elementId.element.addEventListener("focus", this, false); | ||
62 | this.elementId.element.addEventListener("keyup", this, false); | ||
63 | |||
64 | this.elementClass.element.addEventListener("blur", this, false); | ||
65 | this.elementClass.element.addEventListener("focus", this, false); | ||
66 | this.elementClass.element.addEventListener("keyup", this, false); | ||
63 | } | 67 | } |
64 | }, | 68 | }, |
65 | 69 | ||
@@ -73,12 +77,6 @@ exports.Properties = Montage.create(Component, { | |||
73 | if(this.application.ninja.selectedElements.length === 0) { | 77 | if(this.application.ninja.selectedElements.length === 0) { |
74 | this.displayStageProperties(); | 78 | this.displayStageProperties(); |
75 | } | 79 | } |
76 | |||
77 | this.elementId.element.addEventListener("blur", this, false); | ||
78 | this.elementId.element.addEventListener("keyup", this, false); | ||
79 | |||
80 | this.elementNameAttribute.element.addEventListener("blur", this, false); | ||
81 | this.elementNameAttribute.element.addEventListener("keyup", this, false); | ||
82 | } | 80 | } |
83 | }, | 81 | }, |
84 | 82 | ||
@@ -87,9 +85,9 @@ exports.Properties = Montage.create(Component, { | |||
87 | // For now always assume that the stage is selected by default | 85 | // For now always assume that the stage is selected by default |
88 | if(this.application.ninja.selectedElements.length === 0) { | 86 | if(this.application.ninja.selectedElements.length === 0) { |
89 | this.displayStageProperties(); | 87 | this.displayStageProperties(); |
90 | }else { | 88 | } else { |
91 | if(this.application.ninja.selectedElements.length === 1) { | 89 | if(this.application.ninja.selectedElements.length === 1) { |
92 | this.displayElementProperties(this.application.ninja.selectedElements[0]._element); | 90 | this.displayElementProperties(this.application.ninja.selectedElements[0]); |
93 | } else { | 91 | } else { |
94 | this.displayGroupProperties(this.application.ninja.selectedElements); | 92 | this.displayGroupProperties(this.application.ninja.selectedElements); |
95 | } | 93 | } |
@@ -102,17 +100,28 @@ exports.Properties = Montage.create(Component, { | |||
102 | */ | 100 | */ |
103 | handleBlur: { | 101 | handleBlur: { |
104 | value: function(event) { | 102 | value: function(event) { |
105 | console.log(event.target); | 103 | |
106 | if(event.target.id === "elementID") { | 104 | if(event.target.id === "elementId") { |
105 | |||
106 | // Remove all white spaces from the id | ||
107 | this.elementId.value = this.elementId.value.replace(/\s/g, ''); | ||
108 | |||
109 | // Check if that id is in use | ||
110 | if(this.application.ninja.currentDocument._document.getElementById(this.elementId.value) !== null) { | ||
111 | // TODO: Replace with Ninja Alert | ||
112 | alert("The following ID: " + this.elementId.value + " is already in use"); | ||
113 | } | ||
114 | |||
107 | if(this.application.ninja.selectedElements.length) { | 115 | if(this.application.ninja.selectedElements.length) { |
108 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, "Change", "pi"); | 116 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "id", this.elementId.value, "Change", "pi"); |
109 | } else { | 117 | } else { |
110 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.documentRoot, "id", this.elementId.value, "Change", "pi", this.application.ninja.currentDocument.documentRoot.elementModel.id); | 118 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.documentRoot, "id", this.elementId.value, "Change", "pi", this.application.ninja.currentDocument.documentRoot.elementModel.id); |
111 | } | 119 | } |
112 | } else if(event.target.id === "elementNameAttribute") { | 120 | } else if(event.target.id === "elementClass") { |
113 | if(this.application.ninja.selectedElements.length) { | 121 | if(this.application.ninja.selectedElements.length) { |
114 | //ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "name", this.elementNameAttribute.value, "Change", "pi"); | 122 | ElementsMediator.setAttribute(this.application.ninja.selectedElements[0], "class", this.elementClass.value, "Change", "pi"); |
115 | this.application.ninja.selectedElements[0]._element.setAttribute("name", this.elementNameAttribute.value); | 123 | } else { |
124 | ElementsMediator.setAttribute(this.application.ninja.currentDocument.documentRoot, "class", this.elementClass.value, "Change", "pi", this.application.ninja.currentDocument.documentRoot.elementModel.elementClass); | ||
116 | } | 125 | } |
117 | } | 126 | } |
118 | } | 127 | } |
@@ -121,19 +130,15 @@ exports.Properties = Montage.create(Component, { | |||
121 | handleKeyup: { | 130 | handleKeyup: { |
122 | value: function(event) { | 131 | value: function(event) { |
123 | if(event.keyCode === 13) { | 132 | if(event.keyCode === 13) { |
124 | if(event.target === "elementID") { | 133 | event.target.blur(); |
125 | this.elementId.element.blur(); | ||
126 | } else if(event.target === "elementNameAttribute") { | ||
127 | this.elementNameAttribute.element.blur(); | ||
128 | } | ||
129 | } | 134 | } |
130 | } | 135 | } |
131 | }, | 136 | }, |
132 | 137 | ||
133 | handleElementChanging: { | 138 | handleElementChanging: { |
134 | value: function(event) { | 139 | value: function(event) { |
135 | // this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(this.application.ninja.selectedElements[0]._element, "left")); | 140 | // this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(this.application.ninja.selectedElements[0], "left")); |
136 | // this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(this.application.ninja.selectedElements[0]._element, "top")); | 141 | // this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(this.application.ninja.selectedElements[0], "top")); |
137 | } | 142 | } |
138 | }, | 143 | }, |
139 | 144 | ||
@@ -141,24 +146,27 @@ exports.Properties = Montage.create(Component, { | |||
141 | value: function(event) { | 146 | value: function(event) { |
142 | // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update | 147 | // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update |
143 | if(event.detail.source && event.detail.source !== "pi") { | 148 | if(event.detail.source && event.detail.source !== "pi") { |
149 | var el = this.application.ninja.currentDocument.documentRoot; | ||
150 | if(this.application.ninja.selectedElements.length) { | ||
151 | el = this.application.ninja.selectedElements[0]; | ||
152 | } | ||
153 | |||
144 | // TODO - This should only update the properties that were changed. | 154 | // TODO - This should only update the properties that were changed. |
145 | var el = this.application.ninja.selectedElements[0]._element || this.application.ninja.selectedElements[0]; | ||
146 | this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); | 155 | this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); |
147 | this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); | 156 | this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); |
148 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); | 157 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); |
149 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); | 158 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); |
150 | 159 | ||
151 | if(this.threeD.inGlobalMode) | 160 | if(this.threeD.inGlobalMode) { |
152 | { | ||
153 | this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D"); | 161 | this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D"); |
154 | this.threeD.y3D = ElementsMediator.get3DProperty(el, "y3D"); | 162 | this.threeD.y3D = ElementsMediator.get3DProperty(el, "y3D"); |
155 | this.threeD.z3D = ElementsMediator.get3DProperty(el, "z3D"); | 163 | this.threeD.z3D = ElementsMediator.get3DProperty(el, "z3D"); |
156 | this.threeD.xAngle = ElementsMediator.get3DProperty(el, "xAngle"); | 164 | this.threeD.xAngle = ElementsMediator.get3DProperty(el, "xAngle"); |
157 | this.threeD.yAngle = ElementsMediator.get3DProperty(el, "yAngle"); | 165 | this.threeD.yAngle = ElementsMediator.get3DProperty(el, "yAngle"); |
158 | this.threeD.zAngle = ElementsMediator.get3DProperty(el, "zAngle"); | 166 | this.threeD.zAngle = ElementsMediator.get3DProperty(el, "zAngle"); |
167 | } | ||
159 | } | 168 | } |
160 | } | 169 | } |
161 | } | ||
162 | }, | 170 | }, |
163 | 171 | ||
164 | handleSelectionChange: { | 172 | handleSelectionChange: { |
@@ -167,7 +175,7 @@ exports.Properties = Montage.create(Component, { | |||
167 | this.displayStageProperties(); | 175 | this.displayStageProperties(); |
168 | } else { | 176 | } else { |
169 | if(this.application.ninja.selectedElements.length === 1) { | 177 | if(this.application.ninja.selectedElements.length === 1) { |
170 | this.displayElementProperties(this.application.ninja.selectedElements[0]._element); | 178 | this.displayElementProperties(this.application.ninja.selectedElements[0]); |
171 | } else { | 179 | } else { |
172 | this.displayGroupProperties(this.application.ninja.selectedElements); | 180 | this.displayGroupProperties(this.application.ninja.selectedElements); |
173 | } | 181 | } |
@@ -180,10 +188,9 @@ exports.Properties = Montage.create(Component, { | |||
180 | value: function() { | 188 | value: function() { |
181 | var stage = this.application.ninja.currentDocument.documentRoot; | 189 | var stage = this.application.ninja.currentDocument.documentRoot; |
182 | //this is test code please remove | 190 | //this is test code please remove |
183 | this.elementName = "Stage"; | 191 | this.elementName.value = "Stage"; |
184 | this.elementId.value = stage.elementModel.id; | 192 | this.elementId.value = stage.elementModel.id; |
185 | this.elementClassName = ""; | 193 | this.elementClass.value = ""; |
186 | this.nameAttribute = ""; | ||
187 | 194 | ||
188 | this.positionSize.disablePosition = true; | 195 | this.positionSize.disablePosition = true; |
189 | this.threeD.disableTranslation = true; | 196 | this.threeD.disableTranslation = true; |
@@ -191,6 +198,19 @@ exports.Properties = Montage.create(Component, { | |||
191 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(stage, "height")); | 198 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(stage, "height")); |
192 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(stage, "width")); | 199 | this.positionSize.widthSize = parseFloat(ElementsM |