File: //proc/self/cwd/wp-content/new_update/plugins/crop-thumbnails/app/js/app.js
(function(t){function e(e){for(var i,n,r=e[0],c=e[1],l=e[2],u=0,d=[];u<r.length;u++)n=r[u],Object.prototype.hasOwnProperty.call(s,n)&&s[n]&&d.push(s[n][0]),s[n]=0;for(i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=c[i]);p&&p(e);while(d.length)d.shift()();return o.push.apply(o,l||[]),a()}function a(){for(var t,e=0;e<o.length;e++){for(var a=o[e],i=!0,r=1;r<a.length;r++){var c=a[r];0!==s[c]&&(i=!1)}i&&(o.splice(e--,1),t=n(n.s=a[0]))}return t}var i={},s={app:0},o=[];function n(e){if(i[e])return i[e].exports;var a=i[e]={i:e,l:!1,exports:{}};return t[e].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=t,n.c=i,n.d=function(t,e,a){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(a,i,function(e){return t[e]}.bind(null,i));return a},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/";var r=window["webpackJsonp"]=window["webpackJsonp"]||[],c=r.push.bind(r);r.push=e,r=r.slice();for(var l=0;l<r.length;l++)e(r[l]);var p=c;o.push([0,"chunk-vendors"]),a()})({0:function(t,e,a){t.exports=a("56d7")},"39c2":function(t,e,a){a("ac1f"),a("1276"),CROP_THUMBNAILS_DO_CACHE_BREAK=function(t){for(var e=jQuery,a=e(t),i=0;i<a.length;i++){var s=e(a[i]),o=s.attr("src"),n=o.split("?");s.attr("src",n[0]+"?&cacheBreak="+(new Date).getTime())}}},"55d5":function(t,e,a){(function(t){t.CROP_THUMBNAILS_VUE={app:null,components:{}}}).call(this,a("c8ba"))},"56d7":function(t,e,a){"use strict";a.r(e);a("e260"),a("e6cf"),a("cca6"),a("a79d"),a("7046"),a("83a8"),a("55d5"),a("39c2"),a("bc36");var i=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.cropData&&t.lang?a("div",{staticClass:"cptEditorInner",class:{loading:t.loading,cropEditorActive:t.croppingApi}},[t.loading?a("div",{staticClass:"cptWaitingWindow"},[a("div",{staticClass:"msg"},[t._v(" "+t._s(t.lang.waiting)+" "),t._m(0)])]):t._e(),t.cropData.hiddenOnPostType?a("div",{staticClass:"cptWaitingWindow cptCropDisabledMsg"},[a("div",{staticClass:"msg"},[t._v(t._s(t.lang.cropDisabled))])]):t._e(),t.cropData.noPermission?a("div",{staticClass:"cptWaitingWindow cptNoPermissionMsg"},[a("div",{staticClass:"msg"},[t._v(t._s(t.lang.noPermission))])]):t._e(),t.cropData.hiddenOnPostType||t.cropData.noPermission?t._e():a("div",{staticClass:"mainWindow"},[a("div",{staticClass:"cptSelectionPane",class:{cptImagesAreSelected:t.selectedImageSizes.length>0}},[a("div",{staticClass:"cptSelectionPaneInner"},[t.sourceImageHasOrientation?a("message",[t._v(t._s(t.lang.message_image_orientation))]):t._e(),a("div",{staticClass:"cptToolbar"},[a("label",{staticClass:"cptSameRatioMode"},[t._v(" "+t._s(t.lang.label_same_ratio_mode)+" "),a("select",{directives:[{name:"model",rawName:"v-model",value:t.sameRatioMode,expression:"sameRatioMode"}],on:{change:[function(e){var a=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){var e="_value"in t?t._value:t.value;return e}));t.sameRatioMode=e.target.multiple?a:a[0]},t.updateSameRatioMode]}},t._l(t.sameRatioModeOptions,(function(e){return a("option",{key:e.value,domProps:{value:e.value}},[t._v(t._s(e.text))])})),0)]),a("button",{staticClass:"button cptDeselectAll",attrs:{type:"button"},on:{click:function(e){return t.makeAllInactive()}}},[t._v(t._s(t.lang.label_deselect_all))])]),t.filteredImageSizes.length>0?a("ul",{staticClass:"cptImageSizelist"},t._l(t.filteredImageSizes,(function(e){return a("li",{key:e.nameLabel,class:t.imageSizeClass(e),on:{click:function(a){return t.toggleActive(e)}}},[a("section",{staticClass:"cptImageSizeInner"},["group"!==t.sameRatioMode?[a("header",[t._v(t._s(e.nameLabel))]),t.isLowRes(e)?a("div",{staticClass:"lowResWarning",attrs:{title:t.lang.lowResWarning}},[a("span",[t._v("!")])]):t._e(),!t.isLowRes(e)&&e.notYetCropped?a("div",{staticClass:"notYetCropped",attrs:{title:t.lang.notYetCropped}},[a("span",{staticClass:"dashicons dashicons-image-crop"})]):t._e(),a("div",{staticClass:"dimensions"},[t._v(t._s(t.lang.dimensions)+" "+t._s(e.width)+" x "+t._s(e.height)+" "+t._s(t.lang.pixel))]),a("div",{staticClass:"ratio"},[t._v(t._s(t.lang.ratio)+" "+t._s(e.printRatio))])]:[a("header",[t._v(t._s(e.printRatio))]),t.isImageInGroupNotYetCropped(e.printRatio)?a("div",{staticClass:"notYetCropped",attrs:{title:t.lang.notYetCropped}},[a("span",{staticClass:"dashicons dashicons-image-crop"})]):t._e()],a("loadingcontainer",{attrs:{image:e.url+"?cacheBreak="+e.cacheBreak}},[a("div",{staticClass:"cptImageBgContainer",style:{"background-image":"url("+e.url+"?cacheBreak="+e.cacheBreak+")"}})])],2)])})),0):a("div",{staticClass:"cptImageSizelist"},[a("div",{staticClass:"noImageSizesAvailable"},[t._v(" "+t._s(t.lang.infoNoImageSizesAvailable)+" ")])])],1)]),a("div",{staticClass:"cptCropPane"},[a("div",{staticClass:"info"},[a("h3",[t._v(t._s(t.lang.rawImage))]),a("div",{staticClass:"dimensions"},[t._v(t._s(t.lang.dimensions)+" "+t._s(t.cropData.sourceImage.full.width)+" x "+t._s(t.cropData.sourceImage.full.height)+" "+t._s(t.lang.pixel))]),a("div",{staticClass:"ratio"},[t._v(t._s(t.lang.ratio)+" "+t._s(t.cropData.sourceImage.full.printRatio))])]),a("button",{staticClass:"button cptGenerate",class:{"button-primary":t.croppingApi},attrs:{type:"button",disabled:!t.croppingApi},on:{click:function(e){return t.cropThumbnails()}}},[t._v(t._s(t.lang.label_crop))]),a("div",{staticClass:"cropContainer"},[a("img",{ref:"cptCroppingImage",staticClass:"cptCroppingImage",attrs:{src:t.cropImage.url}})]),t.selectedImageSizes.length>0?a("div",{staticClass:"selectionInfo"},[a("h4",[t._v(t._s(t.lang.headline_selected_image_sizes))]),a("ul",t._l(t.selectedImageSizes,(function(e){return a("li",{key:e.nameLabel},[a("div",[a("span",{staticClass:"name"},[t._v(t._s(e.nameLabel))]),t._v(" "),a("span",{staticClass:"dimensions"},[t._v("("+t._s(t.lang.dimensions)+" "+t._s(e.width)+" x "+t._s(e.height)+" "+t._s(t.lang.pixel)+")")])]),t.isLowRes(e)?a("div",{staticClass:"lowResWarning"},[a("span",{staticClass:"icon"},[t._v("!")]),a("span",{staticClass:"text"},[t._v(t._s(t.lang.lowResWarning))])]):t._e(),e.notYetCropped?a("div",{staticClass:"notYetCropped"},[a("span",{staticClass:"icon dashicons dashicons-image-crop"}),a("span",{staticClass:"text"},[t._v(t._s(t.lang.notYetCropped))])]):t._e()])})),0),a("hr")]):t._e(),a("div",{staticClass:"instructionInfo"},[a("h4",[t._v(t._s(t.lang.instructions_header))]),a("ul",{staticClass:"step-info"},[a("li",[t._v(t._s(t.lang.instructions_step_1))]),a("li",[t._v(t._s(t.lang.instructions_step_2))]),a("li",[t._v(t._s(t.lang.instructions_step_3))])])]),a("div",[t.cropData.options.debug_js?a("button",{staticClass:"button",attrs:{type:"button"},on:{click:function(e){return t.showDebugClick("js")}}},[t._v("show JS-Debug")]):t._e(),t.cropData.options.debug_data&&null!==t.dataDebug?a("button",{staticClass:"button",attrs:{type:"button"},on:{click:function(e){return t.showDebugClick("data")}}},[t._v("show Data-Debug")]):t._e(),"data"===t.showDebugType?a("pre",[t._v(t._s(t.dataDebug))]):t._e(),"js"===t.showDebugType?a("pre",[a("br"),t._v("cropImage:"+t._s(t.cropImage)),a("br"),t._v("cropData:"+t._s(t.cropData))]):t._e()])])])]):t._e()},s=[function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("div",{staticClass:"cptLoadingSpinner"})])}],o=(a("a9e3"),a("4de4"),a("159b"),a("b0c0"),function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"loadingcontainer",class:t.status},[a("img",{staticStyle:{display:"none"},attrs:{src:t.image}}),t._t("default"),a("transition",{attrs:{name:"fade"}},["loading"===t.status?a("div",{staticClass:"loadingMsg"},[a("div",{staticClass:"cptLoadingSpinner"})]):t._e()])],2)}),n=[],r={props:{image:{required:!0,type:String}},data:function(){return{status:null}},mounted:function(){this.setup()},watch:{image:function(){this.setup()}},methods:{setup:function(){var t=this;this.setStart(),setTimeout((function(){var e=imagesLoaded(t.$el);e.once("done",(function(){"failed"!==t.status&&t.setComplete()})).once("fail",(function(){t.setFailed()}))}),300)},setComplete:function(){this.status="completed"},setStart:function(){this.status="loading"},setFailed:function(){this.status="failed"}}},c=r,l=a("2877"),p=Object(l["a"])(c,o,n,!1,null,null,null),u=p.exports,d=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.closed?t._e():a("div",{staticClass:"notice notice-warning is-dismissible cptMessage",attrs:{"aria-role":"alert"}},[a("p",[t._t("default")],2),a("button",{staticClass:"notice-dismiss",attrs:{type:"button","aria-label":"close"},on:{click:function(e){return t.close()}}})])},g=[],m={props:{},data:function(){return{closed:!1}},methods:{close:function(){this.closed=!0}}},h=m,_=Object(l["a"])(h,d,g,!1,null,null,null),f=_.exports,v={components:{loadingcontainer:u,message:f},props:{imageId:{required:!0,type:Number},posttype:{required:!1,type:String,default:null}},data:function(){return{cropData:null,loading:!1,croppingApi:null,currentCropSize:null,lang:null,nonce:null,showDebugType:null,dataDebug:null,sameRatioMode:null,sameRatioModeOptions:[]}},mounted:function(){this.loadCropData()},computed:{cropImage:function(){if(void 0!==this.cropData){var t=this.cropData.sourceImage.full,e=Math.round(10*t.ratio);return null!==this.cropData.sourceImage.large&&this.cropData.sourceImage.large.width>745&&e===Math.round(10*this.cropData.sourceImage.large.ratio)&&this.cropData.sourceImage.full.url!==this.cropData.sourceImage.large.url&&(t=this.cropData.sourceImage.large),null!==this.cropData.sourceImage.medium_large&&this.cropData.sourceImage.medium_large.width>745&&e===Math.round(10*this.cropData.sourceImage.medium_large.ratio)&&this.cropData.sourceImage.full.url!==this.cropData.sourceImage.medium_large.url&&(t=this.cropData.sourceImage.medium_large),t}},filteredImageSizes:function(){var t=this.cropData.imageSizes;if("group"===this.sameRatioMode){var e=[];t=t.filter((function(t){var a=e.indexOf(t.printRatio);return!(a>-1)&&(e.push(t.printRatio),!0)}))}return t},selectedImageSizes:function(){return this.cropData.imageSizes.filter((function(t){return t.active}))},sourceImageHasOrientation:function(){try{if("string"===typeof this.cropData.sourceImageMeta.orientation&&"1"!==this.cropData.sourceImageMeta.orientation&&"0"!==this.cropData.sourceImageMeta.orientation)return!0}catch(t){}return!1}},methods:{isImageInGroupNotYetCropped:function(t){return this.cropData.imageSizes.filter((function(e){return e.printRatio===t&&e.notYetCropped})).length>0},setupRatioMode:function(){this.sameRatioModeOptions=[{value:null,text:this.lang.label_same_ratio_mode_nothing},{value:"select",text:this.lang.label_same_ratio_mode_select},{value:"group",text:this.lang.label_same_ratio_mode_group}];try{this.sameRatioMode=localStorage.getItem("cpt_same_ratio_mode")}catch(t){}},updateSameRatioMode:function(){try{localStorage.setItem("cpt_same_ratio_mode",this.sameRatioMode)}catch(t){}},imageSizeClass:function(t){var e={active:t.active};return e["cptImageSize-"+t.nameLabel]=!0,e},loadCropData:function(){var t=this,e={action:"cpt_cropdata",imageId:this.imageId,posttype:this.posttype};t.loading=!0,jQuery.get(ajaxurl,e,(function(e){t.makeAllInactive(e.imageSizes),t.addCacheBreak(e.imageSizes),t.cropData=e,t.lang=t.cropData.lang,t.nonce=t.cropData.nonce,delete t.cropData.nonce})).fail((function(e){t.cropData=e.responseJSON,t.lang=t.cropData.lang,t.nonce=t.cropData.nonce,delete t.cropData.nonce,403===e.status&&(t.cropData.noPermission=!0)})).always((function(){t.loading=!1,t.setupRatioMode(),t.cropData&&t.cropData.imageSizes&&(t.cropData.imageSizes=t.cropData.imageSizes.filter((function(t){return!t.hideByPostType})),t.cropData.imageSizes.forEach((function(e){e.notYetCropped=e.url===t.cropData.sourceImage.full.url})))}))},isLowRes:function(t){return!(!t.active||null===this.currentCropSize)&&(0===t.width&&this.currentCropSize.height<t.height||(0===t.height&&this.currentCropSize.width<t.width||(9999===t.height?this.currentCropSize.width<t.width:9999===t.width?this.currentCropSize.height<t.height:this.currentCropSize.width<t.width||this.currentCropSize.height<t.height)))},toggleActive:function(t){var e=!t.active;!1===t.active&&this.makeAllInactive(),"select"===this.sameRatioMode||"group"===this.sameRatioMode?this.cropData.imageSizes.forEach((function(a){a.printRatio===t.printRatio&&(a.active=e)})):t.active=e,this.selectedImageSizes.length>0?this.activateCropArea():this.deactivateCropArea()},makeAllInactive:function(t){void 0===t&&(t=this.cropData.imageSizes),t.forEach((function(t){t.active=!1,t.lowResWarning=!1})),this.deactivateCropArea()},addCacheBreak:function(t){void 0===t&&(t=this.cropData.imageSizes),t.forEach((function(t){t.cacheBreak=Date.now()}))},updateCurrentCrop:function(){var t=null;if(null!==this.croppingApi){var e=this.croppingApi.tellSelect();t={width:Math.round(e.w),height:Math.round(e.h)}}this.currentCropSize=t},getPreselect:function(t,e,a){var i=0,s=0,o=t,n=e,r=t/e;return r<=a?(s=e/2-t/a/2,n=e-s):(i=t/2-e*a/2,o=t-i),[i,s,o,n]},activateCropArea:function(){var t=this;t.deactivateCropArea();var e={trueSize:[t.cropData.sourceImage.full.width,t.cropData.sourceImage.full.height],aspectRatio:0,setSelect:[],onSelect:t.updateCurrentCrop};t.selectedImageSizes.forEach((function(t){0===e.aspectRatio&&(e.aspectRatio=t.ratio),e.aspectRatio!==t.ratio&&console.info('Crop Thumbnails: print ratio is different from normal ratio on image size "'+t.name+'".')})),e.setSelect=this.getPreselect(t.cropData.sourceImage.full.width,t.cropData.sourceImage.full.height,e.aspectRatio),t.cropData.options.debug_js&&console.info("Cropping options",e),jQuery(this.$refs.cptCroppingImage).Jcrop(e,(function(){t.croppingApi=this,t.updateCurrentCrop()}))},deactivateCropArea:function(){null!==this.croppingApi&&(this.croppingApi.destroy(),this.croppingApi=null,this.currentCropSize=null)},showDebugClick:function(t){this.showDebugType===t?this.showDebugType=null:this.showDebugType=t},cropThumbnails:function(){var t=this;function e(){var e=[];return t.selectedImageSizes.forEach((function(t){t.active&&e.push({name:t.name,width:t.width,height:t.height,ratio:t.ratio,crop:t.crop})})),e}if(!t.loading&&null!==t.croppingApi){t.loading=!0;var a={action:"cptSaveThumbnail",_ajax_nonce:t.nonce,cookie:encodeURIComponent(document.cookie),crop_thumbnails:JSON.stringify({selection:t.croppingApi.tellSelect(),sourceImageId:t.cropData.sourceImageId,activeImageSizes:e()})};jQuery.post(ajaxurl,a,null,"json").done((function(e){if(t.cropData.options.debug_data&&(t.dataDebug=e.debug,console.log("Save Function Debug",e.debug)),void 0===e.error)return void 0!==e.success?(void 0!==e.changedImageName&&t.selectedImageSizes.forEach((function(t,a){void 0!==e.changedImageName[t.name]&&(t.url=e.changedImageName[t.name])})),void t.addCacheBreak(t.selectedImageSizes)):void 0;alert(e.error)})).fail((function(e){alert(t.lang.script_connection_error);var i={status:e.status,statusText:e.statusText,requestUrl:ajaxurl,requestParams:a};console.error("crop-thumbnails connection error",i)})).always((function(){t.loading=!1}))}}}},C=v,b=Object(l["a"])(C,i,s,!1,null,null,null),D=b.exports,y=a("a026");CROP_THUMBNAILS_VUE.modal=function(){var t=jQuery,e=this;function a(){t("#cpt_Modal .cpt_ModalClose, #cpt_Modal").unbind("click"),t("#cpt_Modal").remove(),t("body").removeClass("cpt_ModalIsOpen")}e.close=function(i){CROP_THUMBNAILS_VUE.app.$destroy(),CROP_THUMBNAILS_VUE.app=null,a(),t("body").trigger("cropThumbnailModalClosed"),document.removeEventListener("keydown",e.closeByEscKey,!0)},e.closeByBackground=function(t){t.target==document.getElementById("cpt_Modal")&&e.close(t)},e.closeByEscKey=function(t){t.keyCode&&27!==t.keyCode||(t.stopPropagation(),e.close(t))},e.open=function(a,i,s){var o=a,n="";n+='<div id="cpt_Modal" class="cpt_Modal">',n+='<div class="cpt_ModalDialog" role="dialog" aria-label="'+t("<div>").text(s).html()+'">',n+='<button type="button" class="cpt_ModalClose" aria-label="close">×</button>',n+='<div class="cpt_ModalHeader"><div class="cpt_ModalTitle">'+s+"</div></div>",n+='<div class="cpt_ModalContent" id="cpt_crop_editor">',n+='<cropeditor :image-id="'+o+'"',"string"===typeof i&&(n+=' posttype="'+i+'"'),n+="></cropeditor>",n+="</div>",n+="</div>",n+="</div>",t("body").prepend(n).addClass("cpt_ModalIsOpen"),t("#cpt_Modal .cpt_ModalClose").click(e.close),t("#cpt_Modal").on("touchstart mousedown",e.closeByBackground),document.addEventListener("keydown",e.closeByEscKey,!0),CROP_THUMBNAILS_VUE.app=new y["a"]({el:"#cpt_crop_editor",mounted:function(){console.log("cpt_crop_editor mounted")},components:{cropeditor:D}})}};var I=function(){var t=this,e=t.$createElement,a=t._self._c||e;return t.settingsData?a("div",[a("div",{staticClass:"cptSettingsPostListDescription"},[t._v(t._s(t.settingsData.lang.choose_image_sizes))]),a("ul",{staticClass:"cptSettingsPostList"},t._l(t.settingsData.post_types,(function(e){return a("li",{key:e.name},[e?a("section",[a("header",[a("h3",[t._v(t._s(e.label))])]),a("ul",{staticClass:"cptImageSizes"},[t._l(t.settingsData.image_sizes,(function(i){return[i.crop?a("li",{key:i.id},[a("label",[a("input",{attrs:{type:"checkbox",name:"crop-post-thumbs[hide_size]["+e.name+"]["+i.id+"]"},domProps:{value:i.id,checked:t.isImageSizeHidden(e.name,i.id)}}),a("span",{staticClass:"name"},[t._v(t._s(i.name))]),i.name!==i.id?a("span",{staticClass:"defaultName"},[t._v("("+t._s(i.id)+")")]):t._e()])]):t._e()]}))],2),a("label",[a("input",{attrs:{id:"cpt_settings_post",type:"checkbox",name:"crop-post-thumbs[hide_post_type]["+e.name+"]",value:"1"},domProps:{checked:t.isButtonHiddenOnPostType(e.name)}}),t._v(" "+t._s(t.settingsData.lang.hide_on_post_type)+" ")])]):t._e()])})),0)]):t._e()},S=[],w={props:{settings:{required:!0}},components:{},data:function(){return{settingsData:null}},mounted:function(){this.settingsData=JSON.parse(this.settings)},methods:{isButtonHiddenOnPostType:function(t){return this.settingsData.options&&this.settingsData.options.hide_post_type&&"1"===this.settingsData.options.hide_post_type[t]},isImageSizeHidden:function(t,e){return this.settingsData.options&&this.settingsData.options.hide_size&&this.settingsData.options.hide_size[t]&&"1"===this.settingsData.options.hide_size[t][e]}}},M=w,z=Object(l["a"])(M,I,S,!1,null,null,null),R=z.exports;jQuery((function(t){t("body.settings_page_page-cpt").length>0&&(CROP_THUMBNAILS_VUE.app=new y["a"]({el:"#cpt_settings_settingsscreen",components:{cptSettingsscreen:R}}))}))},7046:function(t,e,a){},"83a8":function(t,e){(function(){var t={}})()},bc36:function(t,e){jQuery((function(t){t(document).on("click",".cropThumbnailsLink",(function(e){e.preventDefault();var a=t(this).data("cropthumbnail"),i=t(this).attr("title"),s=null;void 0!==a.posttype&&(s=a.posttype);var o=new CROP_THUMBNAILS_VUE.modal;o.open(a.image_id,s,i)}))}))}});
//# sourceMappingURL=app.js.map