MooTools IdleTimer

Have you ever wanted to log a user out of your site if he is inactive for a given amount of time?
Create a better user experience by dimming or hiding page elements while the user is watching a video?

A couple of months ago I came across Nick Zakas’ YUI approach to this problem, and recently I found Paul Irish’s jQuery plugin which was based on Nick’s work.

This is my attempt at creating a Mootools class that uses the same approach. Quite simply, it fires a timer that activates a callback after a given amount of time. The timer is reset if the user moves the mouse, presses a key, scrolls using the scroll wheel or clicks any mouse button. This has to be done over the active document, obviously.

Key features:

  • Can be attached to a single element on the page or the entire document/window.
  • Lets you set up multiple instances with different timeouts and events.
  • Easily retrieve the idle status from the instance using the isIdle property.
  • Find the number of milliseconds since the user was last active.
  • Allows you to call the active() method to manually reset the idle state – useful for Flash and other overlays that lets you communicate with Javascript.
  • Easily retrieve an IdleTimer instance using element.get(‘idle’, { options });
  • Free and open source. MIT-licensed.

Check out the demo page for more details. The source is available on Github as well as in the recently opened MooTools Forge.

Tags: , , , ,


3 Responses to “MooTools IdleTimer”

  1. Naturally, what a excellent internet site and informative posts, I will add backlink – bookmark this internet site? Regards,
    Reader.

  2. click to call service…

    [...]MooTools IdleTimer | Rexxars.com[...]…

  3. Wow, incredible blog structure! How lengthy have you ever been blogging for? you make blogging glance easy. The total glance of your web site is great, as smartly as the content!

Leave a Reply