Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从停止idlemonitor的事件中删除mousemove?_Javascript_Jsf_Primefaces - Fatal编程技术网

Javascript 如何从停止idlemonitor的事件中删除mousemove?

Javascript 如何从停止idlemonitor的事件中删除mousemove?,javascript,jsf,primefaces,Javascript,Jsf,Primefaces,我想使用一个简单的p:idleMonitor来实现一些逻辑。 但在我的例子中,我不想为mousemove重新启动idlemonitors计数器(仅用于单击等) 这是否可以通过javascript或其他方式实现?idlemonitor没有该配置的任何属性。将此代码添加到一个JS文件中,该文件在PrimeFaces到MonkeyPatch之后加载。您的idlemonitor仅在键下和单击事件时停止 关键是这一行events:“向下键单击”//define active events 这是基于Prim

我想使用一个简单的p:idleMonitor来实现一些逻辑。 但在我的例子中,我不想为mousemove重新启动idlemonitors计数器(仅用于单击等)


这是否可以通过javascript或其他方式实现?idlemonitor没有该配置的任何属性。

将此代码添加到一个JS文件中,该文件在PrimeFaces到MonkeyPatch之后加载。您的idlemonitor仅在
键下和
单击事件时停止

关键是这一行
events:“向下键单击”//define active events

这是基于PrimeFaces 8的

if(PrimeFaces.widget.IdleMonitor){
PrimeFaces.widget.IdleMonitor.prototype.init=函数(cfg){
PrimeFaces.widget.BaseWidget.prototype.init.call(this,cfg);
var$this=这个;
$(document).on(“idle.idleTimer”+this.cfg.id,function()){
if($this.cfg.onidle){
$this.cfg.onidle.call($this);
}
$this.callBehavior('idle');
})
.on(“active.idleTimer”+this.cfg.id,function()){
if($this.cfg.onactive){
$this.cfg.onactive.call($this);
}
$this.callBehavior('active');
});
变量选项={
idle:false,//表示用户是否空闲
timeout:this.cfg.timeout,//用户被认为空闲之前的时间量(毫秒)
事件:“向下键单击”//定义活动事件
};
$.idleTimer(opts,document,this.cfg.id);
if(cfg.multiWindowSupport){
var globallastativekey=$this.cfg.contextPath+'\u idleMonitor\u lastActive'+this.cfg.id;
//始终在初始化时使用当前时间重置
setItem(globallatastivekey,$(document).data('idleTimerObj'+this.cfg.id).lastActive);
$this.timer=setInterval(函数(){
var idleTimerObj=$(document.data('idleTimerObj'+$this.cfg.id);
var globallastative=parseInt(localStorage.getItem(globallastativekey));
var localLastActive=idleTimerObj.lastActive;
//重置本地状态
如果(GlobalStactive>localLastActive){
//暂停计时器
$.idleTimer('pause',document,$this.cfg.id);
//覆盖真实状态
idleTimerObj.idle=false;
idleTimerObj.olddate=globalastactive;
idleTimerObj.lastActive=globalastactive;
idleTimerObj.remaining=$this.cfg.timeout;
//恢复计时器
$.idleTimer('resume',document,$this.cfg.id);
}
//更新全局状态
else if(localLastActive>GlobalStactive){
setItem(globallastativekey,localLastActive);
}
}, 2000);
}
}
};