Skip to content
This repository has been archived by the owner on Apr 21, 2019. It is now read-only.

Allow repeated calling of $.timeoutDialog() #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions js/timeout-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ String.prototype.format = function() {
};

!function($) {

var $globalTimeoutSettings = {},
sessionTimeoutHandle;

$.timeoutDialog = function(options) {

var settings = {
Expand All @@ -57,18 +61,20 @@ String.prototype.format = function() {
logout_redirect_url: '/',
restart_on_yes: true,
dialog_width: 350
}

$.extend(settings, options);

};

$.extend($globalTimeoutSettings, options);
options = $.extend(settings, $globalTimeoutSettings);

var TimeoutDialog = {
init: function () {
this.setupDialogTimer();
},

setupDialogTimer: function() {
var self = this;
window.setTimeout(function() {
window.clearTimeout(sessionTimeoutHandle);
sessionTimeoutHandle = window.setTimeout(function() {
self.setupDialog();
}, (settings.timeout - settings.countdown) * 1000);
},
Expand Down Expand Up @@ -177,4 +183,5 @@ String.prototype.format = function() {

TimeoutDialog.init();
};
}(window.jQuery);
}(window.jQuery);