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-75d572ba1dddmaster
parent
687f532acb
commit
508c72e5a7
|
@ -143,6 +143,7 @@
|
|||
svgCanvas.open = opts.open;
|
||||
}
|
||||
if(opts.save) {
|
||||
show_save_warning = false;
|
||||
svgCanvas.bind("saved", opts.save);
|
||||
}
|
||||
}
|
||||
|
@ -361,7 +362,8 @@
|
|||
modKey = "", //(isMac ? "meta+" : "ctrl+");
|
||||
path = svgCanvas.pathActions,
|
||||
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
|
||||
// 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 saveHandler = function(window,svg) {
|
||||
show_save_warning = false;
|
||||
|
||||
// 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
|
||||
svg = "<?xml version='1.0'?>\n" + svg;
|
||||
|
@ -525,6 +529,8 @@
|
|||
selectedElement = elem;
|
||||
}
|
||||
}
|
||||
|
||||
show_save_warning = true;
|
||||
|
||||
// we update the contextual panel with potentially new
|
||||
// positional/sizing information (we DON'T want to update the
|
||||
|
@ -2994,6 +3000,19 @@
|
|||
$('#group_opacity').SpinButton({ step: 5, min: 0, max: 100, callback: changeOpacity });
|
||||
$('#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/
|
||||
// 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
|
||||
|
|
|
@ -1320,6 +1320,10 @@ function BatchCommand(text) {
|
|||
undoStack.push(cmd);
|
||||
undoStackPointer = undoStack.length;
|
||||
};
|
||||
|
||||
this.getHistoryPosition = function() {
|
||||
return undoStackPointer;
|
||||
};
|
||||
|
||||
// private functions
|
||||
var getId = function() {
|
||||
|
|
Loading…
Reference in New Issue