root / trunk / web / dojo / dojox / mobile / app / _event.js
History | View | Annotate | Download (2.05 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.mobile.app._event"]){ |
9 |
dojo._hasResource["dojox.mobile.app._event"]=true; |
10 |
dojo.provide("dojox.mobile.app._event");
|
11 |
dojo.experimental("dojox.mobile.app._event.js");
|
12 |
dojo.mixin(dojox.mobile.app,{eventMap:{},connectFlick:function(_1,_2,_3){ |
13 |
var _4;
|
14 |
var _5;
|
15 |
var _6=false; |
16 |
var _7;
|
17 |
var _8;
|
18 |
var _9;
|
19 |
var _a;
|
20 |
var _b;
|
21 |
var _c;
|
22 |
var _d=dojo.connect("onmousedown",_1,function(_e){ |
23 |
_6=false;
|
24 |
_4=_e.targetTouches?_e.targetTouches[0].clientX:_e.clientX;
|
25 |
_5=_e.targetTouches?_e.targetTouches[0].clientY:_e.clientY;
|
26 |
_c=(new Date()).getTime();
|
27 |
_9=dojo.connect(_1,"onmousemove",_f);
|
28 |
_a=dojo.connect(_1,"onmouseup",_10);
|
29 |
}); |
30 |
var _f=function(_11){ |
31 |
dojo.stopEvent(_11); |
32 |
_7=_11.targetTouches?_11.targetTouches[0].clientX:_11.clientX;
|
33 |
_8=_11.targetTouches?_11.targetTouches[0].clientY:_11.clientY;
|
34 |
if(Math.abs(Math.abs(_7)-Math.abs(_4))>15){ |
35 |
_6=true;
|
36 |
_b=(_7>_4)?"ltr":"rtl"; |
37 |
}else{
|
38 |
if(Math.abs(Math.abs(_8)-Math.abs(_5))>15){ |
39 |
_6=true;
|
40 |
_b=(_8>_5)?"ttb":"btt"; |
41 |
} |
42 |
} |
43 |
}; |
44 |
var _10=function(_12){ |
45 |
dojo.stopEvent(_12); |
46 |
_9&&dojo.disconnect(_9); |
47 |
_a&&dojo.disconnect(_a); |
48 |
if(_6){
|
49 |
var _13={target:_1,direction:_b,duration:(new Date()).getTime()-_c}; |
50 |
if(_2&&_3){
|
51 |
_2[_3](_13); |
52 |
}else{
|
53 |
_3(_13); |
54 |
} |
55 |
} |
56 |
}; |
57 |
}}); |
58 |
dojox.mobile.app.isIPhone=(dojo.isSafari&&(navigator.userAgent.indexOf("iPhone")>-1||navigator.userAgent.indexOf("iPod")>-1)); |
59 |
dojox.mobile.app.isWebOS=(navigator.userAgent.indexOf("webOS")>-1); |
60 |
if(dojox.mobile.app.isIPhone){
|
61 |
dojox.mobile.app.eventMap={onmousedown:"ontouchstart",mousedown:"ontouchstart",onmouseup:"ontouchend",mouseup:"ontouchend",onmousemove:"ontouchmove",mousemove:"ontouchmove"}; |
62 |
} |
63 |
dojo._oldConnect=dojo._connect; |
64 |
dojo._connect=function(obj,_14,_15,_16,_17){ |
65 |
_14=dojox.mobile.app.eventMap[_14]||_14; |
66 |
if(_14=="flick"||_14=="onflick"){ |
67 |
if(window["Mojo"]){ |
68 |
_14=Mojo.Event.flick; |
69 |
}else{
|
70 |
return dojox.mobile.app.connectFlick(obj,_15,_16);
|
71 |
} |
72 |
} |
73 |
return dojo._oldConnect(obj,_14,_15,_16,_17);
|
74 |
}; |
75 |
} |