ui-idletimeout.js
1.63 KB
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
40
41
42
43
44
45
46
47
48
49
var UIIdleTimeout = function () {
return {
//main function to initiate the module
init: function () {
// cache a reference to the countdown element so we don't have to query the DOM for it on each ping.
var $countdown;
$('body').append('');
// start the idle timer plugin
$.idleTimeout('#idle-timeout-dialog', '.modal-content button:last', {
idleAfter: 5, // 5 seconds
timeout: 30000, //30 seconds to timeout
pollingInterval: 5, // 5 seconds
keepAliveURL: '../demo/idletimeout_keepalive.php',
serverResponseEquals: 'OK',
onTimeout: function(){
window.location = "?p=page_user_lock_1";
},
onIdle: function(){
$('#idle-timeout-dialog').modal('show');
$countdown = $('#idle-timeout-counter');
$('#idle-timeout-dialog-keepalive').on('click', function () {
$('#idle-timeout-dialog').modal('hide');
});
$('#idle-timeout-dialog-logout').on('click', function () {
$('#idle-timeout-dialog').modal('hide');
$.idleTimeout.options.onTimeout.call(this);
});
},
onCountdown: function(counter){
$countdown.html(counter); // update the counter
}
});
}
};
}();
jQuery(document).ready(function() {
UIIdleTimeout.init();
});