summaryrefslogtreecommitdiff
path: root/js/dojo/dojox/analytics/plugins/idle.js
blob: f266cfbf08a2ea0dbdbf25db2e5b0d493711c20d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//>>built
define("dojox/analytics/plugins/idle", ["dojo/_base/lang", "../_base", "dojo/_base/config", "dojo/ready", 
        "dojo/aspect", "dojo/_base/window"
], function(lang, dxa, config, ready, aspect, window){
	/*=====
		dxa = dojox.analytics;
		ready = dojo.ready;
		aspect = dojo/aspect;
	=====*/

	// window startup data
	return (dxa.plugins.idle = new (function(){
		this.addData = lang.hitch(dxa, "addData", "idle");
		this.idleTime=config["idleTime"] || 60000;
		this.idle=true;

		this.setIdle = function(){
			this.addData("isIdle");
			this.idle=true;

		}

		ready(lang.hitch(this, function(){
			var idleResets=["onmousemove","onkeydown","onclick","onscroll"];
			for (var i=0;i<idleResets.length;i++){
				aspect.after(window.doc,idleResets[i],lang.hitch(this, function(e){
					if (this.idle){
						this.idle=false;
						this.addData("isActive");
						this.idleTimer=setTimeout(lang.hitch(this,"setIdle"), this.idleTime);
					}else{
						clearTimeout(this.idleTimer);
						this.idleTimer=setTimeout(lang.hitch(this,"setIdle"), this.idleTime);
					}
				}),true);
			}
		}));
	})());
});