2024-08-28 18:45:11 +02:00
|
|
|
!function(c){var s=wp.i18n.__,d=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,toggleCropTool:function(t,i,e){var a,o,r,n=c("#image-preview-"+t),s=this.iasapi.getSelection();d.toggleControls(e),"false"==("true"===c(e).attr("aria-expanded")?"true":"false")?(this.iasapi.cancelSelection(),d.setDisabled(c(".imgedit-crop-clear"),0)):(d.setDisabled(c(".imgedit-crop-clear"),1),e=c("#imgedit-start-x-"+t).val()?c("#imgedit-start-x-"+t).val():0,a=c("#imgedit-start-y-"+t).val()?c("#imgedit-start-y-"+t).val():0,o=c("#imgedit-sel-width-"+t).val()?c("#imgedit-sel-width-"+t).val():n.innerWidth(),r=c("#imgedit-sel-height-"+t).val()?c("#imgedit-sel-height-"+t).val():n.innerHeight(),isNaN(s.x1)&&(this.setCropSelection(t,{x1:e,y1:a,x2:o,y2:r,width:o,height:r}),s=this.iasapi.getSelection()),0===s.x1&&0===s.y1&&0===s.x2&&0===s.y2?this.iasapi.setSelection(0,0,n.innerWidth(),n.innerHeight(),!0):this.iasapi.setSelection(e,a,o,r,!0),this.iasapi.setOptions({show:!0}),this.iasapi.update())},handleCropToolClick:function(t,i,e){e.classList.contains("imgedit-crop-clear")?(this.iasapi.cancelSelection(),d.setDisabled(c(".imgedit-crop-apply"),0),c("#imgedit-sel-width-"+t).val(""),c("#imgedit-sel-height-"+t).val(""),c("#imgedit-start-x-"+t).val("0"),c("#imgedit-start-y-"+t).val("0"),c("#imgedit-selection-"+t).val("")):d.crop(t,i,e)},intval:function(t){return 0|t},setDisabled:function(t,i){i?t.removeClass("disabled").prop("disabled",!1):t.addClass("disabled").prop("disabled",!0)},init:function(e){var t=this,i=c("#image-editor-"+t.postid);t.postid!==e&&i.length&&t.close(t.postid),t.hold.sizer=parseFloat(c("#imgedit-sizer-"+e).val()),t.postid=e,c("#imgedit-response-"+e).empty(),c("#imgedit-panel-"+e).on("keypress",function(t){var i=c("#imgedit-nonce-"+e).val();26===t.which&&t.ctrlKey&&d.undo(e,i),25===t.which&&t.ctrlKey&&d.redo(e,i)}),c("#imgedit-panel-"+e).on("keypress",'input[type="text"]',function(t){var i=t.keyCode;if(36<i&&i<41&&c(this).trigger("blur"),13===i)return t.preventDefault(),t.stopPropagation(),!1}),c(document).on("image-editor-ui-ready",this.focusManager)},calculateImgSize:function(t){var i=this,e=i.intval(c("#imgedit-x-"+t).val()),a=i.intval(c("#imgedit-y-"+t).val());i.hold.w=i.hold.ow=e,i.hold.h=i.hold.oh=a,i.hold.xy_ratio=e/a,i.hold.sizer=parseFloat(c("#imgedit-sizer-"+t).val()),i.currentCropSelection=null},toggleEditor:function(t,i,e){t=c("#imgedit-wait-"+t);i?t.fadeIn("fast"):t.fadeOut("fast",function(){e&&c(document).trigger("image-editor-ui-ready")})},togglePopup:function(t){var i=c(t),t=c(t).attr("aria-controls"),t=c("#"+t);return i.attr("aria-expanded","false"===i.attr("aria-expanded")?"true":"false"),t.toggleClass("imgedit-popup-menu-open").slideToggle("fast").css({"z-index":2e5}),"true"===i.attr("aria-expanded")&&t.find("button").first().trigger("focus"),!1},monitorPopup:function(){var e=document.querySelector(".imgedit-rotate-menu-container"),a=document.querySelector(".imgedit-rotate-menu-container .imgedit-rotate");return setTimeout(function(){var t=document.activeElement,i=e.contains(t);t&&!i&&"true"===a.getAttribute("aria-expanded")&&d.togglePopup(a)},100),!1},browsePopup:function(t,i){var e=c(i),i=c(i).parent(".imgedit-popup-menu").find("button"),e=i.index(e),a=e-1,e=e+1,o=i.length,o=(a<0&&(a=o-1),e===o&&(e=0),!1);return 40===t.keyCode?o=i.get(e):38===t.keyCode&&(o=i.get(a)),o&&(o.focus(),t.preventDefault()),!1},closePopup:function(t){var t=c(t).parent(".imgedit-popup-menu"),i=t.attr("id");return c('button[aria-controls="'+i+'"]').attr("aria-expanded","false").trigger("focus"),t.toggleClass("imgedit-popup-menu-open").slideToggle("fast"),!1},toggleHelp:function(t){t=c(t);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},toggleControls:function(t){var t=c(t),i=c("#"+t.attr("aria-controls"));return t.attr("aria-expanded","false"===t.attr("aria-expanded")?"true":"false"),i.parent(".imgedit-group").toggleClass("imgedit-panel-active"),!1},getTarget:function(t){var i=c("#imgedit-save-
|