HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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);
};