diff options
author | Nivesh Rajbhandari | 2012-05-07 11:18:11 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-05-07 11:18:11 -0700 |
commit | e377a8dc0b0e34905782ed867acb5fe725ae0131 (patch) | |
tree | 6931311aabd7a4e366df195a168d437f1d0d8465 /node_modules/montage/ui/toggle-button.reel/toggle-button.js | |
parent | 8be6e94b57f4bd6e28754a6113b4d6a401365e13 (diff) | |
parent | 526e423e4a2734c2b139af23911e912452a4443f (diff) | |
download | ninja-e377a8dc0b0e34905782ed867acb5fe725ae0131.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'node_modules/montage/ui/toggle-button.reel/toggle-button.js')
-rw-r--r-- | node_modules/montage/ui/toggle-button.reel/toggle-button.js | 74 |
1 files changed, 39 insertions, 35 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 eb304007..f668d227 100644 --- a/node_modules/montage/ui/toggle-button.reel/toggle-button.js +++ b/node_modules/montage/ui/toggle-button.reel/toggle-button.js | |||
@@ -3,22 +3,31 @@ | |||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. |
5 | </copyright> */ | 5 | </copyright> */ |
6 | |||
7 | /** | ||
8 | @module "montage/ui/toggle-button.reel" | ||
9 | @requires montage/ui/component | ||
10 | @requires "montage/ui/button.reel" | ||
11 | */ | ||
12 | |||
6 | var Montage = require("montage").Montage, | 13 | var Montage = require("montage").Montage, |
7 | Component = require("ui/component").Component, | 14 | Component = require("ui/component").Component, |
8 | Button = require("ui/button.reel/button").Button; | 15 | Button = require("ui/button.reel/button").Button; |
9 | /** | 16 | /** |
10 | * The Text input | 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 | ||
19 | @extends module:"montage/button.reel".Button | ||
11 | */ | 20 | */ |
12 | var ToggleButton = exports.ToggleButton = Montage.create(Button, { | 21 | var ToggleButton = exports.ToggleButton = Montage.create(Button, /** @lends module:"montage/ui/toggle-button.reel".ToggleButton# */ { |
13 | _pressed: { | 22 | _pressed: { |
14 | enumerable: false, | 23 | enumerable: false, |
15 | value: false | 24 | value: false |
16 | }, | 25 | }, |
17 | /** | 26 | /** |
18 | Whether the toggle button is down/pressed or not. | 27 | Gets and sets the ToggleButton's current state, updates the button's label to its <code>pressedLabel</code> or <code>unpressedLabel</code>, and requests a draw. |
19 | @type {Property} | 28 | @type {Boolean} |
20 | @default {Boolean} false | 29 | @default false |
21 | */ | 30 | */ |
22 | pressed: { | 31 | pressed: { |
23 | get: function() { | 32 | get: function() { |
24 | return this._pressed; | 33 | return this._pressed; |
@@ -35,13 +44,11 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, { | |||
35 | value: null, | 44 | value: null, |
36 | serializable: true | 45 | serializable: true |
37 | }, | 46 | }, |
38 | /** | 47 | /** |
39 | The value the button should take when it is in the unpressed state. If | 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. |
40 | this is not set at initialization it will be set to the `value` of the | 49 | @type {String} |
41 | button. | 50 | @default null |
42 | @type {Property} | 51 | */ |
43 | @default {String} null | ||
44 | */ | ||
45 | unpressedLabel: { | 52 | unpressedLabel: { |
46 | get: function() { | 53 | get: function() { |
47 | return this._unpressedLabel; | 54 | return this._unpressedLabel; |
@@ -60,13 +67,11 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, { | |||
60 | value: null, | 67 | value: null, |
61 | serializable: true | 68 | serializable: true |
62 | }, | 69 | }, |
63 | /** | 70 | /** |
64 | The value the button should take when it is in the pressed state. If | 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. |
65 | this is not set at initialization it will be set to the `value` of the | 72 | @type {Property} |
66 | button. | 73 | @default {String} null |
67 | @type {Property} | 74 | */ |
68 | @default {String} null | ||
69 | */ | ||
70 | pressedLabel: { | 75 | pressedLabel: { |
71 | get: function() { | 76 | get: function() { |
72 | return this._pressedLabel; | 77 | return this._pressedLabel; |
@@ -85,12 +90,12 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, { | |||
85 | value: "pressed", | 90 | value: "pressed", |
86 | serializable: true | 91 | serializable: true |
87 | }, | 92 | }, |
88 | /** | 93 | /** |
89 | The class that should be added to the element when the button is in | 94 | The CSS class that should be added to the element's class list when the button is in |
90 | the pressed state. It is removed when the button is unpressed. | 95 | the pressed state. It is removed when the button is unpressed. |
91 | @type {Property} | 96 | @type {string} |
92 | @default {String} "pressed" | 97 | @default "pressed" |
93 | */ | 98 | */ |
94 | pressedClass: { | 99 | pressedClass: { |
95 | get: function() { | 100 | get: function() { |
96 | return this._pressedClass; | 101 | return this._pressedClass; |
@@ -104,13 +109,12 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, { | |||
104 | }, | 109 | }, |
105 | 110 | ||
106 | /** | 111 | /** |
107 | The current value of the button. It will be set to unpressedLabel or | 112 | The current value of the button. It is set to the value of <code>unpressedLabel</code> or |
108 | pressedLabel depending on state. | 113 | <code>pressedLabel</code> depending on the ToggleButton's state. |
109 | 114 | ||
110 | Setting this property equal to unpressedLabel or pressedLabel will | 115 | Setting this property equal to <code>unpressedLabel</code> or <code>pressedLabel</code> will change the <code>pressed</code> state of the button to `false` or `true`, respectively. |
111 | change the pressed state of the button to `false` and `true` respectively. | 116 | @type {string} |
112 | @type {Property} | 117 | @default null |
113 | @default {String} null, or the value of the element | ||
114 | */ | 118 | */ |
115 | label: { | 119 | label: { |
116 | get: function() { | 120 | get: function() { |
@@ -163,8 +167,8 @@ var ToggleButton = exports.ToggleButton = Montage.create(Button, { | |||
163 | }, | 167 | }, |
164 | 168 | ||
165 | /** | 169 | /** |
166 | Change the button to the inverse of its current state. | 170 | Toggles the state of the button. |
167 | @type {Function} | 171 | @function |
168 | */ | 172 | */ |
169 | toggle: { | 173 | toggle: { |
170 | value: function() { | 174 | value: function() { |