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