1 line
32 KiB
JavaScript
1 line
32 KiB
JavaScript
!function(e){e.fn.wpAssetCleanUp=function(){let a="#wpacu_meta_box_content";return{cssJsManagerActions:function(){let a,t,c,s=".input-unload-on-this-page.wpacu-not-locked";e(document).on("click change",".input-unload-on-this-page",function(s){if(a=e(this).attr("data-handle"),t=e(this).hasClass("wpacu_unload_rule_for_style")?"style":"script",e(this).prop("checked")){if("click"===s.type&&!e.fn.wpAssetCleanUp().triggerAlertWhenAnyUnloadRuleIsChosen(a,t))return!1;e.fn.wpAssetCleanUp().uncheckAllOtherBulkUnloadRules(e(this),!1),e.fn.wpAssetCleanUp().showHandleLoadExceptionArea(t,a),e(this).closest("tr").addClass("wpacu_not_load")}else e(this).closest("tr").removeClass("wpacu_not_load"),c=e(this).parents(".wpacu_asset_row"),e.fn.wpAssetCleanUp().hideHandleLoadExceptionArea(c,a,t)}),e(".wpacu-area-check-all").on("click",function(a){a.preventDefault();let t=e(this).attr("data-wpacu-plugin");e('table.wpacu_list_by_location[data-wpacu-plugin="'+t+'"]').find(s).prop("checked",!0).closest("tr").addClass("wpacu_not_load")}),e(".wpacu-area-uncheck-all").on("click",function(a){a.preventDefault();let t=e(this).attr("data-wpacu-plugin");e('table.wpacu_list_by_location[data-wpacu-plugin="'+t+'"]').find(s).prop("checked",!1).closest("tr").removeClass("wpacu_not_load")}),e(".wpacu-area-check-load-all").on("click change",function(a){a.preventDefault();let t=e(this).attr("data-wpacu-plugin"),c=e('table.wpacu_list_by_location[data-wpacu-plugin="'+t+'"]');c.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!0).closest("tr.wpacu_is_bulk_unloaded").removeClass("wpacu_not_load"),c.find(s).prop("checked",!1).trigger("change")}),e(".wpacu-area-uncheck-load-all").on("click change",function(a){a.preventDefault();let t=e(this).attr("data-wpacu-plugin"),c=e('table.wpacu_list_by_location[data-wpacu-plugin="'+t+'"]');c.find(".wpacu_load_it_option_one.wpacu_load_exception").prop("checked",!1).closest("tr.wpacu_is_bulk_unloaded").addClass("wpacu_not_load"),c.find(s).prop("checked",!1).trigger("change")}),e(document).on("click",".wpacu_keep_bulk_rule",function(){e(this).prop("checked")&&e(this).parents("li").next().removeClass("remove_rule")}),e(document).on("click",".wpacu_remove_bulk_rule",function(){e(this).prop("checked")&&e(this).parents("li").addClass("remove_rule")}),e(document).on("click change",".wpacu_bulk_unload",function(s){a=e(this).attr("data-handle"),t=e(this).attr("data-handle-for"),c=e("[data-"+t+'-handle-row="'+a+'"]');let n=e(this).parents("li");if(e(this).prop("checked")){if("click"===s.type&&!e.fn.wpAssetCleanUp().triggerAlertWhenAnyUnloadRuleIsChosen(a,t))return!1;(e(this).hasClass("wpacu_global_unload")||e(this).hasClass("wpacu_post_type_unload"))&&(e(this).parent("label").addClass("wpacu_input_load_checked"),e(this).closest("tr").addClass("wpacu_not_load")),e.fn.wpAssetCleanUp().showHandleLoadExceptionArea(t,a),e(this).hasClass("wpacu_global_unload")?(e.fn.wpAssetCleanUp().uncheckAllOtherBulkUnloadRules(e(this),!0),e('.input-unload-on-this-page[data-handle-for="'+t+'"][data-handle="'+a+'"]').prop("checked",!1)):e(this).hasClass("wpacu_post_type_unload")&&(e.fn.wpAssetCleanUp().uncheckAllOtherBulkUnloadRules(e(this),!1),e('.input-unload-on-this-page[data-handle-for="'+t+'"][data-handle="'+a+'"]').prop("checked",!1))}else e(this).hasClass("wpacu_unload_it_regex_checkbox")||e(this).hasClass("wpacu_unload_it_via_tax_checkbox")?e(this).hasClass("wpacu_unload_it_regex_checkbox")?(n.find("label").removeClass("wpacu_unload_checked"),n.find("textarea").blur().addClass("wpacu_disabled"),""===n.find("textarea").val().trim()&&(n.find("textarea").prop("disabled",!0).val(""),n.find(".wpacu_handle_unload_regex_input_wrap").addClass("wpacu_hide"))):e(this).hasClass("wpacu_unload_it_via_tax_checkbox")&&(n.find("label").removeClass("wpacu_unload_checked"),n.find(".wpacu_handle_unload_via_tax_input_wrap").addClass("wpacu_hide")):(e(this).parent("label").removeClass("wpacu_input_load_checked"),e(this).closest("tr").removeClass("wpacu_not_load")),e.fn.wpAssetCleanUp().hideHandleLoadExceptionArea(c,a,t);c.hasClass("wpacu_is_bulk_unloaded")||e(".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)").is(":checked")||e(this).closest("tr").removeClass("wpacu_not_load")}),e(document).on("click change",".wpacu_load_it_option_one.wpacu_load_exception,.wpacu_load_it_option_post_type",function(){let a=e(this).attr("data-handle");if(e(this).prop("checked")){e(this).parent("label").addClass("wpacu_global_unload_exception");let t="";e(this).hasClass("wpacu_style")?t="style":e(this).hasClass("wpacu_script")&&(t="script"),e("#"+t+"_"+a).prop("checked",!1).trigger("change")}else e(this).parent("label").removeClass("wpacu_global_unload_exception")}),e(document).on("click",".wpacu-add-handle-note",function(a){a.preventDefault();let t,c,s=e(this).attr("data-handle");e(this).hasClass("wpacu-for-script")?t=e('.wpacu-handle-notes-field[data-script-handle="'+s+'"]'):e(this).hasClass("wpacu-for-style")&&(t=e('.wpacu-handle-notes-field[data-style-handle="'+s+'"]')),t.length<1||(c=t.find(":input"),t.is(":hidden")?(t.show(),c.prop("disabled",!1)):(t.hide(),""===c.val().trim()&&"true"===c.attr("data-wpacu-is-empty-on-page-load")&&c.prop("disabled",!0).val("")))}),e(document).on("click",".wpacu-external-file-size",function(a){a.preventDefault();let t,c=e(this),s=c.attr("data-src");c.hide(),(t=c.next()).show(),s.includes("/?")?e.get(s,{},function(a,c,s){if("success"!==c)return"N/A";t.html(e.fn.wpAssetCleanUp().wpacuBytesToSize(a.length))}):e.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_prefix+"_get_external_file_size",wpacu_remote_file:s,wpacu_nonce:wpacu_object.wpacu_ajax_check_remote_file_size_nonce},function(e){t.html(e)})}),e(document).on("click",".wpacu_handle_row_expand_contract",function(a){a.preventDefault();let t,c=e(this).attr("data-wpacu-handle"),s=e(this).attr("data-wpacu-handle-for");e(this).find("span").hasClass("dashicons-minus")?(t="contracted",e(this).parents("td").attr("data-wpacu-row-status",t).find(".wpacu_handle_row_expanded_area").addClass("wpacu_hide"),e(this).find("span").removeClass("dashicons-minus").addClass("dashicons-plus")):e(this).find("span").hasClass("dashicons-plus")&&(t="expanded",e(this).parents("td").attr("data-wpacu-row-status",t).find(".wpacu_handle_row_expanded_area").removeClass("wpacu_hide"),e(this).find("span").removeClass("dashicons-plus").addClass("dashicons-minus")),e.fn.wpAssetCleanUp().wpacuAjaxUpdateKeepTheAssetRowState(t,c,s,e(this))}),e(document).on("click",".wpacu_area_handles_row_expand_contract",function(a){a.preventDefault();let t,c=e(this).attr("data-wpacu-area"),s=[],n=e('table.wpacu_list_table[data-wpacu-area="'+c+'"]');e(this).hasClass("wpacu-area-contract-all-assets")?t="contracted":e(this).hasClass("wpacu-area-expand-all-assets")&&(t="expanded"),n.find("tr.wpacu_asset_row").each(function(a,c){var n=e(this).attr("data-style-handle-row"),o=e(this).attr("data-script-handle-row");void 0!==n&&!1!==n?s[a]=n+"_style":void 0!==o&&!1!==o&&(s[a]=o+"_script");var p=e(this).find("td[data-wpacu-row-status]");"contracted"===t?(p.attr("data-wpacu-row-status",t).find(".wpacu_handle_row_expanded_area").addClass("wpacu_hide"),p.find("a.wpacu_handle_row_expand_contract").find("span").removeClass("dashicons-minus").addClass("dashicons-plus")):"expanded"===t&&(p.attr("data-wpacu-row-status",t).find(".wpacu_handle_row_expanded_area").removeClass("wpacu_hide"),p.find("a.wpacu_handle_row_expand_contract").find("span").removeClass("dashicons-plus").addClass("dashicons-minus"))}),e.fn.wpAssetCleanUp().wpacuAjaxUpdateAllAreaAssetsRowState(t,s,n)})},triggerAlertWhenAnyUnloadRuleIsChosen:function(a,t){if("dashicons"===a&&"style"===t&&e('input[name="wpacu_ignore_child[styles][nf-display]').length>0&&!confirm(wpacu_object.dashicons_unload_alert_ninja_forms))return!1;if("script"===t){if(("jquery"===a||"jquery-core"===a)&&e("#script_jquery_ignore_children").length>0&&!confirm(wpacu_object.jquery_unload_alert))return!1;if("js-cookie"===a&&!confirm(wpacu_object.woo_js_cookie_unload_alert))return!1;if("wc-cart-fragments"===a&&!confirm(wpacu_object.woo_wc_cart_fragments_unload_alert))return!1;if(("backbone"===a||"underscore"===a)&&!confirm(wpacu_object.sensitive_library_unload_alert))return!1}return!0},showHandleLoadExceptionArea:function(a,t){let c=e("div.wpacu_exception_options_area_wrap[data-"+a+'-handle="'+t+'"]');c.parent("div").removeClass("wpacu_hide"),c.find('input[type="checkbox"]').not(".wpacu_lite_locked").prop("disabled",!1)},hideHandleLoadExceptionArea:function(a,t,c){if(!a.hasClass("wpacu_is_bulk_unloaded")&&!a.find(".wpacu_bulk_unload").is(":checked")){let a=e("div.wpacu_exception_options_area_wrap[data-"+c+'-handle="'+t+'"]');a.parent("div").addClass("wpacu_hide"),a.find('input[type="checkbox"]').prop("disabled",!0)}},uncheckAllOtherBulkUnloadRules:function(e,a){let t=".wpacu_bulk_unload";!1===a&&(t=".wpacu_bulk_unload:not(.wpacu_unload_it_regex_checkbox)"),e.closest("tr").find(t).not(e).prop("checked",!1).parent("label").removeClass("wpacu_input_load_checked").removeClass("wpacu_unload_checked")},limitSubmittedFields:function(){let a=[];if(e("body.wp-admin form#post").length>0||e("body.wp-admin form#edittag").length>0){if(e("#wpacu_unload_assets_area_loaded").length<1)return;return!0}return e('[data-wpacu-input="preload"]').length>0&&a.push('[data-wpacu-input="preload"]'),a.length>0&&e(a.join()).each(function(){let a=e(this);a.val()||(a.prop("disabled","disabled"),setTimeout(function(){a.prop("disabled",!1)},2e3))}),!0},wpacuParseContentsForDirectCall:function(t,c){if(t.lastIndexOf(wpacu_object.start_del_e)<0||t.lastIndexOf(wpacu_object.end_del_e)<0||t.lastIndexOf(wpacu_object.start_del_h)<0||t.lastIndexOf(wpacu_object.end_del_h)<0){let t=wpacu_object.ajax_direct_fetch_error_with_success_response;t=t.replace(/{wpacu_output}/,xhr.responseText.replace(/(<([^>]+)>)/gi,""));try{t=String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}catch(e){console.log(e)}return void e(a).html(t)}let s=t.substring(t.lastIndexOf(wpacu_object.start_del_e)+wpacu_object.start_del_e.length,t.lastIndexOf(wpacu_object.end_del_e)),n=t.substring(t.lastIndexOf(wpacu_object.start_del_h)+wpacu_object.start_del_h.length,t.lastIndexOf(wpacu_object.end_del_h)),o={action:wpacu_object.plugin_prefix+"_get_loaded_assets",wpacu_list_e:s,wpacu_list_h:n,post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,force_manage_dash:wpacu_object.force_manage_dash,is_for_singular:!1,wpacu_nonce:wpacu_object.wpacu_ajax_get_loaded_assets_nonce,time_r:(new Date).getTime()};e("#wpacu_manage_singular_page_assets").length>0&&(o.is_for_singular=!0),e.post(wpacu_object.ajax_url,o,function(t){t&&(e(a).html(t),404===c&&e(a).prepend('<p><span class="dashicons dashicons-warning"></span> '+wpacu_object.server_returned_404_not_found+"</p><hr />"),e("#wpacu_dash_assets_manager_form").length>0&&e("#submit").show(),setTimeout(function(){e.fn.wpAssetCleanUp().cssJsManagerActions(),e(".wpacu_asset_row, .wpacu-page-options .wpacu-assets-collapsible-content").removeClass("wpacu_loading"),e("#wpacu-assets-reloading").remove(),e.fn.wpAssetCleanUp().wpacuCheckSourcesFor404Errors()},200))})},wpacuAjaxGetAssetsArea:function(t){if(!t&&!e("#wpacu_ajax_fetch_assets_list_dashboard_view").length)return!1;if(e("#wpacu_page_options_no_wpacu_load").length>0&&e("#wpacu_page_options_no_wpacu_load").prop("checked")){let t={action:wpacu_object.plugin_prefix+"_load_page_restricted_area",post_id:wpacu_object.post_id,wpacu_nonce:wpacu_object.wpacu_ajax_load_page_restricted_area_nonce,time_r:(new Date).getTime()};return void e.post(wpacu_object.ajax_url,t,function(t){if(!t)return!1;e(a).html(t),e(".wpacu_asset_row, .wpacu-page-options .wpacu-assets-collapsible-content").removeClass("wpacu_loading"),e("#wpacu-assets-reloading").remove()})}let c={};if("direct"===wpacu_object.dom_get_type)c[wpacu_object.plugin_prefix+"_load"]=1,c[wpacu_object.plugin_prefix+"_time_r"]=(new Date).getTime(),e.ajax({method:"GET",url:wpacu_object.page_url,data:c,cache:!1,complete:function(t,c){if("error"===t.statusText){if(404===t.status)return void e.fn.wpAssetCleanUp().wpacuParseContentsForDirectCall(t.responseText,t.status,e);let c=t.responseText.replace(/(<([^>]+)>)/gi,"");try{c=String(c).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}catch(e){console.log(e)}let s=wpacu_object.ajax_direct_fetch_error;s=(s=s.replace(/{wpacu_output}/,c)).replace(/{wpacu_status_code_error}/,t.status),e(a).html(s)}}}).done(function(a,t,c){e("#wpacu-fetch-list-step-1-wrap").addClass("wpacu-completed"),e("#wpacu-fetch-list-step-1-status").html(e("#wpacu-list-step-completed-status").html()),e("#wpacu-fetch-list-step-2-status").html(e("#wpacu-list-step-default-status").html()),e.fn.wpAssetCleanUp().wpacuParseContentsForDirectCall(a)});else if("wp_remote_post"===wpacu_object.dom_get_type){let t={action:wpacu_object.plugin_prefix+"_get_loaded_assets",post_id:wpacu_object.post_id,page_url:wpacu_object.page_url,tag_id:wpacu_object.tag_id,wpacu_taxonomy:wpacu_object.wpacu_taxonomy,force_manage_dash:wpacu_object.force_manage_dash,wpacu_nonce:wpacu_object.wpacu_ajax_get_loaded_assets_nonce,time_r:(new Date).getTime()};e.post(wpacu_object.ajax_url,t,function(t){if(!t)return!1;e(a).html(t),e("#wpacu_dash_assets_manager_form").length>0&&e("#submit").show(),setTimeout(function(){e.fn.wpAssetCleanUp().cssJsManagerActions(),setTimeout(function(){e.fn.wpAssetCleanUp().wpacuCheckSourcesFor404Errors()},100)},200)})}},wpacuParseResultsForHarcodedAssets:function(a){a.lastIndexOf(wpacu_object.start_del_h)<0||a.lastIndexOf(wpacu_object.end_del_h);let t=a.substring(a.lastIndexOf(wpacu_object.start_del_h)+wpacu_object.start_del_h.length,a.lastIndexOf(wpacu_object.end_del_h)),c=e("#wpacu-assets-collapsible-wrap-hardcoded-list").attr("data-wpacu-settings-frontend"),s={action:wpacu_object.plugin_prefix+"_print_loaded_hardcoded_assets",wpacu_list_h:t,wpacu_settings:c,time_r:(new Date).getTime(),wpacu_nonce:wpacu_object.wpacu_print_loaded_hardcoded_assets_nonce};null!==e.fn.wpAssetCleanUpFrontendCssJsManagerArea().getParameterByName("wpacu_ignore_no_load_option")&&(s.wpacu_ignore_no_load_option=1),e.post(wpacu_object.ajax_url,s,function(a){let t="#wpacu-assets-collapsible-wrap-hardcoded-list";if(!a)return;if(a.includes("The security nonce is not valid"))return void e(t).find("> .wpacu-assets-collapsible-content").html(a);let c=JSON.parse(a);e(t).find("> .wpacu-assets-collapsible-content").html(c.output),e(t).find("a.wpacu-assets-collapsible").append(" ➝ Total: "+parseInt(c.total_hardcoded_assets))})},wpacuCheckSourcesFor404Errors:function(){let a=e("[data-wpacu-external-source]");if(a.length<1)return;let t=a.length,c="";a.each(function(a){let s=e(this).attr("data-wpacu-external-source");c+=s+"-at-wpacu-at-",a===t-1&&e.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_prefix+"_check_external_urls_for_status_code",wpacu_check_urls:c,wpacu_nonce:wpacu_object.wpacu_ajax_check_external_urls_nonce},function(a){let t=e.parseJSON(a);e.each(t,function(a,t){e('[data-wpacu-external-source="'+t+'"]').css({color:"#cc0000"}).parent("div").find("[data-wpacu-external-source-status]").html('<small>* <em style="font-weight: 600;">'+wpacu_object.source_load_error_msg+"</em></small>")})})})},wpacuBytesToSize:function(e){return 0===e?"N/A":(e/1024).toFixed(4)+" KB"},wpacuAjaxUpdateKeepTheGroupsState:function(a,t){if(e("#wpacu-assets-groups-change-state-area").attr("data-wpacu-groups-current-state")==a)return void e("#"+t).prop("disabled",!1);let c={action:wpacu_object.plugin_prefix+"_update_settings",wpacu_nonce:wpacu_object.wpacu_update_specific_settings_nonce,wpacu_update_keep_the_groups:"yes",wpacu_keep_the_groups_state:a,time_r:(new Date).getTime()};try{e.post(wpacu_object.ajax_url,c,function(c){"done"==c&&e("#wpacu-assets-groups-change-state-area").attr("data-wpacu-groups-current-state",a),e("#"+t).prop("disabled",!1)})}catch(a){e("#"+t).prop("disabled",!1)}},wpacuAjaxUpdateKeepTheAssetRowState:function(a,t,c,s){let n={action:wpacu_object.plugin_prefix+"_update_asset_row_state",wpacu_update_asset_row_state:"yes",wpacu_asset_row_state:a,wpacu_handle:t,wpacu_handle_for:c,time_r:(new Date).getTime(),wpacu_nonce:wpacu_object.wpacu_update_asset_row_state_nonce};s.addClass("wpacu_hide"),e.post(wpacu_object.ajax_url,n,function(e){s.removeClass("wpacu_hide"),console.log(e)})},wpacuAjaxUpdateAllAreaAssetsRowState:function(a,t,c){let s={action:wpacu_object.plugin_prefix+"_area_update_assets_row_state",wpacu_area_update_assets_row_state:"yes",wpacu_area_assets_row_state:a,wpacu_area_handles:t,time_r:(new Date).getTime(),wpacu_nonce:wpacu_object.wpacu_area_update_assets_row_state_nonce};c.find(".wpacu_handle_row_expand_contract").addClass("wpacu_hide"),e.post(wpacu_object.ajax_url,s,function(e){c.find(".wpacu_handle_row_expand_contract").removeClass("wpacu_hide"),console.log(e)})},wpacuTriggerAdjustTextAreaHeightAllTextareas:function(){[].slice.call(document.querySelectorAll('textarea[data-wpacu-adapt-height="1"]')).forEach(function(a){a.style.boxSizing=a.style.mozBoxSizing="border-box",a.style.overflowY="hidden";let t=a.scrollHeight;a.addEventListener("input",function(){e.fn.wpAssetCleanUp().wpacuAdjustTextareaHeight(a,t)}),window.addEventListener("resize",function(){e.fn.wpAssetCleanUp().wpacuAdjustTextareaHeight(a,t)}),e.fn.wpAssetCleanUp().wpacuAdjustTextareaHeight(a,t)})},wpacuAdjustTextareaHeight:function(e,a){let t=parseInt(window.getComputedStyle(e).height,10)-e.clientHeight;e.style.height=0,e.style.height=Math.max(a,e.scrollHeight+t)+"px"}}}}(jQuery),jQuery(document).ready(function(e){e.fn.wpAssetCleanUpSettingsArea=function(){return{actions:function(){e(document).on("click","a[data-wpacu-vertical-link-target]",function(a){a.preventDefault(),e.fn.wpAssetCleanUpSettingsArea().tabOpenSettingsArea(a,e(this).attr("data-wpacu-vertical-link-target"))}),e(document).on("click","a[data-wpacu-settings-tab-key]",function(a){a.preventDefault(),e.fn.wpAssetCleanUpSettingsArea().tabOpenSettingsArea(a,e(this).attr("data-wpacu-settings-tab-key"))}),e(document).on("click",'input[type="checkbox"]#wpacu_disable_rss_feed',function(){e(this).is(":checked")?e("#wpacu_remove_main_feed_link, #wpacu_remove_comment_feed_link").prop("checked",!0):e("#wpacu_remove_main_feed_link, #wpacu_remove_comment_feed_link").prop("checked",!1)}),e(document).on("click",'input[name="wpacu_sub_tab_area"]',function(){e(this).prop("checked")&&e("#wpacu-selected-sub-tab-area").val(e(this).val())}),e(document).on("click","#wpacu_minify_css_enable, #wpacu_combine_loaded_css_enable, #wpacu_minify_js_enable, #wpacu_combine_loaded_js_enable, #wpacu_cdn_rewrite_enable, #wpacu_enable_test_mode",function(){e(this).prop("checked")?e('[data-linked-to="'+e(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-on").removeClass("wpacu-off"):e('[data-linked-to="'+e(this).attr("id")+'"]').find(".wpacu-circle-status").addClass("wpacu-off").removeClass("wpacu-on")}),e(document).on("click","#wpacu_inline_css_files_below_size_checkbox",function(){e(this).is(":checked")?e("#wpacu_inline_css_files_enable").prop("checked",!0).trigger("tick"):""===e("#wpacu_inline_css_files_list").val()&&e("#wpacu_inline_css_files_enable").prop("checked",!1).trigger("tick")}),e(document).on("click","#wpacu_inline_js_files_below_size_checkbox",function(){if(e(this).is(":checked")){if(!confirm(wpacu_object.inline_auto_js_files_confirm_msg))return!1;e("#wpacu_inline_js_files_enable").prop("checked",!0).trigger("tick")}else""===e("#wpacu_inline_js_files_list").val()&&e("#wpacu_inline_js_files_enable").prop("checked",!1).trigger("tick")}),e(document).on("click","#wpacu_dashboard",function(){e(this).prop("checked")?e("#wpacu-settings-assets-retrieval-mode").show():e("#wpacu-settings-assets-retrieval-mode").hide()}),e(document).on("change",".wpacu-dom-get-type-selection",function(){e(this).is(":checked")&&(e(".wpacu-dom-get-type-info").hide(),e("#"+e(this).attr("data-target")).fadeIn("fast"))}),e(document).on("click","#wpacu_frontend",function(){e(this).prop("checked")?e("#wpacu-settings-frontend-exceptions").show():e("#wpacu-settings-frontend-exceptions").hide()}),e(document).on("change",".google_fonts_combine_type",function(){e(".wpacu_google_fonts_combine_type_area").hide(),"async"===e(this).val()?e("#wpacu_google_fonts_combine_type_async_info_area").fadeIn():"async_preload"===e(this).val()?e("#wpacu_google_fonts_combine_type_async_preload_info_area").fadeIn():e("#wpacu_google_fonts_combine_type_rb_info_area").fadeIn()}),e("#wpacu-allow-manage-assets-to-select-list-area").length>0&&!e("#wpacu-allow-manage-assets-to-select-list-area").hasClass("wpacu_hide")&&setTimeout(function(){jQuery("#wpacu-allow-manage-assets-to-select-list").chosen()},200),e("#wpacu-allow-manage-assets-to-select").on("click change",function(){"chosen"===e(this).val()?(e("#wpacu-allow-manage-assets-to-select-list-area").removeClass("wpacu_hide"),setTimeout(function(){jQuery("#wpacu-allow-manage-assets-to-select-list").chosen()},200)):e("#wpacu-allow-manage-assets-to-select-list-area").addClass("wpacu_hide")}),e("#wpacu_assets_list_layout").on("click change",function(){"by-location"===e(this).val()?e("#wpacu-assets-list-by-location-selected").fadeIn("fast"):e("#wpacu-assets-list-by-location-selected").fadeOut("fast")}),e("#wpacu_disable_jquery_migrate").on("click",function(){return!e(this).is(":checked")||(!(!e(this).is(":checked")||!confirm(wpacu_object.jquery_migration_disable_confirm_msg))||(e(this).prop("checked",!1),!1))}),e("#wpacu_disable_comment_reply").on("click",function(){return!e(this).is(":checked")||(!(!e(this).is(":checked")||!confirm(wpacu_object.comment_reply_disable_confirm_msg))||(e(this).prop("checked",!1),!1))}),e("[data-target-opacity]").on("click change tick",function(){e(this).prop("checked")?e("#"+e(this).attr("data-target-opacity")).css({opacity:1}):e("#"+e(this).attr("data-target-opacity")).css({opacity:.4})}),e("#wpacu-show-assets-meta-box-checkbox").on("click change",function(){e(this).prop("checked")?(e("#wpacu-show-assets-enabled-area").show(),e("#wpacu-show-assets-disabled-area").hide()):(e("#wpacu-show-assets-enabled-area").hide(),e("#wpacu-show-assets-disabled-area").show())}),e(document).on("change",".wpacu-combine-loaded-js-level",function(){e(this).is(":checked")&&(e(".wpacu_combine_loaded_js_level_area").removeClass("wpacu_active"),e("#"+e(this).attr("data-target")).addClass("wpacu_active"))});let a=e('#wpacu-update-button-area input[type="submit"]');e(document).on("submit","#wpacu-settings-form, .wpacu_settings_form",function(){a.attr("disabled",!0),e("#wpacu-updating-settings").addClass("wpacu-show").removeClass("wpacu-hide")}),e(document).on("submit","form#wpacu-settings-form, form#wpacu_dash_assets_manager_form",function(){return a.attr("disabled",!0),e("#wpacu-updating-settings").show(),!0})},tabOpenSettingsArea:function(a,t){let c,s,n;for(a.preventDefault(),s=document.getElementsByClassName("wpacu-settings-tab-content"),c=0;c<s.length;c++)s[c].style.display="none";for(n=document.getElementsByClassName("wpacu-settings-tab-link"),c=0;c<n.length;c++)n[c].className=n[c].className.replace(" active","");document.getElementById(t).style.display="table-cell",e('a[href="#'+t+'"]').addClass("active"),e("#wpacu-selected-tab-area").val(t)}}},e.fn.wpAssetCleanUpSettingsArea().actions(),e.fn.wpAssetCleanUpToolsArea=function(){return{actions:function(){let a,t;e("#wpacu-reset-drop-down").on("change keyup keydown mouseup mousedown click",function(){""===e(this).val()?(e("#wpacu-warning-read").removeClass("wpacu-visible"),e("#wpacu-reset-submit-btn").attr("disabled","disabled").removeClass("button-primary").addClass("button-secondary")):("reset_everything"===e(this).val()?e("#wpacu-license-data-remove-area, #wpacu-cache-assets-remove-area").addClass("wpacu-visible"):e("#wpacu-license-data-remove-area, #wpacu-cache-assets-remove-area").removeClass("wpacu-visible"),e("#wpacu-warning-read").addClass("wpacu-visible"),e("#wpacu-reset-submit-btn").removeAttr("disabled").removeClass("button-secondary").addClass("button-primary")),e(".wpacu-tools-area .wpacu-warning").hide(),a=e(this).find("option:selected"),e("#"+a.attr("data-id")).show()}),e("#wpacu-reset-submit-btn").on("click",function(){if("reset_settings"===e("#wpacu-reset-drop-down").val()?t=wpacu_object.reset_settings_confirm_msg:"reset_critical_css"===e("#wpacu-reset-drop-down").val()?t=wpacu_object.reset_critical_css_confirm_msg:"reset_everything_except_settings"===e("#wpacu-reset-drop-down").val()?t=wpacu_object.reset_everything_except_settings_confirm_msg:"reset_everything"===e("#wpacu-reset-drop-down").val()&&(t=wpacu_object.reset_everything_confirm_msg),!confirm(t))return!1;e("#wpacu-action-confirmed").val("yes"),setTimeout(function(){"yes"===e("#wpacu-action-confirmed").val()&&e("#wpacu-tools-form").trigger("submit")},1e3)}),e(document).on("submit","#wpacu-import-form",function(){if(!confirm(wpacu_object.import_confirm_msg))return!1;e(this).find("button").addClass("wpacu-importing").prop("disabled",!0)})}}},e.fn.wpAssetCleanUpToolsArea().actions(),e.fn.wpAssetCleanUpFrontendCssJsManagerArea=function(){return{getParameterByName:function(e,a=window.location.href){e=e.replace(/[\[\]]/g,"\\$&");var t=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(a);return t?t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"":null},actions:function(){let a=e("#wpacu-update-front-settings-area .wpacu_update_btn");if(e(document).on("submit","#wpacu-frontend-form",function(){return a.attr("disabled",!0).addClass("wpacu_submitting"),e("#wpacu-updating-front-settings").show(),!0}),e("#wpacu_wrap_assets").length>0&&setTimeout(function(){e.fn.wpAssetCleanUp().cssJsManagerActions()},200),e("#wpacu-assets-collapsible-wrap-hardcoded-list").length>0){let a={};a[wpacu_object.plugin_prefix+"_load"]=1,a[wpacu_object.plugin_prefix+"_time_r"]=(new Date).getTime(),a.wpacu_just_hardcoded=1,null!==e.fn.wpAssetCleanUpFrontendCssJsManagerArea().getParameterByName("wpacu_ignore_no_load_option")&&(a.wpacu_ignore_no_load_option=1),e.ajax({method:"GET",url:wpacu_object.page_url,data:a,cache:!1,complete:function(a,t){"error"===a.statusText&&e.fn.wpAssetCleanUp().wpacuParseResultsForHarcodedAssets(a.responseText)}}).done(function(a){e.fn.wpAssetCleanUp().wpacuParseResultsForHarcodedAssets(a)})}}}},e.fn.wpAssetCleanUpFrontendCssJsManagerArea().actions(),e.fn.wpAssetCleanUpDashboardCssJsManagerArea=function(){return{actions:function(){return("default"===wpacu_object.list_show_status||""===wpacu_object.list_show_status||wpacu_object.override_assets_list_load)&&e.fn.wpAssetCleanUp().wpacuAjaxGetAssetsArea(!1),"fetch_on_click"===wpacu_object.list_show_status&&e(document).on("click","#wpacu_ajax_fetch_on_click_btn",function(a){a.preventDefault(),e(this).hide(),e("#wpacu_fetching_assets_list_wrap").show(),e.fn.wpAssetCleanUp().wpacuAjaxGetAssetsArea(!0)}),e(document).on("click",".wp-admin.post-php .edit-post-header__settings button.is-primary",function(){let a=e(this);setTimeout(function(){let t=setInterval(function(){if(!("true"===a.attr("aria-disabled")||e("#editor").hasClass("is-validating")||e("#wpacu_ajax_fetch_on_click_btn").length>0||0!==e(".edit-post-header__settings .is-saving").length)&&e("#wpacu_meta_box_content").length>0){e("#wpacu-assets-reloading").remove();let a='<span id="wpacu-assets-reloading" class="editor-post-saved-state is-wpacu-reloading">'+wpacu_object.reload_icon+wpacu_object.reload_msg+"</span>";e(".wp-admin.post-php .edit-post-header__settings").prepend(a),e(".wpacu_asset_row, .wpacu-page-options .wpacu-assets-collapsible-content").addClass("wpacu_loading"),e.fn.wpAssetCleanUp().wpacuAjaxGetAssetsArea(!0),e.fn.wpAssetCleanUpClearCache().wpacuAjaxClearCache(),clearInterval(t)}},900)},500)}),e.fn.wpAssetCleanUp().limitSubmittedFields()}}},e.fn.wpAssetCleanUpDashboardCssJsManagerArea().actions(),e.fn.wpAssetCleanUpCommonCssJsManagerArea=function(){return{actions:function(){e(document).on("submit","form#wpacu-frontend-form, form#wpacu_dash_assets_manager_form, body.wp-admin form#post, body.wp-admin #edittag",function(){return e.fn.wpAssetCleanUp().limitSubmittedFields()}),e(document).on("click",".wpacu-filter-handle",function(a){alert(e(this).attr("data-wpacu-filter-handle-message")),a.preventDefault()}),e(document).on("click","#wpacu-assets-contract-all",function(){e(this).prop("disabled",!0),e.fn.wpAssetCleanUp().wpacuAjaxUpdateKeepTheGroupsState("contracted",e(this).attr("id"))}),e(document).on("click","#wpacu-assets-expand-all",function(){e(this).prop("disabled",!0),e.fn.wpAssetCleanUp().wpacuAjaxUpdateKeepTheGroupsState("expanded",e(this).attr("id"))})}}},e.fn.wpAssetCleanUpCommonCssJsManagerArea().actions(),e.fn.wpAssetCleanUpClearCache=function(){return{init:function(){let a=!1;""!==wpacu_object.clear_cache_on_page_load&&(e.fn.wpAssetCleanUpClearCache().wpacuAjaxClearCache(),a=!0),""===wpacu_object.clear_other_caches||a||setTimeout(function(){e.fn.wpAssetCleanUpClearCache().wpacuClearAutoptimizeCache(),e.fn.wpAssetCleanUpClearCache().wpacuClearCacheEnablerCache()},150)},afterSubmit:function(){try{let a,t='input[type="hidden"][name="_wp_http_referer"]';e(t).length>0&&((a=e(t).val()).includes("term.php?taxonomy=")&&a.includes("message=")&&e.fn.wpAssetCleanUpClearCache().wpacuAjaxClearCache(),a.includes("post.php?post=")&&a.includes("message=")&&e.fn.wpAssetCleanUpClearCache().wpacuAjaxClearCache())}catch(e){console.log(e)}},wpacuAjaxClearCache:function(){if(void 0===wpacu_object.wpacu_ajax_preload_url_nonce)return;e("#hidden_post_status").length>0&&"draft"===e("#hidden_post_status").val()||e.get(wpacu_object.ajax_url,{action:wpacu_object.plugin_prefix+"_clear_cache",time_r:(new Date).getTime(),wpacu_nonce:wpacu_object.wpacu_ajax_clear_cache_nonce},function(a){setTimeout(function(){e.fn.wpAssetCleanUpClearCache().wpacuClearAutoptimizeCache(),wpacu_object.is_frontend_view?e.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_prefix+"_preload",page_url:wpacu_object.page_url,wpacu_nonce:wpacu_object.wpacu_ajax_preload_url_nonce,time_r:(new Date).getTime()}):e.get(wpacu_object.page_url,{wpacu_preload:1,wpacu_no_frontend_show:1,time_r:(new Date).getTime()},function(){e.post(wpacu_object.ajax_url,{action:wpacu_object.plugin_prefix+"_preload",page_url:wpacu_object.page_url,wpacu_nonce:wpacu_object.wpacu_ajax_preload_url_nonce,time_r:(new Date).getTime()})})},150)})},wpacuClearAutoptimizeCache:function(){if(void 0!==wpacu_object.autoptimize_not_active)return;if("false"==wpacu_object.clear_autoptimize_cache)return void console.log(wpacu_object.plugin_title+': Autoptimize cache clearing is deactivated via "WPACU_DO_NOT_ALSO_CLEAR_AUTOPTIMIZE_CACHE" constant.');e("#wp-admin-bar-autoptimize-default li").length>0&&void 0!==autoptimize_ajax_object.ajaxurl&&void 0!==autoptimize_ajax_object.nonce&&e.ajax({type:"GET",url:autoptimize_ajax_object.ajaxurl,data:{action:"autoptimize_delete_cache",nonce:autoptimize_ajax_object.nonce},dataType:"json",cache:!1,timeout:9e3,success:function(e){},error:function(e,a){}})},wpacuClearCacheEnablerCache:function(){if(void 0!==wpacu_object.cache_enabler_not_active)return;if("false"==wpacu_object.clear_cache_enabler_cache)return void console.log(wpacu_object.plugin_title+': "Cache Enabler" cache clearing is deactivated via "WPACU_DO_NOT_ALSO_CLEAR_CACHE_ENABLER_CACHE" constant.');let a={action:wpacu_object.plugin_prefix+"_cache_enabler_clear_cache",time_r:(new Date).getTime(),wpacu_nonce:wpacu_object.wpacu_ajax_clear_cache_enabler_cache_nonce};e.get(wpacu_object.ajax_url,a,function(e){})}}},e.fn.wpAssetCleanUpClearCache().init(),e.fn.wpAssetCleanUp().wpacuTriggerAdjustTextAreaHeightAllTextareas(),e.fn.wpAssetCleanUpBulkChangesArea=function(){return{actions:function(){e(document).on("click",".wpacu_bulk_rule_checkbox, .wpacu_remove_preload",function(){let a=e(this).parents(".wpacu_bulk_change_row");e(this).prop("checked")?a.addClass("wpacu_selected"):a.removeClass("wpacu_selected")}),e(document).on("change","#wpacu_post_type_select",function(){e("#wpacu_post_type_form").trigger("submit")})}}},e.fn.wpAssetCleanUpBulkChangesArea().actions()}),function(e){e(window).on("load",function(){e.fn.wpAssetCleanUp().wpacuCheckSourcesFor404Errors()})}(jQuery); |