1 line
9.8 KiB
JavaScript
1 line
9.8 KiB
JavaScript
|
!function(t){var e=window.wp_optimize||{},i=e.send_command,n=wpoptimize.refresh_frequency||3e4;if(!i)return void console.error("WP-Optimize Minify: wp_optimize.send_command is required.");var s={};s.init=function(){function e(t){return t.data("url")}function n(e){var i=t("#exclude_js"),n=i.val();n+=e+"\n",i.val(n)}function s(e){var i=t("#exclude_css"),n=i.val();n+=e+"\n",i.val(n)}function a(e){var i=e.data("url"),n=t("#async_js"),s=n.val();s+=i+"\n",n.val(s),c("js"),p(e)}function o(e){var i=e.data("url"),n=t("#async_css"),s=n.val();s+=i+"\n",n.val(s),c("css"),p(e)}function c(e){t("#wp-optimize-nav-tab-wpo_minify-"+e+"-contents form").data("need_saving",!0)}function p(e){e.closest(".wpo_min_log").prev().removeClass("hidden").addClass("updated").slideDown(),e.text(wpoptimize.added_to_list),e.removeClass("exclude"),e.parent().addClass("disable-list-item"),e.replaceWith(t("<span>"+e.text()+"</span>"))}function l(e){t('input[name="enable_defer_js"]').each(function(e,i){t(i).closest("fieldset").removeClass("selected").find(".defer-js-settings").slideUp("fast")}),t('input[name="enable_defer_js"]:checked').closest("fieldset").addClass("selected").find(".defer-js-settings").slideDown("fast")}function d(){h||(h=setInterval(function(){r()},5e3))}function r(){i("get_minify_preload_status",null,function(t){t.done?(_.val(wpoptimize.run_now),_.data("running",!1),clearInterval(h),h=null):(_.val(wpoptimize.cancel),_.data("running",!0)),m.text(t.message),u(t)})}function u(e){t("#wpo_min_cache_size").text(e.size),t("#wpo_min_cache_total_size").text(e.total_size)}var f=this;this.enabled=!1,t(document).on("wp-optimize/minify/toggle-status",function(e,i){i.hasOwnProperty("enabled")&&(t('[data-whichpage="wpo_minify"]').toggleClass("is-enabled",i.enabled),f.enabled=i.enabled,f.enabled&&f.getFiles())}),t(".purge_minify_cache").on("click",function(e){e.preventDefault(),t.blockUI(),i("purge_minify_cache",null,function(t){f.updateFilesLists(t.files),f.updateStats(t.files)}).always(function(){t.unblockUI()})}),t(".purge_all_minify_cache").on("click",function(){t.blockUI(),i("purge_all_minify_cache",null,function(t){f.updateFilesLists(t.files),f.updateStats(t.files)}).always(function(){t.unblockUI()})}),t(".minify_increment_cache").on("click",function(){t.blockUI(),i("minify_increment_cache",null,function(t){t.hasOwnProperty("files")&&(f.updateFilesLists(t.files),f.updateStats(t.files))}).always(function(){t.unblockUI()})}),t("#wp-optimize-nav-tab-wpo_minify-status-contents form :input, #wp-optimize-nav-tab-wpo_minify-js-contents form :input, #wp-optimize-nav-tab-wpo_minify-css-contents form :input, #wp-optimize-nav-tab-wpo_minify-font-contents form :input, #wp-optimize-nav-tab-wpo_minify-settings-contents form :input, #wp-optimize-nav-tab-wpo_minify-advanced-contents form :input").on("change",function(){t(this).closest("form").data("need_saving",!0)}),t("input[type=checkbox].wpo-save-setting").on("change",function(e){var n=t(this),s=n.prop("checked"),a=n.prop("name"),o={};o[a]=s,t.blockUI(),i("save_minify_settings",o,function(t){t.success?(n.trigger("wp-optimize/minify/saved_setting"),t.hasOwnProperty("files")&&(f.updateFilesLists(t.files),f.updateStats(t.files))):console.log("Settings not saved",o)}).always(function(){t.unblockUI()})}),t("#wpo_min_enable_minify").on("wp-optimize/minify/saved_setting",function(){this.enabled=t(this).prop("checked"),t(document).trigger("wp-optimize/minify/toggle-status",{enabled:this.enabled})}),t("#wpo_min_enable_minify").on("wp-optimize/minify/saved_setting",function(){t(this).closest(".wpo_section").toggleClass("wpo-feature-is-disabled",!t(this).is(":checked"))}),t("#wpo_min_enable_minify_css, #wpo_min_enable_minify_js").on("wp-optimize/minify/saved_setting",function(){t('#wp-optimize-nav-tab-wrapper__wpo_minify a[data-tab="'+t(this).data("tabname")+'"] span.disabled').toggleClass("hidden",t(this).is(":checked"))}).each(function(){t('#wp-optimize-nav-tab-wrapper__wpo_minify a[data-tab="'+t(this).data("tabname")+'"] span.disabled').toggleClass("hidden",t(this).is(":checked"))}),t("#wpo_min_enable_minify_debug").on
|