(function ($) { /** * Get an HTMLElement using Jquery, and store them in a cache for a faster access later * @param selector {String} The Jquery selector to use * @return {(jQuery.fn.init | jQuery | HTMLElement)} The JQuery HTMLElement */ $.selector_cache = function (selector) { if (!$.selector_cache[selector]) { $.selector_cache[selector] = $(selector); } return $.selector_cache[selector]; }; })(jQuery); // Edit JQuery namespace to use the function as $.selector_cache('#elements'); $(document).ready(function () { loadHeader(); fixheader(); }); $.selector_cache('.nav-item') .on('mouseover', function () { $(this).find('.link-effect').addClass('link-hovered'); }) .on('mouseleave', function () { $(this).find('.link-effect').removeClass('link-hovered'); }).on('click', function () { $(this).find('.link-effect').removeClass('link-hovered'); $(this).find('.link-effect').addClass('link-active'); }); /** * Stop the header from changing height on mobile (with fullscreen browsing) */ function fixheader() { if ($.selector_cache("#headerJumbotron").length > 0) { let height = $(window).height() * 0.4; $.selector_cache('#headerJumbotron').css('height', height); } } function loadHeader() { if ($.selector_cache("#headerJumbotron").length > 0) { animateCss($.selector_cache('#headerTitle'), 'fadeInUp faster'); $.selector_cache('#headerTitle').css('opacity', 1); setTimeout(function () { animateCss($.selector_cache('#headerSubTitle'), 'fadeInUp faster'); $.selector_cache('#headerSubTitle').css('opacity', 1); }, 100); setTimeout(function () { $.selector_cache('#headerTop').addClass('loaded'); }, 100); setTimeout(function () { $.selector_cache('#headerBottom').addClass('loaded'); }, 300); } } // Using animate.css, translated into jquery // https://github.com/daneden/animate.css function animateCss($elem, animationName, callback) { $elem.addClass('animated ' + animationName); $elem.on('animationend', function () { $elem.removeClass('animated ' + animationName); if (typeof callback === 'function') callback(); }); }