1/* 2 ========================================================================== 3 DOCUMENT INFORMATION 4 ========================================================================== 5 * 6 * Document: BA Main Scripts 7 * Version: 1.0.0 8 * Client: Hubspot Marketplace 9 * Author: Struto Ltd - www.struto.co.uk 10 * 11 12 ========================================================================== */ 13 14$(document).ready(initPage); 15 16function initPage(){ 17 initDOM(); 18} 19 20/* DOM Functions */ 21function initDOM(){ 22 //Mobile Menu 23 $('.custom-menu-primary').addClass('js-enabled'); 24 $('.custom-menu-primary .hs-menu-wrapper').before('<div class="mobile-trigger"><i></i></div>'); 25 $('.custom-menu-primary .flyouts .hs-item-has-children > a').after(' <div class="child-trigger"><i></i></div>'); 26 $(".custom-menu-primary ul li.hs-menu-depth-1.hs-item-has-children").append("<span class='fa fa-angle-down'></span>"); 27 $(".custom-menu-primary ul li.hs-menu-depth-2.hs-item-has-children").append("<span class='fa fa-angle-right'></span>"); 28 $('.mobile-trigger').click(function() { 29 $(this).next('.custom-menu-primary .hs-menu-wrapper').slideToggle(250); 30 $('body').toggleClass('mobile-open'); 31 $('.child-trigger').removeClass('child-open'); 32 $('.hs-menu-children-wrapper').slideUp(250); 33 var wHeight = $(window).height() - 100; 34 $('.hs-menu-wrapper ul:first-child').css({ 35 'height' : wHeight 36 }); 37 return false; 38 }); 39 $('.child-trigger').click(function() { 40 $(this).parent().siblings('.hs-item-has-children').find('.child-trigger').removeClass('child-open'); 41 $(this).parent().siblings('.hs-item-has-children').find('.hs-menu-children-wrapper').slideUp(250); 42 $(this).next('.hs-menu-children-wrapper').slideToggle(250); 43 $(this).next('.hs-menu-children-wrapper').children('.hs-item-has-children').find('.hs-menu-children-wrapper').slideUp(250); 44 $(this).next('.hs-menu-children-wrapper').children('.hs-item-has-children').find('.child-trigger').removeClass('child-open'); 45 $(this).toggleClass('child-open'); 46 return false; 47 }); 48 49 //Google Search Animation 50 $('.search-wrap').click(function() { 51 $('.search-section, .custom-menu-primary, .search-wrap, .search-close, .google-search-wrapper','#mainMenu').addClass('search-open'); 52 return false; 53 }); 54 $('.search-close').click(function() { 55 $('.search-section, .custom-menu-primary, .search-wrap, .search-close, .google-search-wrapper','#mainMenu').removeClass('search-open'); 56 return false; 57 }); 58 59 if ($(window).scrollTop() > 100 ){ 60 $('#mainMenu').addClass('scrolling'); 61 } 62 63 //Menu Background transition 64 $(window).scroll(function() { 65 if ($(window).scrollTop() > 100 ){ 66 $('#mainMenu').addClass('scrolling'); 67 } else { 68 $('#mainMenu').removeClass('scrolling'); 69 }; 70 }); 71 72 //Scroll-to-top 73 $(window).scroll(function() { 74 if ($(window).scrollTop() > 1000) {
75 $(".c-scroll-top").addClass("scroll-show"); 76 } else { 77 $(".c-scroll-top").removeClass("scroll-show"); 78 } 79 }); 80 $(".c-scroll-top").click(function(event) { 81 event.preventDefault(); 82 $("html, body").animate({scrollTop: 0}, 350); 83 return false; 84 }); 85} 86 //Auto height on mobile menu dropdown 87$(window).on('load resize', function () { 88 var wHeight = $(window).height() - 100; 89 $('.mobile-open .hs-menu-wrapper ul:first-child').css({ 90 'height' : wHeight 91 }); 92}); 93/* Run Slider */ 94function runSlick(i, slides){ 95 $(i).slick({ 96 dots: true, 97 infinite: true, 98 centerMode: true, 99 slidesToShow: slides, 100 centerPadding: '0', 101 slidesToScroll: 3, 102 responsive: [ 103 { 104 breakpoint: 991, 105 settings: { 106 slidesToShow: 1 107 } 108 }, 109 { 110 breakpoint: 767, 111 settings: { 112 slidesToShow: 1 113 } 114 }, 115 { 116 breakpoint: 479, 117 settings: { 118 arrows: false, 119 slidesToShow: 1 120 } 121 } 122 ] 123 }); 124} 125/* About us popups */ 126function teamModals(){ 127 $(".team-open").click(function(){ 128 document.body.style.overflow = 'hidden'; 129 $(this).parent().find(".team-modal").addClass("modal-open"); 130 $("#mainMenu, .c-scroll-top").hide(); 131 132 }); 133 $(".close-team-modal").click(function(){ 134 document.body.style.overflow = 'auto'; 135 $(".team-modal").removeClass("modal-open"); 136 $("#mainMenu, .c-scroll-top").show(); 137 }); 138 $(document).keyup(function(e) { 139 if (e.keyCode == 27) { 140 document.body.style.overflow = 'auto'; 141 $(".team-modal").removeClass("modal-open"); 142 $("#mainMenu, .c-scroll-top").show(); 143 } 144 }); 145} 146/* Smooth anchor scrolling */ 147function smoothScroll(){ 148 //by Chris Coyier 149 // Select all links with hashes 150 $('a[href*="#"]') 151 // Remove links that don't actually link to anything 152 .not('[href="#"]') 153 .not('[href="#0"]') 154 .click(function(event) { 155 // On-page links 156 if ( 157 location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') 158 && 159 location.hostname == this.hostname 160 ) { 161 // Figure out element to scroll to 162 var target = $(this.hash); 163 target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); 164 // Does a scroll target exist? 165 if (target.length) { 166 // Only prevent default if animation is actually gonna happen 167 event.preventDefault(); 168 $('html, body').animate({ 169 scrollTop: target.offset().top 170 }, 1000, function() { 171 // Callback after animation 172 // Must change focus! 173 var $target = $(target); 174 $target.focus(); 175 if ($target.is(":focus")) { // Checking if the target was focused 176 return false; 177 } else { 178 $target.attr('tabindex','-1'); // Adding tabindex for elements not focusable 179 $target.focus(); // Set focus again 180 }; 181 }); 182 } 183 } 184 }); 185}
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.