PageSourceSearch

https://www.washingtoncrossingpark.org/wp-content/plugins/photo-gallery/booster/assets/js/global.js?ver=1.0.0

js washingtoncrossingpark.org collected 2026-09-24 09:36:11 UTC 9,527 bytes, 269 lines download raw bytes

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

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.