1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ 2let window = _____WB$wombat$assign$function_____("window"); 3let self = _____WB$wombat$assign$function_____("self"); 4let document = _____WB$wombat$assign$function_____("document"); 5let location = _____WB$wombat$assign$function_____("location"); 6let top = _____WB$wombat$assign$function_____("top"); 7let parent = _____WB$wombat$assign$function_____("parent"); 8let frames = _____WB$wombat$assign$function_____("frames"); 9let opens = _____WB$wombat$assign$function_____("opens"); 10jQuery(function () { 11 /* Change the CTA for pages with PG in it.*/ 12 if (jQuery(".bwg-container").length) { 13 var html = '<div class="twb_admin_bar_menu_header">'; 14 html += '<img class="twb_menu_logo" src="' + twb.plugin_url + '/assets/images/logo_white.svg" />'; 15 html += '<div class="twb_menu_logo">Optimize Images</div>'; 16 html += '</div>'; 17 jQuery(".twb_admin_bar_menu").html(html).on("click", function () { 18 window.open(twb.href, '_blank'); 19 }); 20 jQuery(".twb_admin_bar_menu_main").remove(); 21 } 22 23 /* Is score check in progress.*/ 24 twb_inprogress = false; 25 26 /* Check if any score check is in progress.*/ 27 jQuery(".twb-notoptimized").each(function () { 28 if (jQuery(this).data("status") == 'inprogress') { 29 /* Disable score check button.*/ 30 twb_disable_check(); 31 } 32 }); 33 34 /* Add check score action to the button in page/posts list, 35 if there is no inprogress action.*/ 36 jQuery(".twb-notoptimized .twb_check_score_button").on("click", function () { 37 if (!twb_inprogress) { 38 twb_check_score(this); 39 } 40 }); 41 42 /* Add a hover action to show dismiss tooltip.*/ 43 jQuery("th[id^='twb-speed-']").hover(function () { 44 jQuery(this).find(".twb-dismiss-container").removeClass("twb-hidden"); 45 }, 46 function () { 47 jQuery(this).find(".twb-dismiss-container").addClass("twb-hidden"); 48 }); 49 50 /* Add a hover action to show page score.*/ 51 jQuery(".twb-see-score").hover(function () { 52 jQuery(this).parent().parent().find(".twb-score-container").removeClass("twb-hidden"); 53 }, 54 function () { 55 jQuery(this).parent().parent().find(".twb-score-container").addClass("twb-hidden"); 56 }); 57 jQuery(".twb-score-container:not(.twb_admin_bar_menu_content .twb-score-container), .twb-score-disabled-container").hover(function () { 58 jQuery(this).removeClass("twb-hidden"); 59 }, 60 function () { 61 jQuery(this).addClass("twb-hidden"); 62 }); 63 64 /* Draw circle on given scores.*/ 65 jQuery(".twb-score-circle").each(function () { 66 twb_draw_score_circle(this); 67 }); 68 69 /* Show/hide Image optimizer menu content container */ 70 jQuery("#wp-admin-bar-twb_adminbar_info").mouseenter(function(){ 71 jQuery(".twb_admin_bar_menu_main .twb-score-container").removeClass("twb-hidden"); 72 jQuery(".twb_admin_bar_menu_main").removeClass("twb-hidden"); 73 }).mouseleave(function() { 74 jQuery(".twb_admin_bar_menu_main").addClass("twb-hidden"); 75 }); 76 77 78 /* Draw circle on given scores.*/ 79 jQuery('.twb-score-circle').each(function () { 80 twb_draw_score_circle(this); 81 }); 82 83 if( jQuery(".twb_admin_bar_menu.twb_backend span").hasClass("twb_backend_optimizing_logo") ) { 84 /* Run ajax every 30 seconds to check if score counted */ 85 twb_run_notif_check = setInterval( twb_run_notif_check, 30000 ); 86 } 87}); 88 89/* Run ajax to check score counting status and show notification */ 90function twb_run_notif_check() { 91 jQuery.ajax({ 92 type: "POST", 93 url: twb.ajax_url, 94 data: { 95 action: "twb_notif_check", 96 twb_nonce: twb.nonce, 97 } 98 }).success(function (results) { 99 var result = jQuery.parseJSON(results); 100 if (result.html != "") { 101 /* Show notification popup and change menu icon and text from loading to Not optimised */ 102 if ( result.changeLogo == 1 ) { 103 jQuery(".twb_admin_bar_menu_header span").addClass("twb_counted"); 104 } 105 jQuery("#wp-admin-bar-twb_adminbar_info").append(result.html); 106 jQuery(".twb_admin_bar_menu_content .twb-score-container").removeClass("twb-hidden"); 107 jQuery(".twb_admin_bar_menu_content .twb-score-container .twb-score-circle").each(function () { 108 twb_draw_score_circle(this); 109 }); 110 clearInterval(twb_run_notif_check); 111 } 112 }).error(function () { 113 clearInterval(twb_run_notif_check); 114 }); 115 116} 117 118function twb_disable_check() { 119 twb_inprogress = true; 120 /* Add a hover action to show disabled notification.*/ 121 jQuery(".twb-notoptimized").hover(function () { 122 jQuery(this).parent().find(".twb-score-disabled-container").removeClass("twb-hidden"); 123 }, 124 function () { 125 jQuery(this).parent().find(".twb-score-disabled-container").addClass("twb-hidden"); 126 }); 127} 128/** 129 * Optimize the page. 130 * @param that 131 */ 132function twb_check_score(that) { 133 var post_id = jQuery(that).data("post_id"); 134 var parent = jQuery(that).parent().parent().parent(); 135 //var parent = jQuery(that).closest(".twb-score-container").parent(); 136 /* Class add loading near admin bar menu */ 137 jQuery(".twb_admin_bar_menu.twb_frontend").addClass("twb_score_inprogress"); 138 139 /* If the action is not called with reload button.*/ 140 if (parent.find(".twb-optimized").hasClass("twb-hidden")) { 141 /* Do not show loading in list.*/ 142 parent.find(".twb-optimizing").removeClass("twb-hidden"); 143 } 144 else { 145 /* Show loading on reload buttons.*/ 146 parent.find(".twb-score-overlay").removeClass("twb-hidden"); 147 parent.find(".twb-score-overlay div").removeClass("twb-reload").addClass("twb-loader"); 148 } 149 150 parent.find(".twb-notoptimized").addClass("twb-hidden"); 151 152 /* In case of Elementor */ 153 if( parent.hasClass("twb_elementor_settings_content") ) { 154 jQuery(".twb_elementor_control_title").text(twb.checking).removeClass("twb_not_optimized").prepend("<span class='twb_inprogress'></span>"); 155 } 156 157 /* Disable score check button.*/ 158 twb_disable_check(); 159 160 jQuery.ajax({ 161 url: twb.ajax_url, 162 type: "POST", 163 dataType: 'json', 164 data: { 165 action: "twb_check_score", 166 post_id: post_id, 167 twb_nonce: twb.nonce 168 }, 169 success: function (data) { 170 if (data.error) { 171 /* Show reload buttons on failure.*/ 172 parent.find(".twb-score-overlay").removeClass("twb-hidden"); 173 parent.find(".twb-score-overlay div").removeClass("twb-loader").addClass("twb-reload"); 174 } 175 else { 176 parent.find(".twb-score-overlay").addClass("twb-hidden"); 177 var desktop = parent.find(".twb-score-desktop").find(".twb-score-circle"); 178 desktop.data( 179 { 180 "score": data.desktop_score, 181 "tti": data.desktop_tti, 182 }); 183 twb_draw_score_circle(desktop); 184 var mobile = parent.find(".twb-score-mobile").find(".twb-score-circle"); 185 mobile.data( 186 { 187 "score": data.mobile_score, 188 "tti": data.mobile_tti, 189 }); 190 twb_draw_score_circle(mobile); 191 } 192 }, 193 error: function (xhr, textStatus, errorThrown) { 194 /* Show reload buttons on failure.*/ 195 parent.find(".twb-score-overlay").removeClass("twb-hidden"); 196 parent.find(".twb-score-overlay div").removeClass("twb-loader").addClass("twb-reload"); 197 }, 198 complete: function (xhr, textStatus) { 199 /* Hide optimizing container, show See score container.*/ 200 parent.find(".twb-optimizing").addClass("twb-hidden"); 201 parent.find(".twb-optimized").removeClass("twb-hidden"); 202 203 jQuery("#wpadminbar .twb-optimized .twb-score-container").removeClass("twb-hidden"); 204 jQuery("#wpadminbar .twb_admin_bar_menu").removeClass("twb_score_inprogress"); 205 jQuery("#wpadminbar .twb_menu_logo").remove(); 206 jQuery("#wpadminbar .twb_not_optimized_logo").removeClass("twb-hidden"); 207 jQuery("#wpadminbar .twb_admin_bar_menu_header").addClass("twb_not_optimized"); 208 209 /* Remove disabled action.*/ 210 twb_inprogress = false;
211 jQuery(".twb-notoptimized").hover(function () { 212 jQuery(this).parent().find(".twb-score-disabled-container").addClass("twb-hidden"); 213 }); 214 215 /* In case of Elementor */ 216 if( parent.hasClass("twb_elementor_settings_content") ) { 217 jQuery(".twb_elementor_control_title").text(twb.notoptimized).remove("span.twb_inprogress").addClass("twb_not_optimized"); 218 } 219 } 220 }); 221} 222 223/** 224 * Draw circle on given score. 225 * @param that 226 */ 227function twb_draw_score_circle(that) { 228 var score = parseInt(jQuery(that).data('score')); 229 var size = parseInt(jQuery(that).data('size')); 230 var thickness = parseInt(jQuery(that).data('thickness')); 231 var color = score <= 49 ? "rgb(253, 60, 49)" : (score >= 90 ? "rgb(12, 206, 107)" : "rgb(255, 164, 0)"); 232 jQuery(that).parent().find('.twb-load-time').html(jQuery(that).data('tti')); 233 var _this = that; 234 if( typeof jQuery(_this).circleProgress != 'function' ) { 235 return; 236 } 237 jQuery(_this).circleProgress({ 238 value: score / 100, 239 size: size, 240 startAngle: -Math.PI / 4 * 2, 241 lineCap: 'round', 242 emptyFill: "rgba(255, 255, 255, 0)", 243 thickness: thickness, 244 fill: { 245 color: color 246 } 247 }).on('circle-animation-progress', function (event, progress) { 248 var content = '<span class="twb-score0"></span>'; 249 if (score != 0) { 250 content = Math.round(score * progress); 251 } 252 jQuery(that).find('.twb-score-circle-animated').html(content).css({"color": color}); 253 jQuery(that).find('canvas').html(Math.round(score * progress)); 254 }); 255} 256 257/* Adding button in Elementor edit panel navigation view */ 258function twb_add_elementor_button() { 259 window.elementor.modules.layouts.panel.pages.menu.Menu.addItem({ 260 name: twb.title, 261 icon: "twb-element-menu-icon", 262 title: twb.title, 263 type: "page", 264 callback: () => { 265 try { 266 window.$e.route("panel/page-settings/twb_optimize") 267 } catch (e) { 268 window.$e.route("panel/page-settings/settings"), window.$e.route("panel/page-settings/twb_optimize") 269 } 270 } 271 }, "more") 272} 273 274jQuery(window).on("elementor:init", () => { 275 window.elementor.on("panel:init", () => { 276 setTimeout(twb_add_elementor_button) 277 }) 278}); 279 280}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.