// Hide Header on on scroll down var didScroll; var lastScrollTop = 0; var delta = 5; var navbarHeight = $(".nav").outerHeight(); $(window).scroll(function (event) { didScroll = true; }); setInterval(function () { if (didScroll) { hasScrolled(); didScroll = false; } }, 250); $(".singleSelect").select2({ allowClear: true, }); $(document).on("click", ".mobileFilterBtn", function () { $(".filterItem").toggle("slow"); $(this).toggleClass("rotate"); }); $(document).ready(function () { $(".form_date").datepicker({ format: "M dd yyyy", orientation: "bottom", }); }); function hasScrolled() { var st = $(this).scrollTop(); // Make sure they scroll more than delta if (Math.abs(lastScrollTop - st) <= delta) return; // If they scrolled down and are past the navbar, add class .nav-up. // This is necessary so you never see what is "behind" the navbar. if (st > lastScrollTop && st > navbarHeight) { // Scroll Down $(".nav").addClass("nav-up"); } else { // Scroll Up if (st + $(window).height() < $(document).height()) { $(".nav").removeClass("nav-up"); } } lastScrollTop = st; } var countries = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, // url points to a json file that contains an array of country names, see // https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json prefetch: "../assets/json/country.json", }); var carrier = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, // url points to a json file that contains an array of country names, see // https://github.com/twitter/typeahead.js/blob/gh-pages/data/countries.json prefetch: "../assets/json/carrier.json", }); $(".formAutoComplete").typeahead(null, { name: "countries", source: countries, }); $(".toAutoComplete").typeahead(null, { name: "countries", source: countries, }); $(".carrierAutoComplete").typeahead(null, { name: "carrier", source: carrier, }); $(".scrollTop").click(function () { // When arrow is clicked $("html").animate( { scrollTop: 0, // Scroll to top of body }, 500 ); });