diff options
author | Eric Guzman | 2012-02-13 15:48:37 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-13 15:48:37 -0800 |
commit | b2672478decd3ee3bfacf86b525551c997f9604d (patch) | |
tree | 79a88684406d3adf00350246a4da884b97fb0eac /js/components/ui | |
parent | a738121a921e4c721b280434952b415b9ab3b1a8 (diff) | |
parent | 0620e2f788861e824d6e49fa319da4d20b18a556 (diff) | |
download | ninja-b2672478decd3ee3bfacf86b525551c997f9604d.tar.gz |
Merge branch 'refs/heads/master' into StylesControllerUpdates
Conflicts:
js/controllers/styles-controller.js
Diffstat (limited to 'js/components/ui')
-rw-r--r-- | js/components/ui/color-chip.reel/color-chip.js | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/js/components/ui/color-chip.reel/color-chip.js b/js/components/ui/color-chip.reel/color-chip.js index 5bef7020..e51bdd8a 100644 --- a/js/components/ui/color-chip.reel/color-chip.js +++ b/js/components/ui/color-chip.reel/color-chip.js | |||
@@ -9,32 +9,80 @@ var Montage = require("montage/core/core").Montage, | |||
9 | 9 | ||
10 | var ColorChip = exports.ColorChip = Montage.create(Component, { | 10 | var ColorChip = exports.ColorChip = Montage.create(Component, { |
11 | 11 | ||
12 | chip: { | ||
13 | value: false | ||
14 | }, | ||
15 | |||
12 | hasIcon: { | 16 | hasIcon: { |
13 | value: true | 17 | value: true |
14 | }, | 18 | }, |
15 | 19 | ||
20 | iconType: { | ||
21 | value: null | ||
22 | }, | ||
23 | |||
16 | mode: { | 24 | mode: { |
17 | value: "stroke" | 25 | value: "stroke" |
18 | }, | 26 | }, |
19 | 27 | ||
20 | prepareForDraw: { | 28 | offset: { |
21 | value: function() { | 29 | value: 20 |
22 | // this.colorButton.props = {side: 'right', align: 'bottom', wheel: true, palette: true, gradient: true, image: true, offset: 20}; | 30 | }, |
23 | // this.application.ninja.colorController.addButton('chip', this.colorButton); | ||
24 | 31 | ||
32 | initialColor: { | ||
33 | value: false | ||
34 | }, | ||
25 | 35 | ||
36 | changeDelegate: { | ||
37 | value: null | ||
38 | }, | ||
39 | |||
40 | prepareForDraw: { | ||
41 | value: function() { | ||
26 | this.addEventListener("firstDraw", this, false); | 42 | this.addEventListener("firstDraw", this, false); |
27 | } | 43 | } |
28 | }, | 44 | }, |
29 | 45 | ||
30 | draw: { | 46 | draw: { |
31 | value: function() { | 47 | value: function() { |
48 | if(this.hasIcon) { | ||
49 | var icon = this.iconType || this.mode + "Icon"; | ||
50 | this.application.ninja.colorController.addButton(icon, this.icon); | ||
51 | } | ||
32 | 52 | ||
33 | if(this.hasIcon) this.application.ninja.colorController.addButton(this.mode + 'Icon', this.icon); | 53 | this.chipBtn.props = {side: 'right', align: 'top', wheel: true, palette: true, gradient: true, image: true, offset: this.offset}; |
34 | |||
35 | // this.application.ninja.colorController.addButton(this.mode, this.chipBtn); | ||
36 | this.chipBtn.props = {side: 'right', align: 'top', wheel: true, palette: true, gradient: true, image: true, offset: 20}; | ||
37 | this.application.ninja.colorController.addButton(this.mode, this.chipBtn); | 54 | this.application.ninja.colorController.addButton(this.mode, this.chipBtn); |
55 | |||
56 | } | ||
57 | }, | ||
58 | |||
59 | handleFirstDraw: { | ||
60 | value: function(evt) { | ||
61 | if(this.chip) { | ||
62 | // This is a single chip - Not related to the color panel -- Set the initial color if found | ||
63 | var mode = "rgb", r = 0, g = 0, b = 0, a = 1, css = "rgb(255,0,0)"; | ||
64 | |||
65 | if(this.initialColor) { | ||
66 | var colorObj = this.application.ninja.colorController.getColorObjFromCss(this.initialColor); | ||
67 | mode = colorObj.mode; | ||
68 | r = colorObj.value.r; | ||
69 | g = colorObj.value.g; | ||
70 | b = colorObj.value.b; | ||
71 | a = colorObj.value.a; | ||
72 | css = colorObj.css; | ||
73 | } | ||
74 | |||
75 | this.chipBtn.color(mode, {wasSetByCode: true, type: 'change', color: {r: r, g: g, b: b}, css: css}); | ||
76 | this.chipBtn.addEventListener("change", this, false); | ||
77 | } | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | handleChange: { | ||
82 | value: function(evt) { | ||
83 | if(this.changeDelegate && typeof(this.changeDelegate === "function")) { | ||
84 | this.changeDelegate(evt); | ||
85 | } | ||
38 | } | 86 | } |
39 | } | 87 | } |
40 | 88 | ||