https://github.com/ehynds/jquery-idle-timeoutを使用して、「キープアライブ」ページへの Ajax 呼び出しを実行する Mint スタイルのアイドル タイマーを生成しています。
ページが読み込まれていないにもかかわらず、アクティビティが発生していることをユーザーに警告する「お待ちください」メッセージをポップアップ表示する Ajax フォーム送信用の Javascript もあります。
何らかの理由で、キープアライブ ページがポーリングされるたびに、toggleAjaxLoader() 関数が ajax:before および ajax:complete イベントにバインドされます。ユーザーを混乱させるので、これは望ましくありません。これがアイドルタイムアウトにバインドされるのはなぜですか?また、何が起こっているのかを掘り下げるにはどうすればよいですか?
アニメーションを読み込んでいます:
// Toggles our animated ajax loader image
function toggleAjaxLoader() {
jQuery('#ajax_loader').toggle();
}
アイドル タイムアウト:
/*
* Inactivity notifier and auto logout
*/
jQuery(function(){
var redirectToURL = getAbsoluteUrl('/logout/auto=true'); // URL to relocate the user to once they have timed out
var keepAlive = getAbsoluteUrl('/keep-alive');
if (jQuery("#idletimeout").length) {
$.idleTimeout('#idletimeout', '#idletimeout a', {
idleAfter: 2700, // 45 minutes
warningLength: 60, // number of seconds to wait before redirecting the user
keepAliveURL: keepAlive,
AJAXTimeout: 2500,
pollingInterval: 5, // 60
expiredMessage: 'Your session has expired. You are being logged out for security reasons.', // message to show user when the countdown reaches 0
onTimeout: function(){
$(this).slideUp();
window.location.replace(redirectToURL);
},
onIdle: function(){
$(this).slideDown(); // show the warning bar
},
onCountdown: function( counter ){
$(this).find("span").html( counter ); // update the counter
},
onResume: function(){
$(this).slideUp(); // hide the warning bar
// Tums.bump_tums_session(session[:user].session['sessionGuid']);
}
});
};
});