| 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 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 | <script src="../../../dojo/dojo.js" |
| 32 | data-dojo-config="parseOnLoad:true, async:true, isDebug: true, usePlainJson: true, |
| 33 | sendMethod: 'script', sendInterval: 5000, mblAlwaysHideAddressBar: true, |
| 34 | // the line below can be used to override the swipeSampleDelay, targetProps and textContentMaxChars |
| 35 | //swipeSampleDelay : 500, targetProps : ['id','className'], textContentMaxChars : 12 |
| 36 | analyticsUrl: 'http://dojotoolkit.org/~dmachi/dojo-1.0/dojox/analytics/logger/dojoxAnalytics.php'"> |
| 37 | </script> |
| 38 | |
| 39 | |
| 40 | <script> |
| 41 | require([ |
| 42 | "dojo/ready", |
| 43 | "dojo/parser", |
| 44 | "dojox/mobile", // This is a mobile app. |
| 45 | "dojox/mobile/ScrollableView", |
| 46 | "dojox/mobile/compat", // This mobile app supports running on desktop browsers |
| 47 | "dojox/analytics", |
| 48 | // this plugin returns the information dojo collects when it launches |
| 49 | "dojox/analytics/plugins/dojo", |
| 50 | // this plugin return the information the window has when it launches |
| 51 | // and it also ties to a few events such as window.option |
| 52 | "dojox/analytics/plugins/window", |
| 53 | // this plugin tracks console. message, It logs console.error, warn, and |
| 54 | // info messages to the tracker. It also defines console.rlog() which |
| 55 | // can be used to log only to the server. Note that if isDebug() is disabled |
| 56 | // you will still see the console messages on the sever, but not in the actual |
| 57 | // browser console. |
| 58 | "dojox/analytics/plugins/consoleMessages", |
| 59 | // tracks where a dojox.gesture.tap and swipe events |
| 60 | "dojox/analytics/plugins/gestureEvents", |
| 61 | "dojox/analytics/plugins/idle", |
| 62 | "dojox/gesture/tap", |
| 63 | "dojox/gesture/swipe", |
| 64 | "dojo/_base/html", |
| 65 | "dojo/dom", |
| 66 | "dojo/touch", |
| 67 | "dojo/on", |
| 68 | "dojo/_base/window", |
| 69 | "dojo/has", |
| 70 | "dojo/dom-style", |
| 71 | "dojox/mobile/Heading" |
| 72 | ], function(ready, parser, mobile, scrollableView, compat, |
| 73 | analytics, dojoplugin, windowplugin, consolemsgplugin, |
| 74 | gestureplugin, idleplugin, tap, swipe, |
| 75 | html, dom, touch, on, win, has, domStyle){ |
| 76 | |
| 77 | ready(function(){ |
| 78 | var action = function(e){ |
| 79 | dom.byId("log1").innerHTML = ""; |
| 80 | var info = " e.target.id=" + e.target.id + " | e.type=" + e.type + |
| 81 | " | e.currentTarget.id="+ e.currentTarget.id; |
| 82 | dom.byId("log1").innerHTML += info; |
| 83 | }; |
| 84 | |
| 85 | var swipeAction = function(e){ |
| 86 | dom.byId("log2").innerHTML = ""; |
| 87 | var info = " e.target.id=" + e.target.id + " | e.type=" + e.type + |
| 88 | " | e.currentTarget.id="+ e.currentTarget.id + |
| 89 | " e.dx=" + e.dx + " e.dy=" + e.dy + " e.time=" + e.time + "<br/>"; |
| 90 | dom.byId("log2").innerHTML += info; |
| 91 | }; |
| 92 | |
| 93 | var action2 = function(e){ |
| 94 | dom.byId("log").innerHTML = ""; |
| 95 | var info = "[Touch Event]: " + e.type + "<br/> ------ Event Properties: ------<br/>"; |
| 96 | if(e["target"]){ |
| 97 | info += "target.textContent: " + e["target"]["textContent"] + "<br/>"; |
| 98 | } |
| 99 | for(var i in e){ |
| 100 | if(i == "touches" || i == "targetTouches" || i == "changedTouches"){ |
| 101 | info += i + ": " + e[i].length + "<br/>"; |
| 102 | }else{ |
| 103 | if(typeof e[i] != "function"){ |
| 104 | info += " " + i + ": " + e[i] + "<br/>"; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | dom.byId("log").innerHTML += info + "<br/>"; |
| 109 | }; |
| 110 | |
| 111 | //tap and swipe gestures both work well both on PC and touch devices |
| 112 | var inner = dom.byId("inner"); |
| 113 | on(inner, tap, action); |
| 114 | on(inner, tap.hold, action); |
| 115 | on(inner, tap.doubletap, action); |
| 116 | on(inner, swipe, swipeAction); |
| 117 | |
| 118 | //test gesture events bubbling from inner div |
| 119 | var outer = dom.byId("outer"); |
| 120 | on(outer, tap, action); |
| 121 | on(outer, tap.hold, action); |
| 122 | on(outer, tap.doubletap, action); |
| 123 | on(outer, swipe, swipeAction); |
| 124 | on(outer, swipe.end, swipeAction); |
| 125 | |
| 126 | // Event info, uncomment one of the lines below to see what these events return |
| 127 | //on(outer, tap, action2); |
| 128 | //on(outer, tap.hold, action2); |
| 129 | on(inner, tap.doubletap, action2); |
| 130 | //on(inner, swipe, action2); |
| 131 | on(outer, swipe.end, action2); |
| 132 | //on(outer, touch.move, action2); |
| 133 | //on(outer, touch.press, action2); |
| 134 | //on(inner, touch.release, action2); |
| 135 | |
| 136 | |
| 137 | on(win.doc, "orientationchange", function(e){ |
| 138 | dom.byId("log1").innerHTML=""; |
| 139 | dom.byId("log2").innerHTML=""; |
| 140 | dom.byId("log").innerHTML=""; |
| 141 | }); |
| 142 | }); |
| 143 | }); |
| 144 | </script> |
| 145 | </head> |
| 146 | <body style="visibility:hidden;"> |
| 147 | <div id="categ" dojoType="dojox/mobile/ScrollableView" selected="true"> |
| 148 | <div id="outerHeading" dojoType="dojox/mobile/Heading" fixed="top"> |
| 149 | <div id="outer"> |
| 150 | outer content <div id="inner">inner content</div> |
| 151 | </div> |
| 152 | </div> |
| 153 | <div id="log1"></div> |
| 154 | <hr/> |
| 155 | <div id="log2"></div> |
| 156 | <hr/> |
| 157 | <div id="log"></div> |
| 158 | |
| 159 | </div> |
| 160 | </body> |
| 161 | </html> |