jQuery(document).ready(function() { "use strict"; // slider scrlling if( jQuery('.section-scroll').length > 0 ) { jQuery('.section-scroll').bind('click', function(e) { var anchor = jQuery(this); jQuery('html, body').stop().animate({ scrollTop: jQuery(anchor.attr('href')).offset().top - 50 }, 1000); e.preventDefault(); }); } /* ---------------------------------------------- /* * Intro slider setup /* ---------------------------------------------- */ if( jQuery('.flex-slider').length > 0 ) { jQuery(".flex-slider").flexslider({ animation: "fade", animationSpeed: 1000, animationLoop: true, prevText: '', nextText: '', before: function(slider) { jQuery('.fs-caption').fadeOut().animate({top:'-80px'},{queue:false, easing: 'swing', duration: 700}); slider.slides.eq(slider.currentSlide).delay(500); slider.slides.eq(slider.animatingTo).delay(500); }, after: function(slider) { jQuery('.fs-caption').fadeIn().animate({top:'0'},{queue:false, easing: 'swing', duration: 700}); }, useCSS: true }); } /* Dropdown menus*/ function thDropdownMenu() { var wWidth = jQuery(window).width(); if(wWidth > 1024) { jQuery('.navigation ul.sub-menu, .navigation ul.children').hide(); var timer; var delay = 100; jQuery('.navigation li').hover( function() { var $this = jQuery(this); timer = setTimeout(function() { $this.children('ul.sub-menu, ul.children').slideDown('fast'); }, delay); }, function() { jQuery(this).children('ul.sub-menu, ul.children').hide(); clearTimeout(timer); } ); } else { jQuery('.navigation li').unbind('hover'); jQuery('.navigation li.active > ul.sub-menu, .navigation li.active > ul.children').show(); } } thDropdownMenu(); jQuery(window).resize(function() { thDropdownMenu(); }); /* Vertical menus toggles*/ jQuery('.widget .menu-menu-1-container, .navigation .menu').addClass('toggle-menu'); jQuery('.toggle-menu ul.sub-menu, .toggle-menu ul.children').addClass('toggle-submenu'); jQuery('.toggle-menu ul.sub-menu').parent().addClass('toggle-menu-item-parent'); jQuery('.toggle-menu .toggle-menu-item-parent').append(''); jQuery('.toggle-caret').click(function(e) { e.preventDefault(); jQuery(this).parent().toggleClass('active').children('.toggle-submenu').slideToggle('fast'); }); /*Show-hide Scroll to top & move-to-top arrow*/ jQuery("body").prepend(""); var scrollDes = 'html,body'; /*Opera does a strange thing if we use 'html' and 'body' together so my solution is to do the UA sniffing thing*/ if(navigator.userAgent.match(/opera/i)){ scrollDes = 'html'; } //show ,hide jQuery(window).scroll(function () { if (jQuery(this).scrollTop() > 160) { jQuery('#move-to-top').addClass('filling').removeClass('hiding'); } else { jQuery('#move-to-top').removeClass('filling').addClass('hiding'); } }); /* Make all anchor links smooth scrolling & scroll handler*/ var scrollToAnchor = function( id, event ) { // grab the element to scroll to based on the name var elem = jQuery("a[name='"+ id +"']"); // if that didn't work, look for an element with our ID if ( typeof( elem.offset() ) === "undefined" ) { elem = jQuery("#"+id); } // if the destination element exists if ( typeof( elem.offset() ) !== "undefined" ) { // cancel default event propagation event.preventDefault(); // do the scroll var scroll_to = elem.offset().top; jQuery('html, body').animate({ scrollTop: scroll_to }, 600, 'swing', function() { if (scroll_to > 46) window.location.hash = id; } ); } }; // bind to click event jQuery("a").click(function( event ) { // only do this if it's an anchor link var href = jQuery(this).attr("href"); if ( href && href.match("#") && href !== '#' ) { // scroll to the location var parts = href.split('#'), url = parts[0], target = parts[1]; if ((!url || url == window.location.href.split('#')[0]) && target) scrollToAnchor( target, event ); } }); // Responsive Navigation /* */ if (themehunk_customscript.responsive && themehunk_customscript.nav_menu != 'none') { jQuery(document).ready(function($){ // merge if two menus exist if (themehunk_customscript.nav_menu == 'both') { jQuery('.navigation').not('.mobile-menu-wrapper').find('.menu').clone().appendTo('.mobile-menu-wrapper').hide(); } jQuery('.toggle-mobile-menu').click(function(e) { e.preventDefault(); e.stopPropagation(); jQuery('body').toggleClass('mobile-menu-active'); }); // prevent propagation of scroll event to parent jQuery(document).on('DOMMouseScroll mousewheel', '.mobile-menu-wrapper', function(ev) { var $this = jQuery(this), scrollTop = this.scrollTop, scrollHeight = this.scrollHeight, height = $this.height(), delta = (ev.type == 'DOMMouseScroll' ? ev.originalEvent.detail * -40 : ev.originalEvent.wheelDelta), up = delta > 0; var prevent = function() { ev.stopPropagation(); ev.preventDefault(); ev.returnValue = false; return false; } if ( jQuery('a#pull').css('display') !== 'none' ) { // if toggle menu button is visible ( small screens ) if (!up && -delta > scrollHeight - height - scrollTop) { // Scrolling down, but this will take us past the bottom. $this.scrollTop(scrollHeight); return prevent(); } else if (up && delta > scrollTop) { // Scrolling up, but this will take us past the top. $this.scrollTop(0); return prevent(); } } }); }).on('click', function(event) { var $target = jQuery(event.target); if ( ( $target.hasClass("fa") && $target.parent().hasClass("toggle-caret") ) || $target.hasClass("toggle-caret") ) {// allow clicking on menu toggles return; } jQuery('body').removeClass('mobile-menu-active'); }); } // Scroll down header function init() { window.addEventListener('scroll', function(e){ var distanceY = window.pageYOffset || document.documentElement.scrollTop, shrinkOn = 250, header = document.querySelector("header"); if (distanceY > shrinkOn) { classie.add(header,"smaller"); jQuery( ".main-heading" ).addClass( "smaller" ); } else { if (classie.has(header,"smaller")) { classie.remove(header,"smaller"); jQuery( ".main-heading" ).removeClass( "smaller" ); } } }); } window.onload = init(); /* ---------------------------------------------- /* * Home section height /* ---------------------------------------------- */ var homeOption =jQuery('.home-option'); function effectHomeOption(homeOption, scrollTopp) { if (homeOption.length > 0) { var homeSHeight = homeOption.height(); var topScroll = jQuery(document).scrollTop(); if ((homeOption.hasClass('home-option')) && (jQuery(scrollTopp).scrollTop() <= homeSHeight)) { homeOption.css('top', (topScroll * 0.55)); } } } jQuery(window).scroll(function() { effectHomeOption(homeOption, this); }); });