Fixed misc bugs, made root only include namespace declarations when necessary

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1510 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-04-07 18:18:28 +00:00
parent 30e8bc486c
commit d2bbd0b127
3 changed files with 33 additions and 9 deletions

View File

@ -752,7 +752,7 @@ span.zoom_tool {
#option_lists ul {
display: none;
position: absolute;
height: 90px;
height: auto;
z-index: 3;
margin: 0;
list-style: none;

View File

@ -1711,10 +1711,6 @@
}
}, true);
// $('#cur_linecap').mousedown(function() {
// $('#linecap_opts').show();
// });
addAltDropDown('#stroke_linecap', '#linecap_opts', function() {
var val = this.id.split('_')[1];
svgCanvas.setStrokeAttr('stroke-linecap', val);
@ -2267,7 +2263,8 @@
'line-height': {s: '15px'}
},
"#tools_bottom_2": {
'width': {l: '295px', xl: '355px'}
'width': {l: '295px', xl: '355px'},
'top': {s: '4px'}
},
"#tools_top > div, #tools_top": {
'line-height': {s: '17px', l: '34px', xl: '50px'}

View File

@ -1140,6 +1140,7 @@ function BatchCommand(text) {
var handle = svgroot.suspendRedraw(60);
var defaults = {
'fill-opacity':1,
'stop-opacity':1,
'opacity':1,
'stroke':'none',
'stroke-dasharray':'none',
@ -1600,15 +1601,40 @@ function BatchCommand(text) {
// Process root element separately
var res = canvas.getResolution();
out.push(' width="' + res.w + '" height="' + res.h + '" xmlns="'+svgns+'"');
var nsuris = {};
// Check elements for namespaces, add if found
$(elem).find('*').andSelf().each(function() {
var el = this;
$.each(this.attributes, function(i, attr) {
var uri = attr.namespaceURI;
if(uri && !nsuris[uri] && nsMap[uri] !== 'xmlns') {
nsuris[uri] = true;
// console.log('add', nsMap[uri]);
// if(nsMap[uri] == 'xmlns') {
// console.log('hm',el, attr.nodeName);
// }
out.push(" xmlns:" + nsMap[uri] + '="' + uri +'"');
}
});
});
var i = attrs.length;
while (i--) {
attr = attrs.item(i);
var attrVal = toXml(attr.nodeValue);
// Namespaces have already been dealt with, so skip
if(attr.nodeName.indexOf('xmlns:') === 0) continue;
// only serialize attributes we don't use internally
if (attrVal != "" &&
$.inArray(attr.localName, ['width','height','xmlns','x','y','viewBox','id','overflow']) == -1)
{
if(!attr.namespaceURI || nsMap[attr.namespaceURI]) {
console.log(!attr.namespaceURI, nsMap[attr.namespaceURI]);
out.push(' ');
out.push(attr.nodeName); out.push("=\"");
out.push(attrVal); out.push("\"");
@ -5982,6 +6008,9 @@ function BatchCommand(text) {
}
content.attr(attrs);
this.contentW = attrs['width'];
this.contentH = attrs['height'];
batchCmd.addSubCommand(new InsertElementCommand(svgcontent));
// update root to the correct size
var changes = content.attr(["width", "height"]);
@ -6949,9 +6978,7 @@ function BatchCommand(text) {
if(diff) continue;
}
this.contentW = attrs['width'];
this.contentH = attrs['height'];
// else could be a duplicate, iterate through stops
var stops = grad.getElementsByTagNameNS(svgns, "stop");
var ostops = og.getElementsByTagNameNS(svgns, "stop");