diff options
Diffstat (limited to 'node_modules/montage/ui/bluemoon/toggle.reel/toggle.js')
-rw-r--r-- | node_modules/montage/ui/bluemoon/toggle.reel/toggle.js | 423 |
1 files changed, 423 insertions, 0 deletions
diff --git a/node_modules/montage/ui/bluemoon/toggle.reel/toggle.js b/node_modules/montage/ui/bluemoon/toggle.reel/toggle.js new file mode 100644 index 00000000..d659931d --- /dev/null +++ b/node_modules/montage/ui/bluemoon/toggle.reel/toggle.js | |||
@@ -0,0 +1,423 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<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. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module "montage/ui/bluemoon/toggle.reel" | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/component | ||
10 | */ | ||
11 | var Montage = require("montage").Montage, | ||
12 | Component = require("ui/component").Component; | ||
13 | /** | ||
14 | @class module:"montage/ui/bluemoon/toggle.reel".Toggle | ||
15 | @extends module:montage/ui/component.Component | ||
16 | */ | ||
17 | var Toggle = exports.Toggle = Montage.create(Component, /** @lends module:"montage/ui/bluemoon/toggle.reel".Toggle# */ { | ||
18 | |||
19 | _value: { | ||
20 | enumerable: false, | ||
21 | value: false | ||
22 | }, | ||
23 | /** | ||
24 | Description TODO | ||
25 | @type {Function} | ||
26 | @default {Boolean} false | ||
27 | */ | ||
28 | value: { | ||
29 | enumerable: true, | ||
30 | get: function() { | ||
31 | return this._value; | ||
32 | }, | ||
33 | set: function(value) { | ||
34 | if (!this._pressed) { | ||
35 | value = !!value; | ||
36 | if (this._value !== value) { | ||
37 | this._value = value; | ||
38 | window.clearInterval(this._animation); | ||
39 | this._animation = null; | ||
40 | this._speed = 0; | ||
41 | this.needsDraw = true; | ||
42 | } | ||
43 | } | ||
44 | } | ||
45 | }, | ||
46 | /** | ||
47 | Description TODO | ||
48 | @private | ||
49 | */ | ||
50 | _toggle: { | ||
51 | enumerable: false, | ||
52 | value: null | ||
53 | }, | ||
54 | /** | ||
55 | Description TODO | ||
56 | @private | ||
57 | */ | ||
58 | _scroll: { | ||
59 | enumerable: false, | ||
60 | value: null | ||
61 | }, | ||
62 | /** | ||
63 | Description TODO | ||
64 | @private | ||
65 | */ | ||
66 | _circle: { | ||
67 | enumerable: false, | ||
68 | value: null | ||
69 | }, | ||
70 | /** | ||
71 | Description TODO | ||
72 | @private | ||
73 | */ | ||
74 | _handlerBg: { | ||
75 | enumerable: false, | ||
76 | value: null | ||
77 | }, | ||
78 | /** | ||
79 | Description TODO | ||
80 | @private | ||
81 | */ | ||
82 | _handler: { | ||
83 | enumerable: false, | ||
84 | value: null | ||
85 | }, | ||
86 | /** | ||
87 | Description TODO | ||
88 | @private | ||
89 | */ | ||
90 | _handlerOnBg: { | ||
91 | enumerable: false, | ||
92 | value: null | ||
93 | }, | ||
94 | /** | ||
95 | Description TODO | ||
96 | @private | ||
97 | */ | ||
98 | _handlerOn: { | ||
99 | enumerable: false, | ||
100 | value: null | ||
101 | }, | ||
102 | /** | ||
103 | Description TODO | ||
104 | @private | ||
105 | */ | ||
106 | _handlerDragArea: { | ||
107 | enumerable: false, | ||
108 | value: null | ||
109 | }, | ||
110 | /** | ||
111 | Description TODO | ||
112 | @private | ||
113 | */ | ||
114 | _pressed: { | ||
115 | enumerable: false, | ||
116 | value: false | ||
117 | }, | ||
118 | /** | ||
119 | Description TODO | ||
120 | @private | ||
121 | */ | ||
122 | _cursorPosition: { | ||
123 | enumerable: false, | ||
124 | value: null | ||
125 | }, | ||
126 | /** | ||
127 | Description TODO | ||
128 | @private | ||
129 | */ | ||
130 | _width: { | ||
131 | enumerable: false, | ||
132 | value: 60 - 22 | ||
133 | }, | ||
134 | /** | ||
135 | Description TODO | ||
136 | @private | ||
137 | */ | ||
138 | _scrollTo: { | ||
139 | enumerable: false, | ||
140 | value: null | ||
141 | }, | ||
142 | /** | ||
143 | Description TODO | ||
144 | @private | ||
145 | */ | ||
146 | _touchIdentifier: { | ||
147 | enumerable: false, | ||
148 | value: null | ||
149 | }, | ||
150 | /** | ||
151 | Description TODO | ||
152 | @private | ||
153 | */ | ||
154 | _speed: { | ||
155 | enumerable: false, | ||
156 | value: 0 | ||
157 | }, | ||
158 | /** | ||
159 | Description TODO | ||
160 | @function | ||
161 | @param {Event} event TODO | ||
162 | */ | ||
163 | handleTouchstart: { | ||
164 | enumerable: false, | ||
165 | value: function (event) { | ||
166 | if (event.target === this._toggle) { | ||
167 | this.value = !this.value; | ||
168 | } else { | ||
169 | this._touchIdentifier = event.targetTouches[0].identifier; | ||
170 | document.addEventListener("touchmove", this, false); | ||
171 | document.addEventListener("touchend", this, false); | ||
172 | this._cursorPosition = event.targetTouches[0].clientX; | ||
173 | |||
174 | if (this._scrollTo < 0) { | ||
175 | this._scrollTo = 0; | ||
176 | } else if (this._scrollTo > this._width) { | ||
177 | this._scrollTo = this._width; | ||
178 | } | ||
179 | window.clearInterval(this._animation); | ||
180 | this._animation = null; | ||
181 | this._pressed = true; | ||
182 | this.needsDraw = true; | ||
183 | } | ||
184 | event.preventDefault(); | ||
185 | event.stopPropagation(); | ||
186 | } | ||
187 | }, | ||
188 | /** | ||
189 | Description TODO | ||
190 | @function | ||
191 | @param {Event} event TODO | ||
192 | */ | ||
193 | handleMousedown: { | ||
194 | enumerable: false, | ||
195 | value: function (event) { | ||
196 | if (event.target === this._toggle) { | ||
197 | this.value = !this.value; | ||
198 | } else { | ||
199 | document.addEventListener("mousemove", this, false); | ||
200 | document.addEventListener("mouseup", this, false); | ||
201 | this._cursorPosition = event.clientX; | ||
202 | |||
203 | if (this._scrollTo < 0) { | ||
204 | this._scrollTo = 0; | ||
205 | } else if (this._scrollTo > this._width) { | ||
206 | this._scrollTo = this._width; | ||
207 | } | ||
208 | window.clearInterval(this._animation); | ||
209 | this._animation = null; | ||
210 | this._pressed = true; | ||
211 | this.needsDraw = true; | ||
212 | } | ||
213 | event.preventDefault(); | ||
214 | event.stopPropagation(); | ||
215 | } | ||
216 | }, | ||
217 | /** | ||
218 | Description TODO | ||
219 | @function | ||
220 | @param {Event} event TODO | ||
221 | */ | ||
222 | handleTouchmove: { | ||
223 | enumerable: false, | ||
224 | value: function (event) { | ||
225 | if (this._pressed) { | ||