Added support for unit width/height when set in document properties

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1372 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-02-10 19:29:05 +00:00
parent 9590cf67f5
commit 984d6263c9
3 changed files with 27 additions and 6 deletions

View File

@ -722,6 +722,11 @@ span.zoom_tool {
z-index: 20001;
}
#svg_docprops .error {
border: 1px solid red;
padding: 3px;
}
#svg_docprops #resolution {
max-width: 14em;
}

View File

@ -1513,7 +1513,6 @@ function svg_edit_setup() {
$('#image_save_opts input').val([curPrefs.img_save]);
// update resolution option with actual resolution
// TODO: what if SVG source is changed?
var res = svgCanvas.getResolution();
$('#canvas_width').val(res.w);
$('#canvas_height').val(res.h);
@ -1580,12 +1579,26 @@ function svg_edit_setup() {
svgCanvas.setImageTitle(new_title);
// update resolution
var x = parseInt($('#canvas_width').val());
var y = parseInt($('#canvas_height').val());
if(isNaN(x) || isNaN(y)) {
x ='fit';
var width = $('#canvas_width'), w = width.val();
var height = $('#canvas_height'), h = height.val();
if(w != "fit" && !svgCanvas.isValidUnit('width', w)) {
$.alert(uiStrings.invalidAttrValGiven);
width.parent().addClass('error');
return false;
}
if(!svgCanvas.setResolution(x,y)) {
width.parent().removeClass('error');
if(h != "fit" && !svgCanvas.isValidUnit('height', h)) {
$.alert(uiStrings.invalidAttrValGiven);
height.parent().addClass('error');
return false;
}
height.parent().removeClass('error');
if(!svgCanvas.setResolution(w, h)) {
$.alert(uiStrings.noContentToFitTo);
return false;
}

View File

@ -6105,6 +6105,9 @@ function BatchCommand(text) {
if(!batchCmd) {
batchCmd = new BatchCommand("Change Image Dimensions");
}
x = convertToNum('width', x);
y = convertToNum('height', y);
svgcontent.setAttribute('width', x);
svgcontent.setAttribute('height', y);
batchCmd.addSubCommand(new ChangeElementCommand(svgcontent, {"width":w, "height":h}));