NIHVIVO-161 Tweak the javascript and the arithmetic for cropping the image.

This commit is contained in:
jeb228 2010-07-01 15:54:31 +00:00
parent 61714819b0
commit 15bcf62f7f
3 changed files with 33 additions and 27 deletions

View file

@ -25,21 +25,14 @@
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
marginTop: '-' + Math.round(ry * coords.y) + 'px'
});
$('input[name=x]').val(coords.x);
$('input[name=y]').val(coords.y);
$('input[name=w]').val(coords.w);
$('input[name=h]').val(coords.h);
}
};
function removeAlpha(str) {
return str.replace(/[^\d-]/g,'');
};
$('#cropImage').submit(function() {
var preview = $('#preview');
$('input[name=x]').val(removeAlpha(preview.css('marginLeft')));
$('input[name=y]').val(removeAlpha(preview.css('marginTop')));
$('input[name=w]').val(removeAlpha(preview.css('width')));
$('input[name=h]').val(removeAlpha(preview.css('height')));
});
});
}(jQuery));