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:
Zmago Devetak 2017-11-09 11:35:39 +01:00 committed by GitHub
commit 26260d01fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View file

@ -240,6 +240,7 @@ function initializeEdit() {
// Restore draggable position
restoreDraggablePosition($("#diagram"), $("#canvas-container"));
preventCanvasReloadOnSave();
$("#canvas-container").submit(function (){
animateSpinner(
this,
@ -3108,3 +3109,39 @@ function tutorialAfterCb() {
.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) };
})();

View file

@ -682,6 +682,7 @@ en:
head_title: "%{project} | Overview"
canvas_edit: "Edit experiment"
zoom: "Zoom: "
reload_on_submit: "Save action is running. Reloading this page may cause unexpected behavior."
modal_manage_tags:
head_title: "Manage tags for"
subtitle: "Showing tags of task %{module}"