File: D:/HostingSpaces/SBogers10/spire.komma-mediadesign.nl/wwwroot/kms/js/initCrop.js
/**
* Creates the view for the image cropping
*
* @return null
*/
function initJCrop(target, minW, minH, maxW, maxH){
var ratio = minW / minH;
var posx = 0
var posy = 0;
if(ratio > maxW / maxH)
{
// when images is less wide then ratio
posy = (maxH - (maxW / ratio)) / 2;
maxH = maxW / ratio;
}
else
{
// when images is less wider then ratio
posx = (maxW - (maxH * ratio)) / 2;
maxW = maxH / ratio;
}
$('#'+target).Jcrop({
onSelect: function(c){ showCoords(c,target) },
onRelease: function(c){ showCoords(c ,target) },
bgOpacity: .4,
setSelect: [ posx, posy, posx+maxW, posy+maxH ],
aspectRatio: ratio,
minSize: [minW,minH]
//maxSize: [maxW,maxH]
});
}
/**
* Creates updates the values
*
* @return null
*/
function showCoords(c, target)
{
// variables can be accessed here as
// c.x, c.y, c.x2, c.y2, c.w, c.h
var key = target.substring(11);
var values = c.x+'-'+c.y+'-'+c.x2+'-'+c.y2+'-'+c.w+'-'+c.h;
$('#cropValues'+key).attr('value',values);
};