2010-07-01 20:11:36 +00:00
|
|
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
|
|
|
2010-06-30 20:30:06 +00:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
$(window).load(function(){
|
|
|
|
|
|
|
|
var jcrop_api = $.Jcrop('#cropbox',{
|
2010-07-14 19:49:15 +00:00
|
|
|
/*onChange: showPreview,*/
|
2010-06-30 20:30:06 +00:00
|
|
|
onSelect: showPreview,
|
2010-07-07 14:51:44 +00:00
|
|
|
setSelect: [ 0, 0, 115, 115 ],
|
2010-07-14 14:07:00 +00:00
|
|
|
minSize: [ 115, 115 ],
|
2010-06-30 20:30:06 +00:00
|
|
|
aspectRatio: 1
|
2010-07-14 19:49:15 +00:00
|
|
|
|
2010-06-30 20:30:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var bounds = jcrop_api.getBounds();
|
|
|
|
var boundx = bounds[0];
|
|
|
|
var boundy = bounds[1];
|
|
|
|
|
|
|
|
function showPreview(coords)
|
|
|
|
{
|
|
|
|
if (parseInt(coords.w) > 0)
|
|
|
|
{
|
|
|
|
var rx = 115 / coords.w;
|
|
|
|
var ry = 115 / coords.h;
|
|
|
|
|
|
|
|
$('#preview').css({
|
|
|
|
width: Math.round(rx * boundx) + 'px',
|
|
|
|
height: Math.round(ry * boundy) + 'px',
|
|
|
|
marginLeft: '-' + Math.round(rx * coords.x) + 'px',
|
|
|
|
marginTop: '-' + Math.round(ry * coords.y) + 'px'
|
|
|
|
});
|
2010-07-01 15:54:31 +00:00
|
|
|
|
|
|
|
$('input[name=x]').val(coords.x);
|
|
|
|
$('input[name=y]').val(coords.y);
|
|
|
|
$('input[name=w]').val(coords.w);
|
|
|
|
$('input[name=h]').val(coords.h);
|
2010-06-30 20:30:06 +00:00
|
|
|
}
|
|
|
|
};
|
2010-07-01 14:20:18 +00:00
|
|
|
|
2010-06-30 20:30:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}(jQuery));
|