View file File name : wposmush-3-5-0.min.js Content :jQuery(function(s){WP_Optimize_Smush=WP_Optimize_Smush()});var WP_Optimize_Smush=function(){function s(s){S("#smush-information-modal .smush-information").text(wposmush.server_check),j(S("#smush-information-modal")),data={server:wposmush.smush_settings.compression_server},M("check_server_status",data,function(e){if(e.online){if(s.each(function(s,e){smush_image_list.push({attachment_id:parseInt(e.value),blog_id:wposmush.blog_id})}),data={optimization_id:"smush",selected_images:smush_image_list,smush_options:{compression_server:wposmush.smush_settings.compression_server,image_quality:wposmush.smush_settings.image_quality,lossy_compression:wposmush.smush_settings.lossy_compression,back_up_original:wposmush.smush_settings.back_up_original,preserve_exif:wposmush.smush_settings.preserve_exif}},smush_from_media_library=!0,smush_completed=!1,smush_timer_locked)return;j(S("#wpo_smush_images_information_container")),S("#wpo_smush_images_information_server").html(wposmush.smush_settings.compression_server),g(),smush_timer_handle=window.setInterval(r,1e3),M("process_bulk_smush",data)}else e.error?(error_message=e.error+"<br>"+wposmush.server_error,S("#smush-information-modal .smush-information").html(error_message)):S("#smush-information-modal .smush-information").text(wposmush.server_error),j(S("#smush-information-modal"),S.unblockUI)})}function e(s){smush_from_media_library=!0;var e=[],o=function(o){return function(a){e.push(o),1<e.length&&e.length===s.length?a(wposmush.images_restored_successfully):a()}};s.each(function(s,e){U(wposmush.blog_id,parseInt(e.value),o(parseInt(e.value)))})}function o(){var s=0==S('input[type="checkbox"]:checked',Q).length;L.prop("disabled",s),R.prop("disabled",s)}function a(s,e){if(smush_mark_all_as_uncompressed){s=s?1:0,e=e?1:0;var o=S("#smush-information-modal-cancel-btn .smush-information");M("mark_all_as_uncompressed",{restore_backup:s,delete_only_backups_meta:e},function(i){if(smush_mark_all_as_uncompressed)return i.hasOwnProperty("error")?(j(S("#smush-information-modal"),S.unblockUI),S("#smush-information-modal .smush-information").text(i.error),void t()):void(i.completed?(j(S("#smush-information-modal"),S.unblockUI),S("#smush-information-modal .smush-information").text(i.message),t()):(o.text(i.message),a(s,e)))})}}function n(){S(this).toggleClass("opened"),S(this).hasClass("opened")?S(this).text(wposmush.less):S(this).text(wposmush.more)}function t(s){var s="undefined"==typeof s||s,e={use_cache:s};E.html("..."),J.hide(),I(!0),F.push(T.add_agent({_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:e,subaction:"get_ui_update"},callback:function(s){q(s,l),x(),I(!1),o()}})),Y=!0}function m(){S("#wpo_smush_images_grid input:checked").each(function(){image={attachment_id:S(this).val(),blog_id:S(this).data("blog")},smush_image_list.push(image)}),data={optimization_id:"smush",selected_images:smush_image_list,smush_options:{compression_server:S("input[name='compression_server']:checked").val(),image_quality:S("#image_quality").val(),lossy_compression:S("#smush-lossy-compression").is(":checked"),back_up_original:S("#smush-backup-original").is(":checked"),preserve_exif:S("#smush-preserve-exif").is(":checked")}},d(),F.push(T.add_agent({_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"process_bulk_smush"}}))}function _(){if(S("#wp-optimize-wrap").length){S("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut();var s=ss();M("update_smush_options",s,function(s){S("#wpo_smush_images_save_options_spinner").hide(),s.hasOwnProperty("saved")&&s.saved?S("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut():S("#wpo_smush_images_save_options_fail").show().delay(3e3).fadeOut()})}}function r(){smush_timer_locked=!0,smush_total_seconds++,seconds=smush_total_seconds%60+""<10?"0"+smush_total_seconds%60:smush_total_seconds%60,minutes=parseInt(smush_total_seconds/60)+""<10?"0"+parseInt(smush_total_seconds/60):parseInt(smush_total_seconds/60),S("#smush_stats_timer").text(minutes+":"+seconds),u(smush_total_seconds)}function u(s){0==s%3&&c(s),0==s%60&&(null!=H&&(T.cancel_agent(H),H=null),F.push(T.add_agent({_wait:!1,command:"updraft_smush_ajax",command_data:{data:{},subaction:"process_pending_images"},callback:function(s){q(s,w)}})))}function c(s){data={update_ui:!0,use_cache:!1};var e=s<5,o=T.add_agent({_wait:!e,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"get_ui_update"},callback:function(s){q(s,w)}});null!==o&&(H=o,F.push(o))}function l(s){if(Q.html(""),s&&s.hasOwnProperty("unsmushed_images")){var e=s.unsmushed_images,o=s.pending_tasks,a=0;if(0==e.length&&0==o&&Q.text(wposmush.all_images_compressed).wrapInner("<div class='wpo-fieldgroup'> </div>"),0!=o&&J.show().find(".red").text(s.pending),1===s.is_multisite)a=uncompressed_images_sites_select.find(":selected").val(),p(a,s);else for(a in s.unsmushed_images)p(a,s)}}function h(s,e){return s.id-e.id}function p(s,e){var o="post.php?post=",a="&action=edit",n=e.admin_urls[s],t=e.unsmushed_images[s];"undefined"!=typeof t&&t.sort(h);for(i in t)if(t.hasOwnProperty(i)){var m=t[i];y(m,s,n+o+m.id+a)}}function d(){smush_timer_locked||(j(S("#wpo_smush_images_information_container")),service=S('.compression_server input[type="radio"]:checked + label small').text(),S("#wpo_smush_images_information_server").html(service),g(),smush_timer_handle=window.setInterval(r,1e3),I(!0))}function g(){S("#smush_stats_pending_images").html("..."),S("#smush_stats_completed_images").html("..."),S("#smush_stats_bytes_saved").html("..."),S("#smush_stats_percent_saved").html("..."),S("#smush_stats_timer").html("...")}function f(s){for(var e in s)s.hasOwnProperty(e)&&S("#post-"+e+" .column-wpo_smush").html(s[e]);K()}function w(s){S("#smush_stats_pending_images").html(s.pending_tasks),S("#smush_stats_completed_images").html(s.completed_task_count),S("#smush_stats_bytes_saved").html(s.bytes_saved),S("#smush_stats_percent_saved").html(s.percent_saved),1==s.smush_complete&&setTimeout(function(){b(function(){t(!1)})},1500)}function b(s){data={update_ui:!0,use_cache:!1,image_list:smush_image_list},function(s){F.push(T.add_agent({_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"get_ui_update"},callback:function(e){summary=e.session_stats,0!=e.completed_task_count&&(summary+="<hr>"+e.summary),k(summary),s instanceof Function&&s()}}))}(s)}function k(s){smush_completed||(S("#summary-message").html(s),v(),j(S("#smush-complete-summary")),smush_completed=!0,T.cancel_agents(F))}function v(){smush_total_seconds=0,smush_timer_locked=!1,smush_completed=!1,smush_image_list=[],T.cancel_agents(F),clearInterval(smush_timer_handle),I(!1)}function y(s,e,o){var a=["wpo_smush_",e,"_",s.id].join("");image_html='<div class="wpo_smush_image" data-filesize="'+s.filesize+'">',image_html+='<a class="button" href="'+o+'" target="_blank"> '+wposmush.view_image+" </a>",image_html+='<input id="'+a+'" type="checkbox" data-blog="'+e+'" class="wpo_smush_image__input" value="'+s.id+'">',image_html+='<label for="'+a+'"></a>',image_html+='<div class="thumbnail">',image_html+='<img class="lazyload" src="'+s.thumb_url+'">',image_html+="</div></label></div>",Q.append(image_html)}function x(){features=wposmush.features,service=S("input[name^='compression_server']:checked").val();for(feature in features[service])S("."+feature).prop("disabled",!features[service][feature]);S(".wpo_smush_image").each(function(){S(this).data("filesize")>wposmush.features[service].max_filesize?S(this).hide():S(this).show()})}function I(s){S.each([L,A,B,Z,N,R],function(e,o){o.prop("disabled",s)}),s?(S("#wpo_smush_images_refresh").hide(),S(".wpo_smush_images_loader").show()):(S("#wpo_smush_images_refresh").show(),S(".wpo_smush_images_loader").hide())}function O(s,e){0!=s.length&&(data={selected_image:s,smush_options:e},j(wposmush.compress_single_image_dialog),M("compress_single_image",data,function(s){q(s,z)}))}function U(s,e,o){if(0!=e.length){j(wposmush.please_wait,S.unblockUI);var a={blog_id:s,selected_image:e};M.apply({unique:!1},["restore_single_image",a,function(s){var e=function(e){"undefined"!=typeof e&&(s.summary=e),q(s,z)};o instanceof Function?o(e):e()}])}}function z(s){if(s.hasOwnProperty("success")&&s.success){S(".smush-information").text(s.summary),j(S("#smush-information-modal"),S.unblockUI),S(".wpo-toggle-advanced-options.wpo_smush_single_image").removeClass("opened"),P(s.operation,s.summary,s.restore_possible,s);var e=s.blog_id||s.options.blog_id,o=s.image||s.options.attachment_id;smush_affected_images.hasOwnProperty(e)||(smush_affected_images[e]={}),smush_affected_images[e].hasOwnProperty(o)||(smush_affected_images[e][o]={}),"compress"==s.operation?smush_affected_images[e][o]={operation:s.operation,summary:s.summary,restore_possible:s.restore_possible}:(o&&(D(o),K()),smush_affected_images[e][o]={operation:s.operation})}else S(".smush-information").text(s.error_message),j(S("#smush-information-modal"),S.unblockUI)}function P(s,e,o,a){var i=S("#smush_info").closest("#smush-metabox-inside-wrapper");"compress"==s?(S(".wpo_smush_single_image").hide(),S(".wpo_restore_single_image").show(),a&&a.hasOwnProperty("sizes-info")?(S("#smush_info").text(e),S("#wpo_smush_details").html(a["sizes-info"])):(S("#smush_info").text(e),S("#wpo_smush_details").text("").hide()),S(".wpo_smush_mark_single_image").hide(),o?S(".restore_possible").show():S(".restore_possible").hide()):(S(".wpo_smush_single_image").show(),S(".wpo_restore_single_image").hide(),S(".wpo_smush_mark_single_image").show(),S(".wpo_smush_unmark_single_image",i).hide())}function j(s,e){S.blockUI({message:s,onOverlayClick:e,baseZ:160001,css:{width:"400px",padding:"20px",cursor:"pointer"}})}function q(s,e){s&&s.hasOwnProperty("status")&&s.status?e&&e(s):(alert(wposmush.error_unexpected_response),console.log(s))}function C(){return S('input[name="media[]"]:checked')}function W(){var s=[],e=C();return e.each(function(e,o){s.push(parseInt(o.value))}),s}function D(s){var e=ajaxurl.replace("/admin-ajax.php","/");e+="post.php?post="+s+"&action=edit",S("#post-"+s+" .column-wpo_smush").html('<a href="'+e+'">'+wposmush.compress+"</a><br>")}function K(){S("#bulk-action-selector-top, #bulk-action-selector-bottom").val("-1"),S('input[name="media[]"]:checked, #cb-select-all-1, #cb-select-all-2').prop("checked",!1)}function M(s,e,o,a){a="undefined"==typeof a||a,e=S.isEmptyObject(e)?{use_cache:!1}:e,function(o,i,n){F.push(T.add_agent({_wait:!1,_keep:i,_unique:n,command:"updraft_smush_ajax",command_data:{data:e,subaction:s},callback:function(s){if(a){try{var e=wpo_parse_json(s)}catch(i){console.log("smush_manager_send_command JSON parse error"),console.log(i),console.log(s),alert(wposmush.error_unexpected_response)}"undefined"!=typeof o&&o(e)}else"undefined"!=typeof o&&o(s)}}))}(o,this.keep,this.unique)}var S=jQuery,T=WP_Optimize_Heartbeat(),F=[],H=null,Q=(S("#wp-optimize-images-nav-tab-smush"),S("#wpo_smush_images_grid")),E=S("#smush_info_images"),J=S("#wpo_smush_images_pending_tasks_container"),N=S("#wpo_smush_images_pending_tasks_button"),Z=S("#wpo_smush_images_refresh"),A=S("#wpo_smush_images_select_all"),B=S("#wpo_smush_images_select_none"),G=S("#wpo_smush_clear_stats_btn"),L=S("#wpo_smush_images_btn"),R=S("#wpo_smush_mark_as_compressed"),V=(S(".wpo_smush_single_image .button"),S(".wpo_restore_single_image .button"),S(".wpo_smush.column-wpo_smush .convert-to-webp"));smush_mark_all_as_uncompressed_btn=S("#wpo_smush_mark_all_as_uncompressed_btn"),restore_all_compressed_images_btn=S("#wpo_smush_restore_all_compressed_images_btn"),smush_view_logs_btn=S(".wpo_smush_get_logs"),smush_delete_backup_images_btn=S("#wpo_smush_delete_backup_btn"),compression_server_select=S(".compression_server"),reset_webp_serving_method_btn=S("#wpo_reset_webp_serving_method"),smush_images_tab_loaded=!1,smush_service_features=[],smush_total_seconds=0,smush_timer_locked=!1,smush_timer_handle=0,smush_image_list=[],smush_completed=!1,smush_from_media_library=!1,smush_mark_all_as_uncompressed=!1,smush_affected_images={},pending_tasks_cancel_btn=S("#wpo_smush_images_pending_tasks_cancel_button"),uncompressed_images_sites_select=S("#wpo_uncompressed_images_sites_select"),S("#doaction, #doaction2").on("click",function(o){o.stopImmediatePropagation();var a=S(this).prev("select").val();if("wp_optimize_bulk_compression"===a||"wp_optimize_bulk_restore"===a){var i=C();0!==i.length&&(o.preventDefault(),"wp_optimize_bulk_compression"===a&&s(i),"wp_optimize_bulk_restore"===a&&e(i))}}),Q.on("click",".thumbnail",function(s){S(this).closest('input[type="checkbox"]').prop("checked",!0)});var X=!1;Q.on("mousedown",".thumbnail",function(s){X=s.shiftKey||s.ctrlKey}),Q.on("mouseup",".thumbnail",function(s){X=s.shiftKey||s.ctrlKey}),reset_webp_serving_method_btn.on("click",function(s){s.preventDefault(),M("reset_webp_serving_method",{},function(s){s.success?S("#wpo_reset_webp_serving_method_done").show().delay(3e3).fadeOut():(console.log("[Failed] WebP server capability detection"),S("#enable_webp_conversion").prop("checked",!1),S("#smush-information-modal .smush-information").text(s.error_message),j(S("#smush-information-modal")))})});var Y=!1;S("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab").on("click",function(){Y||S(this).is("#wp-optimize-nav-tab-wpo_images-smush")&&t(!1)}),S("#wp-optimize-wrap").on("page-change",function(s,e){Y||"wpo_images"==e.page&&S("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab-active").is("#wp-optimize-nav-tab-wpo_images-smush")&&t(!1)}),S("#smush-metabox").length>0&&x();var $=null;Q.on("click",".wpo_smush_image",function(s){var e=S('#wpo_smush_images_grid input[type="checkbox"]'),a=S(this).find(".wpo_smush_image__input"),i=!a.prop("checked");if($||(S(this).find(".wpo_smush_image__input").prop("checked",i),$=a),!0===X){var n=e.index(a),t=e.index($);n===t?e.slice(Math.min(n,t),Math.max(n,t)+1).prop("checked",i):!0===$.prop("checked")&&e.slice(Math.min(n,t),Math.max(n,t)+1).prop("checked",i)}$=a,o()}),o(),compression_server_select.on("change",function(s){x(),_()}),L.off().on("click",function(){return 0==S('#wpo_smush_images_grid input[type="checkbox"]:checked').length?(S("#smush-information-modal .smush-information").text(wposmush.please_select_images),void j(S("#smush-information-modal"),S.unblockUI)):(S("#smush-information-modal .smush-information").text(wposmush.server_check),j(S("#smush-information-modal")),data={server:S("input[name='compression_server']:checked").val()},void M("check_server_status",data,function(s){s.online?m():(s.error?(error_message=s.error+"<br>"+wposmush.server_error,S("#smush-information-modal .smush-information").html(error_message)):S("#smush-information-modal .smush-information").text(wposmush.server_error),j(S("#smush-information-modal"),S.unblockUI))}))}),R.off().on("click",function(){if(0==S('#wpo_smush_images_grid input[type="checkbox"]:checked').length)return S("#smush-information-modal .smush-information").text(wposmush.please_select_compressed_images),void j(S("#smush-information-modal"),S.unblockUI);var s,e=[];S("#wpo_smush_images_grid input:checked").each(function(){s={attachment_id:S(this).val(),blog_id:S(this).data("blog")},e.push(s)}),j(wposmush.please_updating_images_info),M("mark_as_compressed",{selected_images:e},function(s){S("#smush-information-modal .smush-information").text(s.summary),j(S("#smush-information-modal"),S.unblockUI),t()})}),smush_mark_all_as_uncompressed_btn.on("click",function(){if(confirm(wposmush.mark_all_images_uncompressed)){var s=confirm(wposmush.restore_images_from_backup);j(S("#smush-information-modal-cancel-btn")),S("#smush-information-modal-cancel-btn .smush-information").text(wposmush.please_wait),smush_mark_all_as_uncompressed=!0,a(s)}}),restore_all_compressed_images_btn.on("click",function(){confirm(wposmush.restore_all_compressed_images)&&(j(S("#smush-information-modal-cancel-btn")),S("#smush-information-modal-cancel-btn .smush-information").text(wposmush.please_wait),smush_mark_all_as_uncompressed=!0,a(!0,!0))}),S('#smush-information-modal-cancel-btn input[type="button"]').on("click",function(){smush_mark_all_as_uncompressed=!1,t(),S.unblockUI()}),Z.off().on("click",function(){t(!1)}),A.off().on("click",function(){S('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!0),$=null,o()}),B.off().on("click",function(){S('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!1),$=null,o()}),smush_view_logs_btn.off().on("click",function(){S("#log-panel").text("Please wait, fetching logs."),M("get_smush_logs",{},function(s){S.blockUI({message:S("#smush-log-modal"),onOverlayClick:S.unblockUI(),css:{width:"80%",height:"80%",top:"15%",left:"15%"}}),S("#log-panel").html("<pre>"+s+"</pre>"),download_link=ajaxurl+"?action=updraft_smush_ajax&subaction=get_smush_logs&nonce="+wposmush.smush_ajax_nonce,S("#smush-log-modal a").attr("href",download_link)},!1)}),smush_delete_backup_images_btn.on("click",function(){if(confirm(wposmush.delete_image_backup_confirm)){smush_delete_backup_images_btn.prop("disabled",!0);var s=S("#wpo_smush_delete_backup_spinner"),e=S("#wpo_smush_delete_backup_done");s.show(),M("clean_all_backup_images",{},function(){s.hide(),smush_delete_backup_images_btn.prop("disabled",!1),e.css("display","inline-block").delay(3e3).fadeOut()})}}),G.off().on("click",function(s){S("#wpo_smush_images_clear_stats_spinner").show().delay(3e3).fadeOut(),M("clear_smush_stats",{},function(s){S("#wpo_smush_images_clear_stats_spinner").hide(),S("#wpo_smush_images_clear_stats_done").show().delay(3e3).fadeOut()})}),N.off().on("click",function(s){S("#smush-information-modal .smush-information").text(wposmush.server_check),j(S("#smush-information-modal"),S.unblockUI),data={server:S("input[name='compression_server']:checked").val()},M("check_server_status",data,function(s){s.online?(d(),M("process_pending_images",{},function(s){q(s,w)})):(s.error?(error_message=s.error+"<br>"+wposmush.server_error,S("#smush-information-modal .smush-information").html(error_message)):S("#smush-information-modal .smush-information").text(wposmush.server_error),j(S("#smush-information-modal"),S.unblockUI))})}),S("body").on("click","#wpo_smush_images_pending_tasks_cancel_button",function(s){wposmush.cancel===pending_tasks_cancel_btn.val()&&(pending_tasks_cancel_btn.val(wposmush.cancelling),pending_tasks_cancel_btn.prop("disabled",!0)),M("clear_pending_images",{},function(s){S.unblockUI(),s.status?(t(),v()):console.log("Cancelling pending images apparently failed.",s),pending_tasks_cancel_btn.val(wposmush.cancel),pending_tasks_cancel_btn.prop("disabled",!1)})}),S("body").on("click",".wpo_smush_single_image .button",function(){image={attachment_id:S(this).data("id"),blog_id:S(this).data("blog")},S("#enable_custom_compression").is(":checked")?image_quality=S("#custom_compression_slider").val():image_quality=S("#enable_lossy_compression").is(":checked")?60:92,lossy_compression=image_quality<92,smush_options={compression_server:S("input[name='compression_server_"+image.attachment_id+"']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:S("#smush_backup_"+image.attachment_id).is(":checked"),preserve_exif:S("#smush_exif_"+image.attachment_id).is(":checked")},data={server:S("input[name='compression_server_"+S(this).attr("id").substring(15)+"']:checked").val()},j(wposmush.server_check),M("check_server_status",data,function(s){s.online?O(image,smush_options):s.error?(error_message=s.error+"<br>"+wposmush.server_error,j(error_message,S.unblockUI)):j(wposmush.server_error,S.unblockUI)})}),S("body").on("click",".wpo_restore_single_image .button",function(){var s=S(this);blog_id=s.data("blog"),image_id=s.data("id"),image_id&&blog_id&&U(blog_id,image_id)}),S("body").on("click",".wpo_smush_mark_single_image .button",function(){var s={attachment_id:S(this).data("id"),blog_id:S(this).data("blog")},e=S(this).closest("#smush-metabox-inside-wrapper");j(wposmush.please_updating_images_info),M("mark_as_compressed",{selected_images:[s]},function(s){S("#smush-information-modal .smush-information").text(s.summary),j(S("#smush-information-modal"),S.unblockUI),s.status&&(S(".wpo_smush_single_image",e).hide(),S(".wpo-toggle-advanced-options",e).removeClass("opened"),S(".wpo_smush_mark_single_image",e).hide(),S(".wpo_smush_unmark_single_image",e).show(),S(".wpo_restore_single_image",e).show(),S("#smush_info",e).text(s.info))})}),S("body").on("click",".wpo_smush_unmark_single_image .button",function(){var s={attachment_id:S(this).data("id"),blog_id:S(this).data("blog")},e=S(this).closest("#smush-metabox-inside-wrapper");j(wposmush.please_updating_images_info),M("mark_as_compressed",{selected_images:[s],unmark:!0},function(s){S("#smush-information-modal .smush-information").text(s.summary),j(S("#smush-information-modal"),S.unblockUI),s.status&&(S(".wpo_smush_single_image",e).show(),S(".wpo_smush_mark_single_image",e).show(),S(".wpo_smush_unmark_single_image",e).hide(),S(".wpo_restore_single_image",e).hide(),S("#smush_info",e).text(""))})}),S("body").on("click","#wpo_smush_details .wpo-collapsible",n),S("body").on("click",".column-wpo_smush .wpo-collapsible",n),S("body").on("click","#smush-log-modal .close, #smush-information-modal .information-modal-close",function(){S.unblockUI(),smush_from_media_library&&K()}),S("body").on("click",".wpo_smush_stats_cta_btn, .wpo_smush_get_logs, #smush-complete-summary .close",function(){if(S.unblockUI(),smush_from_media_library){var s=W();M("get_smush_details",{selected_images:s},function(s){s.success?(window.clearInterval(smush_timer_handle),f(s.smush_details)):console.log(s)})}else t(),setTimeout(v,500)}),S("body").on("click",".wpo-toggle-advanced-options",function(s){s.preventDefault(),S(this).toggleClass("opened")}),S(".wpo-fieldgroup .autosmush input, .wpo-fieldgroup .compression_level, .wpo-fieldgroup .image_options, #smush-show-metabox").on("change",function(s){_()}),S("body").on("change",".smush-options.compression_level",function(){S("#enable_custom_compression").is(":checked")?S(".smush-options.custom_compression").show():S(".smush-options.custom_compression").hide()}),S("body").on("change",'.smush-advanced input[type="radio"]',function(){x()}),S("#enable_webp_conversion").on("change",function(s){if(S("#wp-optimize-wrap").length){S("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut(),S("#enable_webp_conversion").prop("disabled",!0);var e=ss();M("update_webp_options",e,function(s){if(S("#wpo_smush_images_save_options_spinner").hide(),s.hasOwnProperty("saved")&&s.saved)S("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut();else{if(S("#enable_webp_conversion").prop("checked",!1),"update_failed_no_working_webp_converter"===s.error_code){var e="<p>"+wposmush.webp_conversion_tool_error+' <a href="https://getwpo.com/faqs/#How-can-I-get-WebP-conversion-tools-to-work-" target="_blank">'+wposmush.webp_conversion_tool_how_to+"</a></p>";S("#smush-information-modal .smush-information").html(e)}else S("#smush-information-modal .smush-information").text(s.error_message);j(S("#smush-information-modal"))}S("#enable_webp_conversion").prop("disabled",!1)})}}),V.on("click",function(s){s.preventDefault();var e=S(this);data={attachment_id:S(this).data("attachment-id")},j(wposmush.converting_to_webp),M("convert_to_webp_format",data,function(s){s.error?(j(s.error,S.unblockUI),setTimeout(function(){S.unblockUI()},2e3)):(j(s.success,S.unblockUI),setTimeout(function(){S.unblockUI()},2e3),e.next().remove(),e.remove())})}),uncompressed_images_sites_select.on("change",function(){t()}),S(document).on("admin-metabox-smush-loaded",function(){var s=S('.wpo_restore_single_image input[type="button"]').first().data();if(s&&smush_affected_images.hasOwnProperty(s.blog)&&smush_affected_images[s.blog].hasOwnProperty(s.id)){var e=smush_affected_images[s.blog][s.id];"compress"==e.operation?P(e.operation,e.summary,e.restore_possible,e):P(e.operation)}}),T.setup();var ss=function(){var s="";s=S("#enable_custom_compression").is(":checked")?S("#custom_compression_slider").val():S("#enable_lossy_compression").is(":checked")?60:92;var e=s<92;return{compression_server:S("input[name='compression_server']:checked").val(),image_quality:s,lossy_compression:e,back_up_original:S("#smush-backup-original").is(":checked"),back_up_delete_after:S("#smush-backup-delete").is(":checked"),back_up_delete_after_days:S("#smush-backup-delete-days").val(),preserve_exif:S("#smush-preserve-exif").is(":checked"),autosmush:S("#smush-automatically").is(":checked"),show_smush_metabox:S("#smush-show-metabox").is(":checked"),webp_conversion:S("#enable_webp_conversion").is(":checked")}};wp_optimize.smush_settings=ss};