Fixed major part of issue 459 by providing warning onbeforeunload when appropriate
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1473 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -143,6 +143,7 @@
|
|||||||
svgCanvas.open = opts.open;
|
svgCanvas.open = opts.open;
|
||||||
}
|
}
|
||||||
if(opts.save) {
|
if(opts.save) {
|
||||||
|
show_save_warning = false;
|
||||||
svgCanvas.bind("saved", opts.save);
|
svgCanvas.bind("saved", opts.save);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,8 @@
|
|||||||
modKey = "", //(isMac ? "meta+" : "ctrl+");
|
modKey = "", //(isMac ? "meta+" : "ctrl+");
|
||||||
path = svgCanvas.pathActions,
|
path = svgCanvas.pathActions,
|
||||||
default_img_url = curConfig.imgPath + "logo.png",
|
default_img_url = curConfig.imgPath + "logo.png",
|
||||||
workarea = $("#workarea");
|
workarea = $("#workarea"),
|
||||||
|
show_save_warning = false;
|
||||||
|
|
||||||
// This sets up alternative dialog boxes. They mostly work the same way as
|
// This sets up alternative dialog boxes. They mostly work the same way as
|
||||||
// their UI counterparts, expect instead of returning the result, a callback
|
// their UI counterparts, expect instead of returning the result, a callback
|
||||||
@@ -445,6 +447,8 @@
|
|||||||
var strokePaint = new $.jGraduate.Paint({solidColor: curConfig.initStroke.color});
|
var strokePaint = new $.jGraduate.Paint({solidColor: curConfig.initStroke.color});
|
||||||
|
|
||||||
var saveHandler = function(window,svg) {
|
var saveHandler = function(window,svg) {
|
||||||
|
show_save_warning = false;
|
||||||
|
|
||||||
// by default, we add the XML prolog back, systems integrating SVG-edit (wikis, CMSs)
|
// by default, we add the XML prolog back, systems integrating SVG-edit (wikis, CMSs)
|
||||||
// can just provide their own custom save handler and might not want the XML prolog
|
// can just provide their own custom save handler and might not want the XML prolog
|
||||||
svg = "<?xml version='1.0'?>\n" + svg;
|
svg = "<?xml version='1.0'?>\n" + svg;
|
||||||
@@ -526,6 +530,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_save_warning = true;
|
||||||
|
|
||||||
// we update the contextual panel with potentially new
|
// we update the contextual panel with potentially new
|
||||||
// positional/sizing information (we DON'T want to update the
|
// positional/sizing information (we DON'T want to update the
|
||||||
// toolbar here as that creates an infinite loop)
|
// toolbar here as that creates an infinite loop)
|
||||||
@@ -2994,6 +3000,19 @@
|
|||||||
$('#group_opacity').SpinButton({ step: 5, min: 0, max: 100, callback: changeOpacity });
|
$('#group_opacity').SpinButton({ step: 5, min: 0, max: 100, callback: changeOpacity });
|
||||||
$('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom });
|
$('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom });
|
||||||
|
|
||||||
|
window.onbeforeunload = function() {
|
||||||
|
// Suppress warning if page is empty
|
||||||
|
if(svgCanvas.getHistoryPosition() === 0) {
|
||||||
|
show_save_warning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// show_save_warning is set to "false" when the page is saved.
|
||||||
|
if(!curConfig.no_save_warning && show_save_warning) {
|
||||||
|
// Browser already asks question about closing the page
|
||||||
|
return "There are unsaved changes.";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// use HTML5 File API: http://www.w3.org/TR/FileAPI/
|
// use HTML5 File API: http://www.w3.org/TR/FileAPI/
|
||||||
// if browser has HTML5 File API support, then we will show the open menu item
|
// if browser has HTML5 File API support, then we will show the open menu item
|
||||||
// and provide a file input to click. When that change event fires, it will
|
// and provide a file input to click. When that change event fires, it will
|
||||||
|
|||||||
@@ -1321,6 +1321,10 @@ function BatchCommand(text) {
|
|||||||
undoStackPointer = undoStack.length;
|
undoStackPointer = undoStack.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getHistoryPosition = function() {
|
||||||
|
return undoStackPointer;
|
||||||
|
};
|
||||||
|
|
||||||
// private functions
|
// private functions
|
||||||
var getId = function() {
|
var getId = function() {
|
||||||
if (events["getid"]) return call("getid", obj_num);
|
if (events["getid"]) return call("getid", obj_num);
|
||||||
|
|||||||
Reference in New Issue
Block a user