1 | define(["dojo/_base/lang", "../_base", "dojo/_base/config", "dojo/ready", |
---|
2 | "dojo/aspect", "dojo/_base/window" |
---|
3 | ], function(lang, dxa, config, ready, aspect, window){ |
---|
4 | /*===== |
---|
5 | dxa = dojox.analytics; |
---|
6 | ready = dojo.ready; |
---|
7 | aspect = dojo/aspect; |
---|
8 | =====*/ |
---|
9 | |
---|
10 | // window startup data |
---|
11 | return (dxa.plugins.idle = new (function(){ |
---|
12 | this.addData = lang.hitch(dxa, "addData", "idle"); |
---|
13 | this.idleTime=config["idleTime"] || 60000; |
---|
14 | this.idle=true; |
---|
15 | |
---|
16 | this.setIdle = function(){ |
---|
17 | this.addData("isIdle"); |
---|
18 | this.idle=true; |
---|
19 | |
---|
20 | } |
---|
21 | |
---|
22 | ready(lang.hitch(this, function(){ |
---|
23 | var idleResets=["onmousemove","onkeydown","onclick","onscroll"]; |
---|
24 | for (var i=0;i<idleResets.length;i++){ |
---|
25 | aspect.after(window.doc,idleResets[i],lang.hitch(this, function(e){ |
---|
26 | if (this.idle){ |
---|
27 | this.idle=false; |
---|
28 | this.addData("isActive"); |
---|
29 | this.idleTimer=setTimeout(lang.hitch(this,"setIdle"), this.idleTime); |
---|
30 | }else{ |
---|
31 | clearTimeout(this.idleTimer); |
---|
32 | this.idleTimer=setTimeout(lang.hitch(this,"setIdle"), this.idleTime); |
---|
33 | } |
---|
34 | }),true); |
---|
35 | } |
---|
36 | })); |
---|
37 | })()); |
---|
38 | }); |
---|