From f229d4c12ef6f25f75bed6e3a2dffe16dd44d50f Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Wed, 14 Oct 2009 16:29:28 +0000 Subject: [PATCH] Fix Issue 280: Update layer list and Move To select box after moving elements. Fix Issue 281: Make side panel resizable up to 300px, make default snap-open size 150px git-svn-id: http://svg-edit.googlecode.com/svn/trunk@828 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index cfe415ce..9163a36b 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -371,12 +371,15 @@ function svg_edit_setup() { }); // fired when user wants to move elements to another layer + var promptMoveLayerOnce = false; $('#selLayerNames').change(function(){ var destLayer = this.options[this.selectedIndex].value; // TODO: localize this prompt - if (destLayer && confirm('Move selected elements to layer \'' + destLayer + '\'?')) { + if (destLayer && (promptMoveLayerOnce || confirm('Move selected elements to layer \'' + destLayer + '\'?'))) { + promptMoveLayerOnce = true; svgCanvas.moveSelectedToLayer(destLayer); svgCanvas.clearSelection(); + populateLayers(); } }); @@ -1253,6 +1256,8 @@ function svg_edit_setup() { $('#layerlist tr.layer:eq('+curIndex+')').addClass("layersel"); }); + var SIDEPANEL_MAXWIDTH = 300; + var SIDEPANEL_OPENWIDTH = 150; var sidedrag = -1; $('#sidepanel_handle') .mousedown(function(evt) {sidedrag = evt.pageX;}) @@ -1274,9 +1279,9 @@ function svg_edit_setup() { var sidepanels = $('#sidepanels'); var sidewidth = parseInt(sidepanels.css('width')); - if (sidewidth+deltax > 130) { - deltax = 130 - sidewidth; - sidewidth = 130; + if (sidewidth+deltax > SIDEPANEL_MAXWIDTH) { + deltax = SIDEPANEL_MAXWIDTH - sidewidth; + sidewidth = SIDEPANEL_MAXWIDTH; } else if (sidewidth+deltax < 2) { deltax = 2 - sidewidth; @@ -1298,7 +1303,7 @@ function svg_edit_setup() { // the optional close argument forces the side panel closed var toggleSidePanel = function(close){ var w = parseInt($('#sidepanels').css('width')); - var deltax = (w > 2 || close ? 2 : 130) - w; + var deltax = (w > 2 || close ? 2 : SIDEPANEL_OPENWIDTH) - w; var workarea = $('#workarea'); var sidepanels = $('#sidepanels'); var layerpanel = $('#layerpanel'); @@ -1333,24 +1338,27 @@ function svg_edit_setup() { var selLayerNames = $('#selLayerNames'); layerlist.empty(); selLayerNames.empty(); + var currentlayer = svgCanvas.getCurrentLayer(); var layer = svgCanvas.getNumLayers(); // we get the layers in the reverse z-order (the layer rendered on top is listed first) while (layer--) { var name = svgCanvas.getLayer(layer); // contenteditable=\"true\" + var appendstr = ""; + if (svgCanvas.getLayerVisibility(name)) { - layerlist.append("" + name + ""); + appendstr += "" + name + ""; } else { - layerlist.append("" + name + ""); + appendstr += "" + name + ""; } + layerlist.append(appendstr); selLayerNames.append(""); } - // if we only have one layer, then always make sure that layer is selected - // (This is really only required upon first initialization) - if (layerlist.size() == 1) { - $('#layerlist tr:first').addClass("layersel"); - } // handle selection of layer $('#layerlist td.layername') .click(function(evt){