Skip to content
Crisfole edited this page Oct 24, 2014 · 5 revisions

Dependencies

The plugin depends on jquery and the jquery.idletimer plugin.

Signature

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

Element

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.

Resume

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.

Options

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

Callbacks

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
Clone this wiki locally