aboutsummaryrefslogtreecommitdiff
path: root/js/panels/properties.reel/sections/custom.reel
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-04-16 16:06:24 -0700
committerNivesh Rajbhandari2012-04-16 16:06:24 -0700
commitc253192a08b499ea7be46fa5438d273e51f7ec5a (patch)
tree18a1f0e3679c0eb993a9dedb537035d3861f49ac /js/panels/properties.reel/sections/custom.reel
parente19376c54eedd1f1c457ba405b2f110be376a559 (diff)
parent4b900ea5cd6bb77eb30cec8c03b9ec9fa662c1e9 (diff)
downloadninja-c253192a08b499ea7be46fa5438d273e51f7ec5a.tar.gz
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/panels/properties.reel/sections/custom.reel')
-rwxr-xr-xjs/panels/properties.reel/sections/custom.reel/custom.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/js/panels/properties.reel/sections/custom.reel/custom.js b/js/panels/properties.reel/sections/custom.reel/custom.js
index 3c595980..876fe110 100755
--- a/js/panels/properties.reel/sections/custom.reel/custom.js
+++ b/js/panels/properties.reel/sections/custom.reel/custom.js
@@ -15,11 +15,13 @@ var ColorSelect = require("js/panels/properties.reel/sections/custom-rows/color-
15 15
16// Components Needed to make this work 16// Components Needed to make this work
17var Hottext = require("js/components/hottextunit.reel").HotTextUnit; 17var Hottext = require("js/components/hottextunit.reel").HotTextUnit;
18var HT = require("js/components/hottext.reel").HotText;
18var Dropdown = require("js/components/combobox.reel").Combobox; 19var Dropdown = require("js/components/combobox.reel").Combobox;
19var TextField = require("js/components/textfield.reel").TextField; 20var TextField = require("js/components/textfield.reel").TextField;
20var FileInput = require("js/components/ui/file-input.reel").FileInput; 21var FileInput = require("js/components/ui/file-input.reel").FileInput;
21var Checkbox = require("js/components/checkbox.reel").Checkbox; 22var Checkbox = require("js/components/checkbox.reel").Checkbox;
22var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; 23var ColorChip = require("js/components/ui/color-chip.reel").ColorChip;
24var Button = require("montage/ui/button.reel").Button;
23 25
24exports.CustomSection = Montage.create(Component, { 26exports.CustomSection = Montage.create(Component, {
25 27
@@ -128,6 +130,15 @@ exports.CustomSection = Montage.create(Component, {
128 } 130 }
129 }, 131 },
130 132
133 handleAction: {
134 value:function(event) {
135 if(event._event.wasSetByCode) return;
136
137 var obj = event.currentTarget;
138 this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj});
139 }
140 },
141
131 _dispatchPropEvent: { 142 _dispatchPropEvent: {
132 value: function(event) { 143 value: function(event) {
133// console.log(event); 144// console.log(event);
@@ -158,15 +169,44 @@ exports.CustomSection = Montage.create(Component, {
158 value: function(fields) { 169 value: function(fields) {
159 switch(fields.type) { 170 switch(fields.type) {
160 case "hottext" : return this.createHottext(fields); 171 case "hottext" : return this.createHottext(fields);
172 case "ht" : return this.createHT(fields);
161 case "dropdown" : return this.createDropdown(fields); 173 case "dropdown" : return this.createDropdown(fields);
162 case "textbox" : return this.createTextField(fields); 174 case "textbox" : return this.createTextField(fields);
163 case "file" : return this.createFileInput(fields); 175 case "file" : return this.createFileInput(fields);
164 case "checkbox" : return this.createCheckbox(fields); 176 case "checkbox" : return this.createCheckbox(fields);
165 case "chip" : return this.createColorChip(fields); 177 case "chip" : return this.createColorChip(fields);
178 case "button" : return this.createButton(fields);
166 } 179 }
167 } 180 }
168 }, 181 },
169 182
183 createHT: {
184 value: function(aField) {
185
186 // Generate Hottext
187 var obj = HT.create();
188
189 // Set Values for HottextRow
190 if (aField.id) obj.id = aField.id;
191 if (aField.value) obj.value = aField.value;
192 if (aField.min) obj._minValue = aField.min;
193 if (aField.max) obj._maxValue = aField.max;
194 if (aField.prop) obj.prop = aField.prop;
195
196 //Initiate onChange Events
197 obj.addEventListener("change", this, false);
198 obj.addEventListener("changing", this, false);
199
200 //Bind object value to controls list so it can be manipulated
201 Object.defineBinding(this.controls, aField.id, {
202 boundObject: obj,
203 boundObjectPropertyPath: "value"
204 });
205
206 return obj;
207 }
208 },
209
170 //Breaking Up Switch Case Statement to functions to return a row 210 //Breaking Up Switch Case Statement to functions to return a row
171 createHottext: { 211 createHottext: {
172 value: function(aField) { 212 value: function(aField) {
@@ -317,6 +357,19 @@ exports.CustomSection = Montage.create(Component, {
317 if (aField.value) obj.label = aField.value; 357 if (aField.value) obj.label = aField.value;
318 if (aField.prop) obj.prop = aField.prop; 358 if (aField.prop) obj.prop = aField.prop;
319 359
360 if (aField.enabled) {
361 if(aField.enabled.boundObject) {
362 // TODO - For now, always bind to this.controls[someProperty]
363 Object.defineBinding(obj, "enabled", {
364 boundObject: this.controls,
365 boundObjectPropertyPath: aField.enabled.boundProperty,
366 oneway: false
367 });
368 } else {
369 obj.enabled = aField.enabled;
370 }
371 }
372
320 //Initiate onChange Events 373 //Initiate onChange Events
321 obj.addEventListener("change", this, false); 374 obj.addEventListener("change", this, false);
322 375
@@ -351,6 +404,39 @@ exports.CustomSection = Montage.create(Component, {
351 404
352 return obj; 405 return obj;
353 } 406 }
407 },
408
409 createButton: {
410 value: function(aField) {
411 var obj = Button.create();
412
413 // Set Values for Button
414 if (aField.id) obj.id = aField.id;
415 if (aField.label) obj.label = aField.label;
416 if (aField.prop) obj.prop = aField.prop;
417
418 // Special casing button so slot uses "button" tag instead of "div"
419 obj.type = "button";
420
421 if (aField.enabled) {
422 if(aField.enabled.boundObject) {
423 // TODO - For now, always bind to this.controls[someProperty]
424 Object.defineBinding(obj, "enabled", {
425 boundObject: this.controls,
426 boundObjectPropertyPath: aField.enabled.boundProperty,
427 oneway: true
428 });
429 } else {
430 obj.enabled = aField.enabled;
431 }
432 }
433
434 obj.addEventListener("action", this, false);
435
436 this.controls[aField.id] = obj;
437
438 return obj;
439 }
354 } 440 }
355 441
356}); \ No newline at end of file 442}); \ No newline at end of file