diff options
author | Armen Kesablyan | 2012-06-20 15:16:30 -0700 |
---|---|---|
committer | Armen Kesablyan | 2012-06-20 15:16:30 -0700 |
commit | 65b989c7759af923fb9456d34bff89f91831ea1e (patch) | |
tree | e408be732a3eee71229bfc7dbf7cace998ce18de /node_modules/montage/ui/composer/press-composer.js | |
parent | 38f571d1fdf02d36c3816637af7b2ca2493809da (diff) | |
parent | fc818d31de267d2b77fda3b3029ad38d48698be8 (diff) | |
download | ninja-65b989c7759af923fb9456d34bff89f91831ea1e.tar.gz |
Merge branch 'refs/heads/master' into binding
Conflicts:
node_modules/montage/ui/application.js
Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/composer/press-composer.js')
-rw-r--r-- | node_modules/montage/ui/composer/press-composer.js | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/node_modules/montage/ui/composer/press-composer.js b/node_modules/montage/ui/composer/press-composer.js index d71d2ec6..55903b5f 100644 --- a/node_modules/montage/ui/composer/press-composer.js +++ b/node_modules/montage/ui/composer/press-composer.js | |||
@@ -58,9 +58,9 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
58 | load: { | 58 | load: { |
59 | value: function() { | 59 | value: function() { |
60 | if (window.Touch) { | 60 | if (window.Touch) { |
61 | this._element.addEventListener("touchstart", this); | 61 | this._element.addEventListener("touchstart", this, true); |
62 | } else { | 62 | } else { |
63 | this._element.addEventListener("mousedown", this); | 63 | this._element.addEventListener("mousedown", this, true); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | }, | 66 | }, |
@@ -76,6 +76,19 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
76 | }, | 76 | }, |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Delegate that implements <code>surrenderPointer</code>. See Component for | ||
80 | explanation of what this method should do. | ||
81 | |||
82 | @type {Object} | ||
83 | @default null | ||
84 | */ | ||
85 | delegate: { | ||
86 | serializable: true, | ||
87 | value: null | ||
88 | }, | ||
89 | |||
90 | |||
91 | /** | ||
79 | Cancel the current press. | 92 | Cancel the current press. |
80 | 93 | ||
81 | Can be used in a "longPress" event handler to prevent the "press" event | 94 | Can be used in a "longPress" event handler to prevent the "press" event |
@@ -191,16 +204,16 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
191 | return false; | 204 | return false; |
192 | } | 205 | } |
193 | 206 | ||
194 | document.addEventListener("touchend", this); | 207 | document.addEventListener("touchend", this, false); |
195 | document.addEventListener("touchcancel", this); | 208 | document.addEventListener("touchcancel", this, false); |
196 | } else if (event.type === "mousedown") { | 209 | } else if (event.type === "mousedown") { |
197 | this._observedPointer = "mouse"; | 210 | this._observedPointer = "mouse"; |
198 | // Needed to cancel action event dispatch is mouseup'd when | 211 | // Needed to cancel action event dispatch is mouseup'd when |
199 | // not on the component | 212 | // not on the component |
200 | document.addEventListener("mouseup", this); | 213 | document.addEventListener("mouseup", this, false); |
201 | // Needed to preventDefault if another component has claimed | 214 | // Needed to preventDefault if another component has claimed |
202 | // the pointer | 215 | // the pointer |
203 | document.addEventListener("click", this); | 216 | document.addEventListener("click", this, false); |
204 | } | 217 | } |
205 | 218 | ||
206 | this.component.eventManager.claimPointer(this._observedPointer, this); | 219 | this.component.eventManager.claimPointer(this._observedPointer, this); |
@@ -239,18 +252,19 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
239 | // in surrenderPointer, just end the interaction. | 252 | // in surrenderPointer, just end the interaction. |
240 | this._endInteraction(event); | 253 | this._endInteraction(event); |
241 | return; | 254 | return; |
242 | } | 255 | } else if (event.type === "mouseup") { |
243 | |||
244 | if (!isSurrendered && isTarget && event.type === "mouseup") { | ||
245 | this._dispatchPress(event); | ||
246 | this._endInteraction(event); | ||
247 | return; | ||
248 | } | ||
249 | 256 | ||
250 | if (!isSurrendered && !isTarget && event.type === "mouseup") { | 257 | if (!isSurrendered && isTarget) { |
251 | this._dispatchPressCancel(event); | 258 | this._dispatchPress(event); |
252 | this._endInteraction(event); | 259 | this._endInteraction(event); |
253 | return; | 260 | return; |
261 | } else if (!isSurrendered && !isTarget) { | ||
262 | this._dispatchPressCancel(event); | ||
263 | this._endInteraction(event); | ||
264 | return; | ||
265 | } else if (isSurrendered && !isTarget) { | ||
266 | this._endInteraction(event); | ||
267 | } | ||
254 | } | 268 | } |
255 | } | 269 | } |
256 | }, | 270 | }, |
@@ -319,7 +333,7 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
319 | 333 | ||
320 | // Handlers | 334 | // Handlers |
321 | 335 | ||
322 | handleTouchstart: { | 336 | captureTouchstart: { |
323 | value: function(event) { | 337 | value: function(event) { |
324 | this._startInteraction(event); | 338 | this._startInteraction(event); |
325 | } | 339 | } |
@@ -352,7 +366,7 @@ var PressComposer = exports.PressComposer = Montage.create(Composer,/** @lends m | |||
352 | } | 366 | } |
353 | }, | 367 | }, |
354 | 368 | ||
355 | handleMousedown: { | 369 | captureMousedown: { |
356 | value: function(event) { | 370 | value: function(event) { |
357 | this._startInteraction(event); | 371 | this._startInteraction(event); |
358 | } | 372 | } |