From bb38edf3dbfb638d90d45986ac73ed9327f3a8df Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 8 Oct 2009 02:16:36 +0000 Subject: [PATCH] Fix new layer naming code by antimatter15. Fix rotation of groups problem. git-svn-id: http://svg-edit.googlecode.com/svn/trunk@777 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 9 ++++++++- editor/svgcanvas.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 6d4f574d..869c0168 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -1126,7 +1126,14 @@ function svg_edit_setup() { $('#layer_new').click(function() { var curNames = new Array(svgCanvas.getNumLayers()); for (var i = 0; i < curNames.length; ++i) { curNames[i] = svgCanvas.getLayer(i); } - var newName = prompt("Please enter a unique layer name","Layer "+(curNames.length+1)); + + var j = (curNames.length+1); + var uniqName = "Layer " + j; + while (jQuery.inArray(uniqName, curNames) != -1) { + j++; + uniqName = "Layer " + j; + } + var newName = prompt("Please enter a unique layer name",uniqName); if (!newName) return; if (jQuery.inArray(newName, curNames) != -1) { alert("There is already a layer named that!"); diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 27b884be..37bbb400 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -3921,8 +3921,8 @@ function BatchCommand(text) { while (i--) { var elem = elems[i]; if (elem == null) continue; - // only allow the transform attribute to change on elements, slightly hacky - if (elem.tagName == "g" && attr == "transform") continue; + // only allow the transform/opacity attribute to change on elements, slightly hacky + if (elem.tagName == "g" && (attr != "transform" && attr != "opacity")) continue; var oldval = attr == "#text" ? elem.textContent : elem.getAttribute(attr); if (oldval == null) oldval = ""; if (oldval != newValue) {