WordPress/wp-admin/js/image-edit.min.js

2 lines
10 KiB
JavaScript
Raw Normal View History

/*! This file is auto-generated */
!function(m){var l=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,handleCropToolClick:function(i,t,e){var a=m("#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()):l.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=m("#image-editor-"+t.postid),a=t.intval(m("#imgedit-x-"+i).val()),o=t.intval(m("#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(m("#imgedit-sizer-"+i).val()),t.postid=i,m("#imgedit-response-"+i).empty(),m('input[type="text"]',"#imgedit-panel-"+i).keypress(function(i){var t=i.keyCode;if(36<t&&t<41&&m(this).blur(),13===t)return i.preventDefault(),i.stopPropagation(),!1}),m(document).on("image-editor-image-loaded",this.focusManager)},toggleEditor:function(i,t){var e=m("#imgedit-wait-"+i);t?e.fadeIn("fast"):e.fadeOut("fast")},toggleHelp:function(i){var t=m(i);return t.attr("aria-expanded","false"===t.attr("aria-expanded")?"true":"false").parents(".imgedit-group-top").toggleClass("imgedit-help-toggled").find(".imgedit-help").slideToggle("fast"),!1},getTarget:function(i){return m('input[name="imgedit-target-'+i+'"]:checked',"#imgedit-save-target-"+i).val()||"full"},scaleChanged:function(i,t,e){var a=m("#imgedit-scale-width-"+i),o=m("#imgedit-scale-height-"+i),s=m("#imgedit-scale-warn-"+i),n="",d="";!1!==this.validateNumeric(e)&&(t?(d=""!==a.val()?Math.round(a.val()/this.hold.xy_ratio):"",o.val(d)):(n=""!==o.val()?Math.round(o.val()*this.hold.xy_ratio):"",a.val(n)),d&&d>this.hold.oh||n&&n>this.hold.ow?s.css("visibility","visible"):s.css("visibility","hidden"))},getSelRatio:function(i){var t=this.hold.w,e=this.hold.h,a=this.intval(m("#imgedit-crop-width-"+i).val()),o=this.intval(m("#imgedit-crop-height-"+i).val());return a&&o?a+":"+o:t&&e?t+":"+e:"1:1"},filterHistory:function(i,t){var e,a,o,s,n=m("#imgedit-history-"+i).val(),d=[];if(""===n)return"";if(n=JSON.parse(n),0<(e=this.intval(m("#imgedit-undone-"+i).val())))for(;0<e;)n.pop(),e--;if(t){if(!n.length)return this.hold.w=this.hold.ow,this.hold.h=this.hold.oh,"";(o=(o=n[n.length-1]).c||o.r||o.f||!1)&&(this.hold.w=o.fw,this.hold.h=o.fh)}for(a in n)(s=n[a]).hasOwnProperty("c")?d[a]={c:{x:s.c.x,y:s.c.y,w:s.c.w,h:s.c.h}}:s.hasOwnProperty("r")?d[a]={r:s.r.r}:s.hasOwnProperty("f")&&(d[a]={f:s.f.f});return JSON.stringify(d)},refreshEditor:function(n,i,d){var t,r,e=this;e.toggleEditor(n,1),t={action:"imgedit-preview",_ajax_nonce:i,postid:n,history:e.filterHistory(n,1),rand:e.intval(1e6*Math.random())},r=m('<img id="image-preview-'+n+'" alt="" />').on("load",{history:t.history},function(i){var t,e,a,o=m("#imgedit-crop-"+n),s=l;""!==i.data.history&&(a=JSON.parse(i.data.history))[a.length-1].hasOwnProperty("c")&&(s.setDisabled(m("#image-undo-"+n),!0),m("#image-undo-"+n).focus()),o.empty().append(r),t=Math.max(s.hold.w,s.hold.h),e=Math.max(m(r).width(),m(r).height()),s.hold.sizer=e<t?e/t:1,s.initCrop(n,r,o),null!=d&&d(),m("#imgedit-history-"+n).val()&&"0"===m("#imgedit-undone-"+n).val()?m("input.imgedit-submit-btn","#imgedit-panel-"+n).removeAttr("disabled"):m("input.imgedit-submit-btn","#imgedit-panel-"+n).prop("disabled",!0),s.toggleEditor(n,0)}).on("error",function(){m("#imgedit-crop-"+n).empty().append('<div class="error"><p>'+imageEditL10n.error+"</p></div>"),e.toggleEditor(n,0)}).attr("src",ajaxurl+"?"+m.param(t))},action:function(t,i,e){var a,o,s,n,d,r=this;if(r.notsaved(t))return!1;if(a={action:"image-editor",_ajax_nonce:i,postid:t},"scale"===e){if(o=m("#imgedit-scale-width-"+t),s=m("#imgedit-scale-height-"+t),n=r.intval(o.val()),d=r.intval(s.val()),n<1)return o.focus(),!1;if(d<1)return s.focus(),!1;if(n===r