"),1===e.is_multisite)a=ue.find(":selected").val(),d(a,e);else for(a in e.unsmushed_images)d(a,e)}}function h(e,s){return e.id-s.id}function d(e,s){var o="post.php?post=",a="&action=edit",t=s.admin_urls[e],n=s.unsmushed_images[e];"undefined"!=typeof n&&n.sort(h);for(i in n)if(n.hasOwnProperty(i)){var _=n[i];x(_,e,t+o+_.id+a)}}function g(){oe||(E("",W.extend(ce,{message:W("#wpo_smush_images_information_container")}),!1,!0),f(),ae=window.setInterval(u,1e3),z(!0))}function f(){W("#smush_stats_pending_images").html("..."),W("#smush_stats_completed_images").html("..."),W("#smush_stats_bytes_saved").html("..."),W("#smush_stats_percent_saved").html("..."),W("#smush_stats_timer").html("...")}function w(e){for(var s in e)e.hasOwnProperty(s)&&W("#post-"+s+" .column-wpo_smush").html(e[s]);M()}function b(e){W("#smush_stats_pending_images").html(e.pending_tasks),W("#smush_stats_completed_images").html(e.completed_task_count),W("#smush_stats_bytes_saved").html(e.bytes_saved),W("#smush_stats_percent_saved").html(e.percent_saved),1==e.smush_complete&&setTimeout(function(){v(function(){_(!1)})},1500)}function v(e){data={update_ui:!0,use_cache:!1,image_list:ie},function(e){Q.push(F.add_agent({_unique:!1,_wait:!1,_keep:!1,command:"updraft_smush_ajax",command_data:{data:data,subaction:"get_ui_update"},callback:function(s){summary=s.session_stats,s.session_stats&&(0!=s.completed_task_count&&(summary+="
"+s.summary),k(summary),e instanceof Function&&e())}}))}(e)}function k(e){te||(W("#summary-message").html(e),y(),E("",W.extend(ce,{message:W("#smush-complete-summary")})),te=!0,F.cancel_agents(Q))}function y(){se=0,oe=!1,te=!1,ie=[],F.cancel_agents(Q),clearInterval(ae),z(!1)}function x(e,s,o){var a=["wpo_smush_",s,"_",e.id].join("");image_html='',image_html+='
'+wposmush.view_image+" ",image_html+='
',image_html+='
",H.append(image_html)}function O(){features=wposmush.features,service=W("input[name^='compression_server']:checked").val();for(feature in features[service])W("."+feature).prop("disabled",!features[service][feature]);W(".wpo_smush_image").each(function(){W(this).data("filesize")>wposmush.features[service].max_filesize?W(this).hide():W(this).show()})}function z(e){W.each([G,Z,A,N,L],function(s,o){o.prop("disabled",e)}),e?(W("#wpo_smush_images_refresh").hide(),W(".wpo_smush_images_loader").show()):(W("#wpo_smush_images_refresh").show(),W(".wpo_smush_images_loader").hide())}function P(e,s){0!=e.length&&(data={selected_image:e,smush_options:s,skip_notice:!0},E(wposmush.compress_single_image_dialog,{},!1,!0),S("compress_single_image",data,function(e){C(e,j)}))}function I(e,s,o){if(0!=s.length){E(wposmush.please_wait);var a={blog_id:e,selected_image:s};S.apply({unique:!1},["restore_single_image",a,function(e){var s=function(s){"undefined"!=typeof s&&(e.summary=s),C(e,j)};o instanceof Function?o(s):s()}])}}function j(e){if(e.hasOwnProperty("success")&&e.success){W(".smush-information").text(e.summary),E("",W.extend(ce,{message:W("#smush-information-modal")})),W(".wpo-toggle-advanced-options.wpo_smush_single_image").removeClass("opened"),D(e.operation,e.summary,e.restore_possible,e);var s=e.blog_id||e.options.blog_id,o=e.image||e.options.attachment_id;me.hasOwnProperty(s)||(me[s]={}),me[s].hasOwnProperty(o)||(me[s][o]={}),e.hasOwnProperty("media_column_html")&&q(s,o,e.media_column_html),"compress"==e.operation?me[s][o]={operation:e.operation,summary:e.summary,restore_possible:e.restore_possible}:(o&&M(),me[s][o]={operation:e.operation})}else/exceeded_max_filesize/.test(e.error_message)&&(e.error_message=wposmush.exceeded_max_filesize),E(e.error_message,{},4e3)}function q(e,s,o){W(['.wpo-smush-media-library-column[data-blog="',e,'"][data-id="',s,'"]'].join("")).parent().html(o)}function D(e,s,o,a){var i=W("#smush_info").closest("#smush-metabox-inside-wrapper");0!==i.length&&("compress"==e?(W(".wpo_smush_single_image").hide(),W(".wpo_restore_single_image").show(),a&&a.hasOwnProperty("sizes-info")?(W("#smush_info").text(s),W("#wpo_smush_details").html(a["sizes-info"])):(W("#smush_info").text(s),W("#wpo_smush_details").text("").hide()),W(".wpo_smush_mark_single_image").hide(),o?W(".restore_possible").show():W(".restore_possible").hide()):(W(".wpo_smush_single_image").show(),W(".wpo_restore_single_image").hide(),W(".wpo_smush_mark_single_image").show(),W(".wpo_smush_unmark_single_image",i).hide()))}function C(e,s){e&&e.hasOwnProperty("status")&&e.status?s&&s(e):(alert(wposmush.error_unexpected_response),console.log(e))}function U(){return W('input[name="media[]"]:checked')}function K(){var e=[],s=U();return s.each(function(s,o){e.push(parseInt(o.value))}),e}function M(){W("#bulk-action-selector-top, #bulk-action-selector-bottom").val("-1"),W('input[name="media[]"]:checked, #cb-select-all-1, #cb-select-all-2').prop("checked",!1)}function S(e,s,o,a,i){a="undefined"==typeof a||a;var t="undefined"!=typeof i&&i,n=s.hasOwnProperty("skip_notice"),_=n&&1===Object.keys(s).length,m=W.isEmptyObject(s);s=m?{use_cache:!1}:s,_&&(s.use_cache=!1),function(o,i,n){Q.push(F.add_agent({_wait:t,_keep:i,_unique:n,command:"updraft_smush_ajax",command_data:{data:s,subaction:e},callback:function(e){if(a){try{var s=wpo_parse_json(e)}catch(i){console.log("smush_manager_send_command JSON parse error"),console.log(i),console.log(e),alert(wposmush.error_unexpected_response)}"undefined"!=typeof o&&o(s)}else"undefined"!=typeof o&&o(e)}}))}(o,this.keep,this.unique)}var W=jQuery,F=WP_Optimize_Heartbeat(),Q=[],T=null,E=wp_optimize.block_ui,H=W("#wpo_smush_images_grid"),J=W("#smush_info_images"),N=W("#wpo_smush_images_refresh"),Z=W("#wpo_smush_images_select_all"),A=W("#wpo_smush_images_select_none"),B=W("#wpo_smush_clear_stats_btn"),G=W("#wpo_smush_images_btn"),L=W("#wpo_smush_mark_as_compressed"),R=W("#wpo_smush_mark_all_as_uncompressed_btn"),V=W("#wpo_smush_restore_all_compressed_images_btn"),X=W(".wpo_smush_get_logs"),Y=W("#wpo_smush_delete_backup_btn"),$=W(".compression_server"),ee=W("#wpo_reset_webp_serving_method"),se=0,oe=!1,ae=0,ie=[],te=!1,ne=!1,_e=!1,me={},re=W("#wpo_smush_images_pending_tasks_cancel_button"),ue=W("#wpo_uncompressed_images_sites_select"),ce={baseZ:160001,css:{top:"50%",transform:"translate(0, -50%)",width:"400px",padding:"20px",cursor:"pointer"}};W("#doaction, #doaction2").on("click",function(o){o.stopImmediatePropagation();var a=W(this).prev("select").val();if("wp_optimize_bulk_compression"===a||"wp_optimize_bulk_restore"===a){var i=U();0!==i.length&&(o.preventDefault(),"wp_optimize_bulk_compression"===a&&e(i),"wp_optimize_bulk_restore"===a&&s(i))}}),H.on("click",".thumbnail",function(e){W(this).closest('input[type="checkbox"]').prop("checked",!0)});var pe=!1;H.on("mousedown",".thumbnail",function(e){pe=e.shiftKey||e.ctrlKey}),H.on("mouseup",".thumbnail",function(e){pe=e.shiftKey||e.ctrlKey}),ee.on("click",function(e){e.preventDefault(),S("reset_webp_serving_method",{skip_notice:!0},function(e){e.success?W("#wpo_reset_webp_serving_method_done").show().delay(3e3).fadeOut():(W("#enable_webp_conversion").prop("checked",!1),W("#smush-information-modal .smush-information").text(e.error_message),E("",W.extend(ce,{message:W("#smush-information-modal")}),!1,!0))})});var le=!1;W("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab").on("click",function(){le||W(this).is("#wp-optimize-nav-tab-wpo_images-smush")&&_(!1)}),W("#wp-optimize-wrap").on("page-change",function(e,s){le||"wpo_images"==s.page&&W("#wp-optimize-nav-tab-wrapper__wpo_images .nav-tab-active").is("#wp-optimize-nav-tab-wpo_images-smush")&&_(!1)}),W("#smush-metabox").length>0&&O();var he=null;H.on("click",".wpo_smush_image",function(e){var s=W('#wpo_smush_images_grid input[type="checkbox"]'),a=W(this).find(".wpo_smush_image__input"),i=!a.prop("checked");if(he||(W(this).find(".wpo_smush_image__input").prop("checked",i),he=a),!0===pe){var t=s.index(a),n=s.index(he);t===n?s.slice(Math.min(t,n),Math.max(t,n)+1).prop("checked",i):!0===he.prop("checked")&&s.slice(Math.min(t,n),Math.max(t,n)+1).prop("checked",i)}he=a,o()}),o(),$.on("change",function(e){O(),r()}),G.off().on("click",function(){return 0==W('#wpo_smush_images_grid input[type="checkbox"]:checked').length?void E(wposmush.please_select_images):(E(wposmush.server_check),data={server:W("input[name='compression_server']:checked").val(),skip_notice:!0},void S("check_server_status",data,function(e){e.online?m():(error_message=e.error?e.error+"
"+wposmush.server_error:wposmush.server_error,E(error_message))}))}),L.off().on("click",function(){var e,s=[];W("#wpo_smush_images_grid input:checked").each(function(){e={attachment_id:W(this).val(),blog_id:W(this).data("blog")},s.push(e)}),E(wposmush.please_updating_images_info),S("mark_as_compressed",{selected_images:s},function(e){W("#smush-information-modal .smush-information").text(e.summary),E("",W.extend(ce,{message:W("#smush-information-modal")})),_(!1)})}),R.on("click",function(){if(confirm(wposmush.mark_all_images_uncompressed)){var e=confirm(wposmush.restore_images_from_backup);E(wposmush.please_wait),_e=!0,a(e)}}),V.on("click",function(){confirm(wposmush.restore_all_compressed_images)&&(E(wposmush.please_wait),_e=!0,a(!0,!0))}),W('#smush-information-modal-cancel-btn input[type="button"]').on("click",function(){_e=!1,_(),W.unblockUI()}),N.off().on("click",function(){_(!1)}),Z.off().on("click",function(){W('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!0),he=null,o()}),A.off().on("click",function(){W('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!1),he=null,o()}),X.off().on("click",function(){W("#log-panel").text("Please wait, fetching logs."),S("get_smush_logs",{},function(e){W.blockUI({message:W("#smush-log-modal"),onOverlayClick:W.unblockUI(),css:{width:"80%",height:"80%",top:"15%",left:"15%"}}),W("#log-panel").html(""+e+"
"),download_link=ajaxurl+"?action=updraft_smush_ajax&subaction=get_smush_logs&nonce="+wposmush.smush_ajax_nonce,W("#smush-log-modal a").attr("href",download_link)},!1)}),Y.on("click",function(){if(confirm(wposmush.delete_image_backup_confirm)){Y.prop("disabled",!0);var e=W("#wpo_smush_delete_backup_spinner"),s=W("#wpo_smush_delete_backup_done");e.show(),S("clean_all_backup_images",{},function(){e.hide(),Y.prop("disabled",!1),s.css("display","inline-block").delay(3e3).fadeOut()})}}),B.off().on("click",function(e){W("#wpo_smush_images_clear_stats_spinner").show().delay(3e3).fadeOut(),S("clear_smush_stats",{},function(e){W("#wpo_smush_images_clear_stats_spinner").hide(),W("#wpo_smush_images_clear_stats_done").show().delay(3e3).fadeOut()})}),W("body").on("click","#wpo_smush_images_pending_tasks_cancel_button",function(e){wposmush.cancel===re.val()&&(re.val(wposmush.cancelling),re.prop("disabled",!0)),S("clear_pending_images",{restore_images:ie},function(e){W.unblockUI(),e.status?(_(),y()):console.log("Cancelling pending images apparently failed.",e),re.val(wposmush.cancel),re.prop("disabled",!1)})}),W(".column-wpo_smush").on("click",".wpo-smush-compress-popup-btn",function(e){var s=W(this).data("id"),o=W(this).data("blog");e.preventDefault(),S("get_smush_settings_form",{attachment_id:s,blog_id:o},function(e){if(e.success){var a=['",'','',"
"," ",'"].join("");E("",W.extend(ce,{message:a}))}})}),W("body").on("click",".wpo-smush-popup-cancel-btn",function(e){e.preventDefault(),W.unblockUI()}),W("body").on("click",".wpo_smush_single_image .button",function(){image={attachment_id:W(this).data("id"),blog_id:W(this).data("blog")},W("#enable_custom_compression").is(":checked")?image_quality=W("#custom_compression_slider").val():image_quality=W("#enable_lossy_compression").is(":checked")?60:92,lossy_compression=image_quality<92,smush_options={compression_server:W("input[name='compression_server_"+image.attachment_id+"']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:W("#smush_backup_"+image.attachment_id).is(":checked"),preserve_exif:W("#smush_exif_"+image.attachment_id).is(":checked")},data={server:W("input[name='compression_server_"+W(this).attr("id").substring(15)+"']:checked").val()},E(wposmush.server_check),S("check_server_status",data,function(e){e.online?P(image,smush_options):(error_message=e.error?e.error+"
"+wposmush.server_error:wposmush.server_error,E(error_message))})}),W("body").on("click",".wpo_restore_single_image .button, .wpo_restore_single_image a",function(e){var s=W(this);blog_id=s.data("blog"),image_id=s.data("id"),e.preventDefault(),image_id&&blog_id&&I(blog_id,image_id)}),W("body").on("click",".wpo_smush_mark_single_image .button, .wpo_smush_mark_single_image a",function(e){t(W(this),e,!0)}),W("body").on("click",".wpo_smush_unmark_single_image .button, .wpo_smush_unmark_single_image a",function(e){t(W(this),e,!1)}),W("body").on("click","#wpo_smush_details .wpo-collapsible",n),W("body").on("click",".column-wpo_smush .wpo-collapsible",n),W("body").on("click","#smush-log-modal .close, #smush-information-modal .information-modal-close",function(){W.unblockUI(),ne&&M()}),W("body").on("click",".wpo_smush_stats_cta_btn, .wpo_smush_get_logs, #smush-complete-summary .close",function(){if(W.unblockUI(),ne){var e=K();S("get_smush_details",{selected_images:e},function(e){e.success?(window.clearInterval(ae),w(e.smush_details)):console.log(e)})}else _(),setTimeout(y,500)}),W("body").on("click",".wpo-toggle-advanced-options",function(e){e.preventDefault(),W(this).toggleClass("opened")}),W(".wpo-fieldgroup .autosmush input, .wpo-fieldgroup .compression_level, .wpo-fieldgroup .image_options, #smush-show-metabox").on("change",function(e){r()}),W("body").on("change",".smush-options.compression_level",function(){W("#enable_custom_compression").is(":checked")?W(".smush-options.custom_compression").show():W(".smush-options.custom_compression").hide()}),W("body").on("change",'.smush-advanced input[type="radio"]',function(){O()}),W("#enable_webp_conversion").on("change",function(e){if(W("#wp-optimize-wrap").length){W("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut(),W("#enable_webp_conversion").prop("disabled",!0);var s=de();s.skip_notice=!0,S("update_webp_options",s,function(e){if(W("#wpo_smush_images_save_options_spinner").hide(),e.hasOwnProperty("saved")&&e.saved)W("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut();else{if(W("#enable_webp_conversion").prop("checked",!1),"update_failed_no_working_webp_converter"===e.error_code){var s=""+wposmush.webp_conversion_tool_error+' '+wposmush.webp_conversion_tool_how_to+"
";W("#smush-information-modal .smush-information").html(s)}else W("#smush-information-modal .smush-information").text(e.error_message);E("",W.extend(ce,{message:W("#smush-information-modal")}),!1,!0)}W("#enable_webp_conversion").prop("disabled",!1)})}}),W("body").on("click",".wpo_smush.column-wpo_smush .convert-to-webp",function(e){e.preventDefault();var s=W(this);data={attachment_id:W(this).data("attachment-id"),skip_notice:!0},E(wposmush.converting_to_webp,{},0,!0),S("convert_to_webp_format",data,function(e){e.success?(E(e.success,{},2e3),s.next().remove(),s.prev().is(".wpo-action-separator")&&s.prev().remove(),s.remove()):E(e.error||e.error_message||wposmush.server_error,{},2e3)})}),ue.on("change",function(){_()}),W(document).on("admin-metabox-smush-loaded",function(){var e=W('.wpo_restore_single_image input[type="button"]').first().data();if(e&&me.hasOwnProperty(e.blog)&&me[e.blog].hasOwnProperty(e.id)){var s=me[e.blog][e.id];"compress"==s.operation?D(s.operation,s.summary,s.restore_possible,s):D(s.operation)}}),F.setup();var de=function(){var e="";e=W("#enable_custom_compression").is(":checked")?W("#custom_compression_slider").val():W("#enable_lossy_compression").is(":checked")?60:92;var s=e<92;return{compression_server:W("input[name='compression_server']:checked").val(),image_quality:e,lossy_compression:s,back_up_original:W("#smush-backup-original").is(":checked"),back_up_delete_after:W("#smush-backup-delete").is(":checked"),back_up_delete_after_days:W("#smush-backup-delete-days").val(),preserve_exif:W("#smush-preserve-exif").is(":checked"),autosmush:W("#smush-automatically").is(":checked"),show_smush_metabox:W("#smush-show-metabox").is(":checked"),webp_conversion:W("#enable_webp_conversion").is(":checked")}};wp_optimize.smush_settings=de};