; (function() { 'use strict'; var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; var fullHeight = function() { if (!isMobile.any()) { $('.js-fullheight').css('height', $(window).height()); $(window).resize(function() { $('.js-fullheight').css('height', $(window).height()); }); } }; // iPad and iPod detection var isiPad = function() { return (navigator.platform.indexOf("iPad") != -1); }; var isiPhone = function() { return ( (navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) ); }; // Main Menu Superfish var mainMenu = function() { $('#w08g-primary-menu').superfish({ delay: 0, animation: { opacity: 'show' }, speed: 'fast', cssArrows: true, disableHI: true }); }; var sliderMain = function() { $('#w08g-hero .flexslider').flexslider({ animation: "fade", slideshowSpeed: 5000, directionNav: true, start: function() { setTimeout(function() { $('.slider-text').removeClass('animated fadeInUp'); $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp'); }, 500); }, before: function() { setTimeout(function() { $('.slider-text').removeClass('animated fadeInUp'); $('.flex-active-slide').find('.slider-text').addClass('animated fadeInUp'); }, 500); } }); $('#w08g-hero .flexslider .slides > li').css('height', $(window).height()); $(window).resize(function() { $('#w08g-hero .flexslider .slides > li').css('height', $(window).height()); }); }; // Offcanvas and cloning of the main menu var offcanvas = function() { var $clone = $('#w08g-menu-wrap').clone(); $clone.attr({ 'id': 'offcanvas-menu' }); $clone.find('> ul').attr({ 'class': '', 'id': '' }); $('#w08g-page').prepend($clone); // click the burger $('.js-w08g-nav-toggle').on('click', function() { if ($('body').hasClass('w08g-offcanvas')) { $('body').removeClass('w08g-offcanvas'); } else { $('body').addClass('w08g-offcanvas'); } // $('body').toggleClass('w08g-offcanvas'); }); $('#offcanvas-menu').css('height', $(window).height()); $(window).resize(function() { var w = $(window); $('#offcanvas-menu').css('height', w.height()); if (w.width() > 769) { if ($('body').hasClass('w08g-offcanvas')) { $('body').removeClass('w08g-offcanvas'); } } }); } // Click outside of the Mobile Menu var mobileMenuOutsideClick = function() { $(document).click(function(e) { var container = $("#offcanvas-menu, .js-w08g-nav-toggle"); if (!container.is(e.target) && container.has(e.target).length === 0) { if ($('body').hasClass('w08g-offcanvas')) { $('body').removeClass('w08g-offcanvas'); } } }); }; // Animations var contentWayPoint = function() { var i = 0; $('.animate-box').waypoint(function(direction) { if (direction === 'down' && !$(this.element).hasClass('animated')) { i++; $(this.element).addClass('item-animate'); setTimeout(function() { $('body .animate-box.item-animate').each(function(k) { var el = $(this); setTimeout(function() { el.addClass('fadeInUp animated'); el.removeClass('item-animate'); }, k * 200, 'easeInOutExpo'); }); }, 100); } }, { offset: '85%' }); }; var stickyBanner = function() { var $stickyElement = $('.sticky-banner'); var sticky; if ($stickyElement.length) { sticky = new Waypoint.Sticky({ element: $stickyElement[0], offset: 400 }) } }; // Document on load. $(function() { mainMenu(); offcanvas(); mobileMenuOutsideClick(); contentWayPoint(); sliderMain(); fullHeight(); stickyBanner(); }); }());