Merge branch 'develop' into next

This commit is contained in:
Kijin Sung 2020-05-21 21:00:08 +09:00
commit 3c3c8f6712

View file

@ -15,6 +15,11 @@
*/ */
window.show_leaving_warning = false; window.show_leaving_warning = false;
/**
* This variable becomes true when the user tries to navigate away from the page.
*/
var page_unloading = false;
/** /**
* This variable stores the .wfsr jQuery object. * This variable stores the .wfsr jQuery object.
*/ */
@ -127,6 +132,11 @@
return xmlHandler(xhr, textStatus); return xmlHandler(xhr, textStatus);
} }
// If the user is navigating away, don't do anything.
if (xhr.status == 0 && page_unloading) {
return;
}
// Hide the waiting message and display an error notice. // Hide the waiting message and display an error notice.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
@ -266,6 +276,13 @@
// Define the error handler. // Define the error handler.
var errorHandler = function(xhr, textStatus) { var errorHandler = function(xhr, textStatus) {
// If the user is navigating away, don't do anything.
if (xhr.status == 0 && page_unloading) {
return;
}
// Hide the waiting message and display an error notice.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
var error_info; var error_info;
@ -338,6 +355,13 @@
// Define the error handler. // Define the error handler.
var errorHandler = function(xhr, textStatus) { var errorHandler = function(xhr, textStatus) {
// If the user is navigating away, don't do anything.
if (xhr.status == 0 && page_unloading) {
return;
}
// Hide the waiting message and display an error notice.
clearTimeout(wfsr_timeout); clearTimeout(wfsr_timeout);
waiting_obj.hide().trigger("cancel_confirm"); waiting_obj.hide().trigger("cancel_confirm");
var error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")"; var error_info = xhr.status + " " + xhr.statusText + " (" + textStatus + ")";
@ -423,6 +447,7 @@
* Empty placeholder for beforeUnload handler. * Empty placeholder for beforeUnload handler.
*/ */
var beforeUnloadHandler = function() { var beforeUnloadHandler = function() {
page_unloading = true;
return ""; return "";
}; };
@ -438,6 +463,10 @@
}).bind("ajaxStop cancel_confirm", function() { }).bind("ajaxStop cancel_confirm", function() {
$(window).unbind("beforeunload", beforeUnloadHandler); $(window).unbind("beforeunload", beforeUnloadHandler);
}); });
} else {
$(window).on('beforeunload', function() {
page_unloading = true;
});
} }
}); });