mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-16 03:43:13 +08:00
Merge pull request #856 from ZmagoD/zd_SCI_1610
trigger an alert to on canvas save if page reload [fixes SCI-1610]
This commit is contained in:
commit
26260d01fd
2 changed files with 38 additions and 0 deletions
|
@ -240,6 +240,7 @@ function initializeEdit() {
|
||||||
// Restore draggable position
|
// Restore draggable position
|
||||||
restoreDraggablePosition($("#diagram"), $("#canvas-container"));
|
restoreDraggablePosition($("#diagram"), $("#canvas-container"));
|
||||||
|
|
||||||
|
preventCanvasReloadOnSave();
|
||||||
$("#canvas-container").submit(function (){
|
$("#canvas-container").submit(function (){
|
||||||
animateSpinner(
|
animateSpinner(
|
||||||
this,
|
this,
|
||||||
|
@ -3108,3 +3109,39 @@ function tutorialAfterCb() {
|
||||||
.css({'pointer-events': 'auto'});
|
.css({'pointer-events': 'auto'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** prevent reload page */
|
||||||
|
var preventCanvasReloadOnSave = (function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
function confirmReload() {
|
||||||
|
if( confirm(I18n.t('experiments.canvas.reload_on_submit')) ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function preventCanvasReload() {
|
||||||
|
document.onkeydown = function(){
|
||||||
|
switch (event.keyCode){
|
||||||
|
case 116:
|
||||||
|
event.returnValue = false;
|
||||||
|
return confirmReload();
|
||||||
|
case 82:
|
||||||
|
if (event.ctrlKey){
|
||||||
|
event.returnValue = false;
|
||||||
|
return confirmReload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindToCanvasSave(fun) {
|
||||||
|
$('#canvas-save').on('click', function() {
|
||||||
|
fun();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return function() { bindToCanvasSave(preventCanvasReload) };
|
||||||
|
})();
|
||||||
|
|
|
@ -682,6 +682,7 @@ en:
|
||||||
head_title: "%{project} | Overview"
|
head_title: "%{project} | Overview"
|
||||||
canvas_edit: "Edit experiment"
|
canvas_edit: "Edit experiment"
|
||||||
zoom: "Zoom: "
|
zoom: "Zoom: "
|
||||||
|
reload_on_submit: "Save action is running. Reloading this page may cause unexpected behavior."
|
||||||
modal_manage_tags:
|
modal_manage_tags:
|
||||||
head_title: "Manage tags for"
|
head_title: "Manage tags for"
|
||||||
subtitle: "Showing tags of task %{module}"
|
subtitle: "Showing tags of task %{module}"
|
||||||
|
|
Loading…
Reference in a new issue