(function() { "use strict"; // Parallax var parallax = function() { $(window).stellar(); }; // Preloader $(window).on('load', function() { if ($('#preloader').length) { $('#preloader').delay(100).fadeOut('slow', function() { $(this).remove(); }); } }); /** * Easy selector helper function */ const select = (el, all = false) => { el = el.trim() if (all) { return [...document.querySelectorAll(el)] } else { return document.querySelector(el) } } /** * Easy event listener function */ const on = (type, el, listener, all = false) => { let selectEl = select(el, all) if (selectEl) { if (all) { selectEl.forEach(e => e.addEventListener(type, listener)) } else { selectEl.addEventListener(type, listener) } } } /** * Easy on scroll event listener */ const onscroll = (el, listener) => { el.addEventListener('scroll', listener) } $(window).on('load', function() { var $stickyElement = $('#gnbArea'); var sticky; if ($stickyElement.length) { sticky = new Waypoint.Sticky({ element: $stickyElement[0], offset: 0 }); } }); // Offcanvas and cloning of the main menu $(window).on('load', function() { var $clone = $('#navbar').clone(); $clone.attr({ 'id': 'offcanvas' }); $clone.find('> ul').attr({ 'class': '', 'id': '' }); $('#offcanvasWrapper').prepend($clone); // Click the burger $('.js-nav-toggle').on('click', function() { if ($('body').hasClass('offcanvas-indicators')) { $('body').removeClass('offcanvas-indicators'); } else { $('body').addClass('offcanvas-indicators'); } }); $('#offcanvas').css('height', $(window).height()); $(window).resize(function() { var w = $(window); $('#offcanvas').css('height', w.height()); if (w.width() > 1200) { if ($('body').hasClass('offcanvas-indicators')) { $('body').removeClass('offcanvas-indicators'); } } }); }); // Cover carousel var introCarousel = $(".carousel"); var introCarouselIndicators = $("#carouselIndicators"); introCarousel.find(".carousel-inner").children(".carousel-item").each(function(index) { (index === 0) ? introCarouselIndicators.append("
  • "): introCarouselIndicators.append("
  • "); $(this).css("background-image", "url('" + $(this).children('.carousel-img').children('img').attr('src') + "')"); $(this).children('.carousel-img').remove(); }); $(".carousel").swipe({ swipe: function(event, direction, distance, duration, fingerCount, fingerData) { if (direction == 'left') $(this).carousel('next'); if (direction == 'right') $(this).carousel('prev'); }, allowPageScroll: "vertical" }); // Initiate the wowjs animation library new WOW().init(); /** * Back to top button */ let backtotop = select('#backToTop') if (backtotop) { const toggleBacktotop = () => { if (window.scrollY > 100) { backtotop.classList.add('active') } else { backtotop.classList.remove('active') } } window.addEventListener('load', toggleBacktotop) onscroll(document, toggleBacktotop) } }());