2 jQuery("#photo_original img").Jcrop({
4 setSelect: [ 0, 0, $("#photo_original img").attr("width"), $("#photo_original img").attr("height") ],
5 onSelect: updateCoords,
14 function showPreview(coords) {
15 var rx = 96 / coords.w;
16 var ry = 96 / coords.h;
18 var img_width = $("#photo_original img").attr("width");
19 var img_height = $("#photo_original img").attr("height");
21 $('#photo_preview img').css({
22 width: Math.round(rx *img_width) + 'px',
23 height: Math.round(ry * img_height) + 'px',
24 marginLeft: '-' + Math.round(rx * coords.x) + 'px',
25 marginTop: '-' + Math.round(ry * coords.y) + 'px'
29 function updateCoords(c) {
30 $('#photo_crop_x').val(c.x);
31 $('#photo_crop_y').val(c.y);
32 $('#photo_crop_w').val(c.w);
33 $('#photo_crop_h').val(c.h);
36 function checkCoords() {
37 if (parseInt($('#photo_crop_w').val())) return true;
38 alert('Please select a crop region then press submit.');