Advertisement
MikkoDC

Asher Scripts

Mar 22nd, 2025
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.  
  3.   /********************
  4.   Open all external links open in a new tab apart from a domain
  5.   *********************/
  6.   var all_links = document.querySelectorAll('#content a');
  7.   for (var i = 0; i < all_links.length; i++){
  8.         var a = all_links[i];
  9.         if(a.hostname != location.hostname && a.hostname != "javascript:void(0)") {
  10.                 a.rel = 'noopener';
  11.                 a.target = '_blank';
  12.         }
  13.   }
  14.  
  15.  
  16.   /*****************************
  17.   ADA Compliance
  18.   ******************************/
  19.  
  20.   var menuItems = document.querySelectorAll('.desktop-nav .menu  li.menu-item-has-children, #top-navigation .menu  li.menu-item-has-children');
  21.   Array.prototype.forEach.call(menuItems, function(el, i){
  22.     var activatingA = el.querySelector('a');
  23.     var btn = '<button><span><span class="visuallyhidden">show submenu for “' + activatingA.text + '”</span></span></button>';
  24.     activatingA.insertAdjacentHTML('afterend', btn);
  25.  
  26.     el.querySelector('button').addEventListener("click",  function(event){
  27.       if (this.parentNode.className == "menu-item-has-children") {
  28.         this.parentNode.className = "menu-item-has-children open";
  29.         this.parentNode.querySelector('a').setAttribute('aria-expanded', "true");
  30.         this.parentNode.querySelector('button').setAttribute('aria-expanded', "true");
  31.       } else {
  32.         this.parentNode.className = "menu-item-has-children";
  33.         this.parentNode.querySelector('a').setAttribute('aria-expanded', "false");
  34.         this.parentNode.querySelector('button').setAttribute('aria-expanded', "false");
  35.       }
  36.       event.preventDefault();
  37.     });
  38.   });
  39.  
  40.   $(function() {
  41.       $('.wpcf7-form-control-wrap').attr('role','none');
  42.       $('.vc_tta-controls-icon').attr('role','none');
  43.       $('.vc_empty_space_inner').attr('role','none');
  44.       $('figure').attr('role','none');
  45.       $('.menu .menu-item-has-children > a').attr('aria-haspopup','true');
  46.       $('.menu .menu-item-has-children > a').attr('aria-expanded','false');
  47.  
  48.       $('#content .vc_btn3-container > a[target*="_blank"], a[target*="_blank"]').each(function(){
  49.         var buttonTitle = $(this).attr('title');
  50.         $(this).attr('aria-label', buttonTitle);
  51.         // $("<span class='warning'>Open in new window</span>").appendTo(this);
  52.       });
  53.  
  54.       $('.menu a[target*="_blank"]:not(".fa")').each(function(){
  55.         var buttontext = $(this).text();
  56.         $(this).attr('aria-label', buttontext + ' link will open in new tab or window');
  57.         $(this).attr('role', 'button');
  58.       });
  59.  
  60.       $('.menu a:not(".fa")').each(function(){
  61.         var buttontext = $(this).text();
  62.         $(this).attr('aria-label', 'View ' + buttontext);
  63.         $(this).attr('role', 'button');
  64.       });
  65.  
  66.       $('.gform_validation_errors').attr('role', 'alert');
  67.  
  68.   });
  69.  
  70.   /*****************************
  71.   Hide Sub menu using ESC
  72.   ******************************/
  73.   $(document).ready(function() {
  74.     $(document).keyup(function(e) {
  75.         if (e.keyCode == 27) { // Esc keycode
  76.             $('.sub-menu').hide();
  77.             $('.sign-in-menu').hide();
  78.         }
  79.     });
  80.   });
  81.  
  82.   /*****************************
  83.   END ADA Compliance
  84.   ******************************/
  85.  
  86.   $("#toTop a").click(function () {
  87.       $("html, body").animate({scrollTop: 0}, 1000);
  88.    });
  89.  
  90.   /*****************************
  91.   Container Left/Right auto sizing
  92.   ******************************/
  93.   function LRContainerPadding() {
  94.     const elementstyle = document.getElementById("main-container");
  95.     const cssObjstyle = window.getComputedStyle(elementstyle, null);
  96.     let marginLeft = cssObjstyle.getPropertyValue("margin-left");
  97.     let marginRight = cssObjstyle.getPropertyValue("margin-right");
  98.  
  99.     if($(window).width() <= 1999) {
  100.       $('.container_left').css('padding-left',marginLeft );
  101.       $('.container_right').css('padding-right',marginRight );
  102.     }
  103.   }
  104.  
  105.   LRContainerPadding();
  106.  
  107.   $(document).ready(function() {
  108.     LRContainerPadding();  
  109.     $(window).resize(function() {
  110.         LRContainerPadding();
  111.     });
  112.   });
  113.  
  114.  
  115.   /*****************************
  116.   Header Height / mobile custom phone
  117.   ******************************/
  118.   function headerResizefunction() {
  119.     var windowWidth = $(window).width();
  120.     var headerHeight = $('.header_wrapper').outerHeight();
  121.     var bannerHeight = $('.alert-modal').outerHeight();
  122.     var wpadminbarOuterHeight = $('#wpadminbar').outerHeight();
  123.  
  124.  
  125.     if ($('#wpadminbar').length){
  126.      headerOffset =  wpadminbarOuterHeight;
  127.     } else {
  128.       headerOffset = 0;
  129.     }
  130.     // if (windowWidth >= 1081) {
  131.     //   $('.header_wrapper').stickit({
  132.     //       screenMinWidth: 1081,
  133.     //       top: headerOffset
  134.     //   });
  135.     // }
  136.  
  137.       $('.header_wrapper').css('top', headerOffset);
  138.  
  139.      $('.close-alert').click(function(){
  140.         var mainNav = $('.main-header').outerHeight();
  141.         $('.header_wrapper').find('.alert-modal').hide();
  142.         $('.main-nav').css('top', headerHeight);
  143.         $('#content').css('margin-top', mainNav);
  144.  
  145.         if($('.header_wrapper').hasClass('transparent_header')){
  146.           $('#content').css('margin-top', 0);
  147.         }
  148.       });
  149.  
  150.  
  151.     if (windowWidth <= 991) { // For MObile
  152.       // $('.header_wrapper').css('top', headerOffset);
  153.       // $('#content').css('margin-top',headerHeight);
  154.  
  155.       if ($('#wpadminbar').length){
  156.         $('.main-nav').css('top', headerHeight + headerOffset);
  157.       } else {
  158.         $('.header_wrapper').css('top', 0);
  159.         $('.main-nav').css('top', headerHeight - 1);
  160.       }
  161.  
  162.       if ($('.vc_row.hero_section, .vc_row.inner_hero, .vc_section.hero_section, .vc_section.inner_hero').length) {
  163.         $('.header_wrapper').addClass('transparent_header');
  164.         // $('#content').css('margin-top', headerHeight);
  165.       } else {
  166.         $('.header_wrapper').addClass('solid_header');
  167.         $('#content').css('margin-top', headerHeight);
  168.       }
  169.  
  170.     } else {
  171.       if ($('.vc_row.hero_section, .vc_row.inner_hero, .vc_section.hero_section, .vc_section.inner_hero').length) {
  172.         $('.header_wrapper').addClass('transparent_header');
  173.         $('#content').css('margin-top', 0);
  174.       } else {
  175.         $('.header_wrapper').addClass('solid_header');
  176.         $('#content').css('margin-top', headerHeight);
  177.       }
  178.     }
  179.  
  180.   }
  181.  
  182.   $(document).ready(function() {
  183.     headerResizefunction();  
  184.     $(window).resize(function() {
  185.         headerResizefunction();
  186.     });
  187.   });
  188.  
  189.  
  190.  
  191.   /********************
  192.   Sticky Navs
  193.   *********************/
  194.   function stickyNavs() {
  195.     var headerHeight = $('.header_wrapper').outerHeight();
  196.     var wpadminbarOuterHeight = $('#wpadminbar').outerHeight();
  197.  
  198.     if ($('#wpadminbar').length){
  199.       headerOffset =  wpadminbarOuterHeight + headerHeight;
  200.     } else {
  201.       headerOffset = headerHeight;
  202.     }
  203.  
  204.     // Site Navigator
  205.     // $('.sticky_nav').stickit({
  206.     //   top: headerOffset,
  207.     //   scope: StickScope.Document,
  208.     // });
  209.   }
  210.  
  211.   stickyNavs();
  212.  
  213.  
  214.   /*****************************
  215.   Sticky Header
  216.   ******************************/
  217.   $(window).scroll(function() {
  218.     var winTop = $(window).scrollTop();
  219.     if (winTop >= 20) {
  220.       $(".main-header").addClass("sticky");
  221.     } else {
  222.       $(".main-header").removeClass("sticky");
  223.     }
  224.   });
  225.   var didScroll;
  226.   // on scroll, let the interval function know the user has scrolled
  227.   $(window).scroll(function(event){
  228.     didScroll = true;
  229.   });
  230.   // run hasScrolled() and reset didScroll status
  231.   setInterval(function() {
  232.     if (didScroll) {
  233.       hasScrolled();
  234.       didScroll = false;
  235.     }
  236.   }, 250);
  237.   function hasScrolled() {
  238.     // do stuff here...
  239.   }
  240.   $(window).on("scroll", function() {
  241.     didScroll = true;
  242.     scrollTop = $(document).scrollTop();
  243.     var windowWidth = $(window).width();
  244.    
  245.     if (windowWidth <= 1024) {
  246.       var s = 190 - Math.min(190, scrollTop);
  247.     } else {
  248.       var s = 190 - Math.min(190, scrollTop);
  249.  
  250.       if (scrollTop === 0) {
  251.         $(".light_logo").css('opacity',1);
  252.       }
  253.  
  254.     }
  255.  
  256.     if( ($(".main-header").hasClass('sticky')) &&  ($(".main-header").hasClass('transparent_header'))) {
  257.  
  258.     } else {
  259.  
  260.       $(".light_logo").hide();
  261.       $(".dark_logo").show();
  262.       // $(".dark_logo").css("opacity", $(window).scrollTop() / 150);
  263.       $(".fake-bg").css("opacity", 0+ $(window).scrollTop() / 120);
  264.  
  265.       if (scrollTop === 0) {
  266.         $(".dark_logo").hide();
  267.         $(".light_logo").show();
  268.       }
  269.     }
  270.  
  271.   });
  272.  
  273.   // Scroll Position
  274.   var didScroll;
  275.   var lastScrollTop = 0;
  276.   var delta = 5;
  277.   var navbarHeight = $('header').outerHeight();
  278.  
  279.   $(window).scroll(function(event){
  280.       didScroll = true;
  281.   });
  282.  
  283.   setInterval(function() {
  284.       if (didScroll) {
  285.           hasScrolled();
  286.           didScroll = false;
  287.       }
  288.   }, 250);
  289.  
  290.   function hasScrolled() {
  291.       var st = $(this).scrollTop();
  292.       var banner_exist = $(".have-slider-banner").length;
  293.       if(banner_exist > 0) {
  294.         if(Math.abs(lastScrollTop - st) <= delta)
  295.             return;
  296.         if (st > lastScrollTop && st > navbarHeight){
  297.             // Scroll Down
  298.             $('header').addClass('sticky');
  299.         } else {
  300.             // Scroll Up
  301.             if(st + $(window).height() < $(document).height()) {
  302.                 //$('header').removeClass('sticky');
  303.             }
  304.             if(st == 0) {
  305.               $('header').removeClass('sticky');
  306.             }
  307.         }
  308.       }
  309.       lastScrollTop = st;
  310.   }
  311.  
  312. // mobile menu dropdown & sticky header condition for without slider/banner page
  313. jQuery(document).ready(function() {
  314.   if ($(window).width() < 991) {
  315.     $('#navigation ul.menu > li.menu-item-has-children').click(function() {
  316.       $('> ul', this).slideToggle(200);
  317.     });
  318.   }
  319. });
  320. /*****************************
  321. Custom Accordion
  322. ******************************/
  323. $(function() {
  324.   $('.custom_accordion .accordion_wrapper').each(function(index){
  325.     $(this).find('.accordion_title').attr("data-id", index);
  326.  
  327.     if(index === 0) {
  328.       $(this).addClass('active');
  329.     }
  330.  
  331.   });
  332.  
  333.  
  334.   $('.acc_subcontent').each(function(index){
  335.     $(this).attr("id", index);
  336.     if(index === 0) {
  337.       $(this).addClass('active');
  338.     }
  339.  
  340.     mainAcc = $('.custom_accordion .accordion_wrapper .accordion_title[data-id=' + index + ']').parent().find(".accordion_inner");
  341.     $(this).clone().appendTo(mainAcc);
  342.  
  343.   });
  344.  
  345.  
  346.   $('.custom_accordion .accordion_wrapper .accordion_title').on('click', function () {
  347.     if ($(this).parent().hasClass('active')) {
  348.         $(this).parent().removeClass('active');
  349.     } else {
  350.         $('.custom_accordion .accordion_wrapper .accordion_inner').hide();
  351.         $('.custom_accordion .accordion_wrapper').removeClass('active');
  352.         $(this).parent().addClass('active');
  353.         $('.custom_accordion .accordion_wrapper.active .accordion_inner').slideToggle();
  354.     }
  355.   });
  356.  
  357.   $(".accordion_title").click(function() {
  358.     if ($(".accordion_wrapper").hasClass("active") == true) {
  359.       $('.acc_subcontent:visible').hide();
  360.       console.log($(this).data("id"));
  361.       $('.acc_subcontent[id=' + $(this).data("id") + ']').delay(300).fadeIn();
  362.     } else {
  363.       $('.acc_subcontent:visible').hide();
  364.     }
  365.    });
  366. });
  367.  
  368.  
  369.     // Custom Tabs With arrows
  370.   //  $(function() {
  371.   //     $('.tab-prev').click(function() {
  372.   //       if ($('.vc_tta-panels .vc_tta-panel.vc_active').prev().length != 0) {
  373.   //           $('.vc_tta-panels .vc_tta-panel.vc_active').removeClass('vc_active').prev().addClass('vc_active').click();
  374.   //           $('.vc_tta-tabs-list .vc_tta-tab.vc_active').removeClass('vc_active').prev().addClass('vc_active').click();
  375.   //       }
  376.   //   });
  377.    
  378.   //   $('.tab-next').click(function() {
  379.   //       if ($('.vc_tta-panels .vc_tta-panel.vc_active').next().length != 0) {
  380.   //           $('.vc_tta-panels .vc_tta-panel.vc_active').removeClass('vc_active').next().addClass('vc_active').click();
  381.   //           $('.vc_tta-tabs-list .vc_tta-tab.vc_active').removeClass('vc_active').next().addClass('vc_active').click();
  382.   //       }
  383.   //   });
  384.      
  385.   //  });
  386.  
  387.  
  388. /*****************************
  389. Modal
  390. ******************************/
  391. $(function() {
  392.   setTimeout(function() {
  393.     $('.members_modal, .calculator_modal').appendTo('footer.footer');
  394.     $('.search_modal').appendTo('.search_modal_footer');
  395.   }, 1000);
  396.  
  397.   jQuery("div[id^='modal']").each(function(){
  398.  
  399.     var currentModal = jQuery(this);
  400.    
  401.     //click next
  402.     currentModal.find('.btn-next').click(function(){
  403.       currentModal.modal('hide');
  404.       currentModal.closest("div[id^='modal']").nextAll("div[id^='modal']").first().modal('show');
  405.     });
  406.    
  407.     //click prev
  408.     currentModal.find('.btn-prev').click(function(){
  409.       currentModal.modal('hide');
  410.       currentModal.closest("div[id^='modal']").prevAll("div[id^='modal']").first().modal('show');
  411.     });
  412.  
  413.   });
  414.  
  415. });
  416.  
  417.  
  418. /*****************************
  419. Mobile Page Menu
  420. ******************************/
  421. $(function() {
  422.   var windowWidth = $(window).width();
  423.   if (windowWidth <= 767) {
  424.     $('.page_menu .widget_nav_menu').prepend("<a class='open-page-menu'>Open Menu</a>");
  425.     var pageMenuActive = $('.page_menu .widget_nav_menu').find('.current_page_item a').text();
  426.     $('.open-page-menu').text(pageMenuActive);
  427.  
  428.     $('.open-page-menu').click(function(){
  429.       $(this).next('div').slideToggle();
  430.     });
  431. }
  432.  
  433. });
  434.  
  435. /*****************************
  436. Slick Sliders
  437. ******************************/
  438.  
  439. // Image/Video Gallery
  440. $(function() {
  441.  
  442.   $('.image_video_gallery__container').not('.slick-initialized').slick({
  443.     slidesToShow: 1,
  444.     slidesToScroll: 1,
  445.     arrows: false,
  446.     dots: true,
  447.     prevArrow: $('.image_video_gallery .slider-control .prev'),
  448.     nextArrow: $('.image_video_gallery .slider-control .next'),
  449.   });
  450.  
  451. });
  452.  
  453. // Image Meta Slider
  454. $(function() {
  455.   let asNav = ''
  456.   if($('.image_slider__content').length) {
  457.     asNav = '.image_slider__content'
  458.     $('.image_slider__content').slick({
  459.       slidesToShow: 1,
  460.       slidesToScroll: 1,
  461.       dots: false,
  462.       fade: true,
  463.       asNavFor: '.image_slider__container'
  464.     });
  465.   }
  466.   $('.image_slider__container').not('.slick-initialized').slick({
  467.     respondTo: 'slider',
  468.     slidesToShow: 1,
  469.     slidesToScroll: 1,
  470.     dots: false,
  471.     fade: false,
  472.     infinite: false,
  473.     prevArrow: $('.image_slider__control .prev'),
  474.     nextArrow: $('.image_slider__control .next'),
  475.     asNavFor: asNav,
  476.   });
  477. });
  478.  
  479. // Device Specific Slider
  480. $(function() {
  481.   var windowWidth = $(window).width();
  482.  
  483.   // Tablet
  484.   if(windowWidth <= 1024) {
  485.   }
  486.  
  487.   // Mobile
  488.   if (windowWidth <= 767) {
  489.     $('.counter_boxes.vertical_slider .slider-container').not('.slick-initialized').slick({
  490.       slidesToShow: 4,
  491.       slidesToScroll: 4,
  492.       vertical: true,
  493.       arrows: true,
  494.       prevArrow: $('.counter_boxes .slider-control .prev'),
  495.       nextArrow: $('.counter_boxes .slider-control .next'),
  496.     });
  497.    
  498.     $('.mobile_slider .slider-container').not('.slick-initialized').slick({
  499.       slidesToShow: 1,
  500.       slidesToScroll: 1,
  501.       arrows: true,
  502.       fade: true,
  503.       prevArrow: $('.mobile_slider:not(.counter_boxes) .slider-control .prev'),
  504.       nextArrow: $('.mobile_slider:not(.counter_boxes) .slider-control .next'),
  505.       adaptiveHeight: true,
  506.     });
  507.  
  508.  
  509.     $('.gallery-slider').not('.slick-initialized').slick({
  510.       slidesToShow: 1,
  511.       slidesToScroll: 1,
  512.       arrows: false,
  513.     });
  514.   }
  515. });
  516.  
  517. /*****************************
  518. Graphs / Charts / Odometer
  519.   ******************************/
  520. $(function() {
  521.   $('.counter').countUp({
  522.     'time': 2000,
  523.     'delay': 30
  524.   });
  525. });
  526.  
  527. /********************
  528. Mobile  tabs
  529. *********************/
  530. $(function() {
  531.   var windowWidth = $(window).width();
  532.   if (windowWidth <= 767) {
  533.  
  534.  
  535.     $(window).load(function(){
  536.       var activeloadedText=  $('.vc_tta-tab.vc_active > a .vc_tta-title-text').text();
  537.       $('.mobile_tab_menu').text(activeloadedText);
  538.     });
  539.  
  540.     $(".vertical_tabs").each(function(){
  541.  
  542.       var mobileMenu = $(this).find('.mobile_tab_menu');
  543.       var tabItem = $(this).find('.vc_tta-tab > a');
  544.  
  545.  
  546.         var activeText = $(this).find(".vc_tta-tab.vc_active .vc_tta-title-text").text();
  547.         mobileMenu.text(activeText);
  548.  
  549.         mobileMenu.click(function(e){
  550.           e.preventDefault();
  551.             $(this).toggleClass("active");
  552.             $(this).parent().find('.vc_tta.vc_tta-tabs .vc_tta-tabs-container').toggleClass("show");
  553.            
  554.         });
  555.  
  556.        
  557.  
  558.          $('.footer-col a').click(function(e){
  559.           var activeClickedtextonPage = $(this).text();
  560.           mobileMenu.text(activeClickedtextonPage);
  561.  
  562.           $('body').find('.vc_tta.vc_tta-tabs .vc_tta-tabs-container').removeClass("show");
  563.             mobileMenu.removeClass("active");
  564.         });
  565.  
  566.  
  567.         tabItem.click(function(e){
  568.           var activeClickedtext = $(this).find('.vc_tta-title-text').text();
  569.           mobileMenu.text(activeClickedtext);
  570.  
  571.           e.preventDefault();
  572.           $(this).parents().find('.vc_tta.vc_tta-tabs .vc_tta-tabs-container').removeClass("show");
  573.             mobileMenu.removeClass("active");
  574.         });
  575.        
  576.  
  577.       });
  578.   }
  579.  
  580. });
  581.  
  582.  
  583.  
  584.   /********************
  585.   Mobile VC ROW Swap
  586.   *********************/
  587.   $(function() {
  588.     var windowWidth = $(window).width();
  589.     if (windowWidth <= 767) {
  590.       $('.vc_row.mobile_swap').wrapAll('<div class="mobile_swap_wrapper" />');
  591.     }
  592.   });
  593.  
  594.      
  595.   $(document).ready(function() {
  596.     var bodyToggle = $('body');
  597.  
  598.     $('.mobile-toggle-wrap').click(function() {
  599.       bodyToggle.toggleClass('collapse_menu');
  600.     });
  601.  
  602.     function mobile_navigation() {
  603.       var windowWidth_1024px = $(window).width();
  604.       if (windowWidth_1024px <= 1279) {
  605.  
  606.         // Second Level
  607.         $('#mobile-menu li.menu-item-has-children').each(function(el) {
  608.           $(this).prepend("<a class='open-menu'></a>");
  609.         });
  610.  
  611.         $('#mobile-menu li.menu-item-has-children:has(ul)').addClass("inactive");
  612.         $('#mobile-menu li.menu-item-has-children:has(ul) ul').css('display', 'none');
  613.  
  614.         $('.open-menu').click(function() {
  615.  
  616.           if ($(this).closest('li.menu-item-has-children').hasClass('active')){
  617.             $(this + 'a').attr('aria-expanded','false');
  618.           }
  619.           if ($(this).closest('li.menu-item-has-children').hasClass('inactive')){
  620.               $(this + 'a').attr('aria-expanded','true');
  621.           }
  622.  
  623.           var checkElement = $(this).next().next();
  624.           $(this).parent('li.menu-item-has-children ').removeClass('active');
  625.           $(this).parent('li.menu-item-has-children').addClass('active').removeClass("inactive");
  626.  
  627.           if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
  628.  
  629.             console.log
  630.             $(this).parent().siblings('li.menu-item-has-children').removeClass('active').addClass('inactive');
  631.             checkElement.slideUp('normal');
  632.           }
  633.  
  634.           if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
  635.             $('ul ul:visible').not($(this).closest('ul')).slideUp('normal');
  636.             checkElement.slideDown('normal');
  637.           }
  638.  
  639.           if (checkElement.is('ul')) {
  640.             return false;
  641.           } else {
  642.             return true;
  643.           }
  644.         });
  645.         // END Third Level Dropdown
  646.        
  647.         $('#mobile-menu')
  648.       }
  649.     }
  650.    
  651.     mobile_navigation();
  652.  
  653.   });
  654.  
  655.  
  656.   $('a[href^="#"].scrollTo, .scrollTo a[href^="#"], .scrollTo a').click(function()
  657.   {
  658.     var bodyToggle = $('body');
  659.     bodyToggle.toggleClass('collapse_menu');
  660.  
  661.     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  662.         || location.hostname == this.hostname)
  663.     {
  664.  
  665.       var target = $(this.hash),
  666.       headerHeight = $('.header_wrapper').outerHeight(),
  667.       stickyNav =  $('.sticky_nav').outerHeight(), // Get fixed header height
  668.       target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  669.  
  670.       headerOffset = headerHeight + stickyNav;
  671.       headerOffset = headerOffset + 60;
  672.              
  673.       if (target.length)
  674.       {
  675.         $('html,body').animate({
  676.           scrollTop: target.offset().top - headerOffset
  677.         }, 500);
  678.         return false;
  679.       }
  680.     }
  681.   });
  682.  
  683.   // Site Navigator
  684.   $('#navigation a[href^="#"].scrollNav, #navigation .scrollNav a[href^="#"], #navigation .scrollNav a').click(function()
  685.   {
  686.   var bodyToggle = $('body');
  687.   bodyToggle.toggleClass('collapse_menu');
  688.  
  689.     if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  690.         || location.hostname == this.hostname)
  691.     {
  692.      
  693.       var target = $(this.hash),
  694.       headerHeight = $('.header_wrapper').outerHeight(),
  695.       stickyNav =  $('.sticky_nav').outerHeight(), // Get fixed header height
  696.       target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  697.  
  698.       headerOffset = headerHeight + stickyNav;
  699.       headerOffset = headerOffset + 60;
  700.              
  701.       if (target.length)
  702.       {
  703.         $('html,body').animate({
  704.           scrollTop: target.offset().top - headerOffset
  705.         }, 1000, 'swing');
  706.         return false;
  707.       }
  708.     }
  709.   });
  710.  
  711.   //  to top right away
  712.   if ( window.location.hash ) scroll(0,0);
  713.  
  714.   // void some browsers issue
  715.   setTimeout( function() { scroll(0,0); }, 1);
  716.   $(function() {
  717.     headerHeight = $('.header_wrapper').outerHeight(),
  718.     stickyNav =  $('.sticky_nav').outerHeight(), // Get fixed header height
  719.     headerOffset = headerHeight + stickyNav;
  720.     scrollPadding = $('.vc_tta-tabs').length ? 120 : 0
  721.  
  722.     setTimeout(function() {
  723.         // *only* if we have anchor on the url
  724.         if(window.location.hash) {
  725.             // smooth scroll to the anchor id
  726.             $('html, body').animate({
  727.                 scrollTop: $(window.location.hash).offset().top - headerOffset - scrollPadding
  728.             }, 1000, 'swing');
  729.         }
  730.       }, 1000);
  731.   });
  732.  
  733.   function removeBR() {
  734.     if ($(window).width() <= 1080) {
  735.       $('.banner h4 br').remove();
  736.       $('.vc_custom_heading br').remove();
  737.       $('.hero_section p br').remove();
  738.       $('.wpb_text_column:not(.contact_details) p br').remove();
  739.       $('.sub_content br').remove();
  740.       $('.scrollToNav h6 br').remove();
  741.       $('.resource_slider__nav .resource_slider__title br').remove();
  742.     }
  743.     $('.details_content p:empty').remove();
  744.   }
  745.   $(window).resize(removeBR);
  746.   $(window).load(removeBR);
  747.   $(document).ready(removeBR);
  748.  
  749.   $(function() {
  750.     let accordionTarget = document.querySelectorAll('.custom_accordion__target > div')
  751.     let accordionToggle = document.querySelectorAll('.vc_tta-panels .vc_tta-panel')
  752.     let accordionRowTarget = document.querySelectorAll('.custom_accordion__row .vc_row')
  753.     let accordionRowToggle = document.querySelectorAll('.custom_boxes .box_wrap')
  754.  
  755.     function initAccordionTarget(target, trigger) {
  756.       if(target.length > 1) {
  757.         target[0].classList.add('active')
  758.  
  759.         trigger.forEach(function(e, i) {
  760.           e.addEventListener('click', function() {
  761.             triggerTarget(target, i)
  762.           })
  763.         })
  764.       }
  765.  
  766.     }
  767.  
  768.     function triggerTarget(elem, i) {
  769.       elem.forEach(function(j) {
  770.         if(j.classList.contains('active')) {
  771.           j.classList.remove('active')
  772.         }
  773.       })
  774.       elem[i].classList.add('active')
  775.     }
  776.  
  777.     initAccordionTarget(accordionTarget, accordionToggle)
  778.     initAccordionTarget(accordionRowTarget, accordionRowToggle)
  779.  
  780.     $('.custom_accordion .vc_tta-panels').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  781.       if(accordionTarget.length > 0)
  782.         triggerTarget(accordionTarget, nextSlide)
  783.     });
  784.  
  785.     $('.custom_boxes').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  786.       if(accordionRowTarget.length > 0) {
  787.         triggerTarget(accordionRowTarget, currentSlide)
  788.       }
  789.  
  790.     });
  791.   })
  792.  
  793.   $('#copy_text').click(function (e) {
  794.     e.preventDefault();
  795.     // var copyText = window.location.href;
  796.     // //var copyText = $(this).attr('href');
  797.     // document.addEventListener('copy', function(e) {
  798.     //    e.clipboardData.setData('text/plain', copyText);
  799.     //    e.preventDefault();
  800.     // }, true);
  801.     // document.execCommand('copy');
  802.     // $("#tooltiptext").text("Copied");
  803.  
  804.     var dummy = document.createElement('input'),
  805.     text = window.location.href;
  806.     document.body.appendChild(dummy);
  807.     dummy.value = text;
  808.     dummy.select();
  809.     document.execCommand('copy');
  810.     document.body.removeChild(dummy);
  811.     $("#tooltiptext").text("Copied");
  812.  
  813.   });
  814.  
  815.   $("#copy_text").mouseleave(function () {
  816.     $("#tooltiptext").text("Copy to clipboard");
  817.   });
  818.  
  819.   $('.vc_tta-tab').each(function() {
  820.     $(this).click(function() {
  821.       setTimeout(function() {
  822.         $('.image_slider__container, .image_slider__meta').slick('reinit');
  823.       }, 500)
  824.     });
  825.   });
  826.   jQuery(function($){
  827.     // Chosen Select
  828.     $(".gfield_select, .vc_grid-styled-select select").select2({
  829.       minimumResultsForSearch: -1
  830.     });
  831.   });
  832. })($);
  833.  
  834. // Filter
  835. jQuery(function($){
  836.  
  837.   $('.filter_wrap form input:radio').click(function() {
  838.       $('.filter_wrap form input:radio').not(this).prop('checked', false);
  839.       $(".filter_wrap form input[type='radio']").parent().removeClass('active');  
  840.       $(this).parent().addClass('active');
  841.   });
  842.  
  843.   $('#filter').change(function(){
  844.         var filter = $('#filter');
  845.         $.ajax({
  846.             url:filter.attr('action'),
  847.             data:filter.serialize(), // form data
  848.             type:filter.attr('method'), // POST
  849.             beforeSend:function(xhr){
  850.             },
  851.             success:function(data){
  852.                 $('.filter_results').html(data); // insert data
  853.             }
  854.         });
  855.         return false;
  856.     });
  857.  
  858. });
  859.  
  860. $('[data-fancybox]').fancybox({
  861.   maxWidth: "90%",
  862.   infobar : false,
  863.   buttons : false,
  864.   afterLoad : function( instance, current ) {
  865.     if ( instance.group.length > 1 && current.$content ) {
  866.       current.$content.append('<a data-fancybox-next class="button-next" href="javascript:;"><i class="fa-solid fa-arrow-right-long"></i></a><a data-fancybox-prev class="button-previous" href="javascript:;"><i class="fa-solid fa-arrow-left-long"></i></a>');
  867.     }
  868.    
  869.     current.$content.append('<a data-fancybox-close class="button-close" href="javascript:;">×</a>');
  870.   },
  871.   beforeShow: function() {
  872.       $('.caption--image').remove();
  873.   },
  874.   afterShow: function() {
  875.       var caption = $(".fancybox-caption"),
  876.           innerCaption = caption.clone().addClass('caption--image');
  877.  
  878.       $(".fancybox-slide--current .fancybox-content").append(innerCaption);
  879.       caption.not('.caption--image').addClass('caption--bottom');
  880.   }
  881. });
  882.  
  883. jQuery(document).ready(function($) {
  884.   // Add a dropdown toggle button dynamically
  885.   var activeText = $('.filter_main li.active label').text();
  886.   $('.filter_main').before('<div id="dropdownToggle">' + activeText + '</div>');
  887.  
  888.   // Always start as collapsed on mobile
  889.   if (window.innerWidth <= 768) {
  890.       $('.filter_main').addClass('collapsed');
  891.   }
  892.  
  893.   // Toggle dropdown visibility
  894.   $('#dropdownToggle').on('click', function() {
  895.       $('.filter_main').toggleClass('collapsed');
  896.   });
  897.  
  898.   // Update active item and dropdown text
  899.   $('.filter_main li').on('click', function() {
  900.       $('.filter_main li').removeClass('active');
  901.       $(this).addClass('active');
  902.  
  903.       var selectedText = $(this).find('label').text();
  904.       $('#dropdownToggle').text(selectedText);
  905.  
  906.       $('.filter_main').addClass('collapsed');
  907.   });
  908.  
  909.   // Close dropdown when clicking outside
  910.   $(document).on('click', function(e) {
  911.       if (!$(e.target).closest('#dropdownToggle, .filter_main').length) {
  912.           $('.filter_main').addClass('collapsed');
  913.       }
  914.   });
  915.  
  916.   // Re-check on window resize
  917.   $(window).on('resize', function() {
  918.       if (window.innerWidth > 768) {
  919.           $('.filter_main').removeClass('collapsed');
  920.       } else {
  921.           $('.filter_main').addClass('collapsed');
  922.       }
  923.   });
  924. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement