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