oont-contents/plugins/wp-optimize/js/wposmush-4-1-1.min.js
2025-04-06 08:34:48 +02:00

1 line
No EOL
23 KiB
JavaScript

jQuery(function(s){WP_Optimize_Smush=WP_Optimize_Smush()});var WP_Optimize_Smush=function(){function s(s){T(wposmush.server_check),data={server:wposmush.smush_settings.compression_server,skip_notice:!0},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;T("",S.extend(V,{message:S("#wpo_smush_images_information_container")}),!1,!0),S("#wpo_smush_images_information_server").html(wposmush.smush_settings.compression_server),f(),smush_timer_handle=window.setInterval(r,1e3),M("process_bulk_smush",data)}else error_message=e.error?e.error+"<br>"+wposmush.server_error:wposmush.server_error,T(error_message)})}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){I(wposmush.blog_id,parseInt(e.value),o(parseInt(e.value)))})}function o(){var s=0==S('input[type="checkbox"]:checked',E).length;G.prop("disabled",s),L.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,skip_notice:!0},function(t){if(smush_mark_all_as_uncompressed)return t.hasOwnProperty("error")?(T(t.error),void _()):void(t.completed?(T("",S.extend(V,{message:S("#smush-information-modal")})),S("#smush-information-modal .smush-information").text(t.message),_()):(o.text(t.message),a(s,e)))})}}function t(s,e,o){var a=s.data("blog"),t=s.data("id"),i={attachment_id:t,blog_id:a},n=s.closest("#smush-metabox-inside-wrapper");data={selected_images:[i]},o===!1&&(data.unmark=!0),e.preventDefault(),T(wposmush.please_updating_images_info),M("mark_as_compressed",data,function(s){S("#smush-information-modal .smush-information").text(s.summary),T("",S.extend(V,{message:S("#smush-information-modal")})),s.status&&(n.length&&(o?(S(".wpo_smush_single_image",n).hide(),S(".wpo-toggle-advanced-options",n).removeClass("opened"),S(".wpo_smush_mark_single_image",n).hide(),S(".wpo_smush_unmark_single_image",n).show(),S(".wpo_restore_single_image",n).show(),S("#smush_info",n).text(s.info)):(S(".wpo_smush_single_image",n).show(),S(".wpo_smush_mark_single_image",n).show(),S(".wpo_smush_unmark_single_image",n).hide(),S(".wpo_restore_single_image",n).hide(),S("#smush_info",n).text(s.info))),s.hasOwnProperty("media_column_html")&&q(a,t,s.media_column_html))})}function n(){S(this).toggleClass("opened"),S(this).hasClass("opened")?S(this).text(wposmush.less):S(this).text(wposmush.more)}function _(s){var s="undefined"==typeof s||s,e={use_cache:s};J.html("..."),z(!0),H.push(F.add_agent({_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:e,subaction:"get_ui_update"},callback:function(s){C(s,l),O(),z(!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")}},g(),H.push(F.add_agent({_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"process_bulk_smush"}}))}function u(){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),c(smush_total_seconds)}function c(s){0==s%3&&p(s),0==s%60&&(null!=Q&&(F.cancel_agent(Q),Q=null),H.push(F.add_agent({_wait:!1,command:"updraft_smush_ajax",command_data:{data:{},subaction:"process_pending_images"},callback:function(s){C(s,b)}})))}function p(s){data={update_ui:!0,use_cache:!1};var e=s<5,o=F.add_agent({_wait:!e,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"get_ui_update"},callback:function(s){C(s,b)}});null!==o&&(Q=o,H.push(o))}function l(s){if(E.html(""),s&&s.hasOwnProperty("unsmushed_images")){var e=s.unsmushed_images,o=s.pending_tasks,a=0;if(0==e.length&&0==o&&E.text(wposmush.all_images_compressed).wrapInner("<div class='wpo-fieldgroup'> </div>"),1===s.is_multisite)a=uncompressed_images_sites_select.find(":selected").val(),d(a,s);else for(a in s.unsmushed_images)d(a,s)}}function h(s,e){return s.id-e.id}function d(s,e){var o="post.php?post=",a="&action=edit",t=e.admin_urls[s],n=e.unsmushed_images[s];"undefined"!=typeof n&&n.sort(h);for(i in n)if(n.hasOwnProperty(i)){var _=n[i];x(_,s,t+o+_.id+a)}}function g(){smush_timer_locked||(T("",S.extend(V,{message:S("#wpo_smush_images_information_container")}),!1,!0),service=S('.compression_server input[type="radio"]:checked + label small').text(),S("#wpo_smush_images_information_server").html(service),f(),smush_timer_handle=window.setInterval(r,1e3),z(!0))}function f(){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 w(s){for(var e in s)s.hasOwnProperty(e)&&S("#post-"+e+" .column-wpo_smush").html(s[e]);K()}function b(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(){v(function(){_(!1)})},1500)}function v(s){data={update_ui:!0,use_cache:!1,image_list:smush_image_list},function(s){H.push(F.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,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),y(),T("",S.extend(V,{message:S("#smush-complete-summary")})),smush_completed=!0,F.cancel_agents(H))}function y(){smush_total_seconds=0,smush_timer_locked=!1,smush_completed=!1,smush_image_list=[],F.cancel_agents(H),clearInterval(smush_timer_handle),z(!1)}function x(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>",E.append(image_html)}function O(){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 z(s){S.each([G,Z,A,N,L],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 P(s,e){0!=s.length&&(data={selected_image:s,smush_options:e},T(wposmush.compress_single_image_dialog,{},!1,!0),M("compress_single_image",data,function(s){C(s,j)}))}function I(s,e,o){if(0!=e.length){T(wposmush.please_wait);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),C(s,j)};o instanceof Function?o(e):e()}])}}function j(s){if(s.hasOwnProperty("success")&&s.success){S(".smush-information").text(s.summary),T("",S.extend(V,{message:S("#smush-information-modal")})),S(".wpo-toggle-advanced-options.wpo_smush_single_image").removeClass("opened"),D(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]={}),s.hasOwnProperty("media_column_html")&&q(e,o,s.media_column_html),"compress"==s.operation?smush_affected_images[e][o]={operation:s.operation,summary:s.summary,restore_possible:s.restore_possible}:(o&&K(),smush_affected_images[e][o]={operation:s.operation})}else T(s.error_message)}function q(s,e,o){S(['.wpo-smush-media-library-column[data-blog="',s,'"][data-id="',e,'"]'].join("")).parent().html(o)}function D(s,e,o,a){var t=S("#smush_info").closest("#smush-metabox-inside-wrapper");0!==t.length&&("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",t).hide()))}function C(s,e){s&&s.hasOwnProperty("status")&&s.status?e&&e(s):(alert(wposmush.error_unexpected_response),console.log(s))}function U(){return S('input[name="media[]"]:checked')}function W(){var s=[],e=U();return e.each(function(e,o){s.push(parseInt(o.value))}),s}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=e.hasOwnProperty("skip_notice")&&1===Object.keys(e).length||S.isEmptyObject(e)?{use_cache:!1}:e,function(o,t,i){H.push(F.add_agent({_wait:!1,_keep:t,_unique:i,command:"updraft_smush_ajax",command_data:{data:e,subaction:s},callback:function(s){if(a){try{var e=wpo_parse_json(s)}catch(t){console.log("smush_manager_send_command JSON parse error"),console.log(t),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,F=WP_Optimize_Heartbeat(),H=[],Q=null,T=wp_optimize.block_ui,E=S("#wpo_smush_images_grid"),J=S("#smush_info_images"),N=S("#wpo_smush_images_refresh"),Z=S("#wpo_smush_images_select_all"),A=S("#wpo_smush_images_select_none"),B=S("#wpo_smush_clear_stats_btn"),G=S("#wpo_smush_images_btn"),L=S("#wpo_smush_mark_as_compressed"),R=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");var V={baseZ:160001,css:{top:"50%",transform:"translate(0, -50%)",width:"400px",padding:"20px",cursor:"pointer"}};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 t=U();0!==t.length&&(o.preventDefault(),"wp_optimize_bulk_compression"===a&&s(t),"wp_optimize_bulk_restore"===a&&e(t))}}),E.on("click",".thumbnail",function(s){S(this).closest('input[type="checkbox"]').prop("checked",!0)});var X=!1;E.on("mousedown",".thumbnail",function(s){X=s.shiftKey||s.ctrlKey}),E.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",{skip_notice:!0},function(s){s.success?S("#wpo_reset_webp_serving_method_done").show().delay(3e3).fadeOut():(S("#enable_webp_conversion").prop("checked",!1),S("#smush-information-modal .smush-information").text(s.error_message),T("",S.extend(V,{message:S("#smush-information-modal")}),!1,!0))})});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")&&_(!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")&&_(!1)}),S("#smush-metabox").length>0&&O();var $=null;E.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"),t=!a.prop("checked");if($||(S(this).find(".wpo_smush_image__input").prop("checked",t),$=a),!0===X){var i=e.index(a),n=e.index($);i===n?e.slice(Math.min(i,n),Math.max(i,n)+1).prop("checked",t):!0===$.prop("checked")&&e.slice(Math.min(i,n),Math.max(i,n)+1).prop("checked",t)}$=a,o()}),o(),compression_server_select.on("change",function(s){O(),u()}),G.off().on("click",function(){return 0==S('#wpo_smush_images_grid input[type="checkbox"]:checked').length?void T(wposmush.please_select_images):(T(wposmush.server_check),data={server:S("input[name='compression_server']:checked").val(),skip_notice:!0},void M("check_server_status",data,function(s){s.online?m():(error_message=s.error?s.error+"<br>"+wposmush.server_error:wposmush.server_error,T(error_message))}))}),L.off().on("click",function(){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)}),T(wposmush.please_updating_images_info),M("mark_as_compressed",{selected_images:e},function(s){S("#smush-information-modal .smush-information").text(s.summary),T("",S.extend(V,{message:S("#smush-information-modal")})),_(!1)})}),smush_mark_all_as_uncompressed_btn.on("click",function(){if(confirm(wposmush.mark_all_images_uncompressed)){var s=confirm(wposmush.restore_images_from_backup);T(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)&&(T(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,_(),S.unblockUI()}),N.off().on("click",function(){_(!1)}),Z.off().on("click",function(){S('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!0),$=null,o()}),A.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()})}}),B.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()})}),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",{restore_images:smush_image_list},function(s){S.unblockUI(),s.status?(_(),y()):console.log("Cancelling pending images apparently failed.",s),pending_tasks_cancel_btn.val(wposmush.cancel),pending_tasks_cancel_btn.prop("disabled",!1)})}),S(".column-wpo_smush").on("click",".wpo-smush-compress-popup-btn",function(s){var e=S(this).data("id"),o=S(this).data("blog");s.preventDefault(),M("get_smush_settings_form",{attachment_id:e,blog_id:o},function(s){if(s.success){var a=['<div class="wpo-smush-compress-popup-content">',"<h3>",wposmush.compress_image,"</h3>",s.html,"</div>",'<div class="wpo_smush_single_image action_button" style="display:inline-block;">','<input type="button" data-blog="',o,'" data-id="',e,'" id="smush_compress_',e,'" class="button-primary button" value="',wposmush.compress,'">',"</div>","&nbsp;&nbsp;",'<a href="#" class="button wpo-smush-popup-cancel-btn">',wposmush.close,"</a>"].join("");T("",S.extend(V,{message:a}))}})}),S("body").on("click",".wpo-smush-popup-cancel-btn",function(s){s.preventDefault(),S.unblockUI()}),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()},T(wposmush.server_check),M("check_server_status",data,function(s){s.online?P(image,smush_options):(error_message=s.error?s.error+"<br>"+wposmush.server_error:wposmush.server_error,T(error_message))})}),S("body").on("click",".wpo_restore_single_image .button, .wpo_restore_single_image a",function(s){var e=S(this);blog_id=e.data("blog"),image_id=e.data("id"),s.preventDefault(),image_id&&blog_id&&I(blog_id,image_id)}),S("body").on("click",".wpo_smush_mark_single_image .button, .wpo_smush_mark_single_image a",function(s){t(S(this),s,!0)}),S("body").on("click",".wpo_smush_unmark_single_image .button, .wpo_smush_unmark_single_image a",function(s){t(S(this),s,!1)}),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),w(s.smush_details)):console.log(s)})}else _(),setTimeout(y,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){u()}),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(){O()}),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();e.skip_notice=!0,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);T("",S.extend(V,{message:S("#smush-information-modal")}),!1,!0)}S("#enable_webp_conversion").prop("disabled",!1)})}}),R.on("click",function(s){s.preventDefault();var e=S(this);data={attachment_id:S(this).data("attachment-id"),skip_notice:!0},T(wposmush.converting_to_webp,{},0,!0),M("convert_to_webp_format",data,function(s){s.error?T(s.error,{},2e3):(T(s.success,{},2e3),e.next().remove(),e.remove())})}),uncompressed_images_sites_select.on("change",function(){_()}),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?D(e.operation,e.summary,e.restore_possible,e):D(e.operation)}}),F.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};