PageSourceSearch

https://www.whitehorsedc.gov.uk/app/themes/gsd-base/library/js/scripts.js?v=1790916090

js whitehorsedc.gov.uk collected 2026-10-02 04:41:44 UTC 19,620 bytes, 676 lines download raw bytes

1/**
2 *	Hamburger menu toggle
3 *
4 */
5function accessiblityModal() {
6  var focusableElements =
7    'button:not(.btn_hidden), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
8  var modal = document.querySelector("#menu-wrapper");
9  var firstFocusableElement = modal.querySelectorAll(focusableElements)[0];
10  var focusableContent = modal.querySelectorAll(focusableElements);
11  var lastFocusableElement = focusableContent[focusableContent.length - 1];
12  document.addEventListener("keydown", function (e) {
13    var isTabPressed = e.key === "Tab" || e.keyCode === 9;
14
15    if (!isTabPressed) {
16      return;
17    }
18
19    if (e.shiftKey) {
20      if (document.activeElement === firstFocusableElement) {
21        lastFocusableElement.focus();
22        e.preventDefault();
23      }
24    } else {
25      if (document.activeElement === lastFocusableElement) {
26        firstFocusableElement.focus();
27        e.preventDefault();
28      }
29    }
30  });
31  firstFocusableElement.focus();
32}
33
34jQuery(document).ready(function () {
35  jQuery("#services-button").on("click", function (e) {
36    if (jQuery(this).hasClass("is-active")) {
37      jQuery(this).attr("href", "#close");
38    } else {
39      jQuery(this).attr("href", "#menu");
40      setTimeout(function () {
41        accessiblityModal();
42      }, 500);
43    }
44
45    jQuery(this).toggleClass("is-active");
46  });
47
48  jQuery("#close-menu").on("click", function (e) {
49    jQuery("#services-button").trigger("click");
50  });
51
52  jQuery(document).on("keyup", function (e) {
53    if (e.keyCode == 27) {
54      jQuery("#close-menu")[0].click();
55      console.log("trigger");
56    }
57  });
58});
59
60// ccc focus
61jQuery(document).ready(function () {
62  jQuery(document).on(
63    "keypress",
64    "#ccc-recommended-settings, #ccc-close, #ccc-reject-settings, #ccc-dismiss-button",
65    function (e) {
66      setTimeout(function () {
67        if (e.keyCode == 13) {
68          jQuery("#logo").focus();
69          jQuery("#header-inner-vale .splitter-logo").focus();
70        }
71      }, 10);
72    },
73  );
74});
75/**
76 *	Mobile head search
77 *
78 */
79jQuery(document).ready(function () {
80  jQuery(document).on("click", "#mobile-head-search", function (e) {
81    e.preventDefault();
82    if (jQuery("#s-mobile-wrapper").data("status") === "closed") {
83      jQuery("#s-mobile-wrapper").slideDown();
84      jQuery("#s-mobile-wrapper").data("status", "open");
85      jQuery("#mobile-head-search i")
86        .removeClass("fa-search")
87        .addClass("fa-times");
88    } else {
89      jQuery("#s-mobile-wrapper").slideUp();
90      jQuery("#s-mobile-wrapper").data("status", "closed");
91      jQuery("#mobile-head-search i")
92        .removeClass("fa-times")
93        .addClass("fa-search");
94    }
95  });
96});
97
98/**
99 *	News ticker
100 *
101 */
102jQuery(document).ready(function () {
103  if (
104    jQuery("#ticker").length &&
105    jQuery("#ticker").data("animation") === "enable"
106  ) {
107    jQuery("#ticker").ticker({
108      finishOnHover: true,
109    });
110  }
111});
112
113/**
114 *	How can we help
115 *
116 *	Slick slider
117 */
118jQuery(document).ready(function () {
119  if (jQuery(".slick-768-only").length > 0) {
120    jQuery(".slick-768-only").slick({
121      responsive: [
122        {
123          breakpoint: 9999,
124          settings: "unslick",
125        },
126        {
127          breakpoint: 768,
128          settings: {
129            slidesToShow: 1,
130            slidesToScroll: 1,
131            infinite: true,
132            dots: true,
133            centerMode: true,
134            focusOnSelect: true,
135            accessibility: false,
136            prevArrow:
137              '<button type="button" class="slick-prev"><span class="sr-only">Go to previous slide</span><i class="fas fa-arrow-left"></i></button>',
138            nextArrow:
139              '<button type="button" class="slick-next"><span class="sr-only">Go to next slide</span><i class="fas fa-arrow-right"></i></button>',
140            appendArrows: ".slick-768-only .slick-list",
141            dotsClass: "slick-dots",
142            customPaging: function (slick, index) {
143              return (
144                '<button><span class="sr-only">Go to slide </span>' +
145                index +
146                "</button>"
147              );
148            },
149          },
150        },
151      ],
152    });
153    setTimeout(function () {
154      var stHeight = jQuery(".slick-768-only .slick-track").height();
155      jQuery(".slick-768-only .slick-slide").css("height", stHeight + "px");
156    }, 200);
157  }
158});
159jQuery(window).resize(function () {
160  if (jQuery(".slick-768-only").length > 0) {
161    setTimeout(function () {
162      jQuery(".slick-768-only").slick("resize");
163      var stHeight = jQuery(".slick-768-only .slick-track").height();
164      jQuery(".slick-768-only .slick-slide").css("height", stHeight + "px");
165    }, 200);
166  }
167});
168
169/**
170 *	Gallery integration
171 *
172 *	Simple lightbox
173 *	Slick slider
174 */
175jQuery(document).ready(function () {
176  if (jQuery(".wp-block-gallery").length > 0) {
177    jQuery(".wp-block-gallery:not(.default) li figure a").simpleLightbox();
178    jQuery(".wp-block-gallery:not(.default):not(.default)").slick({
179      slidesToShow: 3,
180      slidesToScroll: 1,
181      infinite: true,
182      dots: false,
183      centerMode: false,
184      focusOnSelect: true,
185      prevArrow:
186        '<button type="button" class="slick-prev"><span class="sr-only">
186Go to previous slide</span><i class="fas fa-arrow-left"></i></button>',
187      nextArrow:
188        '<button type="button" class="slick-next"><span class="sr-only">Go to next slide</span><i class="fas fa-arrow-right"></i></button>',
189      responsive: [
190        {
191          breakpoint: 768,
192          settings: {
193            slidesToShow: 1,
194            slidesToScroll: 1,
195            dots: true,
196          },
197        },
198      ],
199    });
200    setTimeout(function () {
201      var stHeight = jQuery(
202        ".wp-block-gallery:not(.default) .slick-track",
203      ).height();
204      jQuery(".wp-block-gallery:not(.default) .slick-slide").css(
205        "height",
206        stHeight + "px",
207      );
208    }, 200);
209  }
210  jQuery(window).resize(function () {
211    if (jQuery(".wp-block-gallery:not(.default)").length > 0) {
212      setTimeout(function () {
213        jQuery(".wp-block-gallery:not(.default)").slick("resize");
214        var stHeight = jQuery(
215          ".wp-block-gallery:not(.default) .slick-track",
216        ).height();
217        jQuery(".wp-block-gallery:not(.default) .slick-slide").css(
218          "height",
219          stHeight + "px",
220        );
221      }, 200);
222    }
223  });
224});
225
226/**
227 *	Video poster image (auto)
228 *
229 */
230jQuery(document).ready(function () {
231  if (jQuery(".wp-block-video")) {
232    jQuery("video").each(function () {
233      jQuery(this).attr("preload", "metadata");
234      var src = jQuery(this).attr("src");
235      jQuery(this).attr("src", src + "#t=0.01");
236    });
237  }
238});
239
240/**
241 *	JS magic to retain taget functionality
242 *	whilst removing browser scroll
243 *
244 *	@link https://medium.com/@pimterry/better-css-only-tabs-with-target-7886c88deb75
245 */
246jQuery(document).ready(function () {
247  var hashLinks = document.querySelectorAll("a[href^='#']");
248  [].forEach.call(hashLinks, function (link) {
249    link.addEventListener("click", function (event) {
250      var hashCheck = link.href.split("#");
251      if (hashCheck[1] !== "") {
252        event.preventDefault();
253        history.pushState({}, "", link.href);
254        history.pushState({}, "", link.href);
255        history.back();
256      }
257    });
258  });
259  /** Prevent jump on page load */
260  if (location.hash && location.hash !== "#info-area-wrapper") {
261    window.scrollTo(0, 0);
262    setTimeout(function () {
263      window.scrollTo(0, 0);
264    }, 1);
265  }
266});
267
268/**
269 *	Step by step
270 *
271 *	Slick slider
272 */
273jQuery(document).ready(function () {
274  jQuery("#step-by-step-wrapper a").on("click", function (e) {
275    e.preventDefault();
276    jQuery("#step-slider-wrapper").slideDown(250);
277    jQuery("#step-nav, #step-slides").slick("resize");
278    jQuery(this).fadeOut(250);
279    fn_scroll_to_anchor("#step-by-step-wrapper", false);
280  });
281
282  if (jQuery("#step-nav").length > 0) {
283    jQuery("#step-nav").slick({
284      slidesToShow: 1,
285      slidesToScroll: 1,
286      infinite: false,
287      dots: false,
288      centerMode: false,
289      focusOnSelect: true,
290      prevArrow:
291        '<button type="button" class="slick-prev"><span class="sr-only">Go to previous slide</span><i class="fas fa-arrow-left"></i></button>',
292      nextArrow:
293        '<button type="button" class="slick-next"><span class="sr-only">Go to next slide</span><i class="fas fa-arrow-right"></i></button>',
294      asNavFor: "#step-slides",
295      appendArrows: "#step-nav .slick-list",
296      adaptiveHeight: true,
297      accessibility: false,
298    });
299  }
300
301  if (jQuery("#step-slides").length > 0) {
302    jQuery("#step-slides").slick({
303      slidesToShow: 1,
304      slidesToScroll: 1,
305      infinite: false,
306      dots: false,
307      centerMode: false,
308      focusOnSelect: true,
309      arrows: false,
310      asNavFor: "#step-nav",
311      appendArrows: "#step-slides .slick-list",
312      adaptiveHeight: true,
313      accessibility: false,
314    });
315  }
316
317  jQuery(".scrollable").on(
318    "afterChange",
319    function (event, slick, currentSlide) {
320      if (currentSlide === 2) {
321        jQuery(".slick-next").addClass("hidden");
322      } else {
323        jQuery(".slick-next").removeClass("hidden");
324      }
325      if (currentSlide === 0) {
326        jQuery(".slick-prev").addClass("hidden");
327      } else {
328        jQuery(".slick-prev").removeClass("hidden");
329      }
330    },
331  );
332
333  jQuery(".slide-link").on("click", function (e) {
334    e.preventDefault();
335    e.stopPropagation();
336    var index = jQuery("#step-wrapper ul li").index(jQuery(this).parent());
337
338    if (jQuery("#step-slider-wrapper").css("display") === "none") {
339      jQuery("#step-slider-wrapper").slideDown(250);
340      jQuery("#step-nav, #step-slides").slick("resize");
341      jQuery("#step-by-step-wrapper a").fadeOut(250);
342      fn_scroll_to_anchor("#step-by-step-wrapper", false);
343    }
344
345    setTimeout(function () {
346      jQuery("#step-slides").slick("slickGoTo", parseInt(index));
347    }, 250);
348  });
349});
350
351/**
352 *	Scroll to anchor point with animation
353 *
354 */
355function fn_scroll_to_anchor(anchor, top) {
356  var currentOffet = jQuery(document).scrollTop();
357  var anchorOffset = jQuery(anchor).offset();
358  if (currentOffet >= anchorOffset.top) {
359    var scroll = (currentOffet - anchorOffset.top) / 2;
360  } else {
361    var scroll = (anchorOffset.top - currentOffet) / 2;
362  }
363  if (top) {
364    var total = anchorOffset.top;
365  } else {
366    var height = jQuery(anchor).height();
367    var total = anchorOffset.top + height;
368  }
369  jQuery("html, body").animate({ scrollTop: total }, scroll);
370  return scroll;
371}
372
373/**
374 *	Ajax search
375 *
376 */
377jQuery(document).ready(function () {
378  /** On load */
379  if (
380    jQuery("body").hasClass("search-results") ||
381    jQuery("body").hasClass("search-no-results")
382  ) {
383    fn_ajax_Search();
384  }
385  /** Search type */
386  jQuery("#search-type li a").on("click", function (e) {
387    e.preventDefault();
388    jQuery("#search-type li").removeClass("active");
389    jQuery(this).parent().addClass("active");
390    var search = jQuery(this).data("search");
391    jQuery("#search-type-search").val(search);
392    jQuery("#search-page").val(1);
393    fn_ajax_Search();
394  });
395  /** Search form */
396  jQuery("#page-search").on("submit", function (e) {
397    e.preventDefault();
398    jQuery("#search-page").val(1);
399    fn_ajax_Search();
400  });
401  /** Pagination */
402  jQuery(document).on("click", ".search a.page-numbers", function (e) {
403    e.preventDefault();
404    var paginationArray = jQuery(this).attr("href").split("/");
405    var pagination = paginationArray[4];
406    jQuery("#search-page").val(pagination);
407    fn_ajax_Search();
408  });
409  /** Clear search */
410  jQuery("#clear-search").on("click", function (e) {
411    e.preventDefault();
412    jQuery("#page-s").val("").focus();
413    jQuery(this).fadeOut(250);
414    jQuery("#search-page").val(1);
415    fn_ajax_Search();
416  });
417  /** Input keypress */
418  jQuery("#page-s").keypress(function () {
419    jQuery("#clear-search").fadeIn(250);
420  });
421  /** Search blur */
422  jQuery("#page-s").blur(function () {
423    if (jQuery("#page-s").val() !== "") {
424      jQuery("#clear-search").fadeIn(250);
425    }
426  });
427  /** Value on load */
428  if (jQuery("#page-s").val() !== "") {
429    jQuery("#clear-search").fadeIn(250);
430  }
431});
432
433/**
434 *	Ajax search
435 *
436 */
437function fn_ajax_Search() {
438  var scroll = fn_scroll_to_anchor("#search-results-wrapper", true);
439  setTimeout(function () {
440    jQuery("#search-results, #pagination-wrapper").fadeOut(250);
441    jQuery("#search-loading").delay(250).fadeIn(250);
442    jQuery.ajax({
443      dataType: "json",
444      type: "POST",
445      data: jQuery("#page-search").serialize(),
446      url: "/app/themes/gsd-base/ajax/ajax.php",
447      context: this,
448      success: function (result) {
449        jQuery("#search-results").html(result["results"]);
450        jQuery("#pagination-wrapper div").html(result["pagination"]);
451        setTimeout(function () {
452          jQuery("#search-loading").fadeOut(250);
453          if (result["pagination"] !== "") {
454            jQuery("#pagination-wrapper").delay(250).fadeIn(250);
455          }
456          jQuery("#search-results").delay(250).fadeIn(250);
457
458          jQuery("#search-type-0 span").html(result["total-pages"]);
459          jQuery("#search-type-1 span").html(result["total-planning"]);
460          jQuery("#search-type-2 span").html(result["total-councillors"]);
461          jQuery("#search-type-3 span").html(result["total-committee-papers"]);
462          jQuery("#search-type-4 span").html(result["total-posts"]);
463
464          // jQuery('ul#search-type li').removeClass('active');
465          // jQuery('ul#search-type li:nth-child(' + result['active-tab'] + ') a').click();
466        }, 1000);
467      },
468    });
469  }, scroll);
470}
471
472/**
473 *	Hide powered by text for Google translate
474 *
475 */
476jQuery(document).ready(function () {
477  setTimeout(function () {
478    var select = jQuery(".goog-te-combo");
479    jQuery(".skiptranslate").html(select);
480  }, 500);
481});
482
483/**
484 *	HCHW scroll
485 *
486 */
487jQuery(document).ready(function () {
488  jQuery("#hcwh-scroll").on("click", function (e) {
489    e.preventDefault();
490    if (jQuery("#page-directory-wrapper").length > 0) {
491      fn_scroll_to_anchor("#page-directory-wrapper", true);
492    }
493    if (jQuery("#parent-page-child-wrapper").length > 0) {
494      fn_scroll_to_anchor("#parent-page-child-wrapper", true);
495    }
496  });
497});
498
499/**
500 *	Postcode lookup part 1
501 *
502 */
503jQuery(document).ready(function () {
504  jQuery("#postcode-search-1").submit(function (e) {
505    e.preventDefault();
506    jQuery("#postcode-lookup-1").slideUp(500);
507    jQuery("#postcode-loading").slideDown(500);
508    jQuery.ajax({
509      dataType: "json",
510      type: "GET",
511      data: jQuery("#postcode-search-1").serialize(),
512      url: "/app/themes/gsd-base/ajax/ajax.php",
513      context: this,
514      success: function (result, textStatus) {
515        jQuery("#postcode-lookup-2").html(result);
516        jQuery("#postcode-loading").slideUp(500);
517        jQuery("#postcode-lookup-2").delay(500).slideDown(500);
518        // console.log(textStatus);
519      },
520      error: function (request, status, error) {
521        console.log(request.responseText);
522      },
523    });
524  });
525});
526
527/**
528 *	Postcode lookup part 2
529 *
530 */
531jQuery(document).ready(function () {
532  jQuery(document).on("click", "#postcode-lookup-2-back", function (e) {
533    e.preventDefault();
534    jQuery("#postcode-lookup-2, #postcode-lookup-3").fadeOut(100);
535    jQuery("#postcode-lookup-1").delay(100).fadeIn(100);
536    jQuery("#postcode-lookup-2, #postcode-lookup-3").delay(200).html("");
537    jQuery(this).blur();
538    jQuery("#postcode-search-1 #postcode").val("");
539    setTimeout(function () {
540      jQuery("#postcode-search-1 #postcode").focus();
541    }, 1000);
542  });
543
544  jQuery(document).on("change", "#reference", function () {
545    jQuery("#postcode-search-2").submit();
546  });
547
548  jQuery(document).on("submit", "#postcode-search-2", function (e) {
549    e.preventDefault();
550    jQuery("#postcode-lookup-2").slideUp(500);
551    jQuery("#postcode-loading").slideDown(500);
552    jQuery.ajax({
553      dataType: "json",
554      type: "GET",
555      data: jQuery("#postcode-search-2").serialize(),
556      url: "/app/themes/gsd-base/ajax/ajax.php",
557      context: this,
558      success: function (result) {
559        jQuery("#postcode-lookup-3").html(result);
560        jQuery("#postcode-loading").slideUp(500);
561        jQuery("#postcode-lookup-3").delay(500).slideDown(500);
562      },
563      error: function (request, status, error) {
564        console.log(request.responseText);
565      },
566    });
567  });
568
569  var downloadButtons = document.getElementsByClassName(
570    "wp-block-file__button",
571  );
572  if (downloadButtons && downloadButtons.length > 0) {
573    for (let i = 0; i < downloadButtons.length; i++) {
574      let downloadText = "Downlad File: " + i + 1;
575      if (
576        downloadButtons[i].previousElementSibling &&
577        downloadButtons[i].previousElementSibling.textContent
578      ) {
579        downloadText = downloadButtons[i].previousElementSibling.textContent;
580      }
581      downloadButtons[i].setAttribute("aria-label", "Downlad: " + downloadText);
582    }
583  }
584
585  var idToCheck = document.getElementById("hcwh-wrapper");
586  if (idToCheck) {
587    var tabIndexLinks = idToCheck.getElementsByTagName("a");
588    if (tabIndexLinks && tabIndexLinks.length > 0) {
589      for (var i = 0; i < tabIndexLinks.length; i++) {
590        var elem = tabIndexLinks[i];
591        elem.parentElement.removeAttribute("aria-hidden");
592        elem.parentElement.removeAttribute("tabindex");
593        elem.removeAttribute("tabindex");
594      }
595    }
596  }
597
598  var idToCheckParent = document.getElementById("parent-page-wrapper");
599  if (idToCheckParent) {
600    var tabIndexLinks = idToCheckParent.getElementsByTagName("a");
601    if (tabIndexLinks && tabIndexLinks.length > 0) {
602      for (var i = 0; i < tabIndexLinks.length; i++) {
603        var elem = tabIndexLinks[i];
604        elem.parentElement.removeAttribute("aria-hidden");
605        elem.parentElement.removeAttribute("tabindex");
606        elem.removeAttribute("tabindex");
607      }
608    }
609  }
610
611  var contentLinkButtons = document.getElementsByClassName(
612    "wp-block-button__link",
613  );
614  if (contentLinkButtons && contentLinkButtons.length > 0) {
615    for (var j = 0; j < contentLinkButtons.length; j++) {
616      var elemLink = contentLinkButtons[j];
617      elemLink.removeAttribute("tabindex");
618      // elemLink.setAttribute('aria-hidden', true);
619    }
620  }
621
622  var scrollLink = document.getElementById("hcwh-scroll");
623  if (scrollLink) {
624    // scrollLink.setAttribute("tabindex", "-1");
625    // scrollLink.setAttribute("aria-hidden", true);
626  }
627
628  var frames = document.getElementsByTagName("iframe");
629  if (frames && frames.length > 0) {
630    for (var k = 0; k < frames.length; k++) {
631      let src = frames[k].src;
632      if (src && src.indexOf("recaptcha") !== -1) {
633        frames[k].title = "Recaptcha iframe";
634      } else if (src && src.indexOf("maps") !== -1) {
635        frames[k].title = "Google Maps iframe";
636      } else {
637        frames[k].title = "Youtube iframe";
638      }
639    }
640  }
641});
642
643/**
644 *	Image map resizing
645 *
646 */
647jQuery(document).ready(function () {
648  if (jQuery("map").length > 0) {
649    jQuery("map").imageMapResize();
650  }
651});
652
653/**
654 *	Cookie opt in
655 *
656 */
657jQuery(document).ready(function () {
658  jQuery("#cookie-continue").on("click", function (e) {
659    e.preventDefault();
660    jQuery.ajax({
661      type: "GET",
662      cache: false,
663      data: "cookies=continue",
664      url: jQuery(this).data("ajax-url"),
665      context: this,
666      dataType: "json",
667      success: function (html) {
668        jQuery("#cookie-layer").slideUp();
669      },
670    });
671  });
672
673  if (jQuery("#cookie-layer").length > 0) {
674    jQuery("#cookie-layer").slideDown();
675  }
676});

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.