diff options
author | Valerio Virgillito | 2012-02-02 00:11:51 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-02 00:11:51 -0800 |
commit | 5a305ec44b2bd5198a248357439aae8ebbd75fee (patch) | |
tree | ec3b756beab7105841353ef79d4e8059b2b6a91c /node_modules/montage/ui/checkbox.reel/checkbox.js | |
parent | dbe9c7705860fb3551321e23e7eab763f622241c (diff) | |
download | ninja-5a305ec44b2bd5198a248357439aae8ebbd75fee.tar.gz |
upgrading to Montage v0.6
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/checkbox.reel/checkbox.js')
-rw-r--r--[-rwxr-xr-x] | node_modules/montage/ui/checkbox.reel/checkbox.js | 464 |
1 files changed, 19 insertions, 445 deletions
diff --git a/node_modules/montage/ui/checkbox.reel/checkbox.js b/node_modules/montage/ui/checkbox.reel/checkbox.js index 2e375348..df2995c3 100755..100644 --- a/node_modules/montage/ui/checkbox.reel/checkbox.js +++ b/node_modules/montage/ui/checkbox.reel/checkbox.js | |||
@@ -3,450 +3,24 @@ | |||
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 | @module "montage/ui/checkbox.reel" | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/component | ||
10 | */ | ||
11 | var Montage = require("montage").Montage, | 6 | var Montage = require("montage").Montage, |
12 | Component = require("ui/component").Component; | 7 | Component = require("ui/component").Component, |
13 | /** | 8 | CheckInput = require("ui/check-input").CheckInput; |
14 | @class module:"montage/ui/checkbox.reel".Checkbox | 9 | |
15 | @extends module:montage/ui/component.Component | 10 | var Checkbox = exports.Checkbox = Montage.create(CheckInput, {}); |
16 | */ | 11 | Checkbox.addAttributes({ |
17 | exports.Checkbox = Montage.create(Component,/** @lends "module:montage/ui/checkbox.reel".Checkbox# */ { | 12 | autofocus: 'off', // on/off |
18 | // Configuration | 13 | disabled: {value: false, dataType: 'boolean'}, |
19 | /** | 14 | checked: {value: false, dataType: 'boolean'}, |
20 | The distance (squared) beyond which a touch will be considered. | 15 | form: null, |
21 | @type {Number} | 16 | name: null, |
22 | @default 256 | 17 | readonly: {value: false, dataType: 'boolean'}, |
23 | */ | 18 | title: null, |
24 | touchMovementThreshold: { | 19 | /* |
25 | enumerable: false, | 20 | "On getting, if the element has a value attribute, it must return that |
26 | value: 256 | 21 | attribute's value; otherwise, it must return the string "on". On setting, |
27 | }, | 22 | it must set the element's value attribute to the new value." |
28 | // Elements | 23 | http://www.w3.org/TR/html5/common-input-element-attributes.html#dom-input-value-default-on |
29 | /** | 24 | */ |
30 | Description TODO | 25 | value: {value: 'on'} |
31 | @private | ||
32 | */ | ||
33 | _nativeCheckbox: { | ||
34 | enumerable: false, | ||
35 | value: null | ||
36 | }, | ||
37 | /** | ||
38 | Description TODO | ||
39 | @private | ||
40 | */ | ||
41 | _background: { | ||
42 | enumerable: false, | ||
43 | value: null | ||
44 | }, | ||
45 | /** | ||
46 | Description TODO | ||
47 | @private | ||
48 | */ | ||
49 | _button: { | ||
50 | enumerable: false, | ||
51 | value: null | ||
52 | }, | ||
53 | /** | ||
54 | Description TODO | ||
55 | @private | ||
56 | */ | ||
57 | _checkmark: { | ||
58 | enumerable: false, | ||
59 | value: null | ||
60 | }, | ||
61 | // Event Handling APIs | ||
62 | /** | ||
63 | Description TODO | ||
64 | @function | ||
65 | @param {Event Handler} event handleMousedown | ||
66 | */ | ||
67 | handleMousedown: { | ||
68 | enumerable: false, | ||
69 | value: function (event) { | ||
70 | event.preventDefault(); | ||
71 | |||
72 | if (!this._disabled) { | ||
73 | this._acknowledgeIntent("mouse"); | ||
74 | } | ||
75 | } | ||
76 | }, | ||
77 | /** | ||
78 | Description TODO | ||
79 | @function | ||
80 | @param {Event Handler} event handleMouseup | ||
81 | */ | ||
82 | handleMouseup: { | ||
83 | value: function(event) { | ||
84 | this._interpretInteraction(event); | ||
85 | } | ||
86 | }, | ||
87 | /** | ||
88 | Description TODO | ||
89 | @private | ||
90 | */ | ||
91 | _touchX: { | ||
92 | enumerable: false, | ||
93 | value: null | ||
94 | }, | ||
95 | /** | ||
96 | Description TODO | ||
97 | @private | ||
98 | */ | ||
99 | _touchY: { | ||
100 | enumerable: false, | ||
101 | value: null | ||
102 | }, | ||
103 | /** | ||
104 | Description TODO | ||
105 | @function | ||
106 | @param {Event Handler} event handleTouchstart | ||
107 | */ | ||
108 | handleTouchstart: { | ||
109 | enumerable: false, | ||
110 | value: function (event) { | ||
111 | |||
112 | if (this._disabled || this._observedPointer !== null) { | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | event.preventDefault(); | ||
117 | |||
118 | this._acknowledgeIntent(event.targetTouches[0].identifier); | ||
119 | this._touchX = event.targetTouches[0].clientX; | ||
120 | this._touchY = event.targetTouches[0].clientY; | ||
121 | } | ||
122 | }, | ||
123 | /** | ||
124 | Description TODO | ||
125 | @function | ||
126 | @param {Event Handler} event handleTouchmove | ||
127 | */ | ||
128 | handleTouchmove: { | ||
129 | enumerable: false, | ||
130 | value: function (event) { | ||
131 | var i = 0, length = event.touches.length, xDistance, yDistance; | ||
132 | |||
133 | while ((i < length) && (event.touches[i].identifier !== this._observedPointer)) { | ||
134 | i++; | ||
135 | } | ||
136 | |||
137 | if (i < length) { | ||
138 | xDistance = this._touchX - event.touches[i].clientX; | ||
139 | yDistance = this._touchY - event.touches[i].clientY; | ||
140 | |||
141 | var squaredDist = (xDistance * xDistance) + (yDistance * yDistance); | ||
142 | |||
143 | if (squaredDist > this.touchMovementThreshold) { | ||
144 | event.preventDefault(); | ||
145 | |||
146 | this._releaseInterest(); | ||
147 | |||
148 | this.active = false; | ||
149 | this.needsDraw = true; | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | }, | ||
154 | /** | ||
155 | Description TODO | ||
156 | @function | ||
157 | @param {Event Handler} event handleTouchend | ||
158 | */ | ||
159 | handleTouchend: { | ||
160 | enumerable: false, | ||
161 | value: function (event) { | ||
162 | var i = 0, | ||
163 | changedTouchCount = event.changedTouches.length; | ||
164 | |||
165 | for (; i < changedTouchCount; i++) { | ||
166 | if (event.changedTouches[i].identifier === this._observedPointer) { | ||
167 | this._interpretInteraction(event); | ||
168 | return; | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | }, | ||
173 | /** | ||
174 | Description TODO | ||
175 | @function | ||
176 | @param {Event Handler} event handleTouchcancel | ||
177 | */ | ||
178 | handleTouchcancel: { | ||
179 | value: function(event) { | ||
180 | |||
181 | var i = 0, | ||
182 | changedTouchCount = event.changedTouches.length; | ||
183 | |||
184 | for (; i < changedTouchCount; i++) { | ||
185 | if (event.changedTouches[i].identifier === this._observedPointer) { | ||
186 | this._releaseInterest(); | ||
187 | |||
188 | this.active = false; | ||
189 | this.needsDraw = true; | ||
190 | |||
191 | return; | ||
192 | } | ||
193 | } | ||
194 | |||
195 | } | ||
196 | }, | ||
197 | |||
198 | // Internal state management | ||
199 | /** | ||
200 | Description TODO | ||
201 | @private | ||
202 | */ | ||
203 | _active: { | ||
204 | enumerable: false, | ||
205 | value: false |