mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-19 05:47:53 +08:00
Fix issue with unexpected notification windows appearing after report editor exit [fixes SCI-463]
This commit is contained in:
parent
c6c169f744
commit
2c144aa2f3
1 changed files with 44 additions and 38 deletions
|
@ -435,40 +435,43 @@ function initializeSaveToPdf() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeUnsavedWorkDialog() {
|
function initializeUnsavedWorkDialog() {
|
||||||
var dh = $("#data-holder");
|
var dh = $('#data-holder');
|
||||||
var alertText = dh.attr("data-unsaved-work-text");
|
var alertText = dh.attr('data-unsaved-work-text');
|
||||||
|
|
||||||
ignoreUnsavedWorkAlert = false;
|
ignoreUnsavedWorkAlert = false;
|
||||||
|
if ( ignoreUnsavedWorkAlert ) return;
|
||||||
|
|
||||||
$(window)
|
$(document).on('page:before-change', beforechange);
|
||||||
.on("beforeunload", function(ev) {
|
$(window).on('beforeunload', beforeunload);
|
||||||
if (ignoreUnsavedWorkAlert) {
|
|
||||||
// Remove unload listeners
|
|
||||||
$(window).off("beforeunload");
|
|
||||||
$(document).off("page:before-change");
|
|
||||||
|
|
||||||
ev.returnValue = undefined;
|
function beforeunload(ev) {
|
||||||
return undefined;
|
//Check if we are actually in report editor
|
||||||
} else {
|
if ( $(REPORT_CONTENT).length ) {
|
||||||
return alertText;
|
return alertText;
|
||||||
}
|
|
||||||
});
|
|
||||||
$(document).on("page:before-change", function(ev) {
|
|
||||||
var exit;
|
|
||||||
if (ignoreUnsavedWorkAlert) {
|
|
||||||
exit = true;
|
|
||||||
} else {
|
} else {
|
||||||
|
// We are at another page so remove unload handlers if they exists
|
||||||
|
$(window).off('beforeunload', beforeunload);
|
||||||
|
$(document).off('page:before-change', beforechange);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforechange(ev) {
|
||||||
|
//Check if we are actually in report editor
|
||||||
|
if ( $(REPORT_CONTENT).length ) {
|
||||||
|
var exit;
|
||||||
exit = confirm(alertText);
|
exit = confirm(alertText);
|
||||||
}
|
|
||||||
|
|
||||||
if ( exit ) {
|
if ( exit ) {
|
||||||
// Remove unload listeners
|
// We leave the page so remove all listeners
|
||||||
$(window).off("beforeunload");
|
$(window).off();
|
||||||
$(document).off("page:before-change");
|
$(document).off();
|
||||||
}
|
}
|
||||||
|
|
||||||
return exit;
|
return exit;
|
||||||
});
|
} else {
|
||||||
|
// We are at another page so remove unload handlers if they exists
|
||||||
|
$(window).off('beforeunload', beforeunload);
|
||||||
|
$(document).off('page:before-change', beforechange);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1197,6 +1200,8 @@ $(document).ready(function() {
|
||||||
/**
|
/**
|
||||||
* ACTUAL CODE
|
* ACTUAL CODE
|
||||||
*/
|
*/
|
||||||
|
//Check if we are actually at new report page
|
||||||
|
if ( $(REPORT_CONTENT).length ) {
|
||||||
initializeReportElements($(REPORT_CONTENT));
|
initializeReportElements($(REPORT_CONTENT));
|
||||||
initializeGlobalReportSort();
|
initializeGlobalReportSort();
|
||||||
initializePrintPopup();
|
initializePrintPopup();
|
||||||
|
@ -1210,6 +1215,7 @@ $(document).ready(function() {
|
||||||
$(".report-nav-link").each( function(){
|
$(".report-nav-link").each( function(){
|
||||||
truncateLongString( $(this), 30);
|
truncateLongString( $(this), 30);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document).change(function(){
|
$(document).change(function(){
|
||||||
|
|
Loading…
Reference in a new issue