PageSourceSearch

https://nbrc.net/wp-content/themes/planeteriaweb/js/custom.js?ver=1790342240

js nbrc.net collected 2026-09-25 18:40:30 UTC 56,480 bytes, 1,796 lines download raw bytes

1$(document).ready(function () {
2	 $('.center-grp .wp-block-table').each(function () {
3    $(this).wrap('<div class="table-wrapper"></div>');
4  });
5   $('.owl-general .owl-carousel').owlCarousel({
6  loop: true,
7  dots: false,
8  autoplay: true,
9  margin: 10,
10  nav: true,
11  autoWidth: false,
12  items: 1,
13  navText: [
14    '<img src="/wp-content/themes/planeteriaweb/img/arrow_forward.svg">',
15    '<img src="/wp-content/themes/planeteriaweb/img/arrow_forward.svg">'
16  ],
17  navContainer: '.owl-general .custom-nav',
18  responsive: {
19    0: {
20      items: 1,
21      stagePadding: 0,    // ADD: removes next-slide bleed on mobile
22      margin: 0           // ADD: no gap on mobile
23    },
24    600: {
25      items: 1,
26      stagePadding: 0,    // ADD: removes bleed on tablet too
27      margin: 10
28    },
29    1000: {
30      items: 1,
31      stagePadding: 200   // KEPT: your original desktop peek effect
32    }
33  }
34});
35   
36   // jQuery(document).ready(function($) {
37  // // Select all default WP gallery blocks
38  // $('.wp-block-gallery').each(function(index, gallery) {
39    
40    // // Add Owl classes
41    // $(gallery).addClass('owl-carousel owl-theme').removeClass('wp-block-gallery');
42
43    // // Each inner figure becomes a slide
44    // $(gallery).children('figure').addClass('item');
45
46    // // Initialize Owl on this gallery
47    // $(gallery).owlCarousel({
48      // loop: true,
49      // dots: false,
50      // autoplay: true,
51      // margin: 10,
52      // nav: true,
53      // autoWidth: false,
54      // items: 1,
55      // navText: [
56        // '<img src="/wp-content/themes/your-theme/img/arrow_forward.svg">',
57        // '<img src="/wp-content/themes/your-theme/img/arrow_forward.svg">'
58      // ]
59    // });
60  // });
61// });
62
63       $('.wp-block-group,.wp-block-columns ,.wp-block-column').removeClass('is-layout-flow');
64
65   // Function to activate the tab based on URL fragment
66   var hash = window.location.hash;
67   if (hash) {
68      $('.nav-link[href="' + hash + '"]').tab('show');
69   }
70
71   // Update URL when tab is clicked
72   $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
73      history.pushState(null, null, e.target.hash);
74   });
75
76   //Navbar
77
78if (window.matchMedia("(min-width: 1200px)").matches) {
79    // Append toggle button to menu items with children
80    $('.dropdown-menu > li.menu-item-has-children').prepend('<div class="plus-minus" tabindex="0" aria-expanded="false" role="button" aria-label="Toggle submenu"></div>');
81
82    // Handle toggle click
83    $('.dropdown-menu').on('click keydown', '.plus-minus', function(e) {
84        // Handle click or Enter/Space key
85        if (e.type === 'click' || (e.type === 'keydown' && (e.key === 'Enter' || e.key === ' '))) {
86            e.preventDefault(); // Prevent scrolling on Space
87
88            const $this = $(this);
89            const $submenu = $this.parent().find('> .mega-submenu');
90            const isOpen = $this.attr('aria-expanded') === 'true';
91
92            // Toggle current
93            $submenu.slideToggle('fast');
94            $this.toggleClass('minus-icon').attr('aria-expanded', String(!isOpen));
95
96            // Close others
97            $this.parent().siblings('li').find('> .mega-submenu').slideUp('fast');
98            $this.parent().siblings('li').find('.plus-minus')
99                .removeClass('minus-icon')
100                .attr('aria-expanded', 'false');
101        }
102    });
103}
104
105
106
107   if (jQuery(window).width() < 1200) {
108      $('.navbar-nav  > li.menu-item-has-children, .navbar-nav  > li.megamenu_item   ').append('<div class="plusMinus"></div>');
109      jQuery(".navbar-nav > li.menu-item-has-children > .plusMinus, .navbar-nav > li.megamenu_item > .plusMinus").click(function () {
110    var $parentLi = jQuery(this).parent();
111    var $submenu = $parentLi.find('.dropdown-menu, .megamenu_drop, .megamenu');
112    var $headerWrapper = $parentLi.closest('.header_group_wraper');
113    var menuTitle = $parentLi.children("a").text().trim();
114
115    // Add submenu header if not already added
116    if ($submenu.find('.submenu-header').length === 0) {
117        var headerHtml = `
118            <li class="submenu-header">
119                <button class="submenu-back" aria-label="Go back">Back</button>
120                <span class="submenu-title">${menuTitle}</span>
121            </li>`;
122        $submenu.prepend(headerHtml);
123    }
124
125    // Toggle active classes
126    $parentLi.toggleClass('activeBlue');
127    jQuery(this).toggleClass("minsicon");
128    $headerWrapper.toggleClass('sub_menu_opened');
129
130    // Get submenu height and set to header wrapper
131    if ($headerWrapper.hasClass('sub_menu_opened')) {
132        var submenuHeight = $submenu.outerHeight(true); // true = includes margins
133        $headerWrapper.css('height', submenuHeight + 'px');
134    } else {
135        $headerWrapper.css('height', ''); // Reset height when closed
136    }
137});
138
139
140// Back button handler
141jQuery(document).on("click", ".submenu-back", function () {
142    var $headerWrapper = jQuery(this).closest('.header_group_wraper');
143    $headerWrapper.removeClass('sub_menu_opened').css('height', 'auto');
144    jQuery(this).closest('.activeBlue').removeClass('activeBlue');
145    
146});
147
148
149
150
151        $('.megadrop  > li.menu-item-has-children').append('<div class="plus-minus"></div>');
152   let megasubmenuHeight = 0; // define globally for both events
153
154jQuery(".megadrop > li.menu-item-has-children > .plus-minus").click(function () {
155    console.log('mega menu clicked');
156    var $parentLi = jQuery(this).parent();
157    var $submenu = $parentLi.find('.mega-submenu');
158    const megasubmenu = $parentLi.closest('.megadrop');
159    megasubmenuHeight = megasubmenu.outerHeight(true); // assign here
160    console.log('mega menu clicked', $submenu);
161    var $headerWrapperSm = $parentLi.closest('.header_group_wraper');
162    var menuTitle = $parentLi.children("a").text().trim();
163
164    if ($submenu.find('.submenu-header').length === 0) {
165        var headerHtml = `
166            <li class="submenu-header">
167                <button class="mg-submenu-back" aria-label="Go back">Back</button>
168                <span class="submenu-title">${menuTitle}</span>
169            </li>`;
170        $submenu.prepend(headerHtml);
171    }
172
173    $parentLi.toggleClass('activeBlue');
174    jQuery(this).toggleClass("minsicon");
175    $headerWrapperSm.toggleClass('megasub_menu_opened');
176
177    if ($headerWrapperSm.hasClass('megasub_menu_opened')) {
178        var submenuHeight = $submenu.outerHeight(true);
179        $headerWrapperSm.css('height', submenuHeight + 'px');
180    } else {
181        $headerWrapperSm.css('height', '');
182    }
183});
184
185jQuery(document).on("click", ".mg-submenu-back", function () {
186    var $headerWrapperSm = jQuery(this).closest('.header_group_wraper');
187    $headerWrapperSm.removeClass('megasub_menu_opened').css('height', megasubmenuHeight + 'px');
188    jQuery(this).closest('.activeBlue').removeClass('activeBlue');
189});
190
191
192
193
194    $('.megamenu_drop  li.menu-item-has-children  ').append('<div class="pls_minus"></div>');
195
196      jQuery(".megamenu_drop  li.menu-item-has-children  .pls_minus").click(function () {
197         $(this).parent().find('.sub-menu').slideToggle("fast");
198         $(this).parent().toggleClass('active-item');
199         $(this).toggleClass("minus-info");
200      });
201      $('.wp-block-advgb-table').each(function () {
202         $(this).wrap('<div class="table-wrap"></div>');
203      });
204      $('.wp-block-group > table').wrap('<div class="table-wrapper"></div>');
205      
206
207   }
208
209
210 
211   $(".navbar-toggler").on("click", function () {
212      $(this).toggleClass("active");
213      $('.main_header').toggleClass("headerActive");
214   });
215   
216   // Mirror behavior: when navbar toggler opens the menu (adds .active),
217   // trigger .promagnifier only if .prosettings.hiddend exists.
218   $(".navbar-toggler").on("click", function () {
219     var $btn = $(this);
220     var isActive = $btn.hasClass("active");
221       
222     // Find promagnifier (prefer inside header, then global)
223     var $pm = $btn.closest("header, .main_header").find(".promagnifier");
224     if ($pm.length === 0) {
225       $pm = $(".promagnifier").first();
226     }
227       
228     if ($pm.length) {
229       // Check for .prosettings.hiddend inside header first, then globally
230       var $ps = $btn.closest("header, .main_header").find(".prosettings.hiddend");
231       if ($ps.length === 0) {
232         $ps = $(".prosettings.hiddend");
233       }
234           
235       if ($ps.length && isActive) {
236         // navbar was opened (active present after toggle)
237         $pm.trigger("click");
238       }
239     }
240   });
241
242
243
244 
245
246
247   $('.text_card_block .btn_sm  ').parents('.img_text_card_col').find('.text-img-wrap').addClass("has-button ");
248
249   $('.advgb-accordion-body').each(function () {
250      $(this).wrapInner('<div class="accordion-content"></div>');
251   });
252   /*
253                     $('.main_content > *').wrapAll('<div class="main-wrap"></div>');*/
254   if (window.location.hash) {
255    
256     var target = $(window.location.hash); // Get the element based on the hash
257    if (target.length) { // Check if the element exists
258        var offset = $('.advgb-tabs-panel').outerHeight() + 30; // Adjust the offset
259        $('html, body').animate({
260            scrollTop: target.offset().top - offset // Scroll to the element
261        }, 1000);
262    }
263   }
264   $('.rel_forms').parent(".col_right").addClass("has_forms ");
265   $('.alerticon').parent(".rtTitle").addClass("p-left ");
266   $('a[href$=".pdf"]').each(function () {
267      // Open the PDF link in a new window
268      $(this).attr('target', '_blank');
269   });
270   $('.carousel-inner').each(function () {
271      if ($(this).children('div').length === 1) $(this).siblings('.carousel-indicators, .carousel-control-prev, .carousel-control-next').hide();
272
273   });
274   $('.img_block .img_block_descr').each(function () {
275      // Check if this div contains a p tag
276      if ($(this).find('p').length === 0) {
277         // If no p tag is found, add the class to the closest div
278         $(this).closest('.img_block').addClass('no-p-tag');
279      }
280   });
281       $(".links li .expand_det").matchHeight({
282    byRow: true,
283    property: 'height',
284    target: null,
285    remove: false
286});
287
288    $(".img_text_card_col .text_card_block ").matchHeight({
289        byRow: true,
290        property: 'height',
291        target: null,
292        remove: false
293    });
294$('.advgb-accordion-item .advgb-accordion-body').css('border', '0px');
295
296//Translate using keyboard
297 setTimeout(function () {
298        let $translateButton = $(".gt_selected");
299        let $translateMenu = $(".gt_option"); 
300
301        if ($translateButton.length && $translateMenu.length) {
302            $translateButton.on("click", function () {
303                setTimeout(function () {
304                    let $iframe = $(".gt_option");
305                    if ($iframe.length) {
306                        $iframe.attr("tabindex", "-1").focus(); 
307                    }
308                }, 500); 
309            });
310            $(document).on("keydown", function (event) {
311                if (event.key === "Escape") {
312                    let $iframe = $(".gt_option");
313                    if ($iframe.length) {
314                        $iframe.hide(); 
315                        $translateButton.focus(); 
316                    }
317                }
318            });
319        }
320    }, 2000);
321
322
323});
324
325$(window).on('resize', function () {
326/*
327   if (jQuery(window).width() < 1200) {
328      $(".select_language ").insertBefore('.navbar-toggler  ');
329      $(".soc_nav_wrap ").insertAfter('.nav_bottom');
330   }
331   if (jQuery(window).width() > 1200) {
332      $(".select_language ").insertBefore('.top_search  ');
333      $(".soc_nav_wrap ").insertBefore('.select_language');
334   }*/
335
336
337});
338
339//Url in window target
340(function ($, window) {
341   var adjustAnchor = function () {
342
343      var $anchor = $(':target'),
344         fixedElementHeight = 150;
345
346      if ($anchor.length > 0) {
347
348         $('html, body')
349            .stop()
350            .animate({
351               scrollTop: $anchor.offset().top - fixedElementHeight
352            }, 200);
353         window.scrollTo(0, $anchor.offset().top - fixedElementHeight);
354
355      }
356
357   };
358
359   $(window).on('hashchange load', function () {
360      adjustAnchor();
361   });
362
363})(jQuery, window);
364
365
366
367//Header shrink on scroll
368$(document).on("scroll ", function () {
369   if ($(document).scrollTop() > 0) {
370      $(".main_header ").addClass("shrink ");
371
372   } else {
373      $(".main_header ").removeClass("shrink ");
374
375   }
376});
377
378//main accordion
379
380(function ($) {
381   $('.accmain .acctitle').click(function (j) {
382      var dropDown = $(this).closest('.acccard').find('.accpanel');
383      $(this).closest('.accmain').find('.accpanel').not(dropDown).slideUp();
384      if ($(this).hasClass('active')) {
385         $(this).removeClass('active');
386      } else {
387         $(this).closest('.accmain').find('.acctitle.active').removeClass('active');
388         $(this).addClass('active');
389      }
390
391      dropDown.stop(false, true).slideToggle();
392
393      j.preventDefault();
394   });
395})(jQuery);
396$(function () {
397   $('[data-toggle="tooltip"]').tooltip()
398})
399
400$(window).on('load', function () {
401   $('.wp-block-image.alignleft,  .wp-block-image.alignright').wrap('<div class="left_right_wraper"></div>');
402});
403
404
405
406         function checkOverflow() {
407                $('.advgb-tabs-wrapper').each(function() {
408                    var $tabs = $(this).find('.advgb-tabs-panel');
409                    if ($tabs[0].scrollWidth > $tabs[0].clientWidth) {
410                        $(this).addClass('overflowing');
411                    } else {
412                        $(this).removeClass('overflowing');
413                    }
414                });
415            }
416
417            // Initial check
418            checkOverflow();
419
420            // Check on window resize
421            $(window).on('resize', function() {
422                checkOverflow();
423            });
424			
425			
426			
427			
428			 function checkOverflow1() {
429                $('.kt-tabs-wrap').each(function() {
430                    var $tabs1 = $(this).find('.kt-tabs-title-list');
431                    if ($tabs1[0].scrollWidth > $tabs1[0].clientWidth) {
432                        $(this).addClass('overflowing');
433                    } else {
434                        $(this).removeClass('overflowing');
435                    }
436                });
437            }
438
439            // Initial check
440            checkOverflow1();
441
442            // Check on window resize
443            $(window).on('resize', function() {
444                checkOverflow1();
445            });
446			
447         //    $(document).ready(function () {
448         //       function moveLogo() {
449         //           if ($(window).width() < 1200) {
450         //               $(".logo_wrap").insertBefore('.navbar-toggler');
451         //           } else {
452         //               $(".logo_wrap").insertBefore('.navbar-nav '); // adjust selector as needed
453         //           }
454         //       }
455           
456         //       moveLogo(); // Initial call
457           
458         //       $(window).resize(function () {
459         //           moveLogo(); // Call on resize
460         //       });
461         //   });
462
463
464  $(document).ready(function(){
465
466
467
468  var announcementsOwl = $(".announcements-carousel").owlCarousel({
469    items: 1,
470    nav: false,
471    dots: false,
472    loop: true,               // looping ON
473    autoplay: true,
474    autoplayHoverPause: true,
475    startPosition: 0,         // start from first real slide
476    smartSpeed: 450,         // smooth slide transition
477    // Use shared pagination updater below via events
478  });
479
480  // ✅ Custom next / prev buttons
481  $(".announcement-container .owl-custom-next").click(function () {
482    announcementsOwl.trigger("next.owl.carousel");
483  });
484  $(".announcement-container .owl-custom-prev").click(function () {
485    announcementsOwl.trigger("prev.owl.carousel");
486  });
487
488  // Helper: update page number while ignoring cloned slides (when loop=true)
489  function updatePageNumberFromEvent(event, currentSelector, totalSelector) {
490    // event.item.count is number of real items
491    var total = event.item.count || 0;
492    var index = event.item.index;
493
494    // When loop is enabled, owl adds clones and index references cloned items.
495    // Calculate the real index within [0 .. total-1]
496    if (event.relatedTarget && typeof event.relatedTarget.normalize === 'function') {
497      // If available, use normalized position (safer across versions)
498      index = event.relatedTarget.normalize(index, true);
499    } else if (total) {
500      // Fallback: map index into real range
501      index = ((index % total) + total) % total; // ensure positive
502    }
503
504    var current = (index || 0) + 1; // show 1-based
505    $(currentSelector).text(current);
506    $(totalSelector).text(total);
507  }
508
509  // Bind announcements pagination updates
510  $(".announcements-carousel").on('initialized.owl.carousel changed.owl.carousel', function(event) {
511    updatePageNumberFromEvent(event, '.current_page_announcements', '.total_pages_announcements');
512  });
513
514  // Bind events pagination updates using the same helper BEFORE initializing
515  $(".events-carousel").on('initialized.owl.carousel changed.owl.carousel', function(event) {
516    updatePageNumberFromEvent(event, '.current_page_events', '.total_pages_events');
517  });
518
519  // Initialize Events carousel and store reference (single init)
520  var eventsOwl = $(".events-carousel").owlCarousel({
521     items: 1,
522     nav: false,
523     loop: false,
524     dots: false,
525     autoplay: true,
526     startPosition: 0,         // start from first real slide
527    smartSpeed: 450, 
528     autoplayHoverPause: true
529   });
530
531   // Add custom navigation for events carousel
532   $(".events_container .owl-custom-prev").click(function() {
533     eventsOwl.trigger("prev.owl.carousel");
534   });
535
536   $(".events_container .owl-custom-next").click(function() {
537     eventsOwl.trigger("next.owl.carousel");
538   });
539
540 });
541
542/**
543 * WCAG 2.4.7: inactive Owl slides sit off-screen behind overflow:hidden, so their
544 * links still receive Tab focus but show no visible focus ring. Keep only the
545 * active slide(s) in the tab order. Wired via [data-a11y-owl-links] on home carousels.
546 */
547function planeteriawebSyncOwlSlideTabStops($carousel) {
548  if (!$carousel || !$carousel.length) {
549    return;
550  }
551
552  $carousel.find('.owl-item').each(function () {
553    var $item = $(this);
554    var isActive = $item.hasClass('active');
555
556    $item.attr('aria-hidden', isActive ? 'false' : 'true');
557
558    $item.find('a, button, input, select, textarea, [tabindex]').each(function () {
559      var $el = $(this);
560
561      if (isActive) {
562        if ($el.data('a11yPrevTabindex') !== undefined) {
563          var prev = $el.data('a11yPrevTabindex');
564          if (prev === null || prev === '') {
565            $el.removeAttr('tabindex');
566          } else {
567            $el.attr('tabindex', prev);
568          }
569        } else {
570          $el.removeAttr('tabindex');
571        }
572        $el.removeData('a11yPrevTabindex');
573      } else {
574        if ($el.data('a11yPrevTabindex') === undefined) {
575          var existing = $el.attr('tabindex');
576          $el.data('a11yPrevTabindex', existing !== undefined ? existing : null);
577        }
578        $el.attr('tabindex', '-1');
579      }
580    });
581  });
582}
583
584function planeteriawebBindOwlSlideTabStops($carousel) {
585  if (!$carousel || !$carousel.length || $carousel.data('a11yOwlBound')) {
586    return;
587  }
588
589  $carousel.data('a11yOwlBound', true);
590
591  $carousel.on('initialized.owl.carousel refreshed.owl.carousel changed.owl.carousel translated.owl.carousel', function () {
592    window.setTimeout(function () {
593      planeteriawebSyncOwlSlideTabStops($carousel);
594    }, 0);
595  });
596
597  $carousel.on('focusin', function () {
598    $carousel.trigger('stop.owl.autoplay');
599  });
600  $carousel.on('focusout', function (e) {
601    if (!$carousel[0].contains(e.relatedTarget)) {
602      $carousel.trigger('play.owl.autoplay');
603    }
604  });
605
606  planeteriawebSyncOwlSlideTabStops($carousel);
607}
608
609$(document).ready(function () {
610  $('[data-a11y-owl-links]').each(function () {
611    planeteriawebBindOwlSlideTabStops($(this));
612  });
613});
614
615
616
617$(document).ready(function() {
618  var bigimage = $("#big");
619  var thumbs = $("#thumbs");
620  //var totalslides = 10;
621  var syncedSecondary = true;
622
623  bigimage
624    .owlCarousel({
625    items: 1,
626    slideSpeed: 2000,
627    nav: true,
628    autoplay: true,
629    dots: false,
630    loop: true,
631    responsiveRefreshRate: 200,
632    navText: [
633      '<img src="/wp-content/themes/planeteriaweb/img/left-arrow.svg" alt="arrow icon">',
634        '<img src="/wp-content/themes/planeteriaweb/img/right-arrow.svg" alt="arrow icon">'
635    ]
636  })
637    .on("changed.owl.carousel", syncPosition);
638
639  thumbs
640    .on("initialized.owl.carousel", function() {
641    thumbs
642      .find(".owl-item")
643      .eq(0)
644      .addClass("current");
645  })
646    .owlCarousel({
647    dots: true,
648    nav: false,
649    smartSpeed: 200,
650    slideSpeed: 500,
651    slideBy: 4,
652    responsive: {
653    0: {
654      items: 4   // Force 4 thumbs on mobile
655    },
656    600: {
657      items: 4
658    },
659    1000: {
660      items: 4
661    }
662  }
663  })
664    .on("changed.owl.carousel", syncPosition2);
665
666  function syncPosition(el) {
667    //if loop is set to false, then you have to uncomment the next line
668    //var current = el.item.index;
669
670    //to disable loop, comment this block
671    var count = el.item.count - 1;
672    var current = Math.round(el.item.index - el.item.count / 2 - 0.5);
673
674    if (current < 0) {
675      current = count;
676    }
677    if (current > count) {
678      current = 0;
679    }
680    //to this
681    thumbs
682      .find(".owl-item")
683      .removeClass("current")
684      .eq(current)
685      .addClass("current");
686    var onscreen = thumbs.find(".owl-item.active").length - 1;
687    var start = thumbs
688    .find(".owl-item.active")
689    .first()
690    .index();
691    var end = thumbs
692    .find(".owl-item.active")
693    .last()
694    .index();
695
696    if (current > end) {
697      thumbs.data("owl.carousel").to(current, 100, true);
698    }
699    if (current < start) {
700      thumbs.data("owl.carousel").to(current - onscreen, 100, true);
701    }
702  }
703
704  function syncPosition2(el) {
705    if (syncedSecondary) {
706      var number = el.item.index;
707      bigimage.data("owl.carousel").to(number, 100, true);
708    }
709  }
710
711  thumbs.on("click", ".owl-item", function(e) {
712    e.preventDefault();
713    var number = $(this).index();
714    bigimage.data("owl.carousel").to(number, 300, true);
715  });
716});
717
718
719
720
721  (function($) {
722            /* $('.accordion_event > li:eq(0) .acco_title').addClass('active').next().slideDown();*/
723
724            $('.acc__main .acc__title').click(function(j) {
725                var dropDown = $(this).closest('.acc__card').find('.acc__panel');
726
727                $(this).closest('.acc__main').find('.acc__panel').not(dropDown).slideUp();
728
729                if ($(this).hasClass('active')) {
730                    $(this).removeClass('active');
731                } else {
732                    $(this).closest('.acc__main').find('.acc__title.active').removeClass('active');
733                    $(this).addClass('active');
734                }
735
736                dropDown.stop(false, true).slideToggle();
737
738                j.preventDefault();
739            });
740})(jQuery);
741
742
743$(document).ready(function () {
744  $('.aspm-container.menu-item-object-custom').on('click keydown', function (e) {
745    // Trigger only if clicked directly or Enter key pressed while focused
746    if (e.target !== this) return;
747
748    // Allow activation via Enter key or mouse click
749    if (e.type === 'click' || (e.type === 'keydown' && e.key === 'Enter')) {
750      e.preventDefault();
751      e.stopPropagation();
752
753      var $this = $(this);
754      var $searchWrapper = $this.find('.asp_m').length
755        ? $this.find('.asp_m')
756        : $('.asp_m').first();
757      var $proInput = $searchWrapper.find('.proinput');
758      var $searchInput = $searchWrapper.find('input.orig');
759
760      $this.toggleClass('search_open');
761
762      if ($this.hasClass('search_open')) {
763        searchVisible = true;
764        // $proInput.removeClass('hiddend').show();
765        setTimeout(function () {
766          $searchInput.focus();
767        }, 100);
768      }
769    }
770  });
771});
772
773  
774jQuery(document).ready(function ($) {
775    // Store original parent and position
776    var $aspm = $('.aspm-container');
777    var $originalParent = $aspm.parent();
778    var $originalNext = $aspm.next();
779
780    function moveASPMContainer() {
781        if ($(window).width() < 1200) {
782            $aspm.insertBefore('#menu-main-menu');
783        } else {
784            if ($originalNext.length) {
785                $aspm.insertBefore($originalNext);
786            } else {
787                $aspm.appendTo($originalParent);
788            }
789        }
790    }
791
792    // Run on page load
793    moveASPMContainer();
794
795    // Run on window resize
796    $(window).resize(function () {
797        moveASPMContainer();
798    });
799});
800
801
802  
803   
804
805$(".kb-table").each(function() {
806    const $table = $(this);
807    const $tbody = $table.find("tbody").first();
808    if ($tbody.length === 0) return;
809
810    const $firstRow = $tbody.find("tr").first();
811    if ($firstRow.length === 0) return;
812
813    const $thElements = $firstRow.find("th");
814
815    if ($thElements.length > 0) {
816        const $thead = $("<thead></thead>");
817        $thead.append($firstRow); // Move the first row into the thead
818        $table.prepend($thead); // Insert thead before tbody
819    }
820});
821//
822
823document.addEventListener("DOMContentLoaded", function () {
824  document.querySelectorAll(".wp-block-media-text.custom_media").forEach(function (block, index) {
825    
826    const figure = block.querySelector("figure");
827    const img = block.querySelector("img");
828    if (!img) return;
829    const imgSrc = img.getAttribute("src");
830    // Unique clipPath id per instance (WCAG 4.1.1).
831    const clipId = "clipPathScaled-media-" + index;
832
833    const template = `
834      <figure class="cs_media_img">
835        <svg xmlns="http://www.w3.org/2000/svg" width="548" height="459" viewBox="0 0 548 459">
836          <defs>
837            <clipPath id="${clipId}">
838              <path d="M348.848 454.743C73.6394 467.664 -32.5061 327.996 8.97387 126.977C50.4539 -74.0415 96.3323 22.045 168.034 36.1563C350.424 77.7852 538.681 150.957 547.301 358.488C550.867 496.795 407.87 449.732 348.848 454.743Z"></path>
839            </clipPath>
840          </defs>
841
842          <!-- Background shape (border) -->
843          <path d="M348.848 454.743C73.6394 467.664 -32.5061 327.996 8.97387 126.977C50.4539 -74.0415 96.3323 22.045 168.034 36.1563C350.424 77.7852 538.681 150.957 547.301 358.488C550.867 496.795 407.87 449.732 348.848 454.743Z" fill="#D27D29"></path>
844
845          <!-- Slightly scaled down image inside clip -->
846          <g transform="scale(0.97) translate(5, 0)">
847            <image xlink:href="${imgSrc}" width="548" height="570" x="0" y="0"
848              preserveAspectRatio="xMaxYMin slice" clip-path="url(#${clipId})"></image>
849          </g>
850        </svg>
851      </figure>
852    `;
853
854    // ✅ Convert string to DOM and replace properly
855    const wrapper = document.createElement("div");
856    wrapper.innerHTML = template.trim();
857    const newFigure = wrapper.firstChild;
858
859    figure.replaceWith(newFigure);
860  });
861});
862
863document.addEventListener("DOMContentLoaded", function () {
864  document.querySelectorAll(".wp-block-media-text.custom_media_optional").forEach(function (block, index) {
865    
866    const figure = block.querySelector("figure");
867    const img = block.querySelector("img");
868    if (!img) return;
869    const imgSrc = img.getAttribute("src");
870    // Unique clipPath id per instance (WCAG 4.1.1).
871    const maskId = "jamesMask-media-" + index;
872
873    const template = `
874      <figure class="cs_media_img">
875                                    <svg width="536" height="783" viewBox="0 0 536 783" fill="none" xmlns="http://www.w3.org/2000/svg">
876                        <path d="M469.373 37.1576C596.116 380.977 543.599 682.503 242.803 765.741C168.207 786.544 132.54 821.569 55.7838 634.344C-20.9729 447.119 -21.2248 147.406 207.256 72.4402C264.986 54.3177 419.361 100.22 469.373 37.1576Z" fill="#0F8642"></path>
877
878                        <clipPath id="${maskId}">
879                            <path d="M465.235 0C588.038 344.372 532.442 644.648 231.454 724.502C156.809 744.466 120.853 779.031 46.2598 591.423C-28.3334 403.814 -25.4041 104.787 203.347 32.4192C261.136 14.951 381.306 0 465.235 0Z"></path>
880                        </clipPath>
881                        <image xlink:href="${imgSrc}" x="0" y="0" width="640" height="783" clip-path="url(#${maskId})" preserveAspectRatio="xMaxYMin slice"></image>
882                        </svg>
883
884                    </figure>
885    `;
886
887    // ✅ Convert string to DOM and replace properly
888    const wrapper = document.createElement("div");
889    wrapper.innerHTML = template.trim();
890    const newFigure = wrapper.firstChild;
891
892    figure.replaceWith(newFigure);
893  });
894});
895
896
897$(".contact_detail_wrap p").each(function() {
898  let text = $(this).text().toLowerCase();
899  
900  if (text.includes("phone") && text.includes("email") && text.includes("hours")) {
901    $(this).addClass("contact-details");
902  }
903});
904
905jQuery(document).ready(function($) {
906  $(".wp-block-table td:has(a)").addClass("linked_td");
907});
908
909
910// Initialize search functionality
911// jQuery(document).ready(function($) {
912//     // Global search state management
913//     var searchVisible = false;
914    
915//     // Handle magnifier click
916//     jQuery(document).on('click', '.promagnifier', function(e) {
917//         e.preventDefault();
918//         e.stopPropagation();
919        
920//         var $wrapper = jQuery(this).closest('.asp_m');
921//         var $input = $wrapper.find('input.orig');
922//         var $proinput = $wrapper.find('.proinput');
923//         var $container = jQuery(this).closest('.aspm-container');
924        
925//         // Force show search
926//         $proinput.removeClass('hiddend');
927//         $container.addClass('search_open');
928//         searchVisible = true;
929        
930//         // Focus and trigger search
931//         $input.focus();
932        
933//         // Force trigger search
934//         $input.trigger({
935//             type: 'keyup',
936//             which: 13,
937//             keyCode: 13
938//         });
939//     });
940    
941//     // Prevent search from being hidden
942//     jQuery(document).on('click', function(e) {
943//         if (searchVisible && jQuery(e.target).closest('.asp_m').length) {
944//             e.stopPropagation();
945//         }
946//     });
947    
948//     // Monitor for class changes
949//     var observer = new MutationObserver(function(mutations) {
950//         mutations.forEach(function(mutation) {
951//             if (mutation.attributeName === 'class') {
952//                 var $element = jQuery(mutation.target);
953//                 if ($element.hasClass('proinput') && $element.hasClass('hiddend') && searchVisible) {
954//                     $element.removeClass('hiddend');
955//                 }
956//             }
957//         });
958//     });
959    
960//     // Observe all search inputs
961//     jQuery('.proinput').each(function() {
962//         observer.observe(this, { attributes: true });
963//     });
964// });
965jQuery(function ($) {
966  if (typeof Choices !== 'function') {
967    console.warn('Choices library not loaded; skipping language selects initialization.');
968    return;
969  }
970
971  $('.select_language select').each(function () {
972    var el = this;
973    if (el.dataset.choicesInitialized) return;
974    new Choices(el, {
975      searchEnabled: false,
976      itemSelectText: '',
977      shouldSort: false
978    });
979    el.dataset.choicesInitialized = '1';
980  });
981});
982
983
984$(document).ready(function () {
985    let maxHeight = 0;
986    $(".simple_list_col").each(function () {
987        maxHeight = Math.max(maxHeight, $(this).outerHeight());
988    });
989    $(".simple_list_col").css("height", maxHeight);
990});
991
992
993
994/*let x = document.querySelectorAll(".count");
995
996let arr = Array.from(x);
997
998arr.map((item) => {
999  let count = item.innerHTML;
1000  item.innerHTML = "0";
1001  let countNumber = 0;
1002  setInterval((counterUp) => {
1003    if (countNumber <= count) {
1004      item.innerHTML = countNumber;
1005      countNumber++;
1006    } else {
1007      clearInterval;
1008    }
1009  }, item.dataset.speed / count);
1010});*/
1011
1012document.addEventListener("DOMContentLoaded", () => {
1013
1014  const counters = document.querySelectorAll(".count");
1015
1016  const startCounter = (counter) => {
1017    const target = parseInt(counter.dataset.target);
1018    const duration = parseInt(counter.dataset.speed) || 1500;
1019
1020    let start = 0;
1021    let startTime = null;
1022
1023    const animate = (time) => {
1024      if (!startTime) startTime = time;
1025      const progress = Math.min((time - startTime) / duration, 1);
1026
1027      // smooth slow-down effect
1028      const eased = 1 - Math.pow(1 - progress, 3);
1029      const value = Math.floor(eased * target);
1030
1031      counter.innerText = value.toLocaleString();
1032
1033      if (progress < 1) {
1034        requestAnimationFrame(animate);
1035      } else {
1036        counter.innerText = target.toLocaleString();
1037      }
1038    };
1039
1040    requestAnimationFrame(animate);
1041  };
1042
1043  const observer = new IntersectionObserver(
1044    (entries) => {
1045      entries.forEach(entry => {
1046        if (entry.isIntersecting && !entry.target.classList.contains("counted")) {
1047          entry.target.classList.add("counted");
1048          startCounter(entry.target);
1049        }
1050      });
1051    },
1052    { threshold: 0.5 }
1053  );
1054
1055  counters.forEach(counter => observer.observe(counter));
1056});
1057
1058jQuery(document).ready(function($) {
1059
1060  function updateFeaturedPagination(event) {
1061    if (!event.namespace || event.property.name !== "position") {
1062      return;
1063    }
1064    var carousel = event.relatedTarget;
1065    var current  = (carousel.relative(carousel.current()) + 1);
1066    var total    = carousel.items().length;
1067
1068    $(".current_page_featured").text(current);
1069    $(".total_pages_featured").text(total);
1070  }
1071
1072  // Initialize featured carousel
1073  var featuredOwl = $(".featured-carousel").owlCarousel({
1074    items: 1,
1075    loop: false,
1076    nav: false,
1077    dots: false,
1078    autoplay: true,
1079    autoplayHoverPause: true,
1080    smartSpeed: 450,
1081  });
1082
1083  // Pagination update on init + slide change
1084  $(".featured-carousel").on('initialized.owl.carousel changed.owl.carousel', function(event) {
1085    updateFeaturedPagination(event);
1086  });
1087
1088  // Custom nav buttons
1089  $(".featured-story-container .owl-custom-prev").click(function() {
1090    featuredOwl.trigger("prev.owl.carousel");
1091  });
1092  $(".featured-story-container .owl-custom-next").click(function() {
1093    featuredOwl.trigger("next.owl.carousel");
1094  });
1095
1096});
1097
1098
1099
1100// events replace
1101// jQuery(document).ready(function ($) {
1102//     var searchBar = $('.tribe-events-c-events-bar__search');
1103//     var filtersBar = $('.tribe-filter-bar__filters');
1104
1105//     if (searchBar.length && filtersBar.length) {
1106//         searchBar.insertBefore(filtersBar);
1107//     }
1108// });
1109
1110
1111jQuery(document).ready(function ($) {
1112
1113    let isRunning = false;
1114
1115    function tribeUIFixes() {
1116
1117        if (isRunning) return;
1118        isRunning = true;
1119
1120        setTimeout(() => {
1121
1122            /* =========================
1123               1. Move Search Bar (SAFE)
1124            ========================== */
1125            const $searchBar = $('.tribe-events-c-events-bar__search');
1126            const $filtersBar = $('.tribe-filter-bar__filters');
1127
1128            if ($searchBar.length && $filtersBar.length) {
1129
1130                // 🚨 Skip if user is typing (prevents focus loss)
1131                if (!$searchBar.find(':focus').length) {
1132
1133                    if (!$searchBar.prev().is($filtersBar)) {
1134                        $searchBar.insertBefore($filtersBar);
1135                    }
1136                }
1137            }
1138
1139            /* =========================
1140               1b. Add Reset Filters link (Calendar)
1141            ========================== */
1142            if ($filtersBar.length) {
1143                const isCalendarPage =
1144                    window.location.pathname.replace(/\/+$/, '') === '/calendar' ||
1145                    $('.vmrc-cal-archive').length > 0 ||
1146                    $('body').hasClass('page-template-template-events');
1147
1148                if (isCalendarPage) {
1149                    const $existing = $filtersBar.next('.reset.text-md-left');
1150                    if (!$existing.length) {
1151                        const $reset = $(
1152                            '<div class="reset text-md-left">' +
1153                                '<a href="/calendar/">Reset filters</a>' +
1154                            '</div>'
1155                        );
1156                        $filtersBar.after($reset);
1157                    }
1158                }
1159            }
1160
1161            /* =========================
1162               2. Move View Selector
1163            ========================== */
1164            const $viewSelector = $('.tribe-events-c-view-selector__content');
1165            const $datepicker = $('.tribe-events-c-top-bar__datepicker');
1166
1167            if ($viewSelector.length && $datepicker.length) {
1168                if ($viewSelector.prev()[0] !== $datepicker[0]) {
1169                    $viewSelector.insertAfter($datepicker);
1170                }
1171            }
1172
1173            /* =========================
1174               3. Convert View List → Dropdown
1175            ========================== */
1176            const $list = $('.tribe-events-c-view-selector__list');
1177
1178            if ($list.length && !$('.tribe-view-dropdown').length) {
1179
1180                const dropdownId = 'tribe-view-dropdown';
1181                const $label = $('<label />', {
1182                    class: 'tribe-view-dropdown-label',
1183                    for: dropdownId,
1184                    text: 'View'
1185                });
1186                const $select = $('<select />', {
1187                    class: 'tribe-view-dropdown',
1188                    id: dropdownId,
1189                    'aria-label': 'View'
1190                });
1191
1192                $list.find('a').each(function () {
1193                    const $a = $(this);
1194
1195                    $select.append(
1196                        $('<option />', {
1197                            text: $a.find('.tribe-events-c-view-selector__list-item-text').text().trim(),
1198                            value: $a.attr('href'),
1199                            selected: $a.attr('aria-current') === 'true'
1200                        })
1201                    );
1202                });
1203
1204                $select.on('change', function () {
1205                    window.location.href = $(this).val();
1206                });
1207
1208                $list.replaceWith($label.add($select));
1209            }
1210
1211            isRunning = false;
1212
1213        }, 80); // small throttle
1214
1215    }
1216
1217    /* =========================
1218       Initial Run
1219    ========================== */
1220    tribeUIFixes();
1221
1222    /* =========================
1223       Scoped Observer (PERFORMANCE SAFE)
1224    ========================== */
1225    const target = document.querySelector('body,.tribe-events');
1226
1227    if (target) {
1228        const observer = new MutationObserver(function () {
1229            tribeUIFixes();
1230        });
1231
1232        observer.observe(target, {
1233            childList: true,
1234            subtree: true
1235        });
1236    }
1237
1238});
1239
1240jQuery(document).ready(function ($) {
1241    function expandVmrcMonthDay($trigger) {
1242        let $cell = $trigger.closest('.tribe-events-calendar-month__day-cell--desktop');
1243
1244        if (!$cell.length) {
1245            const dayDate = $trigger.closest('.tribe-events-calendar-month__more-events').data('dayDate');
1246            if (dayDate) {
1247                $cell = $('#tribe-events-calendar-day-' + dayDate);
1248            }
1249        }
1250
1251        if (!$cell.length) {
1252            return;
1253        }
1254
1255        $cell.addClass('vmrc-month-day-expanded is-expanded');
1256        $cell.find('.tribe-events-calendar-month__calendar-event--overflow').show();
1257        $trigger.attr('aria-expanded', 'true');
1258        $trigger.closest('.tribe-events-calendar-month__more-events').hide();
1259    }
1260
1261    $(document).on('click', '[data-vmrc-month-expand]', function (event) {
1262        event.preventDefault();
1263        event.stopPropagation();
1264        expandVmrcMonthDay($(this));
1265    });
1266
1267    $(document).on('tribe_ev_calendar_init tribe-events-view-changed', function () {
1268        setTimeout(function () {
1269            $('.tribe-events-calendar-month__day-cell--desktop.vmrc-month-day-expanded .tribe-events-calendar-month__calendar-event--overflow').show();
1270        }, 60);
1271    });
1272});
1273
1274jQuery(document).ready(function ($) {
1275
1276    function moveLanguageSwitcher() {
1277        const $switcher = $('.trp-language-switcher');
1278        const $target = $('.top_inner_menu');
1279
1280        // Only move if not already in correct position
1281        if (
1282            $switcher.length &&
1283            $target.length &&
1284            !$switcher.prev().is($target)
1285        ) {
1286            $switcher.insertAfter($target);
1287        }
1288    }
1289
1290    // Run once after page load
1291    moveLanguageSwitcher();
1292
1293    // Optional delayed check for AJAX-loaded content
1294    setTimeout(moveLanguageSwitcher, 1000);
1295
1296});
1297
1298document.addEventListener('DOMContentLoaded', function () {
1299  // Find the Calendar of Events heading
1300  const heading = Array.from(document.querySelectorAll('h1, h2, h3, h4, h5, h6'))
1301    .find(el => el.textContent.trim() === 'Calendar of Events');
1302
1303  // Find the tribe events calendar table
1304  const table = document.querySelector('table.tribe-events-calendar-month');
1305
1306  if (heading && table) {
1307    // Give the heading an ID if it doesn't have one
1308    if (!heading.id) {
1309      heading.id = 'calendar-of-events-heading';
1310    }
1311    // Link the table to the heading
1312    table.setAttribute('aria-labelledby', heading.id);
1313  }
1314});
1315
1316
1317// ADA language
1318document.addEventListener('DOMContentLoaded', function () {
1319  const currentLangItem = document.querySelector(
1320    '.trp-language-item__current'
1321  );
1322
1323  if (currentLangItem) {
1324    const visibleText = currentLangItem
1325      .querySelector('.trp-language-item-name')
1326      ?.textContent.trim();
1327
1328    if (visibleText) {
1329      // Accessible name now contains the visible label text
1330      currentLangItem.setAttribute(
1331        'aria-label',
1332        visibleText
1333      );
1334    }
1335  }
1336});
1337
1338
1339
1340
1341document.addEventListener('DOMContentLoaded', function () {
1342
1343  // Helper: close a specific dropdown
1344  function closeDropdown(toggleBtn) {
1345    const parentLi = toggleBtn.closest('li');
1346    const submenu = parentLi?.querySelector(
1347      '.megadrop, .mega-submenu'
1348    );
1349
1350    toggleBtn.setAttribute('aria-expanded', 'false');
1351
1352    if (submenu) {
1353      submenu.classList.remove('open', 'show');
1354      submenu.style.display = '';
1355    }
1356
1357    // Return focus to the toggle button
1358    toggleBtn.focus();
1359  }
1360
1361  // Helper: close ALL open dropdowns
1362  function closeAllDropdowns() {
1363    document.querySelectorAll(
1364      '.plus-minus[aria-expanded="true"]'
1365    ).forEach(function (btn) {
1366      closeDropdown(btn);
1367    });
1368
1369    // Also close top-level nav items
1370    document.querySelectorAll(
1371      '.nav-item.menu-item-has-children .nav-link[aria-expanded="true"]'
1372    ).forEach(function (link) {
1373      link.setAttribute('aria-expanded', 'false');
1374      const menu = link.nextElementSibling;
1375      if (menu) {
1376        menu.classList.remove('open', 'show');
1377        menu.style.display = '';
1378      }
1379      link.focus();
1380    });
1381  }
1382
1383  // ESC key: close the innermost open dropdown first,
1384  // then progressively close parent levels
1385  document.addEventListener('keydown', function (e) {
1386    if (e.key !== 'Escape') return;
1387
1388    // Find the deepest open dropdown containing the focused element
1389    const focused = document.activeElement;
1390
1391    // Walk up from focused element to find nearest open submenu
1392    const openParent = focused?.closest(
1393      '.megadrop.show, .mega-submenu.show, .megadrop.open, .mega-submenu.open'
1394    );
1395
1396    if (openParent) {
1397      // Find the toggle that opened this specific submenu
1398      const parentLi = openParent.closest('li');
1399      const toggleBtn = parentLi?.querySelector(
1400        ':scope > .plus-minus, :scope > .nav-link'
1401      );
1402
1403      if (toggleBtn) {
1404        closeDropdown(toggleBtn);
1405        e.preventDefault();
1406        return;
1407      }
1408    }
1409
1410    // No specific submenu found — close everything
1411    closeAllDropdowns();
1412    e.preventDefault();
1413  });
1414
1415  // Also handle ESC when focus is inside an open dropdown
1416  document.querySelectorAll('.nav_bottom').forEach(function (nav) {
1417    nav.addEventListener('keydown', function (e) {
1418      if (e.key !== 'Escape') return;
1419
1420      const openMenus = nav.querySelectorAll(
1421        '.megadrop.show, .megadrop.open'
1422      );
1423
1424      if (openMenus.length > 0) {
1425        closeAllDropdowns();
1426
1427        // Return focus to the parent nav-link
1428        const firstOpen = openMenus[0];
1429        const parentNavLink = firstOpen
1430          .closest('.nav-item')
1431          ?.querySelector('.nav-link');
1432        if (parentNavLink) parentNavLink.focus();
1433
1434        e.preventDefault();
1435        e.stopPropagation();
1436      }
1437    });
1438  });
1439
1440});
1441
1442
1443
1444
1445// ADA filter dropdowns
1446document.addEventListener('DOMContentLoaded', function () {
1447
1448  // ─── SEARCH INPUT ───────────────────────────────────────────
1449  // Already has for/id linked correctly in the HTML:
1450  // <label for="tribe-events-events-bar-keyword">Search Events</label>
1451  // <input id="tribe-events-events-bar-keyword" ...>
1452  // No fix needed here — it's compliant as-is.
1453
1454
1455  // ─── FOUR SELECT2 DROPDOWNS ─────────────────────────────────
1456  // for/id cannot be used on <span> elements (Select2 output).
1457  // aria-labelledby is the correct ARIA approach for these.
1458
1459  const fieldMap = [
1460    {
1461      labelText: 'Event Category',
1462      labelId:   'filter-label-event-category',
1463      selectionSelector: '[aria-labelledby*="filterbar_category-container"]'
1464    },
1465    {
1466      labelText: 'County',
1467      labelId:   'filter-label-county',
1468      selectionSelector: '[aria-labelledby="select2-vmrc-filterbar-county-container"]'
1469    },
1470    {
1471      labelText: 'Month',
1472      labelId:   'filter-label-month',
1473      selectionSelector: '[aria-labelledby="select2-vmrc-filterbar-month-container"]'
1474    },
1475    {
1476      labelText: 'Year',
1477      labelId:   'filter-label-year',
1478      selectionSelector: '[aria-labelledby="select2-vmrc-filterbar-year-container"]'
1479    }
1480  ];
1481
1482  fieldMap.forEach(function ({ labelText, labelId, selectionSelector }) {
1483
1484    // Find label by visible text
1485    const labelEl = Array.from(
1486      document.querySelectorAll('.vmrc-filterbar-field__label')
1487    ).find(el => el.textContent.trim() === labelText);
1488
1489    // Find the focusable Select2 span
1490    const selectionEl = document.querySelector(selectionSelector);
1491
1492    if (labelEl && selectionEl) {
1493
1494      // Assign stable ID to the label
1495      labelEl.setAttribute('id', labelId);
1496
1497      // Chain our label ID before the existing aria-labelledby value
1498      const existing = selectionEl.getAttribute('aria-labelledby') || '';
1499      selectionEl.setAttribute(
1500        'aria-labelledby',
1501        (labelId + ' ' + existing).trim()
1502      );
1503
1504      // Make label clickable → focuses the dropdown (mimics for/id behaviour)
1505      labelEl.style.cursor = 'pointer';
1506      labelEl.addEventListener('click', function () {
1507        selectionEl.focus();
1508      });
1509    }
1510
1511  });
1512
1513});
1514
1515
1516jQuery(document).ready(function($) {
1517
1518    function fixSearchAccessibility() {
1519
1520        // Fix main search input
1521        $('.ajaxsearchpro input[type="search"].orig').each(function() {
1522            if (!$(this).attr('aria-label')) {
1523                $(this).attr('aria-label', 'Search');
1524            }
1525        });
1526
1527        // Fix autocomplete input - hide from screen readers
1528        $('.ajaxsearchpro input.autocomplete').each(function() {
1529            $(this).attr({
1530                'aria-label'  : 'Search autocomplete suggestions',
1531                'aria-hidden' : 'true',
1532                'tabindex'    : '-1'
1533            });
1534        });
1535
1536        // Fix search form
1537        $('.ajaxsearchpro form').each(function() {
1538            if (!$(this).attr('aria-label')) {
1539                $(this).attr('aria-label', 'Site Search');
1540            }
1541        });
1542
1543        // Fix search button
1544        $('.ajaxsearchpro .promagnifier').each(function() {
1545            if (!$(this).attr('aria-label')) {
1546                $(this).attr('aria-label', 'Submit Search');
1547            }
1548        });
1549    }
1550
1551    // Run on page load
1552    fixSearchAccessibility();
1553
1554    // Run again after ASP initializes (it loads dynamically)
1555    $(document).on('ajaxsearchpro_init', function() {
1556        fixSearchAccessibility();
1557    });
1558
1559    // Fallback: run after short delay for dynamic load
1560    setTimeout(function() {
1561        fixSearchAccessibility();
1562    }, 1000);
1563
1564});
1565
1566
1567jQuery(document).ready(function($) {
1568
1569    // Close dropdown on ESC key
1570    $(document).on('keydown', function(e) {
1571        if (e.key === 'Escape' || e.keyCode === 27) {
1572
1573            // Find any open dropdown
1574            var $openDropdown = $('.main_header .navbar-nav > li .dropdown-menu:visible');
1575
1576            if ($openDropdown.length) {
1577                // Hide the dropdown
1578                $openDropdown.hide();
1579
1580                // Return focus to the parent nav item link
1581                $openDropdown.closest('li').find('> a').focus();
1582            }
1583        }
1584    });
1585
1586    // Re-show dropdown on hover (restore original behavior)
1587    $('.main_header .navbar-nav > li').on('mouseenter', function() {
1588        $(this).find('.dropdown-menu').first().show();
1589    }).on('mouseleave', function() {
1590        $(this).find('.dropdown-menu').first().hide();
1591    });
1592
1593    // Reset hidden dropdowns when mouse leaves nav entirely
1594    $('.main_header .navbar-nav').on('mouseleave', function() {
1595        $('.main_header .navbar-nav > li .dropdown-menu').removeAttr('style');
1596    });
1597
1598});
1599
1600// calendar select ADA fix
1601document.addEventListener('DOMContentLoaded', function () {
1602  const labelMap = {
1603    'tribe-events-filterbar-80d5fd0c-filterbar_category': 'Event Category',
1604    'vmrc-filterbar-county': 'County',
1605    'vmrc-filterbar-month': 'Month',
1606    'vmrc-filterbar-year': 'Year',
1607  };
1608
1609  Object.entries(labelMap).forEach(([id, label]) => {
1610    const input = document.getElementById(id);
1611    if (input) {
1612      input.setAttribute('aria-label', label);
1613    }
1614
1615    // Also patch the visible Select2 combobox span
1616    const select2 = document.querySelector(
1617      `[aria-labelledby="select2-${id}-container"]`
1618    );
1619    if (select2) {
1620      select2.setAttribute('aria-label', label);
1621    }
1622  });
1623}); 
1624
1625
1626
1627
1628$(document).ready(function () {
1629
1630    (function () {
1631      document.querySelectorAll('[role="main"]').forEach(function (el) {
1632        if (el.tagName.toLowerCase() !== 'main') {
1633          el.removeAttribute('role');
1634        }
1635      });
1636    })();
1637
1638});
1639
1640
1641
1642document.addEventListener('DOMContentLoaded', function () {
1643  fixAriaAttributes();
1644
1645  const observer = new MutationObserver(function () {
1646    fixAriaAttributes();
1647  });
1648
1649  observer.observe(document.body, { childList: true, subtree: true });
1650});
1651
1652function fixAriaAttributes() {
1653
1654  // Fix 1: Remove aria-expanded from role="listbox" <ul>
1655  document.querySelectorAll('ul[role="listbox"]').forEach(el => {
1656    el.removeAttribute('aria-expanded');
1657  });
1658
1659  // Fix 2: Remove aria-expanded from Select2 search inputs
1660  document.querySelectorAll('.select2-search__field').forEach(el => {
1661    el.removeAttribute('aria-expanded');
1662  });
1663
1664  // Fix 3: Remove tabindex from ul[role="listbox"]
1665  document.querySelectorAll('ul[role="listbox"]').forEach(el => {
1666    el.removeAttribute('tabindex');
1667  });
1668
1669  // Fix 4–7: Name filterbar Select2 widgets from their visible field labels.
1670  // Select2 puts role="textbox" on .select2-selection__rendered; axe WCAG 4.1.2
1671  // requires those ARIA inputs to have aria-label / aria-labelledby / title.
1672  // (Do not strip aria-label from these spans — that undoes the naming.)
1673  document.querySelectorAll('.vmrc-filterbar-field').forEach(field => {
1674    const labelEl = field.querySelector('.vmrc-filterbar-field__label');
1675    if (!labelEl) {
1676      return;
1677    }
1678
1679    const labelText = labelEl.textContent.trim();
1680    if (!labelText) {
1681      return;
1682    }
1683
1684    if (!labelEl.id) {
1685      const control = field.querySelector('select, input.tribe-filter-bar-c-dropdown__input, input[type="hidden"]');
1686      const seed = (control && control.id) ? control.id : labelText.toLowerCase().replace(/\s+/g, '-');
1687      labelEl.id = 'filter-label-' + seed;
1688    }
1689
1690    const nativeInput = field.querySelector('select, input.tribe-filter-bar-c-dropdown__input, input[type="hidden"]');
1691    if (nativeInput && !nativeInput.getAttribute('aria-label')) {
1692      nativeInput.setAttribute('aria-label', labelText);
1693    }
1694
1695    const searchInput = field.querySelector('.select2-search__field');
1696    if (searchInput) {
1697      searchInput.setAttribute('aria-label', 'Search ' + labelText);
1698    }
1699
1700    const combobox = field.querySelector('.select2-selection[role="combobox"], [role="combobox"]');
1701    if (combobox) {
1702      combobox.setAttribute('aria-labelledby', labelEl.id);
1703    }
1704
1705    // The failing nodes: Select2's readonly "textbox" showing the current value.
1706    const rendered = field.querySelector('.select2-selection__rendered[role="textbox"]');
1707    if (rendered) {
1708      rendered.setAttribute('aria-labelledby', labelEl.id);
1709      rendered.setAttribute('aria-label', labelText);
1710    }
1711  });
1712
1713  // Fallback for Select2 textboxes outside .vmrc-filterbar-field (id pattern match).
1714  document.querySelectorAll('.select2-selection__rendered[role="textbox"]').forEach(el => {
1715    if (el.getAttribute('aria-label') || el.getAttribute('aria-labelledby')) {
1716      return;
1717    }
1718    const id = (el.id || '').toLowerCase();
1719    let label = '';
1720    if (id.includes('category')) {
1721      label = 'Event Category';
1722    } else if (id.includes('county')) {
1723      label = 'County';
1724    } else if (id.includes('month')) {
1725      label = 'Month';
1726    } else if (id.includes('year')) {
1727      label = 'Year';
1728    }
1729    if (label) {
1730      el.setAttribute('aria-label', label);
1731    }
1732  });
1733}
1734
1735(function ($) {
1736    function fixAllIframeTitles() {
1737        $('iframe').each(function () {
1738            var $iframe = $(this);
1739            var title = ($iframe.attr('title') || '').trim();
1740            var ariaLabel = ($iframe.attr('aria-label') || '').trim();
1741            var ariaLabelledby = ($iframe.attr('aria-labelledby') || '').trim();
1742
1743            // Skip only if a NON-EMPTY accessible name already exists
1744            if (title !== '' || ariaLabel !== '' || ariaLabelledby !== '') {
1745                return;
1746            }
1747
1748            var src = $iframe.attr('src') || '';
1749            var name = $iframe.attr('name') || '';
1750            var accessibleTitle = 'Embedded content';
1751
1752            if (src.indexOf('google.com/recaptcha') !== -1 || name.indexOf('a-') === 0) {
1753                accessibleTitle = 'reCAPTCHA';
1754            } else if (src.indexOf('youtube.com') !== -1 || src.indexOf('youtu.be') !== -1) {
1755                accessibleTitle = 'YouTube video';
1756            } else if (src.indexOf('vimeo.com') !== -1) {
1757                accessibleTitle = 'Vimeo video';
1758            } else if (src.indexOf('canva.com') !== -1) {
1759                accessibleTitle = 'Canva presentation';
1760            } else if (src.indexOf('google.com/maps') !== -1) {
1761                accessibleTitle = 'Google Map';
1762            } else if (src.indexOf('facebook.com') !== -1) {
1763                accessibleTitle = 'Facebook content';
1764            } else if (src.indexOf('twitter.com') !== -1 || src.indexOf('x.com') !== -1) {
1765                accessibleTitle = 'Twitter content';
1766            } else if (src.indexOf('spotify.com') !== -1) {
1767                accessibleTitle = 'Spotify player';
1768            }
1769
1770            $iframe.attr('title', accessibleTitle);
1771            $iframe.attr('aria-label', accessibleTitle);
1772        });
1773    }
1774
1775    fixAllIframeTitles();
1776
1777    $(document).ready(function () {
1778        fixAllIframeTitles();
1779    });
1780
1781    $(window).on('load', function () {
1782        fixAllIframeTitles();
1783    });
1784
1785    var iframeObserver = new MutationObserver(function () {
1786        fixAllIframeTitles();
1787    });
1788
1789    iframeObserver.observe(document.body, {
1790        childList: true,
1791        subtree: true,
1792        attributes: true,
1793        attributeFilter: ['title', 'aria-label', 'aria-labelledby']
1794    });
1795
1796})(jQuery);

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.