aboutsummaryrefslogtreecommitdiff
path: root/js/panels/properties.reel/sections/custom.reel/custom.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-27 09:10:58 -0700
committerPushkar Joshi2012-03-27 09:10:58 -0700
commit0c26aff9c19c2b39fca06fa6b3bc76b672204065 (patch)
treee778f2b9d5d525aa364360d5996536a0a06379bd /js/panels/properties.reel/sections/custom.reel/custom.js
parent753244b4713243ab19ca246be674f0b45fb85b72 (diff)
parent309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff)
downloadninja-0c26aff9c19c2b39fca06fa6b3bc76b672204065.tar.gz
Merge branch 'master' into brushtool
Conflicts: js/controllers/elements/shapes-controller.js
Diffstat (limited to 'js/panels/properties.reel/sections/custom.reel/custom.js')
-rwxr-xr-xjs/panels/properties.reel/sections/custom.reel/custom.js57
1 files changed, 57 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..ac316907 100755
--- a/js/panels/properties.reel/sections/custom.reel/custom.js
+++ b/js/panels/properties.reel/sections/custom.reel/custom.js
@@ -20,6 +20,7 @@ var TextField = require("js/components/textfield.reel").TextField;
20var FileInput = require("js/components/ui/file-input.reel").FileInput; 20var FileInput = require("js/components/ui/file-input.reel").FileInput;
21var Checkbox = require("js/components/checkbox.reel").Checkbox; 21var Checkbox = require("js/components/checkbox.reel").Checkbox;
22var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; 22var ColorChip = require("js/components/ui/color-chip.reel").ColorChip;
23var Button = require("montage/ui/button.reel").Button;
23 24
24exports.CustomSection = Montage.create(Component, { 25exports.CustomSection = Montage.create(Component, {
25 26
@@ -128,6 +129,15 @@ exports.CustomSection = Montage.create(Component, {
128 } 129 }
129 }, 130 },
130 131
132 handleAction: {
133 value:function(event) {
134 if(event._event.wasSetByCode) return;
135
136 var obj = event.currentTarget;
137 this._dispatchPropEvent({"type": "change", "id": obj.id, "prop": obj.prop, "value": obj.value, "control": obj});
138 }
139 },
140
131 _dispatchPropEvent: { 141 _dispatchPropEvent: {
132 value: function(event) { 142 value: function(event) {
133// console.log(event); 143// console.log(event);
@@ -163,6 +173,7 @@ exports.CustomSection = Montage.create(Component, {
163 case "file" : return this.createFileInput(fields); 173 case "file" : return this.createFileInput(fields);
164 case "checkbox" : return this.createCheckbox(fields); 174 case "checkbox" : return this.createCheckbox(fields);
165 case "chip" : return this.createColorChip(fields); 175 case "chip" : return this.createColorChip(fields);
176 case "button" : return this.createButton(fields);
166 } 177 }
167 } 178 }
168 }, 179 },
@@ -317,6 +328,19 @@ exports.CustomSection = Montage.create(Component, {
317 if (aField.value) obj.label = aField.value; 328 if (aField.value) obj.label = aField.value;
318 if (aField.prop) obj.prop = aField.prop; 329 if (aField.prop) obj.prop = aField.prop;
319 330
331 if (aField.enabled) {
332 if(aField.enabled.boundObject) {
333 // TODO - For now, always bind to this.controls[someProperty]
334 Object.defineBinding(obj, "enabled", {
335 boundObject: this.controls,
336 boundObjectPropertyPath: aField.enabled.boundProperty,
337 oneway: false
338 });
339 } else {
340 obj.enabled = aField.enabled;
341 }
342 }
343
320 //Initiate onChange Events 344 //Initiate onChange Events
321 obj.addEventListener("change", this, false); 345 obj.addEventListener("change", this, false);
322 346
@@ -351,6 +375,39 @@ exports.CustomSection = Montage.create(Component, {
351 375
352 return obj; 376 return obj;
353 } 377 }
378 },
379
380 createButton: {
381 value: function(aField) {
382 var obj = Button.create();
383
384 // Set Values for Button
385 if (aField.id) obj.id = aField.id;
386 if (aField.label) obj.label = aField.label;
387 if (aField.prop) obj.prop = aField.prop;
388
389 // Special casing button so slot uses "button" tag instead of "div"
390 obj.type = "button";
391
392 if (aField.enabled) {
393 if(aField.enabled.boundObject) {
394 // TODO - For now, always bind to this.controls[someProperty]
395 Object.defineBinding(obj, "enabled", {
396 boundObject: this.controls,
397 boundObjectPropertyPath: aField.enabled.boundProperty,
398 oneway: true
399 });
400 } else {
401 obj.enabled = aField.enabled;
402 }
403 }
404
405 obj.addEventListener("action", this, false);
406
407 this.controls[aField.id] = obj;
408
409 return obj;
410 }
354 } 411 }
355 412
356}); \ No newline at end of file 413}); \ No newline at end of file