Fixed several minor bugs

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1652 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-07-29 19:43:52 +00:00
parent bcbb43ec91
commit 30248d4790
2 changed files with 21 additions and 5 deletions

View File

@ -1188,7 +1188,7 @@
// updates the toolbar (colors, opacity, etc) based on the selected element // updates the toolbar (colors, opacity, etc) based on the selected element
// This function also updates the opacity and id elements that are in the context panel // This function also updates the opacity and id elements that are in the context panel
var updateToolbar = function() { var updateToolbar = function() {
if (selectedElement != null && $.inArray(selectedElement.tagName, ['image', 'foreignObject', 'g', 'a']) === -1) { if (selectedElement != null && $.inArray(selectedElement.tagName, ['use', 'image', 'foreignObject', 'g', 'a']) === -1) {
// get opacity values // get opacity values
var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity")); var fillOpacity = parseFloat(selectedElement.getAttribute("fill-opacity"));
@ -1296,6 +1296,11 @@
} }
} }
var setInputWidth = function(elem) {
var w = Math.min(Math.max(12 + elem.value.length * 6, 50), 300);
$(elem).width(w);
}
// updates the context panel tools based on the selected element // updates the context panel tools based on the selected element
var updateContextPanel = function() { var updateContextPanel = function() {
var elem = selectedElement; var elem = selectedElement;
@ -1450,7 +1455,15 @@
else if(el_name == 'g' || el_name == 'use') { else if(el_name == 'g' || el_name == 'use') {
$('#container_panel').show(); $('#container_panel').show();
var title = svgCanvas.getTitle(); var title = svgCanvas.getTitle();
$('#g_title').val(title); var label = $('#g_title')[0];
label.value = title;
setInputWidth(label);
var d = 'disabled';
if(el_name == 'use') {
label.setAttribute(d, d);
} else {
label.removeAttribute(d);
}
} }
} }
} // if (elem != null) } // if (elem != null)
@ -1649,7 +1662,8 @@
$('#g_title').change(function() { $('#g_title').change(function() {
svgCanvas.setGroupTitle(this.value); svgCanvas.setGroupTitle(this.value);
$(this).width(17 + this.value.length * 5); setInputWidth(this);
}); });
$('.attr_changer').change(function() { $('.attr_changer').change(function() {

View File

@ -7999,6 +7999,9 @@ this.setSvgString = function(xmlString) {
// Wrap child SVGs in group elements // Wrap child SVGs in group elements
$(svgcontent).find('svg').each(function() { $(svgcontent).find('svg').each(function() {
// Skip if it's in a <defs>
if($(this).closest('defs').length) return;
uniquifyElems(this); uniquifyElems(this);
// Check if it already has a gsvg group // Check if it already has a gsvg group
@ -8218,7 +8221,6 @@ this.importSvgString = function(xmlString) {
recalculateDimensions(use_el); recalculateDimensions(use_el);
$(use_el).data('symbol', symbol); $(use_el).data('symbol', symbol);
addToSelection([use_el]); addToSelection([use_el]);
return true; return true;
@ -8753,7 +8755,7 @@ this.setGroupTitle = function(val) {
if(!val.length) { if(!val.length) {
// Remove title element // Remove title element
batchCmd.addSubCommand(new RemoveElementCommand(ts[i], elem)); batchCmd.addSubCommand(new RemoveElementCommand(ts[0], elem));
ts.remove(); ts.remove();
} else if(ts.length) { } else if(ts.length) {
// Change title contents // Change title contents