HamroKhanpin/hamrokhaanpaan/wp-content/__plugins/wp-optimize/js/wpo-images-view-3-2-3.min.js
2024-04-29 13:12:44 +05:45

1 line
6.6 KiB
JavaScript

WP_Optimize_Images_View=function(e){function t(e,t,i){var a,o,n,_=e,c=!1;if(t&&e)for(a=C(O).index(C("#"+e)),o=C(O).index(C("#"+t)),-1==a&&(a=o),-1==o&&(o=a),a<o?(n=C(O).eq(a).closest(I),t=C(O).eq(o).attr("id")):(n=C(O).eq(o).closest(I),t=C(O).eq(a).attr("id"));!c;)i?(n.addClass("selected"),C(O,n).prop("checked",i)):(n.removeClass("selected"),C(O,n).prop("checked",i)),C(O,n).attr("id")==t&&(c=!0),n=n.next();else i?C("#"+_).closest(I).addClass("selected"):C("#"+_).closest(I).removeClass("selected");s(0==d().length)}function s(e){D.action_buttons&&C.each(D.action_buttons,function(t,s){s.prop("disabled",e)})}function i(){if(D.hide_when_empty){var e=C([".",D.image_container_class,":visible"].join(""),B).length;0===e?(0==C(".wpo-images-view-empty",B).length&&B.append(C('<div class="wpo-images-view-empty wpo-fieldgroup" />').text(D.no_images_found_message)),C(".wpo-images-view-empty",B).show()):C(".wpo-images-view-empty",B).hide(),C.each(D.hide_when_empty,function(t,s){e>0?s.show():s.hide()})}}function a(){m()&&(i(),s(0==d().length))}function o(){B.scrollTop()+B.height()+100>B[0].scrollHeight&&"function"==typeof D.load_next_page_callback&&D.load_next_page_callback()}function n(e,t,s,i,a,o){var n,_="image_"+(65536*(1+Math.random())|0).toString(16).substring(1),c="";if(D.row_action_buttons)for(n in D.row_action_buttons)D.row_action_buttons.hasOwnProperty(n)&&(c+=['<button href="javascript: ;" class="',D.row_action_buttons[n]["class"]?D.row_action_buttons[n]["class"]:"",'"',' title="',D.row_action_buttons[n].hint?D.row_action_buttons[n].hint:"",'">',D.row_action_buttons[n].title?D.row_action_buttons[n].title:"","</button>"].join(""));z.hasOwnProperty(e)||(z[e]=0),z[e]++,B.append(['\t\t\t<div class="',D.image_container_class," ",D.image_container_custom_classes," ",D.image_container_blog_class_prefix,e,'">\t\t\t\t<a class="button ',D.view_image_btn_link_class,'" href="',s,'" target="_blank">',D.view_image_btn_text,"</a>",'<div class="',D.row_id_class,'">\t\t\t\t\t<input id="',_,'" type="checkbox" class="',D.checkbox_class,'" value="',t,'">\t\t\t\t</div>\t\t\t\t<div class="',D.row_thumb_class,'">\t\t\t\t\t<a href="',s,'" target="_blank">\t\t\t\t\t\t<img class="lazyload" src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=" data-src="',i,'" title="',a,'" alt="',a,'">\t\t\t\t\t</a>\t\t\t\t</div>\t\t\t\t<div class="',D.row_file_class,'">\t\t\t\t\t<a href="',s,'" target="_blank">',o,'</a>\t\t\t\t</div>\t\t\t\t<div class="',D.row_action_class,'">',c,'</div>\t\t\t\t<label for="',_,'" class="',D.label_class,'">\t\t\t\t\t<div class="thumbnail">\t\t\t\t\t\t<img class="lazyload" src="data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=" data-src="',i,'" title="',a,'" alt="',a,'">\t\t\t\t\t</div>\t\t\t\t</label>\t\t\t</div>'].join(""))}function _(e){C(I,B).hide(),C([".",D.image_container_blog_class_prefix,e].join(""),B).show(),a()}function c(e){return z.hasOwnProperty(e)?z[e]:0}function l(e){return C([".",D.image_container_blog_class_prefix,e].join(""),B).length}function r(e){e!==Q&&(Q=e,e===P.GRID&&B.removeClass(D.list_mode_class),e===P.LIST&&B.addClass(D.list_mode_class))}function d(){var e=[];return 0==C('input[type="checkbox"]',B).length?e:(C([".",D.image_container_class,":visible input:checked"].join(""),B).each(function(){e.push(C(this).val())}),e)}function u(){var e=[".",D.image_container_class].join("");C([e,":visible input:checked"].join(""),B).each(function(){C(this).closest(e).remove()})}function h(){B.show(),C(D.related_elements).each(function(){C(this).show()}),a(),o()}function p(){B.hide(),C(D.related_elements).each(function(){C(this).hide()})}function m(){return B.is(":visible")}function g(){w(wpoptimize.loading_data,"",D.loader_additional_html)}function w(e,t,s){t=t?t:"",s=s?s:"",B.css({"min-height":"220px"}),B.append(['<div class="wpo_shade">','<div class="wpo_shade_inner">','<span class="dashicons dashicons-update-alt wpo-rotate"></span>',"<h4>",e,"</h4>",'<p class="wpo-shade-progress-message">',t,"</p>",s,"</div>","</div>"].join("")),b()}function f(){B.css("min-height","initial"),C(".wpo_shade",B).remove()}function b(){C(".wpo_shade",B).css("top",B.scrollTop()+"px")}function v(e){C(".wpo-shade-progress-message",B).html(e)}function A(){C(".wpo_unused_image__input").each(function(){C(this).prop("checked")||(C(this).closest(".wpo_unused_image").addClass("selected"),C(this).prop("checked",!0),R=null,s(0==d().length))})}function k(){C(".wpo_unused_image__input").each(function(){C(this).prop("checked")&&(C(this).closest(".wpo_unused_image").removeClass("selected"),C(this).prop("checked",!1),R=null,s(0==d().length))})}function x(){C([".",D.image_container_class].join(""),B).remove(),z={},s(!0),"function"==typeof D.onclear&&D.onclear()}function y(){x(),o()}var C=jQuery,j={container:"",image_container_class:"wpo_unused_image",image_container_custom_classes:"wpo_unused_image_row",image_container_blog_class_prefix:"wpo_unused_image_site_",view_image_btn_link_class:"wpo_unused_image_view_link",view_image_btn_text:wpoptimize.view_image_link_text,row_selector:".wpo_unused_image_row",row_id_class:"wpo_unused_images_row_id",row_thumb_class:"wpo_unused_images_row_thumb",row_file_class:"wpo_unused_images_row_file",row_action_class:"wpo_unused_images_row_action",row_action_buttons:[],label_class:"wpo_unused_image_thumb_label",loader_additional_html:"",action_btn_text:"Remove",action_btn_class:"button button-primary wpo_unused_images_remove_single",checkbox_class:"wpo_unused_image__input",list_mode_class:"wpo_unused_image_list_view",no_images_found_message:"No images found",related_elements:[],action_buttons:[],hide_when_empty:[],load_next_page_callback:null,onclear:null},D=jQuery.extend({},j,e),P={GRID:"grid",LIST:"list"},Q=P.GRID,B=D.container,I="."+D.image_container_class,O="."+D.checkbox_class,R="",z={};B.on("scroll mousewheel",function(){o(),b()});var G=!1;return B.on("mousedown",D.row_selector,function(e){G=e.shiftKey||e.ctrlKey}),B.on("mouseup",D.row_selector,function(e){G=e.shiftKey||e.ctrlKey}),B.on("click","."+D.image_container_class,function(e){var i=C(this).find("."+D.checkbox_class),a=i.attr("id");!0===i.prop("checked")?C(this).addClass("selected"):C(this).removeClass("selected"),G&&(!0===i.prop("checked")?(C(this).removeClass("selected"),i.prop("checked",!1)):(C(this).addClass("selected"),i.prop("checked",!0)),1<=d().length&&!0===C("#"+R).prop("checked")&&t(R,a,!0===i.prop("checked"))),R=a,s(0==d().length)}),{show:h,hide:p,clear:x,reload:y,show_loader:g,show_custom_loader:w,hide_loader:f,loader_message:v,append_image:n,get_selected_images:d,remove_selected_images:u,get_images_count:c,get_visible_images_count:l,load_next_page_if_need:o,filter_by_site:_,switch_view_mode:r,select_all:A,select_none:k,is_visible:m,update_view:a}};