CoreFiles by mySites.guru
site-icon-crop.js53 lines, 1,635 bytes, from wordpress-4.3-beta2.zip
Raw History Compare with 4.3-beta1
md5
7035565f6569ed3728aec8f46cf762ca
sha1
1fc2bb325a457343de2e8539fdf29a9b1b353cc0
sha256
b17b847e6261de8f5f20057e4d545bee9e8d71ecbcc4f7cba414ed670f8a9a0b
/* global wpSiteIconCropData, jQuery */
(function($) {
	var jcrop_api = {},
		siteIconCrop = {

		updateCoords : function ( coords ) {
			$( '#crop-x' ).val( coords.x );
			$( '#crop-y' ).val( coords.y );
			$( '#crop-width' ).val( coords.w );
			$( '#crop-height' ).val( coords.h );

			siteIconCrop.showPreview( coords );
		},

		showPreview : function( coords ){
			var rx = 64 / coords.w,
				ry = 64 / coords.h,
				preview_rx = 16 / coords.w,
				preview_ry = 16 / coords.h;

			$( '#preview-homeicon' ).css({
				width: Math.round(rx * wpSiteIconCropData.width ) + 'px',
				height: Math.round(ry * wpSiteIconCropData.height ) + 'px',
				marginLeft: '-' + Math.round(rx * coords.x) + 'px',
				marginTop: '-' + Math.round(ry * coords.y) + 'px'
			});

			$( '#preview-favicon' ).css({
				width: Math.round( preview_rx * wpSiteIconCropData.width ) + 'px',
				height: Math.round( preview_ry * wpSiteIconCropData.height ) + 'px',
				marginLeft: '-' + Math.round( preview_rx * coords.x ) + 'px',
				marginTop: '-' + Math.floor( preview_ry* coords.y ) + 'px'
			});
		},

		ready: function() {
			jcrop_api = $.Jcrop( '#crop-image' );
			jcrop_api.setOptions({
				bgColor: 'transparent',
				aspectRatio: 1,
				onSelect: siteIconCrop.updateCoords,
				onChange: siteIconCrop.updateCoords,
				trueSize: [ wpSiteIconCropData.width, wpSiteIconCropData.height ],
				minSize: [ wpSiteIconCropData.min_size, wpSiteIconCropData.min_size ]
			});
			jcrop_api.animateTo([wpSiteIconCropData.init_x, wpSiteIconCropData.init_y, wpSiteIconCropData.init_size, wpSiteIconCropData.init_size]);
		}

	};

	siteIconCrop.ready();

})(jQuery);

The same content is in 2 releases, WordPress 4.3-beta2 to 4.3-beta3. See them all, or every version of this file.