diff options
author | Jose Antonio Marquez | 2012-03-21 09:52:47 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-21 09:52:47 -0700 |
commit | 37cafa09653ff3e2cb88c5b51cdc1f6e066aa3e8 (patch) | |
tree | 3e8e0fa4e170763baad97f39fff3817893cec90a /js/panels/properties.reel/sections/custom.reel | |
parent | 44b66216531a872f8dba6a11f1cf13c612c90247 (diff) | |
parent | 9facfb41b0b0f9fab9ddc9c8473af1d1d7e1ff18 (diff) | |
download | ninja-37cafa09653ff3e2cb88c5b51cdc1f6e066aa3e8.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO-Montage-Components
Diffstat (limited to 'js/panels/properties.reel/sections/custom.reel')
-rwxr-xr-x | js/panels/properties.reel/sections/custom.reel/custom.js | 44 |
1 files changed, 44 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..703ef950 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; | |||
20 | var FileInput = require("js/components/ui/file-input.reel").FileInput; | 20 | var FileInput = require("js/components/ui/file-input.reel").FileInput; |
21 | var Checkbox = require("js/components/checkbox.reel").Checkbox; | 21 | var Checkbox = require("js/components/checkbox.reel").Checkbox; |
22 | var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; | 22 | var ColorChip = require("js/components/ui/color-chip.reel").ColorChip; |
23 | var Button = require("montage/ui/button.reel").Button; | ||
23 | 24 | ||
24 | exports.CustomSection = Montage.create(Component, { | 25 | exports.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 | }, |
@@ -351,6 +362,39 @@ exports.CustomSection = Montage.create(Component, { | |||
351 | 362 | ||
352 | return obj; | 363 | return obj; |
353 | } | 364 | } |
365 | }, | ||
366 | |||
367 | createButton: { | ||
368 | value: function(aField) { | ||
369 | var obj = Button.create(); | ||
370 | |||
371 | // Set Values for Button | ||
372 | if (aField.id) obj.id = aField.id; | ||
373 | if (aField.label) obj.label = aField.label; | ||
374 | if (aField.prop) obj.prop = aField.prop; | ||
375 | |||
376 | // Special casing button so slot uses "button" tag instead of "div" | ||
377 | obj.type = "button"; | ||
378 | |||
379 | if (aField.enabled) { | ||
380 | if(aField.enabled.boundObject) { | ||
381 | // TODO - For now, always bind to this.controls[someProperty] | ||
382 | Object.defineBinding(obj, "enabled", { | ||
383 | boundObject: this.controls, | ||
384 | boundObjectPropertyPath: aField.enabled.boundProperty, | ||
385 | oneway: true | ||
386 | }); | ||
387 | } else { | ||
388 | obj.enabled = aField.enabled; | ||
389 | } | ||
390 | } | ||
391 | |||
392 | obj.addEventListener("action", this, false); | ||
393 | |||
394 | this.controls[aField.id] = obj; | ||
395 | |||
396 | return obj; | ||
397 | } | ||
354 | } | 398 | } |
355 | 399 | ||
356 | }); \ No newline at end of file | 400 | }); \ No newline at end of file |