From 86173b183205fbc5d63687a93696ae50c6365164 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Thu, 6 Aug 2009 11:43:19 +0000 Subject: [PATCH] Fix Issue 78: Merge copy/paste button into one clone button git-svn-id: http://svg-edit.googlecode.com/svn/trunk@354 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.html | 5 ++--- editor/svg-editor.js | 15 +++++---------- editor/svgcanvas.js | 12 +++--------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/editor/svg-editor.html b/editor/svg-editor.html index 731b5fdd..681d6881 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -42,13 +42,12 @@ | Undo Redo - Paste
| - Copy + Copy Delete Top Bottom @@ -69,7 +68,7 @@
| - Copy + Clone Delete
diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 0bc1783a..e43a3c0e 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -457,11 +457,8 @@ function svg_edit_setup() { svgCanvas.redo(); }; - var clickCopy = function(){ - svgCanvas.copySelectedElements(); - }; - var clickPaste = function(){ - svgCanvas.pasteElements(); + var clickClone = function(){ + svgCanvas.cloneSelectedElements(); }; var showSourceEditor = function(){ @@ -519,9 +516,8 @@ function svg_edit_setup() { $('#tool_move_bottom').click(moveToBottomSelected); $('#tool_undo').click(clickUndo); $('#tool_redo').click(clickRedo); - $('#tool_paste').click(clickPaste); - $('#tool_copy').click(clickCopy); - $('#tool_copy_multi').click(clickCopy); + $('#tool_clone').click(clickClone); + $('#tool_clone_multi').click(clickClone); // these two lines are required to make Opera work properly with the flyout mechanism $('#tools_rect_show').click(clickSquare); $('#tools_ellipse_show').click(clickCircle); @@ -590,8 +586,7 @@ function svg_edit_setup() { $(document).bind('keydown', {combi:'shift+z', disableInInput: true}, clickRedo); $(document).bind('keydown', {combi:'y', disableInInput: true}, clickRedo); $(document).bind('keydown', {combi:'u', disableInInput: true}, function(evt){showSourceEditor();evt.preventDefault();}); - $(document).bind('keydown', {combi:'c', disableInInput: true}, clickCopy); - $(document).bind('keydown', {combi:'v', disableInInput: true}, clickPaste); + $(document).bind('keydown', {combi:'c', disableInInput: true}, clickClone); $(document).bind('keydown', {combi:'esc', disableInInput: false}, hideSourceEditor); // TODO: fix opacity being updated diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 8718a81d..019e41c5 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1905,17 +1905,14 @@ function SvgCanvas(c) }; // this creates deep DOM copies (clones) of all selected elements - this.copySelectedElements = function() { + this.cloneSelectedElements = function() { + var batchCmd = new BatchCommand("Clone Elements"); copiedElements = []; var len = selectedElements.length; for (var i = 0; i < len; ++i) { if (selectedElements[i] == null) break; copiedElements.push(selectedElements[i].cloneNode(true)); } - }; - - this.pasteElements = function() { - var batchCmd = new BatchCommand("Paste Elements"); this.clearSelection(); var len = copiedElements.length; for (var i = 0; i < len; ++i) { @@ -1929,11 +1926,8 @@ function SvgCanvas(c) this.addToSelection(copiedElements); this.moveSelectedElements(20,20,false); addCommandToHistory(batchCmd); - // re-copy the elements so we can paste again - this.copySelectedElements(); call("selected", selectedElements); - } - + } }; }