PageSourceSearch

https://www.apbs.org/wp-content/themes/apbs/assets/js/mobile-script.js?ver=1791011751

js apbs.org collected 2026-10-03 23:50:06 UTC 8,327 bytes, 287 lines download raw bytes

1jQuery(document).ready(function () {
2  /*  function maybeAppendWebp(url) {
3     // Check if the URL already contains '.webp'
4     if (url.includes('.webp')) {
5       return url; // Return the URL as-is
6     }
7   
8     // Otherwise, append '.webp' if necessary
9     return url + '.webp';
10   }
11   
12   // Target the element with the background image
13   let backgroundElement = $('.background-element');
14   
15   // Ensure the element exists and has a background image
16   if (backgroundElement.length > 0) {
17     let backgroundImage = backgroundElement.attr('background-image');
18   
19     // Check if a valid background-image value is present
20     if (backgroundImage && backgroundImage !== 'none') {
21       // Extract the actual URL from the `background-image` property
22       let matches = backgroundImage.match(/url\(["']?([^"')]+)["']?\)/);
23   
24       if (matches && matches[1]) {
25         let imageUrl = matches[1]; // Extracted URL
26         let newImageUrl = maybeAppendWebp(imageUrl); // Apply maybeAppendWebp logic
27   
28         // Set the new background image URL
29         backgroundElement.css('background-image', `url('${newImageUrl}')`);
30       } else {
31         console.log('Could not extract a valid URL from the background-image.');
32       }
33     } else {
34       console.log('No valid background-image found on the element.');
35     }
36   } else {
37     console.log('The target element does not exist.');
38   } */
39
40  /* carousel */
41  if (jQuery(".banner-slider").length > 0) {
42    const $carousel = jQuery(".banner-slider");
43    const $loader = jQuery(".carousel-loader");
44
45    setTimeout(function () {
46      jQuery(".banner-slider").owlCarousel({
47        items: 1,
48        margin: 10,
49        loop: true,
50        nav: true,
51        animateOut: "fadeOut",
52        autoplay: true,
53        autoplayTimeout: 7000,
54        autoplayHoverPause: true,
55        onInitialized: function () {
56          // Remove placeholder once the carousel is loaded
57          // jQuery(".carousel-placeholder").remove();
58
59          // Remove role="presentation" from the navigation buttons
60          /* do not remove */
61          jQuery(".owl-prev, .owl-next").removeAttr("role");
62          /*  $loader.hide();
63           $carousel.fadeIn(); */
64
65          // Add ARIA labels for navigation buttons
66          jQuery(".owl-nav .owl-prev").attr("aria-label", "Previous Slide");
67          jQuery(".owl-nav .owl-next").attr("aria-label", "Next Slide");
68
69          // Add ARIA labels for dots
70          jQuery(".owl-dots .owl-dot").each(function (index) {
71            jQuery(this).attr("aria-label", "Slide " + (index + 1));
72          });
73        },
74      });
75    }, 2000); // Delay initialization by 2 seconds
76  }
77
78  /* Mobile script start = function is in used */
79  /*  for mobile device image */
80  /* var $window = jQuery(window);
81  function checkWidth() {
82    windowsize = $window.width();
83    document.cookie = "dv-width=" + windowsize;
84  }
85
86  jQuery(function () {
87    checkWidth();
88  });
89
90  setTimeout(
91    (window.onresize = function () {
92      checkWidth();
93    }),
94    2000
95  ); */
96  /* Mobile script end*/
97
98  /* carousel */
99  /* jQuery(window).on("load", function () {
100    jQuery(".owl-nav .owl-prev").attr("aria-label", "Previous Slide");
101    jQuery(".owl-nav .owl-next").attr("aria-label", "Next Slide");
102    jQuery(".owl-nav .owl-dots .owl-dot").attr("aria-label", "Slider Dot");
103  }); */
104
105  // Check URL hash and scroll to section on page load
106  jQuery(window).on("load", function () {
107    if (jQuery("body").hasClass("page-template-about-us")) {
108      setTimeout(function () {
109        about_checkHashAndScroll();
110        console.log('about');
111      }, 1000);
112    } else {
113      checkHashAndScroll();
114    }
115  });
116}); /* jquery end */
117
118if (jQuery("body").hasClass("page-template-about-us")) {
119  function about_checkHashAndScroll() {
120    if (window.location.hash) {
121      var currentURL = window.location.href;
122      var cat = currentURL.split("#");
123      var id = "#" + cat[1];
124  
125      var offSet = 0;
126      var speed = 200;
127      var viewportWidth = jQuery(window).width();
128      if (viewportWidth > 1024) {
129        offSet = 130;
130      } else if (
131        jQuery(window).width() <= 1024 &&
132        jQuery(window).width() >= 768
133      ) {
134        offSet = 140;
135      } else {
136        offSet = 90;
137      }
138  
139      // Check if the target section exists
140      if (jQuery(id).length) {
141        var targetOffset = jQuery(id).offset().top - offSet;
142  
143        // Perform the scroll animation once
144        jQuery("html, body").animate(
145          { scrollTop: targetOffset },
146          speed
147        );
148      }
149    } 
150
151    /* if (window.location.hash) {
152
153      var currentURL = window.location.href;
154      var cat = currentURL.split("#");
155      var id = "#" + cat[1];
156  
157      var offSet = 0;
158      var speed = 200;
159      var viewportWidth = jQuery(window).width();
160      if (viewportWidth > 1024) {
161        offSet = 100;
162      } else if (
163        jQuery(window).width() <= 1024 &&
164        jQuery(window).width() >= 768
165      ) {
166        offSet = 110;
167      } else {
168        offSet = 60;
169      }
170  
171      if (jQuery(id).length) {
172        var obj = jQuery(id).offset();
173        var targetOffset = obj.top - offSet;
174        // jQuery('html,body').animate({ scrollTop: targetOffset }, speed);
175  
176        jQuery("html, body").animate(
177          { scrollTop: targetOffset },
178          1000, // Scroll duration in milliseconds
179          function () {
180            // After scrolling to the section, wait 1 second
181            setTimeout(function () {
182              jQuery("html, body").animate(
183                {
184                  scrollTop: jQuery(window).scrollTop() - 40,
185                },
186                500 // Adjust duration for the final scroll up
187              );
188              // console.log(offSet);
189            }, 1000); // Delay before the second scroll (in milliseconds)
190          }
191        );
192      }
193    }*/
194
195  }
196}
197// Function to check URL hash and scroll to section on page load
198function checkHashAndScroll() {
199  if (window.location.hash) {
200    var currentURL = window.location.href;
201    var cat = currentURL.split("#");
202    var id = "#" + cat[1];
203
204    var offSet = 0;
205    var speed = 200;
206    var viewportWidth = jQuery(window).width();
207    if (viewportWidth > 1024) {
208      offSet = 180;
209    } else if (
210      jQuery(window).width() <= 1024 &&
211      jQuery(window).width() >= 768
212    ) {
213      offSet = 170;
214    } else {
215      offSet = 110;
216    }
217
218    // Check if the target section exists
219    if (jQuery(id).length) {
220      var targetOffset = jQuery(id).offset().top - offSet;
221
222      // Perform the scroll animation once
223      jQuery("html, body").animate(
224        { scrollTop: targetOffset },
225        speed
226      );
227    }
228  }
229}
230
231/* function checkHashAndScroll() {
232  if (window.location.hash) {
233    var currentURL = window.location.href;
234    var cat = currentURL.split("#");
235    var id = "#" + cat[1]; 
236
237    var offSet = 0;
238    var speed = 200;
239    var viewportWidth = jQuery(window).width();
240    if (viewportWidth > 1024) {
241      offSet = 120;
242    } else if (
243      jQuery(window).width() <= 1024 &&
244      jQuery(window).width() >= 768
245    ) {
246      offSet = 110;
247    } else {
248      offSet = 80;
249    }
250  }
251
252  if (jQuery(id).length) scrollToID(id, speed);
253
254  function scrollToID(id, speed) {
255    $([document.documentElement, document.body]).animate(
256      { scrollTop: $(id).offset().top - offSet },
257      "3500"
258    );
259  }
260} */
261
262/* Function to scroll to a section */
263function scrollToSection(id) {
264  var offSet = 0;
265  var speed = 200;
266  var viewportWidth = jQuery(window).width();
267  if (viewportWidth > 1024) {
268    offSet = 130;
269  } else if (jQuery(window).width() <= 1024 && jQuery(window).width() >= 768) {
270    offSet = 130;
271  } else {
272    offSet = 130;
273  }
274
275  if (jQuery(id).length) {
276    scrollToID(id, speed);
277  }
278
279  function scrollToID(id, speed) {
280    setTimeout(function () {
281      jQuery([document.documentElement, document.body]).animate(
282        { scrollTop: $(id).offset().top - offSet },
283        "3500"
284      );
285    }, speed);
286  }
287}

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.