diff --git a/js/main.js b/js/main.js index aa6bfe4..e6736f7 100755 --- a/js/main.js +++ b/js/main.js @@ -1,306 +1,306 @@ ;(function () { - - 'use strict'; - - - - // 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) - ); - }; - - var fullHeight = function() { - if ( !isiPad() || !isiPhone() ) { - $('.js-fullheight-home').css('height', $(window).height() - $('.fh5co-main-nav').height()); - $(window).resize(function(){ - $('.js-fullheight-home').css('height', $(window).height() - $('.fh5co-main-nav').height()); - }) - } - }; - - // Loading page - var loaderPage = function() { - $(".fh5co-loader").fadeOut("slow"); - }; - - var fh5coTabs = function() { - // $('.fh5co-tabs-container'). - $('.fh5co-tabs li a').click(function(event){ - event.preventDefault(); - var $this = $(this), - tab = $this.data('tab'); - $('.fh5co-tabs li').removeClass('active'); - $this.closest('li').addClass('active'); - $this.closest('.fh5co-tabs-container').find('.fh5co-tab-content').removeClass('active'); - $this.closest('.fh5co-tabs-container').find('.fh5co-tab-content[data-tab-content="'+tab+'"]').addClass('active'); - }); - } - - var gridAutoHeight = function() { - if (!isiPhone() || !isiPad()) { - $('.fh5co-grid-item').css('height', $('.fh5co-2col-inner').outerHeight()/2); - } - $(window).resize(function(){ - if (!isiPhone() && !isiPad()) { - $('.fh5co-grid-item').css('height', $('.fh5co-2col-inner').outerHeight()/2); - } - }); - } - - var sliderSayings = function() { - $('#fh5co-sayings .flexslider').flexslider({ - animation: "slide", - slideshowSpeed: 5000, - directionNav: false, - controlNav: true, - smoothHeight: true, - reverse: true - }); - } - - var offcanvasMenu = function() { - $('body').prepend('
'); - $('body').prepend(''); - - $('.fh5co-main-nav .fh5co-menu-1 a, .fh5co-main-nav .fh5co-menu-2 a').each(function(){ - - var $this = $(this); - - $('#fh5co-offcanvas').append($this.clone()); - - }); - // $('#fh5co-offcanvas').append - }; - - var mainMenuSticky = function() { - - var sticky = $('.js-sticky'); - - sticky.css('height', sticky.height()); - $(window).resize(function(){ - sticky.css('height', sticky.height()); - }); - - var $section = $('.fh5co-main-nav'); - - $section.waypoint(function(direction) { - - if (direction === 'down') { - - $section.css({ - 'position' : 'fixed', - 'top' : 0, - 'width' : '100%', - 'z-index' : 99999 - }).addClass('fh5co-shadow');; - - } - - }, { - offset: '0px' - }); - - $('.js-sticky').waypoint(function(direction) { - if (direction === 'up') { - $section.attr('style', '').removeClass('fh5co-shadow'); - } - }, { - offset: function() { return -$(this.element).height() + 69; } - }); - - }; - - // Parallax - var parallax = function() { - - // $(window).stellar(); - if (!isiPhone() || isiPad() ) { - $(window).stellar({ horizontalScrolling: false }); - } - - }; - - - // Burger Menu - var burgerMenu = function() { - - $('body').on('click', '.js-fh5co-nav-toggle', function(event){ - - var $this = $(this); - - if( $('body').hasClass('offcanvas-visible') ) { - $('body').removeClass('offcanvas-visible fh5co-overflow'); - $this.removeClass('active'); - } else { - $('body').addClass('offcanvas-visible fh5co-overflow'); - $this.addClass('active'); - } - event.preventDefault(); + 'use strict'; + + + + // 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) + ); + }; + + var fullHeight = function() { + if ( !isiPad() || !isiPhone() ) { + $('.js-fullheight-home').css('height', $(window).height() - $('.fh5co-main-nav').height()); + $(window).resize(function(){ + $('.js-fullheight-home').css('height', $(window).height() - $('.fh5co-main-nav').height()); + }) + } + }; + + // Loading page + var loaderPage = function() { + $(".fh5co-loader").fadeOut("slow"); + }; + + var fh5coTabs = function() { + // $('.fh5co-tabs-container'). + $('.fh5co-tabs li a').click(function(event){ + event.preventDefault(); + var $this = $(this), + tab = $this.data('tab'); + $('.fh5co-tabs li').removeClass('active'); + $this.closest('li').addClass('active'); + $this.closest('.fh5co-tabs-container').find('.fh5co-tab-content').removeClass('active'); + $this.closest('.fh5co-tabs-container').find('.fh5co-tab-content[data-tab-content="'+tab+'"]').addClass('active'); + }); + } + + var gridAutoHeight = function() { + if (!isiPhone() || !isiPad()) { + $('.fh5co-grid-item').css('height', $('.fh5co-2col-inner').outerHeight()/2); + } + $(window).resize(function(){ + if (!isiPhone() && !isiPad()) { + $('.fh5co-grid-item').css('height', $('.fh5co-2col-inner').outerHeight()/2); + } + }); + } - }); + var sliderSayings = function() { + $('#fh5co-sayings .flexslider').flexslider({ + animation: "slide", + slideshowSpeed: 5000, + directionNav: false, + controlNav: true, + smoothHeight: true, + reverse: true + }); + } - }; + var offcanvasMenu = function() { + $('body').prepend('
'); + $('body').prepend(''); - var scrolledWindow = function() { + $('.fh5co-main-nav .fh5co-menu-1 a, .fh5co-main-nav .fh5co-menu-2 a').each(function(){ - $(window).scroll(function(){ + var $this = $(this); - var scrollPos = $(this).scrollTop(); + $('#fh5co-offcanvas').append($this.clone()); - - if ( $('body').hasClass('offcanvas-visible') ) { - $('body').removeClass('offcanvas-visible'); - $('.js-fh5co-nav-toggle').removeClass('active'); - } + }); + // $('#fh5co-offcanvas').append + }; - }); + var mainMenuSticky = function() { - $(window).resize(function() { - if ( $('body').hasClass('offcanvas-visible') ) { - $('body').removeClass('offcanvas-visible'); - $('.js-fh5co-nav-toggle').removeClass('active'); - } - }); - - }; + var sticky = $('.js-sticky'); - // Click outside of offcanvass - var mobileMenuOutsideClick = function() { + sticky.css('height', sticky.height()); + $(window).resize(function(){ + sticky.css('height', sticky.height()); + }); - $(document).click(function (e) { - var container = $("#fh5co-offcanvas, .js-fh5co-nav-toggle"); - if (!container.is(e.target) && container.has(e.target).length === 0) { + var $section = $('.fh5co-main-nav'); - if ( $('body').hasClass('offcanvas-visible') ) { + $section.waypoint(function(direction) { - $('body').removeClass('offcanvas-visible'); - $('.js-fh5co-nav-toggle').removeClass('active'); - - } - - - } - }); + if (direction === 'down') { - }; + $section.css({ + 'position' : 'fixed', + 'top' : 0, + 'width' : '100%', + 'z-index' : 99999 + }).addClass('fh5co-shadow');; - var goToTop = function() { + } - $('.js-gotop').on('click', function(event){ - - event.preventDefault(); + }, { + offset: '0px' + }); - $('html, body').animate({ - scrollTop: $('html').offset().top - }, 500, 'easeInOutExpo'); - - return false; - }); + $('.js-sticky').waypoint(function(direction) { + if (direction === 'up') { + $section.attr('style', '').removeClass('fh5co-shadow'); + } + }, { + offset: function() { return -$(this.element).height() + 69; } + }); - $(window).scroll(function(){ + }; - var $win = $(window); - if ($win.scrollTop() > 200) { - $('.js-top').addClass('active'); - } else { - $('.js-top').removeClass('active'); - } + // Parallax + var parallax = function() { - }); - - }; + // $(window).stellar(); + if (!isiPhone() || isiPad() ) { + $(window).stellar({ horizontalScrolling: false }); + } + }; - // Page Nav - var clickMenu = function() { - var topVal = ( $(window).width() < 769 ) ? 0 : 58; - $(window).resize(function(){ - topVal = ( $(window).width() < 769 ) ? 0 : 58; - }); - $('.fh5co-main-nav a:not([class="external"]), #fh5co-offcanvas a:not([class="external"]), a.fh5co-content-nav:not([class="external"])').click(function(event){ - var section = $(this).data('nav-section'); + // Burger Menu + var burgerMenu = function() { - if ( $('div[data-section="' + section + '"]').length ) { + $('body').on('click', '.js-fh5co-nav-toggle', function(event){ - $('html, body').animate({ - scrollTop: $('div[data-section="' + section + '"]').offset().top - topVal - }, 500, 'easeInOutExpo'); - - } + var $this = $(this); - event.preventDefault(); + if( $('body').hasClass('offcanvas-visible') ) { + $('body').removeClass('offcanvas-visible fh5co-overflow'); + $this.removeClass('active'); + } else { + $('body').addClass('offcanvas-visible fh5co-overflow'); + $this.addClass('active'); + } - // return false; - }); + event.preventDefault(); + }); - }; + }; - // Reflect scrolling in navigation - var navActive = function(section) { - - $('.fh5co-main-nav a[data-nav-section], #fh5co-offcanvas a[data-nav-section]').removeClass('active'); - $('.fh5co-main-nav, #fh5co-offcanvas').find('a[data-nav-section="'+section+'"]').addClass('active'); - - }; + var scrolledWindow = function() { - var navigationSection = function() { + $(window).scroll(function(){ - var $section = $('div[data-section]'); - - $section.waypoint(function(direction) { - if (direction === 'down') { - navActive($(this.element).data('section')); - } + var scrollPos = $(this).scrollTop(); - }, { - offset: '150px' - }); - $section.waypoint(function(direction) { - if (direction === 'up') { - navActive($(this.element).data('section')); - } - }, { - offset: function() { return -$(this.element).height() + 155; } - }); + if ( $('body').hasClass('offcanvas-visible') ) { + $('body').removeClass('offcanvas-visible'); + $('.js-fh5co-nav-toggle').removeClass('active'); + } - }; + }); + $(window).resize(function() { + if ( $('body').hasClass('offcanvas-visible') ) { + $('body').removeClass('offcanvas-visible'); + $('.js-fh5co-nav-toggle').removeClass('active'); + } + }); - + }; + // Click outside of offcanvass + var mobileMenuOutsideClick = function() { - // Document on load. - $(function(){ + $(document).click(function (e) { + var container = $("#fh5co-offcanvas, .js-fh5co-nav-toggle"); + if (!container.is(e.target) && container.has(e.target).length === 0) { - fullHeight(); - loaderPage(); - fh5coTabs(); - gridAutoHeight(); + if ( $('body').hasClass('offcanvas-visible') ) { - // sliderMain(); - // sliderSayings(); - offcanvasMenu(); - mainMenuSticky(); - parallax(); - burgerMenu(); - scrolledWindow(); - mobileMenuOutsideClick(); - clickMenu(); - navigationSection(); - goToTop(); + $('body').removeClass('offcanvas-visible'); + $('.js-fh5co-nav-toggle').removeClass('active'); - }); + } -}()); \ No newline at end of file + } + }); + + }; + + var goToTop = function() { + + $('.js-gotop').on('click', function(event){ + + event.preventDefault(); + + $('html, body').animate({ + scrollTop: $('html').offset().top + }, 1000, 'easeInOutExpo'); + + return false; + }); + + $(window).scroll(function(){ + + var $win = $(window); + if ($win.scrollTop() > 200) { + $('.js-top').addClass('active'); + } else { + $('.js-top').removeClass('active'); + } + + }); + + }; + + + // Page Nav + var clickMenu = function() { + var topVal = ( $(window).width() < 769 ) ? 0 : 58; + + $(window).resize(function(){ + topVal = ( $(window).width() < 769 ) ? 0 : 58; + }); + $('.fh5co-main-nav a:not([class="external"]), #fh5co-offcanvas a:not([class="external"]), a.fh5co-content-nav:not([class="external"])').click(function(event){ + var section = $(this).data('nav-section'); + + if ( $('div[data-section="' + section + '"]').length ) { + + $('html, body').animate({ + scrollTop: $('div[data-section="' + section + '"]').offset().top - topVal + }, 1000, 'easeInOutExpo'); + + } + + event.preventDefault(); + + // return false; + }); + + + }; + + // Reflect scrolling in navigation + var navActive = function(section) { + + $('.fh5co-main-nav a[data-nav-section], #fh5co-offcanvas a[data-nav-section]').removeClass('active'); + $('.fh5co-main-nav, #fh5co-offcanvas').find('a[data-nav-section="'+section+'"]').addClass('active'); + + }; + + var navigationSection = function() { + + var $section = $('div[data-section]'); + + $section.waypoint(function(direction) { + if (direction === 'down') { + navActive($(this.element).data('section')); + } + + }, { + offset: '150px' + }); + + $section.waypoint(function(direction) { + if (direction === 'up') { + navActive($(this.element).data('section')); + } + }, { + offset: function() { return -$(this.element).height() + 155; } + }); + + }; + + + + + + // Document on load. + $(function(){ + + fullHeight(); + loaderPage(); + fh5coTabs(); + gridAutoHeight(); + + // sliderMain(); + // sliderSayings(); + offcanvasMenu(); + mainMenuSticky(); + parallax(); + burgerMenu(); + scrolledWindow(); + mobileMenuOutsideClick(); + clickMenu(); + navigationSection(); + goToTop(); + + }); + + +}());