Added ability to set title for image (issue 125). Also: use native base64 encoder if found when encoding

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@843 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2009-10-19 19:06:07 +00:00
parent e667d63ac8
commit df8c220714
4 changed files with 48 additions and 4 deletions

View File

@@ -526,6 +526,10 @@ span.zoom_tool {
margin-bottom: .2em;
}
#canvas_title {
display: block;
}
#svg_source_editor #svg_source_textarea {
position: relative;
width: 95%;

View File

@@ -373,17 +373,20 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
<button id="tool_docprops_save">Save</button>
<button id="tool_docprops_cancel">Cancel</button>
<label><span id="svginfo_title">Image title:</span> <input type="text" id="canvas_title" size="24"></label>
<fieldset id="change_background">
<legend id="svninfo_change_background">Canvas Background</legend>
<legend id="svginfo_change_background">Canvas Background</legend>
<div id="bkgnd_color" class="color_block" title="Change background color/opacity"></div>
</fieldset>
<fieldset id="change_resolution">
<legend id="svninfo_dim">Canvas Dimensions</legend>
<legend id="svginfo_dim">Canvas Dimensions</legend>
<label id="svginfo_width">Width: </label><input type="text" id="canvas_width" size="6">
<label><span id="svginfo_width">Width:</span> <input type="text" id="canvas_width" size="6"></label>
<label id="svginfo_height">Height: </label><input type="text" id="canvas_height" size="6">
<label><span id="svginfo_height">Height:</span> <input type="text" id="canvas_height" size="6"></label>
<label>
<select id="resolution">

View File

@@ -806,6 +806,7 @@ function svg_edit_setup() {
var res = svgCanvas.getResolution();
$('#canvas_width').val(res.w);
$('#canvas_height').val(res.h);
$('#canvas_title').val(svgCanvas.getImageTitle())
$('#svg_docprops').fadeIn();
};
@@ -831,6 +832,9 @@ function svg_edit_setup() {
};
var saveDocProperties = function(){
// set title
svgCanvas.setImageTitle($('#canvas_title').val());
// update resolution
var x = parseInt($('#canvas_width').val());
var y = parseInt($('#canvas_height').val());

View File

@@ -3639,6 +3639,38 @@ function BatchCommand(text) {
return {'w':vb[2], 'h':vb[3], 'zoom': current_zoom};
};
this.getImageTitle = function() {
var childs = svgzoom.childNodes;
for (var i=0; i<childs.length; i++) {
if(childs[i].nodeName == 'title') {
return childs[i].textContent;
}
}
return '';
}
this.setImageTitle = function(newtitle) {
var childs = svgzoom.childNodes, doc_title = false;
for (var i=0; i<childs.length; i++) {
if(childs[i].nodeName == 'title') {
var doc_title = childs[i];
break;
}
}
if(!doc_title) {
doc_title = svgdoc.createElementNS(svgns, "title");
svgzoom.insertBefore(doc_title, svgzoom.firstChild);
}
if(newtitle.length) {
doc_title.textContent = newtitle;
} else {
// No title given, so element is not necessary
doc_title.parentNode.removeChild(doc_title);
}
}
this.setResolution = function(x, y) {
var res = canvas.getResolution();
var w = res.w, h = res.h;
@@ -4893,6 +4925,7 @@ var Utils = {
// base64 strings are 4/3 larger than the original string
// input = Utils.encodeUTF8(input); // convert non-ASCII characters
input = Utils.convertToXMLReferences(input);
if(window.btoa) return window.btoa(input); // Use native if available
var output = new Array( Math.floor( (input.length + 2) / 3 ) * 4 );
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;