change beforeunload to use addEventListener (only supporting IE9 now and better to allow multiple if user wishes); also CamelCase internal variable for consistency; add brackets
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2639 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
var svgCanvas = null;
|
var svgCanvas = null;
|
||||||
|
|
||||||
function init_embed() {
|
function initEmbed() {
|
||||||
var doc, mainButton,
|
var doc, mainButton,
|
||||||
frame = document.getElementById('svgedit');
|
frame = document.getElementById('svgedit');
|
||||||
svgCanvas = new EmbeddedSVGEdit(frame);
|
svgCanvas = new EmbeddedSVGEdit(frame);
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
$('#save').click(saveSvg);
|
$('#save').click(saveSvg);
|
||||||
|
|
||||||
// Export globals
|
// Export globals
|
||||||
window.init_embed = init_embed;
|
window.initEmbed = initEmbed;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@@ -51,6 +51,6 @@
|
|||||||
<button id="load">Load example</button>
|
<button id="load">Load example</button>
|
||||||
<button id="save">Save data</button>
|
<button id="save">Save data</button>
|
||||||
<br/>
|
<br/>
|
||||||
<iframe src="svg-editor.html" width="900px" height="600px" id="svgedit" onload="init_embed();"></iframe>
|
<iframe src="svg-editor.html" width="900px" height="600px" id="svgedit" onload="initEmbed();"></iframe>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -220,7 +220,9 @@ svgedit.history.RemoveElementCommand.prototype.unapply = function(handler) {
|
|||||||
|
|
||||||
svgedit.transformlist.removeElementFromListMap(this.elem);
|
svgedit.transformlist.removeElementFromListMap(this.elem);
|
||||||
if (this.nextSibling == null) {
|
if (this.nextSibling == null) {
|
||||||
if (window.console) console.log('Error: reference element was lost');
|
if (window.console) {
|
||||||
|
console.log('Error: reference element was lost');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.parent.insertBefore(this.elem, this.nextSibling);
|
this.parent.insertBefore(this.elem, this.nextSibling);
|
||||||
|
|
||||||
|
|||||||
@@ -1801,7 +1801,9 @@
|
|||||||
|
|
||||||
var operaRepaint = function() {
|
var operaRepaint = function() {
|
||||||
// Repaints canvas in Opera. Needed for stroke-dasharray change as well as fill change
|
// Repaints canvas in Opera. Needed for stroke-dasharray change as well as fill change
|
||||||
if (!window.opera) return;
|
if (!window.opera) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$('<p/>').hide().appendTo('body').remove();
|
$('<p/>').hide().appendTo('body').remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -4235,7 +4237,7 @@
|
|||||||
$('#cmenu_canvas li').disableContextMenu();
|
$('#cmenu_canvas li').disableContextMenu();
|
||||||
canv_menu.enableContextMenuItems('#delete,#cut,#copy');
|
canv_menu.enableContextMenuItems('#delete,#cut,#copy');
|
||||||
|
|
||||||
window.onbeforeunload = function() {
|
window.addEventListener('beforeunload', function() {
|
||||||
if ('localStorage' in window) {
|
if ('localStorage' in window) {
|
||||||
var name = 'svgedit-' + Editor.curConfig.canvasName;
|
var name = 'svgedit-' + Editor.curConfig.canvasName;
|
||||||
window.localStorage.setItem(name, svgCanvas.getSvgString());
|
window.localStorage.setItem(name, svgCanvas.getSvgString());
|
||||||
@@ -4252,7 +4254,7 @@
|
|||||||
// Browser already asks question about closing the page
|
// Browser already asks question about closing the page
|
||||||
return uiStrings.notification.unsavedChanges;
|
return uiStrings.notification.unsavedChanges;
|
||||||
}
|
}
|
||||||
};
|
}, false);
|
||||||
|
|
||||||
Editor.openPrep = function(func) {
|
Editor.openPrep = function(func) {
|
||||||
$('#main_menu').hide();
|
$('#main_menu').hide();
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ svgedit.utilities.encode64 = function(input) {
|
|||||||
// base64 strings are 4/3 larger than the original string
|
// base64 strings are 4/3 larger than the original string
|
||||||
// input = svgedit.utilities.encodeUTF8(input); // convert non-ASCII characters
|
// input = svgedit.utilities.encodeUTF8(input); // convert non-ASCII characters
|
||||||
input = svgedit.utilities.convertToXMLReferences(input);
|
input = svgedit.utilities.convertToXMLReferences(input);
|
||||||
if(window.btoa) return window.btoa(input); // Use native if available
|
if(window.btoa) {
|
||||||
|
return window.btoa(input); // Use native if available
|
||||||
|
}
|
||||||
var output = new Array( Math.floor( (input.length + 2) / 3 ) * 4 );
|
var output = new Array( Math.floor( (input.length + 2) / 3 ) * 4 );
|
||||||
var chr1, chr2, chr3;
|
var chr1, chr2, chr3;
|
||||||
var enc1, enc2, enc3, enc4;
|
var enc1, enc2, enc3, enc4;
|
||||||
@@ -116,7 +118,9 @@ svgedit.utilities.encode64 = function(input) {
|
|||||||
// Function: svgedit.utilities.decode64
|
// Function: svgedit.utilities.decode64
|
||||||
// Converts a string from base64
|
// Converts a string from base64
|
||||||
svgedit.utilities.decode64 = function(input) {
|
svgedit.utilities.decode64 = function(input) {
|
||||||
if(window.atob) return window.atob(input);
|
if(window.atob) {
|
||||||
|
return window.atob(input);
|
||||||
|
}
|
||||||
var output = '';
|
var output = '';
|
||||||
var chr1, chr2, chr3 = '';
|
var chr1, chr2, chr3 = '';
|
||||||
var enc1, enc2, enc3, enc4 = '';
|
var enc1, enc2, enc3, enc4 = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user