timeout-dialog.js icon indicating copy to clipboard operation
timeout-dialog.js copied to clipboard

How do I reset the timer on-demand?

Open jezs opened this issue 11 years ago • 2 comments

I tried returning the variable TimeoutDialog and calling keepAlive, setupDialog, etc. but it results to multiple timeout dialogs.

Basically, what I want to accomplish is that if user clicks or inputs in any text area in the page, the timeout counter will reset.

jezs avatar Oct 31 '13 09:10 jezs

@jezs - were you able to figure out how to reset the timer on-demand?

skilledmonster avatar Apr 03 '14 01:04 skilledmonster

Have a look at my fork (branch michael-fork). I refactored the code to expose the functions and added the ability to reset the timer. The new code must call the setupDialogTimer directly with the options as a parameter. I also added the ability to pass in a function for when the keep-alive and logout calls are made.

https://github.com/MichaelApproved/timeout-dialog.js/tree/michael-fork

jQuery.timeoutDialog.setupDialogTimer(yourOptionsHere);

To reset, just call the setupDialogTimer() again. If you want to use the same options as before, just call it without the options parameter. It'll use the previously set options

jQuery.timeoutDialog.setupDialogTimer();

If someone is reading this months later and the branch is no longer there, it's likely I merged the changes with my master. I'll polish things off soon and write full docs on my edits.

https://github.com/MichaelApproved/timeout-dialog.js

MichaelApproved avatar Oct 20 '14 18:10 MichaelApproved