/*! This file is auto-generated */ !function(g){var r=wp.i18n.__,d=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,handleCropToolClick:function(i,t,e){var a=g("#image-preview-"+i),o=this.iasapi.getSelection();isNaN(o.x1)&&(this.setCropSelection(i,{x1:0,y1:0,x2:a.innerWidth(),y2:a.innerHeight(),width:a.innerWidth(),height:a.innerHeight()}),o=this.iasapi.getSelection()),0===o.x1&&0===o.y1&&0===o.x2&&0===o.y2?(this.iasapi.setSelection(0,0,a.innerWidth(),a.innerHeight(),!0),this.iasapi.setOptions({show:!0}),this.iasapi.update()):d.crop(i,t,e)},intval:function(i){return 0|i},setDisabled:function(i,t){t?i.removeClass("disabled").prop("disabled",!1):i.addClass("disabled").prop("disabled",!0)},init:function(i){var t=this,e=g("#image-editor-"+t.postid),a=t.intval(g("#imgedit-x-"+i).val()),o=t.intval(g("#imgedit-y-"+i).val());t.postid!==i&&e.length&&t.close(t.postid),t.hold.w=t.hold.ow=a,t.hold.h=t.hold.oh=o,t.hold.xy_ratio=a/o,t.hold.sizer=parseFloat(g("#imgedit-sizer-"+i).val()),t.postid=i,g("#imgedit-response-"+i).empty(),g("#imgedit-panel-"+i).on("keypress",'input[type="text"]',function(i){var t=i.keyCode;if(36this.hold.oh||s&&s>this.hold.ow?i.css("visibility","visible"):i.css("visibility","hidden"))},getSelRatio:function(i){var t=this.hold.w,e=this.hold.h,a=this.intval(g("#imgedit-crop-width-"+i).val()),i=this.intval(g("#imgedit-crop-height-"+i).val());return a&&i?a+":"+i:t&&e?t+":"+e:"1:1"},filterHistory:function(i,t){var e,a,o,s=g("#imgedit-history-"+i).val(),n=[];if(""===s)return"";if(s=JSON.parse(s),0<(e=this.intval(g("#imgedit-undone-"+i).val())))for(;0').on("load",{history:i.history},function(i){var t,e=g("#imgedit-crop-"+o),a=d;""!==i.data.history&&(i=JSON.parse(i.data.history))[i.length-1].hasOwnProperty("c")&&(a.setDisabled(g("#image-undo-"+o),!0),g("#image-undo-"+o).trigger("focus")),e.empty().append(n),i=Math.max(a.hold.w,a.hold.h),t=Math.max(g(n).width(),g(n).height()),a.hold.sizer=t

'+i+"

"),t.toggleEditor(o,0,!0),wp.a11y.speak(i,"assertive")}).attr("src",ajaxurl+"?"+g.param(i))},action:function(t,i,e){var a,o,s,n,r=this;if(r.notsaved(t))return!1;if(i={action:"image-editor",_ajax_nonce:i,postid:t},"scale"===e){if(a=g("#imgedit-scale-width-"+t),o=g("#imgedit-scale-height-"+t),s=r.intval(a.val()),n=r.intval(o.val()),s<1)return a.trigger("focus"),!1;if(n<1)return o.trigger("focus"),!1;if(s===r.hold.ow||n===r.hold.oh)return!1;i.do="scale",i.fwidth=s,i.fheight=n}else{if("restore"!==e)return!1;i.do="restore"}r.toggleEditor(t,1),g.post(ajaxurl,i,function(i){g("#image-editor-"+t).empty().append(i.data.html),r.toggleEditor(t,0,!0),r._view&&r._view.refresh()}).done(function(i){i&&i.data.message.msg?wp.a11y.speak(i.data.message.msg):i&&i.data.message.error&&wp.a11y.speak(i.data.message.error)})},save:function(t,i){var e=this.getTarget(t),a=this.filterHistory(t,0),o=this;if(""===a)return!1;this.toggleEditor(t,1),i={action:"image-editor",_ajax_nonce:i,postid:t,history:a,target:e,context:g("#image-edit-context").length?g("#image-edit-context").val():null,do:"save"},g.post(ajaxurl,i,function(i){if(i.data.error)return g("#imgedit-response-"+t).html('"),d.close(t),void wp.a11y.speak(i.data.error);i.data.fw&&i.data.fh&&g("#media-dims-"+t).html(i.data.fw+" × "+i.data.fh),i.data.thumbnail&&g(".thumbnail","#thumbnail-head-"+t).attr("src",""+i.data.thumbnail),i.data.msg&&(g("#imgedit-response-"+t).html('"),wp.a11y.speak(i.data.msg)),o._view?o._view.save():d.close(t)})},open:function(e,i,t){this._view=t;var a=g("#image-editor-"+e),o=g("#media-head-"+e),s=g("#imgedit-open-btn-"+e),n=s.siblings(".spinner");if(!s.hasClass("button-activated"))return n.addClass("is-active"),g.ajax({url:ajaxurl,type:"post",data:{action:"image-editor",_ajax_nonce:i,postid:e,do:"open"},beforeSend:function(){s.addClass("button-activated")}}).done(function(i){var t;"-1"===i&&(t=r("Could not load the preview image."),a.html('")),i.data&&i.data.html&&a.html(i.data.html),o.fadeOut("fast",function(){a.fadeIn("fast",function(){t&&g(document).trigger("image-editor-ui-ready")}),s.removeClass("button-activated"),n.removeClass("is-active")}),d.init(e)})},imgLoaded:function(i){var t=g("#image-preview-"+i),e=g("#imgedit-crop-"+i);void 0===this.hold.sizer&&this.init(i),this.initCrop(i,t,e),this.setCropSelection(i,{x1:0,y1:0,x2:0,y2:0,width:t.innerWidth(),height:t.innerHeight()}),this.toggleEditor(i,0,!0)},focusManager:function(){setTimeout(function(){var i=g('.notice[role="alert"]');(i=i.length?i:g(".imgedit-wrap").find(":tabbable:first")).trigger("focus")},100)},initCrop:function(a,i,t){var o=this,s=g("#imgedit-sel-width-"+a),n=g("#imgedit-sel-height-"+a),i=g(i);i.data("imgAreaSelect")||(o.iasapi=i.imgAreaSelect({parent:t,instance:!0,handles:!0,keys:!0,minWidth:3,minHeight:3,onInit:function(i){g(i).next().css("position","absolute").nextAll(".imgareaselect-outer").css("position","absolute"),t.children().on("mousedown, touchstart",function(i){var t,e=!1;i.shiftKey&&(i=o.iasapi.getSelection(),t=o.getSelRatio(a),e=i&&i.width&&i.height?i.width+":"+i.height:t),o.iasapi.setOptions({aspectRatio:e})})},onSelectStart:function(){d.setDisabled(g("#imgedit-crop-sel-"+a),1)},onSelectEnd:function(i,t){d.setCropSelection(a,t)},onSelectChange:function(i,t){var e=d.hold.sizer;s.val(d.round(t.width/e)),n.val(d.round(t.height/e))}}))},setCropSelection:function(i,t){if(!(t=t||0)||t.width<3&&t.height<3)return this.setDisabled(g(".imgedit-crop","#imgedit-panel-"+i),1),this.setDisabled(g("#imgedit-crop-sel-"+i),1),g("#imgedit-sel-width-"+i).val(""),g("#imgedit-sel-height-"+i).val(""),g("#imgedit-selection-"+i).val(""),!1;t={x:t.x1,y:t.y1,w:t.width,h:t.height},this.setDisabled(g(".imgedit-crop","#imgedit-panel-"+i),1),g("#imgedit-selection-"+i).val(JSON.stringify(t))},close:function(i,t){if((t=t||!1)&&this.notsaved(i))return!1;this.iasapi={},this.hold={},this._view?this._view.back():g("#image-editor-"+i).fadeOut("fast",function(){g("#media-head-"+i).fadeIn("fast",function(){g("#imgedit-open-btn-"+i).trigger("focus")}),g(this).empty()})},notsaved:function(i){var t=g("#imgedit-history-"+i).val(),t=""!==t?JSON.parse(t):[];return this.intval(g("#imgedit-undone-"+i).val())