Add a default autosave canvas to localstorage
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2273 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
// changed in the UI and are stored in the browser, config can not
|
// changed in the UI and are stored in the browser, config can not
|
||||||
|
|
||||||
curConfig = {
|
curConfig = {
|
||||||
|
canvasName: 'default',
|
||||||
canvas_expansion: 3,
|
canvas_expansion: 3,
|
||||||
dimensions: [640,480],
|
dimensions: [640,480],
|
||||||
initFill: {
|
initFill: {
|
||||||
@@ -254,6 +255,12 @@
|
|||||||
} else if(urldata.url) {
|
} else if(urldata.url) {
|
||||||
svgEditor.loadFromURL(urldata.url);
|
svgEditor.loadFromURL(urldata.url);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
var name = 'svgedit-' + Editor.curConfig.canvasName;
|
||||||
|
var cached = window.localStorage.getItem(name);
|
||||||
|
if (cached) {
|
||||||
|
Editor.loadFromString(cached);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -4364,6 +4371,13 @@
|
|||||||
canv_menu.enableContextMenuItems('#delete,#cut,#copy');
|
canv_menu.enableContextMenuItems('#delete,#cut,#copy');
|
||||||
|
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
|
|
||||||
|
if ('localStorage' in window) {
|
||||||
|
var name = 'svgedit-' + Editor.curConfig.canvasName;
|
||||||
|
window.localStorage.setItem(name, svgCanvas.getSvgString());
|
||||||
|
Editor.show_save_warning = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Suppress warning if page is empty
|
// Suppress warning if page is empty
|
||||||
if(undoMgr.getUndoStackSize() === 0) {
|
if(undoMgr.getUndoStackSize() === 0) {
|
||||||
Editor.show_save_warning = false;
|
Editor.show_save_warning = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user