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('<div class="modal fade" id="idle-timeout-dialog" data-backdrop="static"><div class="modal-dialog modal-small"><div class="modal-content"><div class="modal-header"><h4 class="modal-title">Your session is about to expire.</h4></div><div class="modal-body"><p><i class="fa fa-warning"></i> You session will be locked in <span id="idle-timeout-counter"></span> seconds.</p><p>Do you want to continue your session?</p></div><div class="modal-footer"><button id="idle-timeout-dialog-logout" type="button" class="btn btn-default">No, Logout</button><button id="idle-timeout-dialog-keepalive" type="button" class="btn btn-primary" data-dismiss="modal">Yes, Keep Working</button></div></div></div></div>'); |
||
| 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 = "extra_lock.html"; |
||
| 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 | }(); |