151 lines
4.4 KiB
JavaScript
151 lines
4.4 KiB
JavaScript
(function($) {
|
|
|
|
"use strict";
|
|
|
|
function updateNavbarSpacer() {
|
|
var navbar = document.querySelector('.scrolling-navbar');
|
|
var spacer = document.querySelector('.navbar-spacer');
|
|
|
|
if (!navbar || !spacer) {
|
|
return;
|
|
}
|
|
|
|
var height = Math.ceil(navbar.getBoundingClientRect().height);
|
|
spacer.style.height = height + 'px';
|
|
document.documentElement.style.setProperty('--site-header-height', height + 'px');
|
|
}
|
|
|
|
window.updateNavbarSpacer = updateNavbarSpacer;
|
|
|
|
function initNavbarSpacer() {
|
|
updateNavbarSpacer();
|
|
|
|
var navbar = document.querySelector('.scrolling-navbar');
|
|
if (navbar && typeof ResizeObserver !== 'undefined') {
|
|
var resizeObserver = new ResizeObserver(updateNavbarSpacer);
|
|
resizeObserver.observe(navbar);
|
|
}
|
|
|
|
var headerLogo = document.querySelector('[data-logo-placement="header"] [data-logo-image]');
|
|
if (headerLogo) {
|
|
if (headerLogo.complete) {
|
|
updateNavbarSpacer();
|
|
}
|
|
headerLogo.addEventListener('load', updateNavbarSpacer);
|
|
}
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initNavbarSpacer);
|
|
} else {
|
|
initNavbarSpacer();
|
|
}
|
|
|
|
$(window).on('load', function() {
|
|
|
|
/*Page Loader active
|
|
========================================================*/
|
|
$('#preloader').fadeOut();
|
|
|
|
updateNavbarSpacer();
|
|
|
|
// Sticky Nav
|
|
$(window).on('scroll', function() {
|
|
var wasCollapsed = $('.scrolling-navbar').hasClass('top-nav-collapse');
|
|
|
|
if ($(window).scrollTop() > 200) {
|
|
$('.scrolling-navbar').addClass('top-nav-collapse');
|
|
} else {
|
|
$('.scrolling-navbar').removeClass('top-nav-collapse');
|
|
}
|
|
|
|
if (wasCollapsed !== $('.scrolling-navbar').hasClass('top-nav-collapse')) {
|
|
requestAnimationFrame(updateNavbarSpacer);
|
|
}
|
|
});
|
|
|
|
$(window).on('resize', updateNavbarSpacer);
|
|
|
|
if (document.documentElement.classList.contains('site-config-loaded')) {
|
|
updateNavbarSpacer();
|
|
} else {
|
|
var configObserver = new MutationObserver(function() {
|
|
if (document.documentElement.classList.contains('site-config-loaded')) {
|
|
updateNavbarSpacer();
|
|
configObserver.disconnect();
|
|
}
|
|
});
|
|
configObserver.observe(document.documentElement, {
|
|
attributes: true,
|
|
attributeFilter: ['class']
|
|
});
|
|
}
|
|
|
|
/* ==========================================================================
|
|
countdown timer — initialized from site.json via site-config.js
|
|
========================================================================== */
|
|
|
|
/* Auto Close Responsive Navbar on Click
|
|
========================================================*/
|
|
function close_toggle() {
|
|
if ($(window).width() <= 768) {
|
|
$('.navbar-collapse a').on('click', function () {
|
|
$('.navbar-collapse').collapse('hide');
|
|
});
|
|
}
|
|
else {
|
|
$('.navbar .navbar-inverse a').off('click');
|
|
}
|
|
}
|
|
close_toggle();
|
|
$(window).resize(close_toggle);
|
|
|
|
/* WOW Scroll Spy
|
|
========================================================*/
|
|
var wow = new WOW({
|
|
//disabled for mobile
|
|
mobile: false
|
|
});
|
|
wow.init();
|
|
|
|
/* Nivo Lightbox
|
|
========================================================*/
|
|
$('.lightbox').nivoLightbox({
|
|
effect: 'fadeScale',
|
|
keyboardNav: true,
|
|
});
|
|
|
|
// one page navigation
|
|
$('.navbar-nav').onePageNav({
|
|
currentClass: 'active'
|
|
});
|
|
|
|
/* Counter (static placeholders only; event stats are animated in site-config.js) */
|
|
$('.counterUp').not('[data-event-stats-list] .counterUp').counterUp({
|
|
delay: 10,
|
|
time: 1500
|
|
});
|
|
|
|
/* Back Top Link active
|
|
========================================================*/
|
|
var offset = 200;
|
|
var duration = 500;
|
|
$(window).scroll(function() {
|
|
if ($(this).scrollTop() > offset) {
|
|
$('.back-to-top').fadeIn(400);
|
|
} else {
|
|
$('.back-to-top').fadeOut(400);
|
|
}
|
|
});
|
|
|
|
$('.back-to-top').on('click',function(event) {
|
|
event.preventDefault();
|
|
$('html, body').animate({
|
|
scrollTop: 0
|
|
}, 600);
|
|
return false;
|
|
});
|
|
|
|
});
|
|
|
|
}(jQuery)); |