Skip to content

Public Configuration Variables

JillElaine edited this page Mar 25, 2015 · 24 revisions

Below is a list of the public configuration variables and their default values. If you want to modify the default values of these variables, you may include any or all of these variables in your 'document ready' function when you call the jquery-idleTimeout script.

Note that you must include and set the redirectUrl variable to your site's logout or redirect page in the 'document ready' function. If you receive a "404 Page Not Found" at timeout, it is likely because this variable was not correctly configured.

All user messages may be translated to your desired language via the configuration variables, such as the 'warning dialog' text.

activityEvents Variable

The activityEvents variable is a string of event names. The default setting for activityEvents is 'click keypress scroll wheel mousewheel mousemove' and covers most common keyboard and mouse events. Each event name must be separated by one space.

Note that the 'mousemove' event adds some overhead to the function as it fires multiple times on even small mouse movements. And some browsers may detect the 'mousemove' event even when the mouse has not moved.

You can learn more about events at Mozilla's Event Reference and whether a browser correctly detects events (or not) at Quirksmode.

Variable Syntax Syntax - variableName: variableValue

If more than one variable is listed in the 'document ready' function, you must put a comma at the end of each variableName: variableValue combination except the last combination in the list.

Example - 'Document Ready' Multiple Variables

  $(document).ready(function () {
    $(document).idleTimeout({
      idleTimeLimit: 1200,          // trailing comma
      redirectUrl:  '/logout',      // trailing comma
      sessionKeepAliveTimer: false  // NO trailing comma - last one in the list
    });
  });

String variables, such as user messages, activityEvents and redirectUrl, must be enclosed within single quotation marks.

Timer variables, such as idleTimeLimit, are in seconds and should not be enclosed in quotation marks.

Please note that all variables are case-sensitive and must be spelled correctly. If you have problems, please check for typos, spelling errors and missing commas.

//##############################
//## Public Configuration Variables
//##############################
var defaults = {
  idleTimeLimit: 1200, // 'No activity' time limit in seconds. 1200 = 20 Minutes
  redirectUrl: '/logout', // redirect to this url on timeout logout. Set to "redirectUrl: false" to disable     redirect
  // optional custom callback to perform before logout
  customCallback: false, // set to false for no customCallback
  // customCallback: function () { // define optional custom js function
    // perform custom action before logout
  // },

  // configure which activity events to detect
  // http://www.quirksmode.org/dom/events/
  // https://developer.mozilla.org/en-US/docs/Web/Reference/Events
  activityEvents: 'click keypress scroll wheel mousewheel mousemove', // separate each event with a space
  
  // warning dialog box configuration
  enableDialog: true, // set to false for logout without warning dialog
  dialogDisplayLimit: 180, // time to display the warning dialog before logout (and optional callback) in seconds. 180 = 3 Minutes
  dialogTitle: 'Session Expiration Warning', // also displays on browser title bar
  dialogText: 'Because you have been inactive, your session is about to expire.',
  dialogTimeRemaining: 'Time remaining',
  dialogStayLoggedInButton: 'Stay Logged In',
  dialogLogOutNowButton: 'Log Out Now',
  
  // error message
  errorAlertMessage: 'Please disable "Private Mode", or upgrade to a modern browser. Or perhaps a dependent file missing. Please see: https://github.com/marcuswestin/store.js',
  
  // server-side session keep-alive timer
  sessionKeepAliveTimer: 600, // Ping the server at this interval in seconds. 600 = 10 Minutes
  // sessionKeepAliveTimer: false, // Set to false to disable pings
  sessionKeepAliveUrl: window.location.href // set URL to ping - does not apply if sessionKeepAliveTimer: false
}
Clone this wiki locally