]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/event/event-touch.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / event / event-touch.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('event-touch', function(Y) {
9
10 /**
11  * Adds touch event facade normalization properties (touches, changedTouches, targetTouches etc.) to the DOM event facade
12  *
13  * @module event-touch
14  */
15
16 var SCALE = "scale",
17     ROTATION = "rotation",
18     IDENTIFIER = "identifier";
19
20 /**
21  * Adds touch event facade normalization properties to the DOM event facade
22  *
23  * @method _touch
24  * @for DOMEventFacade
25  * @private
26  * @param ev {Event} the DOM event
27  * @param currentTarget {HTMLElement} the element the listener was attached to
28  * @param wrapper {Event.Custom} the custom event wrapper for this DOM event
29  */
30 Y.DOMEventFacade.prototype._touch = function(e, currentTarget, wrapper) {
31
32     var i,l, etCached, et,touchCache;
33
34
35     if (e.touches) {
36
37         this.touches = [];
38         touchCache = {};
39
40         for (i = 0, l = e.touches.length; i < l; ++i) {
41             et = e.touches[i];
42             touchCache[Y.stamp(et)] = this.touches[i] = new Y.DOMEventFacade(et, currentTarget, wrapper);
43         }
44     }
45
46     if (e.targetTouches) {
47
48         this.targetTouches = [];
49
50         for (i = 0, l = e.targetTouches.length; i < l; ++i) {
51             et = e.targetTouches[i];
52             etCached = touchCache && touchCache[Y.stamp(et, true)];
53
54             this.targetTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper);
55             
56         }
57     }
58
59     if (e.changedTouches) {
60
61         this.changedTouches = [];
62
63         for (i = 0, l = e.changedTouches.length; i < l; ++i) {
64             et = e.changedTouches[i];
65             etCached = touchCache && touchCache[Y.stamp(et, true)];
66
67             this.changedTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper);
68             
69         }
70     }
71
72     if (SCALE in e) {
73         this[SCALE] = e[SCALE];
74     }
75
76     if (ROTATION in e) {
77         this[ROTATION] = e[ROTATION];
78     }
79
80     if (IDENTIFIER in e) {
81         this[IDENTIFIER] = e[IDENTIFIER];
82     }
83 };
84
85 if (Y.Node.DOM_EVENTS) {
86     Y.mix(Y.Node.DOM_EVENTS, {
87         touchstart:1,
88         touchmove:1,
89         touchend:1,
90         touchcancel:1,
91         gesturestart:1,
92         gesturechange:1,
93         gestureend:1
94     });
95 }
96
97
98 }, '3.3.0' ,{requires:['node-base']});