mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-17 21:53:43 +09:00
1 line
2.0 KiB
JavaScript
1 line
2.0 KiB
JavaScript
"object"!=typeof window.UM&&(window.UM={}),"object"!=typeof UM.frontend&&(UM.frontend={}),UM.frontend={cropper:{obj:null,init:function(){var o=jQuery(".um-modal .um-single-image-preview img").first();if(o.length&&""!==o.attr("src")){UM.frontend.cropper.obj&&UM.frontend.cropper.destroy();var t=jQuery(".um-modal .um-single-image-preview"),n=o.parent().data("crop"),r=o.parent().data("min_width"),i=o.parent().data("min_height"),d=o.parent().data("ratio"),a=jQuery(".um-modal").find("#um_upload_single").data("ratio"),a=(a&&(d=a.split(":")[0]),jQuery(window).height()-(jQuery(".um-modal-footer a").height()+20)-50-jQuery(".um-modal-header:visible").height());o.css({height:"auto"}),t.css({height:"auto"}),jQuery(window).height()<=400?(t.css({height:a+"px","max-height":a+"px"}),o.css({height:"auto"})):(o.css({height:"auto","max-height":a+"px"}),t.css({height:o.height(),"max-height":a+"px"}));let e;"square"===n?e={minWidth:r,minHeight:i,dragCrop:!1,aspectRatio:1,zoomable:!1,rotatable:!1,dashed:!1}:"cover"===n?(0<Math.round(r/d)&&(i=Math.round(r/d)),e={minWidth:r,minHeight:i,dragCrop:!1,aspectRatio:d,zoomable:!1,rotatable:!1,dashed:!1}):"user"===n&&(e={minWidth:r,minHeight:i,dragCrop:!0,aspectRatio:"auto",zoomable:!1,rotatable:!1,dashed:!1}),e&&(UM.frontend.cropper.obj=new Cropper(o[0],e))}},destroy:function(){0<jQuery(".cropper-container").length&&UM.frontend.cropper.obj&&(UM.frontend.cropper.obj.destroy(),UM.frontend.cropper.obj=null)}},iframe:{resize:function(e){let o;o=150<e.contentWindow.document.documentElement.scrollHeight&&e.contentWindow.document.documentElement.scrollHeight>e.contentWindow.document.documentElement.offsetHeight?e.contentWindow.document.documentElement.scrollHeight:e.contentWindow.document.documentElement.offsetHeight,e.style.height=o+"px"}}},wp.hooks.addAction("um_remove_modal","um_common_frontend",function(){UM.frontend.cropper.destroy()}),wp.hooks.addAction("um_after_removing_preview","um_common_frontend",function(){UM.frontend.cropper.destroy()}),wp.hooks.addAction("um_window_resize","um_common_frontend",function(){UM.frontend.cropper.destroy()}); |