Move image cropping js out of template into separate js file. Use existing jquery.js rather than the one included with jcrop.
This commit is contained in:
parent
643ed3d53f
commit
681cc62c21
4 changed files with 39 additions and 6283 deletions
33
webapp/web/js/imageUpload/cropImage.js
Normal file
33
webapp/web/js/imageUpload/cropImage.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
(function($) {
|
||||
|
||||
$(window).load(function(){
|
||||
|
||||
var jcrop_api = $.Jcrop('#cropbox',{
|
||||
onChange: showPreview,
|
||||
onSelect: showPreview,
|
||||
aspectRatio: 1
|
||||
});
|
||||
|
||||
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'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
}(jQuery));
|
Loading…
Add table
Add a link
Reference in a new issue