mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-22 23:48:18 +08:00
Merge pull request #7140 from lasniscinote/gl_SCI_10004
(fix) Add warning for unsaved changes when leaving Task workflow editmode (Canvas view) [SCI-10004]
This commit is contained in:
commit
9299cb7a52
1 changed files with 29 additions and 0 deletions
|
@ -545,6 +545,35 @@ function bindTouchDropdowns(selector) {
|
|||
});
|
||||
}
|
||||
|
||||
function handleAnchorClick(event) {
|
||||
event.preventDefault();
|
||||
|
||||
// check if the clicked element is an anchor tag with an href
|
||||
if (event.target.tagName === 'A' && event.target.href) {
|
||||
const targetUrl = event.target.href;
|
||||
|
||||
const alertText = $("#update-canvas").attr("data-unsaved-work-text");
|
||||
const exit = confirm(alertText);
|
||||
|
||||
if (exit) {
|
||||
// remove unload listeners and navigate to location
|
||||
$(window).off("beforeunload");
|
||||
$(document).off("page:before-change");
|
||||
|
||||
window.location.href = targetUrl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// listen to clicks on links in navigator and leftMenuContainer
|
||||
$(document).ready(function() {
|
||||
const navigatorEl = $('.sci--layout-navigation-navigator');
|
||||
const leftMenuContainerEl = $('.sci--layout--left-menu-container');
|
||||
|
||||
navigatorEl.on('click', 'a', handleAnchorClick);
|
||||
leftMenuContainerEl.on('click', 'a', handleAnchorClick);
|
||||
});
|
||||
|
||||
function bindEditModeCloseWindow() {
|
||||
var alertText = $("#update-canvas").attr("data-unsaved-work-text");
|
||||
|
||||
|
|
Loading…
Reference in a new issue