Fix Issue 14: manual merge of text-enabled branch into trunk to enable text element creation/editing

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@85 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2009-06-10 03:12:19 +00:00
parent cd86b6520c
commit 4e27f43026
4 changed files with 183 additions and 31 deletions

View File

@@ -3,8 +3,20 @@ var palette = ["#000000","#202020","#404040","#606060","#808080","#a0a0a0","#c0c
function svg_edit_setup() {
var svgCanvas = new SvgCanvas(document.getElementById("svgcanvas"));
var setSelectMode = function() {
$('.tool_button_current').removeClass('tool_button_current').addClass('tool_button');
$('#tool_select').addClass('tool_button_current');
$('#styleoverrides').text('*{cursor:move;pointer-events:all} svg{cursor:default}');
svgCanvas.setMode('select');
}
var textBeingEntered = false;
var selectedChanged = function(window,elem) {
if (elem != null) {
// set the mode of the editor to select
setSelectMode();
// update fill color
var fillColor = elem.getAttribute("fill");
@@ -56,9 +68,24 @@ function svg_edit_setup() {
strokeDashArray = "none";
}
$('#stroke_style').val(strokeDashArray);
if (elem.tagName == "text") {
$('.text_tool').removeAttr('disabled');
$('#font_family').val(elem.getAttribute("font-family"));
$('#font_size').val(elem.getAttribute("font-size"));
$('#text').val(elem.textContent);
$('#text').focus();
$('#text').select();
}
else {
$('.text_tool').attr('disabled', "disabled");
}
}
}
$('#text').focus( function(){ textBeingEntered = true; } );
$('#text').blur( function(){ textBeingEntered = false; } );
// bind the selected event to our function that handles updates to the UI
svgCanvas.bind("selected", selectedChanged);
@@ -92,6 +119,18 @@ function svg_edit_setup() {
$('#group_opacity').change(function(){
svgCanvas.setOpacity(this.options[this.selectedIndex].value);
});
$('#font_size').change(function(){
svgCanvas.setFontSize(this.options[this.selectedIndex].value);
});
$('#font_family').change(function(){
svgCanvas.setFontFamily(this.options[this.selectedIndex].value);
});
$('#text').keyup(function(){
svgCanvas.setTextContent(this.value);
});
$('.palette_item').click(function(){
color = $(this).css('background-color');
@@ -210,6 +249,7 @@ function svg_edit_setup() {
$('#tool_save').click(clickSave);
$('#workarea').keyup(function(event){
if( textBeingEntered ) { return; }
switch (event.keyCode) {
case 37: // left-arrow
break;