add page leave handler on image editor
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
function initUploadDialog(){
|
||||
var url='imageUpload.cgi?project_id='+ getProjectId()+"&studio_id="+getStudioId();
|
||||
updateContainer("image-tabs-upload", url);
|
||||
updateContainer("image-tabs-upload", url, pageLeaveHandler);
|
||||
}
|
||||
|
||||
function uploadImage(){
|
||||
|
||||
@@ -2,8 +2,15 @@ var pageHasChangedCounter=0;
|
||||
var pageIsLoaded=0;
|
||||
|
||||
function pageHasChanged(){
|
||||
console.log("pageHasChanged="+pageHasChangedCounter)
|
||||
if (pageIsLoaded==0) return;
|
||||
pageHasChangedCounter++;
|
||||
console.log("pageHasChanged="+pageHasChangedCounter)
|
||||
}
|
||||
|
||||
function confirmPageLeave(){
|
||||
if(pageHasChangedCounter==0) return null;
|
||||
return "Unsaved changed! Continue?";
|
||||
}
|
||||
|
||||
function pageLeaveHandler(){
|
||||
@@ -12,14 +19,17 @@ function pageLeaveHandler(){
|
||||
$('div.editor select' ).change(function(){pageHasChanged()});
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
if(pageHasChangedCounter==0)return null;
|
||||
return "Unsaved changed! Continue?";
|
||||
return confirmPageLeave();
|
||||
};
|
||||
|
||||
//$(window).unload(function(){});
|
||||
pageIsLoaded=1;
|
||||
console.log("pageLeaveHandler=initialized")
|
||||
|
||||
}
|
||||
|
||||
function leavePage(){
|
||||
pageHasChangedCounter=0;
|
||||
console.log("leavePage")
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user