(function($) {
var __ = wp.i18n.__;
var imageEdit = window.imageEdit = {
iasapi : {},
hold : {},
postid : '',
_view : false,
toggleCropTool: function( postid, nonce, cropButton ) {
var img = $( '#image-preview-' + postid ),
selection = this.iasapi.getSelection();
imageEdit.toggleControls( cropButton );
var $el = $( cropButton );
var state = ( $el.attr( 'aria-expanded' ) === 'true' ) ? 'true' : 'false';
if ( 'false' === state ) {
this.iasapi.cancelSelection();
imageEdit.setDisabled($('.imgedit-crop-clear'), 0);
} else {
imageEdit.setDisabled($('.imgedit-crop-clear'), 1);
var startX = ( $( '#imgedit-start-x-' + postid ).val() ) ? $('#imgedit-start-x-' + postid).val() : 0;
var startY = ( $( '#imgedit-start-y-' + postid ).val() ) ? $('#imgedit-start-y-' + postid).val() : 0;
var width = ( $( '#imgedit-sel-width-' + postid ).val() ) ? $('#imgedit-sel-width-' + postid).val() : img.innerWidth();
var height = ( $( '#imgedit-sel-height-' + postid ).val() ) ? $('#imgedit-sel-height-' + postid).val() : img.innerHeight();