dojox
Version:
Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.
34 lines (29 loc) • 991 B
JavaScript
define(["dojo/_base/lang", "../_base", "dojo/_base/config", "dojo/ready",
"dojo/aspect", "dojo/_base/window"
], function(lang, dxa, config, ready, aspect, window){
// 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);
}
}));
})());
});