changeset 517:aed9bccfe159

svg-edit: saveHandler for moin-1.9
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 11 Apr 2010 14:39:51 +0200
parents 2b7a77acc967
children 236d21d4b0b7
files htdocs/svg-edit/editor/svg-editor.js
diffstat 1 files changed, 11 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/htdocs/svg-edit/editor/svg-editor.js	Sun Apr 11 14:01:35 2010 +0200
+++ b/htdocs/svg-edit/editor/svg-editor.js	Sun Apr 11 14:39:51 2010 +0200
@@ -460,39 +460,19 @@
 		
 			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
+				var titlename = window.content.parent.document.title.split('-')[0];
 				svg = "<?xml version='1.0'?>\n" + svg;
-				
-				// Creates and opens an HTML page that provides a link to the SVG, a preview, and the markup. 
-				// Also includes warning about Mozilla bug #308590 when applicable
-				
-				var win = window.open("data:image/svg+xml;base64," + Utils.encode64(svg));
+				var svg_data = Utils.encode64(svg);
+				var loc = document.location.href;
+				var pagename = loc.split('?url=')[1].split('?')[0];
+				var svg_target = titlename.split(':')[1];
+				$.post(
+					pagename,
+					{'action': "SvgEditor", 'do': "save", 'target': svg_target, 'svg_data': svg_data}
+				      );
 				
-				// Alert will only appear the first time saved OR the first time the bug is encountered
-				var done = $.pref('save_notice_done');
-				if(done !== "all") {
-		
-					var note = 'Select "Save As..." in your browser to save this image as an SVG file.';
-					
-					// Check if FF and has <defs/>
-					if(navigator.userAgent.indexOf('Gecko/') !== -1) {
-						if(svg.indexOf('<defs') !== -1) {
-							note += "\n\nNOTE: Due to a bug in your browser, this image may appear wrong (missing gradients or elements). It will however appear correct once actually saved.";
-							$.pref('save_notice_done', 'all');
-							done = "all";
-						} else {
-							$.pref('save_notice_done', 'part');
-						}
-					} else {
-						$.pref('save_notice_done', 'all'); 
-					}
-					
-					if(done !== 'part') {
-						win.alert(note);
-					}
-				}
+
+				top.window.location = pagename;
 			};
 			
 			// called when we've selected a different element