Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1 | espaco | 1 | var UIIdleTimeout = function () { |
| 2 | |||
| 3 | return { |
||
| 4 | |||
| 5 | //main function to initiate the module |
||
| 6 | init: function () { |
||
| 7 | |||
| 8 | // cache a reference to the countdown element so we don't have to query the DOM for it on each ping. |
||
| 9 | var $countdown; |
||
| 10 | |||
| 11 | $('body').append(''); |
||
| 12 | |||
| 13 | // start the idle timer plugin |
||
| 14 | $.idleTimeout('#idle-timeout-dialog', '.modal-content button:last', { |
||
| 15 | idleAfter: 5, // 5 seconds |
||
| 16 | timeout: 30000, //30 seconds to timeout |
||
| 17 | pollingInterval: 5, // 5 seconds |
||
| 18 | keepAliveURL: '../demo/idletimeout_keepalive.php', |
||
| 19 | serverResponseEquals: 'OK', |
||
| 20 | onTimeout: function(){ |
||
| 21 | window.location = "?p=page_user_lock_1"; |
||
| 22 | }, |
||
| 23 | onIdle: function(){ |
||
| 24 | $('#idle-timeout-dialog').modal('show'); |
||
| 25 | $countdown = $('#idle-timeout-counter'); |
||
| 26 | |||
| 27 | $('#idle-timeout-dialog-keepalive').on('click', function () { |
||
| 28 | $('#idle-timeout-dialog').modal('hide'); |
||
| 29 | }); |
||
| 30 | |||
| 31 | $('#idle-timeout-dialog-logout').on('click', function () { |
||
| 32 | $('#idle-timeout-dialog').modal('hide'); |
||
| 33 | $.idleTimeout.options.onTimeout.call(this); |
||
| 34 | }); |
||
| 35 | }, |
||
| 36 | onCountdown: function(counter){ |
||
| 37 | $countdown.html(counter); // update the counter |
||
| 38 | } |
||
| 39 | }); |
||
| 40 | |||
| 41 | } |
||
| 42 | |||
| 43 | }; |
||
| 44 | |||
| 45 | }(); |
||
| 46 | |||
| 47 | jQuery(document).ready(function() { |
||
| 48 | UIIdleTimeout.init(); |
||
| 49 | }); |