Fixed issue 81: Source Editor needs Cancel/Save buttons
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@401 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
e13c674692
commit
4e5a45642e
|
@ -301,8 +301,17 @@ div.color_block {
|
|||
#svg_source_textarea {
|
||||
position: relative;
|
||||
width: 95%;
|
||||
top: 35px;
|
||||
top: 5px;
|
||||
height: 250px;
|
||||
padding: 5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#tool_source_back {
|
||||
text-align: left;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
#tool_source_back button {
|
||||
margin: 10px;
|
||||
}
|
|
@ -265,7 +265,10 @@
|
|||
<div id="svg_source_editor">
|
||||
<div id="svg_source_overlay"></div>
|
||||
<div id="svg_source_container">
|
||||
<div id="tool_source_back" class="toolbar_button"></div>
|
||||
<div id="tool_source_back" class="toolbar_button">
|
||||
<button id="tool_source_save">Save</button>
|
||||
<button id="tool_source_cancel">Cancel</button>
|
||||
</div>
|
||||
<form>
|
||||
<textarea id="svg_source_textarea"></textarea>
|
||||
</form>
|
||||
|
|
|
@ -506,19 +506,34 @@ function svg_edit_setup() {
|
|||
|
||||
var properlySourceSizeTextArea = function(){
|
||||
// TODO: remove magic numbers here and get values from CSS
|
||||
var height = ($(window).height() - 120)+'px';
|
||||
var height = $('#svg_source_container').height() - 80;
|
||||
$('#svg_source_textarea').css('height', height);
|
||||
};
|
||||
|
||||
var hideSourceEditor = function(){
|
||||
var saveSourceEditor = function(){
|
||||
if (!editingsource) return;
|
||||
|
||||
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.');
|
||||
|
||||
if (!svgCanvas.setSvgString($('#svg_source_textarea').val())) {
|
||||
if( !confirm('There were parsing errors in your SVG source.\nRevert back to original SVG source?') ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
hideSourceEditor();
|
||||
};
|
||||
|
||||
var cancelSourceEditor = function() {
|
||||
if (!editingsource) return;
|
||||
|
||||
var oldString = svgCanvas.getSvgString();
|
||||
if (oldString != $('#svg_source_textarea').val()) {
|
||||
if( !confirm('Ignore changes made to SVG source?') ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
hideSourceEditor();
|
||||
};
|
||||
|
||||
var hideSourceEditor = function(){
|
||||
$('#svg_source_editor').hide();
|
||||
editingsource = false;
|
||||
$('#svg_source_textarea').blur();
|
||||
|
@ -544,6 +559,8 @@ function svg_edit_setup() {
|
|||
$('#tool_clear').click(clickClear);
|
||||
$('#tool_save').click(clickSave);
|
||||
$('#tool_source').click(showSourceEditor);
|
||||
$('#tool_source_cancel,#svg_source_overlay').click(cancelSourceEditor);
|
||||
$('#tool_source_save').click(saveSourceEditor);
|
||||
$('#tool_delete').click(deleteSelected);
|
||||
$('#tool_delete_multi').click(deleteSelected);
|
||||
$('#tool_move_top').click(moveToTopSelected);
|
||||
|
@ -629,7 +646,7 @@ function svg_edit_setup() {
|
|||
$(document).bind('keydown', {combi:'6', disableInInput: true}, clickText);
|
||||
$(document).bind('keydown', {combi:'7', disableInInput: true}, clickPoly);
|
||||
$(document).bind('keydown', {combi:modKey+'N', disableInInput: true}, function(evt){clickClear();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:modKey+'S', disableInInput: true}, function(evt){clickSave();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:modKey+'S', disableInInput: true}, function(evt){editingsource?saveSourceEditor():clickSave();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'del', disableInInput: true}, function(evt){deleteSelected();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'backspace', disableInInput: true}, function(evt){deleteSelected();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'shift+up', disableInInput: true}, moveToTopSelected);
|
||||
|
@ -642,7 +659,7 @@ function svg_edit_setup() {
|
|||
$(document).bind('keydown', {combi:modKey+'y', disableInInput: true}, function(evt){clickRedo();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:modKey+'u', disableInInput: true}, function(evt){showSourceEditor();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:modKey+'c', disableInInput: true}, function(evt){clickClone();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'esc', disableInInput: false}, hideSourceEditor);
|
||||
$(document).bind('keydown', {combi:'esc', disableInInput: false}, cancelSourceEditor);
|
||||
|
||||
// TODO: fix opacity being updated
|
||||
// TODO: go back to the color boxes having white background-color and then setting
|
||||
|
|
Loading…
Reference in New Issue