Properly-formed URLs will not have spaces, so no need to replace; no need for "/" escaping unless within HTML doc; properly encode loadingImage window text; support loading of (properly URL encoded) non-base64 "data:image/svg+xml;utf8,"-style data URIs

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2782 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Brett Zamir 2014-04-08 01:31:22 +00:00
parent 91a627d53d
commit 0d34fcfa7d
7 changed files with 28 additions and 18 deletions

View File

@ -83,7 +83,7 @@ svgEditor.addExtension("Connector", function(S) {
function showPanel(on) {
var conn_rules = $('#connector_rules');
if(!conn_rules.length) {
conn_rules = $('<style id="connector_rules"><\/style>').appendTo('head');
conn_rules = $('<style id="connector_rules"></style>').appendTo('head');
}
conn_rules.text(!on?"":"#tool_clone, #tool_topath, #tool_angle, #xy_panel { display: none !important; }");
$('#connector_panel').toggle(on);

View File

@ -30,7 +30,7 @@ svgEditor.addExtension("foreignObject", function(S) {
function showPanel(on) {
var fc_rules = $('#fc_rules');
if(!fc_rules.length) {
fc_rules = $('<style id="fc_rules"><\/style>').appendTo('head');
fc_rules = $('<style id="fc_rules"></style>').appendTo('head');
}
fc_rules.text(!on?"":" #tool_topath { display: none !important; }");
$('#foreignObject_panel').toggle(on);

View File

@ -17,13 +17,13 @@ svgEditor.addExtension("overview_window", function() { 'use strict';
<div id=\"overview_window_content\" style=\"position:relative; left:12px; top:0px;\">\
<div style=\"background-color:#A0A0A0; display:inline-block; overflow:visible;\">\
<svg id=\"overviewMiniView\" width=\"150\" height=\"100\" x=\"0\" y=\"0\" viewBox=\"0 0 4800 3600\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\
<use x=\"0\" y=\"0\" xlink:href=\"#svgroot\"> <\/use>\
<use x=\"0\" y=\"0\" xlink:href=\"#svgroot\"> </use>\
</svg>\
<div id=\"overview_window_view_box\" style=\"min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);\">\
<\/div>\
<\/div>\
<\/div>\
<\/div>";
</div>\
</div>\
</div>\
</div>";
$("#sidepanels").append(propsWindowHtml);
//define dynamic animation of the view box.

View File

@ -40,7 +40,7 @@ svgEditor.addExtension("polygon", function(S) {'use strict';
function showPanel(on){
var fc_rules = $('#fc_rules');
if (!fc_rules.length) {
fc_rules = $('<style id="fc_rules"><\/style>').appendTo('head');
fc_rules = $('<style id="fc_rules"></style>').appendTo('head');
}
fc_rules.text(!on ? "" : " #tool_topath { display: none !important; }");
$('#polygon_panel').toggle(on);

View File

@ -88,7 +88,7 @@ svgEditor.addExtension('shapes', function() {'use strict';
var vb = [-off, -off, size + off*2, size + off*2].join(' ');
var stroke = fill ? 0: (size/30);
var shape_icon = new DOMParser().parseFromString(
'<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="' + vb + '"><path fill="'+(fill?'#333':'none')+'" stroke="#000" stroke-width="' + stroke + '" /><\/svg><\/svg>',
'<svg xmlns="http://www.w3.org/2000/svg"><svg viewBox="' + vb + '"><path fill="'+(fill?'#333':'none')+'" stroke="#000" stroke-width="' + stroke + '" /></svg></svg>',
'text/xml');
var width = 24;

View File

@ -27,7 +27,7 @@ svgEditor.addExtension('star', function(S){'use strict';
function showPanel(on){
var fc_rules = $('#fc_rules');
if (!fc_rules.length) {
fc_rules = $('<style id="fc_rules"><\/style>').appendTo('head');
fc_rules = $('<style id="fc_rules"></style>').appendTo('head');
}
fc_rules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#star_panel').toggle(on);

View File

@ -501,8 +501,6 @@ TODOS
}
if (src) {
if (src.indexOf('data:') === 0) {
// plusses get replaced by spaces, so re-insert
src = src.replace(/ /g, '+');
editor.loadFromDataURI(src);
} else {
editor.loadFromString(src);
@ -2348,7 +2346,7 @@ TODOS
var rule_elem = $('#tool_size_rules');
if (!rule_elem.length) {
rule_elem = $('<style id="tool_size_rules"><\/style>').appendTo('head');
rule_elem = $('<style id="tool_size_rules"></style>').appendTo('head');
} else {
rule_elem.empty();
}
@ -3591,7 +3589,9 @@ TODOS
// Open placeholder window (prevents popup)
if (!customHandlers.exportImage) {
var str = uiStrings.notification.loadingImage;
exportWindow = window.open('data:text/html;charset=utf-8,<title>' + str + '<\/title><h1>' + str + '<\/h1>');
exportWindow = window.open(
'data:text/html;charset=utf-8,' + encodeURIComponent('<title>' + str + '</title><h1>' + str + '</h1>')
);
}
var quality = parseInt($('#image-slider').val(), 10)/100;
if (window.canvg) {
@ -3667,7 +3667,7 @@ TODOS
if (supportsNonSS) {return;}
var wf_rules = $('#wireframe_rules');
if (!wf_rules.length) {
wf_rules = $('<style id="wireframe_rules"><\/style>').appendTo('head');
wf_rules = $('<style id="wireframe_rules"></style>').appendTo('head');
} else {
wf_rules.empty();
}
@ -5095,9 +5095,19 @@ TODOS
editor.loadFromDataURI = function(str) {
editor.ready(function() {
var pre = 'data:image/svg+xml;base64,';
var src = str.substring(pre.length);
loadSvgString(Utils.decode64(src));
var base64 = false;
var pre = str.match(/^data:image\/svg\+xml;base64,/);
if (pre) {
base64 = true;
}
else {
pre = str.match(/^data:image\/svg\+xml(?:;(?:utf8)?)?,/);
}
if (pre) {
pre = pre[0];
}
var src = str.slice(pre.length);
loadSvgString(base64 ? Utils.decode64(src) : decodeURIComponent(src));
});
};