| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 6 |
<meta name="apple-mobile-web-app-capable" content="yes" /> |
| 7 |
<title>DojoX Analytics Touch and Gesture Test</title> |
| 8 |
<style type="text/css"> |
| 9 |
@import "../../mobile/themes/iphone/base.css"; |
| 10 |
@import "../../mobile/themes/iphone/TabBar.css"; |
| 11 |
#outerHeading { |
| 12 |
height: 240px; |
| 13 |
} |
| 14 |
#outer { |
| 15 |
width: 100%; |
| 16 |
height: 240px; |
| 17 |
border: 1px solid #54A201; |
| 18 |
background-color: #54A201; |
| 19 |
} |
| 20 |
#inner { |
| 21 |
width: 250px; |
| 22 |
height: 110px; |
| 23 |
border: 1px solid #7FB0DB; |
| 24 |
background-color: #7FB0DB |
| 25 |
} |
| 26 |
#log1, #log2 { |
| 27 |
width: 100%; |
| 28 |
height: 50px; |
| 29 |
} |
| 30 |
</style> |
| 31 |
|
| 32 |
<script src="../../../dojo/dojo.js" |
| 33 |
data-dojo-config="parseOnLoad:true, async:true, isDebug: true, usePlainJson: true, |
| 34 |
sendMethod: 'script', sendInterval: 5000, mblAlwaysHideAddressBar: true, |
| 35 |
// the line below can be used to override the touchSampleDelay for touchMove |
| 36 |
// and to override the swipeSampleDelay for gestureEvents and targetProps. |
| 37 |
//touchSampleDelay : 500, swipeSampleDelay : 800, targetProps : ['id','className'], |
| 38 |
analyticsUrl: 'http://dojotoolkit.org/~dmachi/dojo-1.0/dojox/analytics/logger/dojoxAnalytics.php'"> |
| 39 |
</script> |
| 40 |
|
| 41 |
|
| 42 |
<script> |
| 43 |
require([ |
| 44 |
"dojo/ready", |
| 45 |
"dojo/parser", |
| 46 |
"dojox/mobile", // This is a mobile app. |
| 47 |
"dojox/mobile/ScrollableView", |
| 48 |
"dojox/mobile/compat", // This mobile app supports running on desktop browsers |
| 49 |
"dojox/analytics", |
| 50 |
// this plugin returns the information dojo collects when it launches |
| 51 |
"dojox/analytics/plugins/dojo", |
| 52 |
// this plugin return the information the window has when it launches |
| 53 |
// and it also ties to a few events such as window.option |
| 54 |
"dojox/analytics/plugins/window", |
| 55 |
// this plugin tracks console. message, It logs console.error, warn, and |
| 56 |
// info messages to the tracker. It also defines console.rlog() which |
| 57 |
// can be used to log only to the server. Note that if isDebug() is disabled |
| 58 |
// you will still see the console messages on the sever, but not in the actual |
| 59 |
// browser console. |
| 60 |
"dojox/analytics/plugins/consoleMessages", |
| 61 |
// tracks where a dojo.touch.press is on a page an what it is over, periodically sampling |
| 62 |
// and storing this data |
| 63 |
"dojox/analytics/plugins/touchPress", |
| 64 |
// tracks where a dojo.touch.move is on a page an what it is over, periodically sampling |
| 65 |
// and storing this data |
| 66 |
"dojox/analytics/plugins/touchMove", |
| 67 |
// tracks where a dojox.gesture.tap and swipe events |
| 68 |
"dojox/analytics/plugins/gestureEvents", |
| 69 |
"dojox/analytics/plugins/idle", |
| 70 |
"dojox/gesture/tap", |
| 71 |
"dojox/gesture/swipe", |
| 72 |
"dojo/dom", |
| 73 |
"dojo/touch", |
| 74 |
"dojo/on", |
| 75 |
"dojo/_base/window", |
| 76 |
"dojo/has", |
| 77 |
"dojo/dom-style", |
| 78 |
"dojox/mobile/Heading" |
| 79 |
], function(ready, parser, mobile,scrollableView, compat, |
| 80 |
analytics, dojoplugin, windowplugin, consolemsgplugin, |
| 81 |
touchpressplugin, touchmoveplugin, gestureplugin, idleplugin, tap, swipe, |
| 82 |
dom, touch, on, win, has, domStyle){ |
| 83 |
|
| 84 |
ready(function(){ |
| 85 |
var action = function(e){ |
| 86 |
dom.byId("log1").innerHTML = ""; |
| 87 |
var info = " e.target.id=" + e.target.id + " | e.type=" + e.type + |
| 88 |
" | e.currentTarget.id="+ e.currentTarget.id; |
| 89 |
dom.byId("log1").innerHTML += info; |
| 90 |
}; |
| 91 |
|
| 92 |
var swipeAction = function(e){ |
| 93 |
dom.byId("log2").innerHTML = ""; |
| 94 |
var info = " e.target.id=" + e.target.id + " | e.type=" + e.type + |
| 95 |
" | e.currentTarget.id="+ e.currentTarget.id + |
| 96 |
" e.dx=" + e.dx + " e.dy=" + e.dy + " e.time=" + e.time + "<br/>"; |
| 97 |
dom.byId("log2").innerHTML += info; |
| 98 |
}; |
| 99 |
|
| 100 |
var action2 = function(e){ |
| 101 |
dom.byId("log").innerHTML = ""; |
| 102 |
var info = "[Touch Event]: " + e.type + "<br/> ------ Event Properties: ------<br/>"; |
| 103 |
if(e["target"]){ |
| 104 |
info += "target.textContent: " + e["target"]["textContent"] + "<br/>"; |
| 105 |
} |
| 106 |
for(var i in e){ |
| 107 |
if(i == "touches" || i == "targetTouches" || i == "changedTouches"){ |
| 108 |
info += i + ": " + e[i].length + "<br/>"; |
| 109 |
}else{ |
| 110 |
if(typeof e[i] != "function"){ |
| 111 |
info += " " + i + ": " + e[i] + "<br/>"; |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
dom.byId("log").innerHTML += info + "<br/>"; |
| 116 |
}; |
| 117 |
|
| 118 |
//tap and swipe gestures both work well both on PC and touch devices |
| 119 |
var inner = dom.byId("inner"); |
| 120 |
on(inner, tap, action); |
| 121 |
on(inner, tap.hold, action); |
| 122 |
on(inner, tap.doubletap, action); |
| 123 |
on(inner, swipe, swipeAction); |
| 124 |
|
| 125 |
//test gesture events bubbling from inner div |
| 126 |
var outer = dom.byId("outer"); |
| 127 |
on(outer, tap, action); |
| 128 |
on(outer, tap.hold, action); |
| 129 |
on(outer, tap.doubletap, action); |
| 130 |
on(outer, swipe, swipeAction); |
| 131 |
on(outer, swipe.end, swipeAction); |
| 132 |
|
| 133 |
// Event info, uncomment one of the lines below to see what these events return |
| 134 |
//on(outer, tap, action2); |
| 135 |
on(inner, tap, action2); |
| 136 |
//on(outer, tap.doubletap, action2); |
| 137 |
//on(inner, swipe, action2); |
| 138 |
on(outer, swipe.end, action2); |
| 139 |
//on(outer, touch.move, action2); |
| 140 |
//on(outer, touch.press, action2); |
| 141 |
//on(inner, touch.release, action2); |
| 142 |
|
| 143 |
on(win.doc, "orientationchange", function(e){ |
| 144 |
dom.byId("log1").innerHTML=""; |
| 145 |
dom.byId("log2").innerHTML=""; |
| 146 |
dom.byId("log").innerHTML=""; |
| 147 |
}); |
| 148 |
}); |
| 149 |
}); |
| 150 |
</script> |
| 151 |
</head> |
| 152 |
<body style="visibility:hidden;"> |
| 153 |
<div id="categ" dojoType="dojox.mobile.ScrollableView" selected="true"> |
| 154 |
<div id="outerHeading" dojoType="dojox.mobile.Heading" fixed="top"> |
| 155 |
<div id="outer"> |
| 156 |
outer content <div id="inner">inner content</div> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
<div id="log1"></div> |
| 160 |
<hr/> |
| 161 |
<div id="log2"></div> |
| 162 |
<hr/> |
| 163 |
<div id="log"></div> |
| 164 |
|
| 165 |
</div> |
| 166 |
</body> |
| 167 |
</html> |