From 30248d4790d99274d652003267092f12fd44ab90 Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Thu, 29 Jul 2010 19:43:52 +0000 Subject: [PATCH] Fixed several minor bugs git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1652 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 20 +++++++++++++++++--- editor/svgcanvas.js | 6 ++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index e334cde5..fead569c 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1188,7 +1188,7 @@ // 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 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 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 var updateContextPanel = function() { var elem = selectedElement; @@ -1450,7 +1455,15 @@ else if(el_name == 'g' || el_name == 'use') { $('#container_panel').show(); 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) @@ -1649,7 +1662,8 @@ $('#g_title').change(function() { svgCanvas.setGroupTitle(this.value); - $(this).width(17 + this.value.length * 5); + setInputWidth(this); + }); $('.attr_changer').change(function() { diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index a6c1cba1..1ba06339 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -7999,6 +7999,9 @@ this.setSvgString = function(xmlString) { // Wrap child SVGs in group elements $(svgcontent).find('svg').each(function() { + // Skip if it's in a + if($(this).closest('defs').length) return; + uniquifyElems(this); // Check if it already has a gsvg group @@ -8218,7 +8221,6 @@ this.importSvgString = function(xmlString) { recalculateDimensions(use_el); $(use_el).data('symbol', symbol); addToSelection([use_el]); - return true; @@ -8753,7 +8755,7 @@ this.setGroupTitle = function(val) { if(!val.length) { // Remove title element - batchCmd.addSubCommand(new RemoveElementCommand(ts[i], elem)); + batchCmd.addSubCommand(new RemoveElementCommand(ts[0], elem)); ts.remove(); } else if(ts.length) { // Change title contents