-
Notifications
You must be signed in to change notification settings - Fork 106
Home
The plugin depends on jquery
and the jquery.idletimer
plugin.
To use this plugin call the below after loading jquery.js
, jquery.idletimer.js
and jquery.idletimeout.js
.
$.jqueryTimeout(element, resume, options)
See each section below for explanations of the arguments
Any valid jquery selector works here.
The Element
is the warning element. This should probably be hidden by default. It will be bound as this
in all callbacks this plugin uses, most notably the onIdle
callback, which is where you will probably call show
or insert
to make it visible in the page.
The element a user must click to resume usage of the website. This will stop the countdown to 0 which when reached will trigger the timeout function.
Note: the user must click to resume usage, moving the mouse is no longer sufficient to wake the browser up when the page is considered to have gone idle.
Option | Comment description (hover for long description) | Default |
---|---|---|
warningLength |
Number of seconds after user is idle to show the warning. | 30 |
keepAliveUrl |
url to call to keep the session alive while the user is active | "" |
serverResponseEquals |
the response from keepAliveURL must equal this text | "OK" |
idleAfter |
user is considered idle after this many seconds. 10 minutes default | 600 |
pollingInterval |
a polling request will be sent to the server every X seconds | 60 |
failedRequests |
number of failed polling requests until we abort this script | 5 |
AJAXTimeout |
the $.ajax timeout in MILLISECONDS! | 250 |
titleMessage |
%s will be replaced by the counter value | "Warning: %s seconds until log out" |
CallBacks | All callbacks must be registered here, not via jquery events | All callbacks default to no-ops $.noop
|
The plugin does not support regular javascript events (using on
, off
and company). They must be passed in via the options object. In any callback this
refers to the element found by the first selector passed to $.idleTimeout
.
Callback | description |
---|---|
onTimeout |
fires when the session times out |
onIdle |
fires when the user becomes idle |
onCountdown(secondsLeft) |
fires during each second of warningLength, receives the number of seconds left until the timeout |
onResume |
fires when the user resumes the session |
onAbort |
fires when the script is aborted due to too many failed requests |