text: !function(t,o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof exports?module.exports=o(require("jquery")):t.IdleTimeoutPlus=o(t.jQuery)}(this,function(t){function o(){null===tt&&(tt=t.localStorage?t.initNamespaceStorage("jqueryIdleTimeoutPlus").localStorage:{})}function n(t,o){$.multiWindowSupport?tt.set(t,o):tt[t]=o}function e(t,o){if(o="undefined"==typeof o?null:o,$.multiWindowSupport){if(tt.isSet(t))return tt.get(t)}else if(t in tt)return tt[t];return o}function l(){n("warningStartTime",-1),n("lockStartTime",-1),i(),$.idleCallback!==!1&&$.idleCallback($)}function i(){a(),n("lastActivity",t.now()),nt=setInterval(r,$.idleCheckHeartbeat)}function a(){clearInterval(nt)}function r(){var o=e("lastActivity",t.now())+$.idleTimeLimit;return e("logoutTriggered")===!0?N():e("lockStartTime",-1)!==-1?(a(),A()):t.now()>=o?(a(),$.warnEnabled?d():$.lockEnabled?L():O()):void 0}function c(){t(document).on($.activityEvents,function(t){if("mousemove"===t.type){if(t.clientX===at[0]&&t.clientY===at[1])return;at[0]=t.clientX,at[1]=t.clientY}e("warningStartTime",-1)===-1&&e("lockStartTime",-1)===-1&&i()})}function u(){s(),et=setInterval(function(){t.ajax({type:$.keepAliveAjaxType,url:$.keepAliveUrl,data:$.keepAliveAjaxData})},$.keepAliveInterval)}function s(){clearInterval(et)}function d(){k(),$.warnCallback!==!1&&(rt=$.warnCallback($)),v()}function p(){f(),w(),n("warningStartTime",-1),l()}function k(){n("warningStartTime",t.now()),lt=setInterval(m,500)}function f(){clearInterval(lt)}function m(){if(e("logoutTriggered")===!0)return f(),N();if(e("warningStartTime",-1)===-1)return p();var o=e("warningStartTime")+$.warnTimeLimit-1;return t.now()>=o?(f(),$.lockEnabled?(w(),L()):O()):void b()}function v(){rt&&(g(),b(),$.bootstrap?(ut.modal("show"),ut.focus()):ut.dialog("open"),ct=!0)}function w(){ct=!1,null!==ut&&($.bootstrap?(ut.modal("hide"),_.removeClass("modal-open"),t("div.modal-backdrop").remove()):ut.dialog("close"))}function b(){if(null!==ut&&(null!==st||null!==dt)){var o=t.now(),n=Math.floor((e("warningStartTime",o)+$.warnTimeLimit-o)/1e3);if(null!==st&&st.html(V(n)),null!==dt){var l=Math.floor(n/($.warnTimeLimit/1e3)*100);$.bootstrap?dt.css("width",l+"%"):dt.progressbar("value",l)}}}function g(){if(null===ut){var t="";t=$.warnContentCallback===!1?$.bootstrap?j():C():$.warnContentCallback($),$.bootstrap?h(t):y(t)}}function h(o){_.append(o),null!==$.warnLogoutButton&&t("#jitp-warn-logout").on("click",function(){T()}),t("#jitp-warn-alive").on("click",function(){S()}),ut=t("#jitp-warn-display"),(null!==$.warnCountdownMessage||$.warnCountdownBar)&&(st=ut.find(".jitp-countdown-holder")),$.warnCountdownBar&&(dt=t("#jitp-warn-bar"))}function y(o){var n=[];null!==$.warnLogoutButton&&n.push({text:$.warnLogoutButton,click:function(){T()}}),n.push({text:$.warnStayAliveButton,click:function(){S()}}),t(o).dialog({buttons:n,closeOnEscape:!1,modal:!0,title:$.warnTitle,minWidth:320,autoOpen:!1,open:function(){null===$.warnTitle?t(this).closest(".ui-dialog").find(".ui-dialog-titlebar").hide():t(this).closest(".ui-dialog").find(".ui-dialog-titlebar-close").hide(),t(this).parent().find("button:nth-child(2)").focus()}}),ut=t("#jitp-warn-display"),null!==$.warnCountdownMessage&&(st=ut.find(".jitp-countdown-holder")),$.warnCountdownBar&&(dt=t("#jitp-warn-bar"),dt.progressbar({value:0,max:100}))}function j(){var t=null===$.warnTitle?"":'<div class="modal-header"><h4 class="modal-title">'+$.warnTitle+"</h4></div>",o=null===$.warnCountdownMessage?"":"<p>"+$.warnCountdownMessage.replace(/\{timer}/g,'<span class="jitp-countdown-holder"></span>')+"</p>",n=null===$.warnLogoutButton?"":'<button id="jitp-warn-logout" type="button" class="btn btn-default">'+$.warnLogoutButton+"</button>",e=null===$.warnCountdownBar?"":'<div class="progress"><div id="jitp-warn-bar" class="progress-bar progress-bar-striped active" role="progressbar" style="min-width: 15px; width: 100%;"><span class="jitp-countdown-holder"></span></div></div>';return'<div class="modal fade" id="jitp-warn-display" data-backdrop="static" data-keyboard="false" tabindex="-1"><div class="modal-dialog"><div class="modal-content">'+t+'<div class="modal-body"><p>'+$.warnMessage+"</p>"+o+e+'</div><div class="modal-footer">'+n+'<button id="jitp-warn-alive" type="button" class="btn btn-primary">'+$.warnStayAliveButton+"</button></div></div></div></div>"}function C(){var t=null===$.warnCountdownMessage?"":"<p>"+$.warnCountdownMessage.replace(/\{timer}/g,'<span class="jitp-countdown-holder"></span>')+"</p>",o=null===$.warnCountdownBar?"":'<div id="jitp-warn-bar"></div>';return'<div id="jitp-warn-display"><p>'+$.warnMessage+"</p>"+t+o+"</div>"}function T(){f(),D()}function S(){p()}function L(){$.lockHaltKeepAlive&&s(),I(),$.lockCallback!==!1&&(pt=$.lockCallback($)),E()}function A(){$.lockHaltKeepAlive?s():$.keepAliveInterval&&u(),e("lockStartTime",-1)===-1?I():it=setInterval(B,500),E()}function U(){M(),x(),t("#jitp-lock-pass").val(""),$.keepAliveInterval&&u(),n("lockStartTime",-1),l()}function I(){n("lockStartTime",t.now()),it=setInterval(B,500)}function M(){clearInterval(it)}function B(){if(e("logoutTriggered")===!0)return M(),N();if(e("lockStartTime",-1)===-1)return U();var o=e("lockStartTime")+$.lockTimeLimit-1;return t.now()>=o?(M(),e("logoutTriggered")===!0?N():O()):void W()}function E(){if(pt){q(),W();var o={message:t("#jitp-lock-display")};o=t.extend(o,$.lockBlockUiConfig),t.blockUI(o),kt=!0}}function x(){t.unblockUI(),kt=!1}function W(){if(null!==mt){var o=t.now(),n=Math.floor((e("lockStartTime",o)+$.lockTimeLimit-o)/1e3);mt.html(V(n))}}function q(){if(null===ft){var o="";o=$.lockContentCallback===!1?$.bootstrap?P():H():$.lockContentCallback($),_.append(o),ft=t("#jitp-lock-display"),$.lockCountdownMessage!==!1&&(mt=ft.find(".jitp-countdown-holder")),t("#jitp-lock-logout").on("click",function(){K()}),t("#jitp-lock-unlock").on("click",function(){Q()}),t("#jitp-lock-form").length&&t("#jitp-lock-form").submit(function(){return Q(),!1}),W()}}function P(){var t=null===$.lockTitle?"":'<div class="panel-heading"><h2 class="panel-title">'+$.lockTitle+"</h2></div>",o=$.lockLogoutButton.replace(/\{username}/g,$.lockUsername),n=null===$.lockCountdownMessage?"":'<div class="panel-footer">'+$.lockCountdownMessage.replace(/\{timer}/g,'<span class="jitp-countdown-holder"></span>')+"</div>";return'<div id="jitp-lock-display" class="jitp-lock-back" style="display: none;"><div class="panel panel-default jitp-lock-panel">'+t+'<div class="panel-body"><h4>'+$.lockUsername+"</h4><p>"+$.lockMessage+'</p><div class="input-group"><input id="jitp-lock-pass" type="password" class="form-control" placeholder="Password..."/><span class="input-group-btn"><button id="jitp-lock-unlock" class="btn btn-primary" type="button">'+$.lockUnlockButton+'</button></span></div><a id="jitp-lock-logout" href="javascript:;">'+o+"</a></div>"+n+"</div></div>"}function H(){var t=null===$.lockTitle?"":"<header>"+$.lockTitle+"</header>",o=$.lockLogoutButton.replace(/\{username}/g,$.lockUsername),n=null===$.lockCountdownMessage?"":"<footer>"+$.lockCountdownMessage.replace(/\{timer}/g,'<span class="jitp-countdown-holder"></span>')+"</footer>";return'<div id="jitp-lock-display" class="jitp-lock-back" style="display: none;"><div class="jitp-lock-panel jitp-lock-jqpanel">'+t+'<div class="jitp-lock-jqpanel-body"><h2>'+$.lockUsername+"</h2><p>"+$.lockMessage+'</p><div><input id="jitp-lock-pass" type="text" class="form-control" placeholder="Password..."/></div><button id="jitp-lock-unlock" type="button">'+$.lockUnlockButton+'</button><a id="jitp-lock-logout" href="javascript:;">'+o+"</a></div>"+n+"</div></div>"}function K(){M(),D()}function Q(){$.lockPassCallback(t("#jitp-lock-pass").val())}function Y(){s(),a(),f(),M()}function D(){Y(),n("logoutTriggered",!0),("function"!=typeof $.logoutCallback||$.logoutCallback($))&&window.location.replace($.logoutUrl)}function N(){Y(),("function"!=typeof $.logoutAutoCallback||$.logoutAutoCallback($))&&window.location.replace($.logoutAutoUrl)}function O(){return Y(),$.multiWindowSupport?void setTimeout(X,Z(100,500)):X()}function X(){return e("logoutTriggered",!1)?N():(n("logoutTriggered",!0),void(("function"!=typeof $.redirectCallback||$.redirectCallback($))&&window.location.replace($.redirectUrl)))}function F(){n("activityEvents",$.activityEvents)}function G(){t(document).on("dialogopen shown.bs.modal",function(){ct||kt||J()})}function J(){var t,o=function(){"complete"===document.readyState&&(clearInterval(t),R())};t=setInterval(o,1e3)}function R(o){o||(o=t(document));var n=0;o.find("iframe,frame").each(function(){if(t(this).hasClass("jitp-inspected")===!1)try{R(t(this).contents()),t(this).on("load",z(t(this)));var o=t(this)[n];o.attachEvent&&o.attachEvent("onload",z(t(this))),n++}catch(e){t(this).addClass("jitp-inspected cross-site")}})}function z(o){var n=o.contents(),l=e("activityEvents","");try{n.on(l,function(o){t("body").trigger(o)}),o.addClass("jitp-inspected")}catch(i){}}function V(t){var o=Math.floor(t/60);if(o<=15){var n=t%60,e=o>0?o+"m ":"";return e+=n+"s"}if(o<=75)return o<=22?"about 15 mins":o<=37?"about 30 mins":o<=52?"about 25 mins":"about 1 hour";var l=Math.floor(o/60);return o%=60,o<=15?"about "+l+" hours":o>52?"about "+(l+1)+" hours":"about "+l+"&frac12; hours"}function Z(t,o){return Math.floor(Math.random()*(o-t))+t}var $={idleTimeLimit:1200,idleCallback:!1,idleCheckHeartbeat:2,bootstrap:!1,activityEvents:"click keypress scroll wheel mousewheel mousemove touchmove",warnEnabled:!0,warnTimeLimit:180,warnCallback:!1,warnContentCallback:!1,warnTitle:"Session Timeout",warnMessage:"Your session is about to expire!",warnStayAliveButton:"Stay Connected",warnLogoutButton:"Logout",warnCountdownMessage:"Time remaining: {timer}",warnCountdownBar:!1,redirectUrl:"/timed-out",logoutUrl:"/logout",logoutAutoUrl:"null",redirectCallback:!1,logoutCallback:!1,logoutAutoCallback:!1,keepAliveInterval:600,keepAliveUrl:window.location.href,keepAliveAjaxType:"GET",keepAliveAjaxData:"",lockEnabled:!1,lockTimeLimit:7200,lockHaltKeepAlive:!0,lockCallback:!1,lockContentCallback:!1,lockPassCallback:!1,lockTitle:null,lockUsername:"System User",lockMessage:"Enter your password to unlock the screen",lockUnlockButton:"UnLock",lockLogoutButton:"Not {username} ?",lockCountdownMessage:"Auto-logout in: {timer}",lockBlockUiConfig:{},lockLoadActive:!1,iframesSupport:!1,multiWindowSupport:!1},_=t("body"),tt=null,ot={};ot.start=function(l){if($=t.extend($,l),null===$.logoutAutoUrl&&($.logoutAutoUrl=$.logoutUrl),$.idleTimeLimit*=1e3,$.idleCheckHeartbeat*=1e3,$.warnTimeLimit*=1e3,$.lockTimeLimit*=1e3,$.keepAliveInterval*=1e3,$.multiWindowSupport&&!t.localStorage)return console.error("jitp: Multi-Window support requested but JQuery Storage API is unavailable."),!1;if($.warnEnabled&&$.warnCallback===!1||$.lockEnabled&&$.lockCallback===!1)if($.bootstrap){if("undefined"==typeof t.fn.modal)return console.error("jitp: Bootstrap library is unavailable"),!1}else if("undefined"==typeof t.ui)return console.error("jitp: jQueryUI library is unavailable"),!1;if($.lockEnabled&&!$.multiWindowSupport)return console.error("jitp: Lock screen requested but multi-window support is not enabled."),!1;if($.lockEnabled&&$.lockCallback===!1){if("undefined"==typeof t.blockUI)return console.error("jitp: Lock screen requested but blockUI library is unavailable."),!1;if($.lockPassCallback===!1)return console.error("jitp: Lock screen requested but lockPassCallback function is not set."),!1}return $.iframesSupport&&!$.multiWindowSupport?(console.error("jitp: IFrame support requested but Multi-Window support disabled."),!1):(o(),$.lockEnabled&&($.lockLoadActive||e("lockStartTime",-1)>0)?A():(n("logoutTriggered",!1),n("warningStartTime",-1),n("lockStartTime",-1),n("lastActivity",t.now()),i(),$.keepAliveInterval&&u()),$.keepAliveInterval&&u(),F(),G(),c(),J(),!0)},ot.cleanUpLockScreen=function(){o(),t.localStorage&&tt.set("lockStartTime",-99)},ot.logout=function(){D()},ot.displayWarning=function(){v()},ot.displayLockScreen=function(){E()},ot.initLockScreen=function(){a(),f(),L()},ot.setIdleTimeLimit=function(t){"number"==typeof t&&($.idleTimeLimit=1e3*t,ot.rollback())},ot.setWarnTimeLimit=function(t){"number"==typeof t&&($.warnTimeLimit=1e3*t,ot.rollback())},ot.setLockTimeLimit=function(t){"number"==typeof t&&($.lockTimeLimit=1e3*t,ot.rollback())},ot.rollback=function(){U(),p()},ot.iframeRecheck=function(){J()};var nt,et,lt,it,at=[-1,-1],rt=!0,ct=!1,ut=null,st=null,dt=null,pt=!0,kt=!1,ft=null,mt=null;return ot});