From 4f4d42ff85ab7731882a282653935ebf3a958ddf Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Mon, 13 Jul 2009 03:52:31 +0000 Subject: [PATCH] Prevent change source command if user did not change the source git-svn-id: http://svg-edit.googlecode.com/svn/trunk@317 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svg-editor.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/editor/svg-editor.js b/editor/svg-editor.js index 04fa43f7..47f1150b 100644 --- a/editor/svg-editor.js +++ b/editor/svg-editor.js @@ -410,8 +410,6 @@ function svg_edit_setup() { svgCanvas.redo(); }; - // TODO: create new button for Source Editor - // TODO: prevent creating an undo-able event if the source has not changed - how? --> var showSourceEditor = function(){ if (editingsource) return; editingsource = true; @@ -423,7 +421,7 @@ function svg_edit_setup() { }; var properlySourceSizeTextArea = function(){ - // TODO: remove magic numbers here + // TODO: remove magic numbers here and get values from CSS var height = ($(window).height() - 120)+'px'; $('#svg_source_textarea').css('height', height); }; @@ -431,11 +429,11 @@ function svg_edit_setup() { var hideSourceEditor = function(){ if (!editingsource) return; - if (svgCanvas.setSvgString($('#svg_source_textarea').val())) { - console.log('yo'); - } - else { - alert('There were parsing errors in your SVG source.\nReverting back to original SVG source.'); + var oldString = svgCanvas.getSvgString(); + if (oldString != $('#svg_source_textarea').val()) { + if (!svgCanvas.setSvgString($('#svg_source_textarea').val())) { + alert('There were parsing errors in your SVG source.\nReverting back to original SVG source.'); + } } $('#svg_source_editor').hide(); editingsource = false;