diff options
author | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-19 00:45:26 -0700 |
commit | c59eb371559a3061ce53223e249ca97daace5968 (patch) | |
tree | f9540e26c0f273d35f92010605da65dd85bbe70c /node_modules/montage/ui/toggle-button.reel | |
parent | 0f040acabfb7a4bf3138debec5aff869487ceb11 (diff) | |
parent | 918a4f5870e972b6e4e301c3237e065a1ffd26f5 (diff) | |
download | ninja-c59eb371559a3061ce53223e249ca97daace5968.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal
Diffstat (limited to 'node_modules/montage/ui/toggle-button.reel')
-rw-r--r-- | node_modules/montage/ui/toggle-button.reel/toggle-button.js | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/node_modules/montage/ui/toggle-button.reel/toggle-button.js b/node_modules/montage/ui/toggle-button.reel/toggle-button.js index f668d227..e12e9ba0 100644 --- a/node_modules/montage/ui/toggle-button.reel/toggle-button.js +++ b/node_modules/montage/ui/toggle-button.reel/toggle-button.js | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | var Montage = require("montage").Montage, | 13 | var Montage = require("montage").Montage, |
14 | Component = require("ui/component").Component, | 14 | Component = require("ui/component").Component, |
15 | Button = require("ui/button.reel/button").Button; | 15 | Button = require("ui/button.reel").Button; |
16 | /** | 16 | /** |
17 | The ToggleButton component extends the Button component to include state management (pressed or not pressed), and the ability to specify labels and CSS classes for each state. | 17 | The ToggleButton component extends the Button component to include state management (pressed or not pressed), and the ability to specify labels and CSS classes for each state. |
18 | @class module:"montage/ui/toggle-button.reel".ToggleButton | 18 | @class module:"montage/ui/toggle-button.reel".ToggleButton |
@@ -20,7 +20,6 @@ var Montage = require("montage").Montage, | |||
20 | */ | 20 | */ |
21 | var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends module:"montage/ui/toggle-button.reel".ToggleButton# */ { | 21 | var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends module:"montage/ui/toggle-button.reel".ToggleButton# */ { |
22 | _pressed: { | 22 | _pressed: { |
23 | enumerable: false, | ||
24 | value: false | 23 | value: false |
25 | }, | 24 | }, |
26 | /** | 25 | /** |
@@ -36,13 +35,12 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends modu | |||
36 | this._pressed = !!value; | 35 | this._pressed = !!value; |
37 | this._label = (this._pressed) ? this._pressedLabel : this._unpressedLabel; | 36 | this._label = (this._pressed) ? this._pressedLabel : this._unpressedLabel; |
38 | this.needsDraw = true; | 37 | this.needsDraw = true; |
39 | } | 38 | }, |
39 | serializable: true | ||
40 | }, | 40 | }, |
41 | 41 | ||
42 | _unpressedLabel: { | 42 | _unpressedLabel: { |
43 | enumerable: false, | 43 | value: null |
44 | value: null, | ||
45 | serializable: true | ||
46 | }, | 44 | }, |
47 | /** | 45 | /** |
48 | The label to display when the ToggleButton is in its unpressed state. By default, it is set to the value of the <code>value</code> attribute assigned to the input element. | 46 | The label to display when the ToggleButton is in its unpressed state. By default, it is set to the value of the <code>value</code> attribute assigned to the input element. |
@@ -59,13 +57,12 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends modu | |||
59 | this.label = this._unpressedLabel; | 57 | this.label = this._unpressedLabel; |
60 | this.needsDraw = true; | 58 | this.needsDraw = true; |
61 | } | 59 | } |
62 | } | 60 | }, |
61 | serializable: true | ||
63 | }, | 62 | }, |
64 | 63 | ||
65 | _pressedLabel: { | 64 | _pressedLabel: { |
66 | enumerable: false, | 65 | value: null |
67 | value: null, | ||
68 | serializable: true | ||
69 | }, | 66 | }, |
70 | /** | 67 | /** |
71 | The value the button should take when it is in the pressed state. By default, it is set to the value of the <code>value</code> attribute assigned to the input element. | 68 | The value the button should take when it is in the pressed state. By default, it is set to the value of the <code>value</code> attribute assigned to the input element. |
@@ -82,13 +79,12 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends modu | |||
82 | this.label = this._pressedLabel; | 79 | this.label = this._pressedLabel; |
83 | this.needsDraw = true; | 80 | this.needsDraw = true; |
84 | } | 81 | } |
85 | } | 82 | }, |
83 | serializable: true | ||
86 | }, | 84 | }, |
87 | 85 | ||
88 | _pressedClass: { | 86 | _pressedClass: { |
89 | enumerable: false, | ||
90 | value: "pressed", | 87 | value: "pressed", |
91 | serializable: true | ||
92 | }, | 88 | }, |
93 | /** | 89 | /** |
94 | The CSS class that should be added to the element's class list when the button is in | 90 | The CSS class that should be added to the element's class list when the button is in |
@@ -105,7 +101,8 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends modu | |||
105 | if (this._pressed) { | 101 | if (this._pressed) { |
106 | this.needsDraw = true; | 102 | this.needsDraw = true; |
107 | } | 103 | } |
108 | } | 104 | }, |
105 | serializable: true | ||
109 | }, | 106 | }, |
110 | 107 | ||
111 | /** | 108 | /** |
@@ -117,18 +114,19 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends modu | |||
117 | @default null | 114 | @default null |
118 | */ | 115 | */ |
119 | label: { | 116 | label: { |
120 | get: function() { | 117 | get: function() { |
121 | return Object.getOwnPropertyDescriptor(Object.getPrototypeOf(ToggleButton),"label").get.call(this); | 118 | return Object.getOwnPropertyDescriptor(Object.getPrototypeOf(ToggleButton),"label").get.call(this); |
122 | }, | 119 | }, |
123 | set: function(value) { | 120 | set: function(value) { |
124 | // Call super | 121 | // Call super |
125 | Object.getOwnPropertyDescriptor(Object.getPrototypeOf(ToggleButton),"label").set.call(this, value); | 122 | Object.getOwnPropertyDescriptor(Object.getPrototypeOf(ToggleButton),"label").set.call(this, value); |
126 | if (this._pressed === true && this._label === this._unpressedLabel) { | 123 | if (this._pressed === true && this._label === this._unpressedLabel) { |
127 | this.pressed = false; | 124 | this.pressed = false; |
128 | } else if (this._pressed === false && this._label === this._pressedLabel) { | 125 | } else if (this._pressed === false && this._label === this._pressedLabel) { |
129 | this.pressed = true; | 126 | this.pressed = true; |
130 | } | 127 | } |
131 | } | 128 | }, |
129 | serializable: true | ||
132 | }, | 130 | }, |
133 | 131 | ||
134 | didSetElement: { | 132 | didSetElement: { |