//////////////////////////////////////// // // Helpers // //////////////////////////////////////// /////////////// Mobile detection var isMobile = false; if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { isMobile = true; } ///////////////////////////////////////// // // znav // ///////////////////////////////////////// $(document).ready(function() { if($('#znav-container').length){ var previousScroll = 0, navBarOrgOffset = $('#znav-container').offset().top; $this = $('#znav-container'); ///////////////////////////////////// // Scrollup Fixed Navbar ///////////////////////////////////// // $(window).scroll(function() { // var currentScroll = $(this).scrollTop(); // if(currentScroll > navBarOrgOffset) { // if (currentScroll > previousScroll) { // $this.fadeOut(); // } else { // $this.fadeIn(); // $this.addClass('znav-revealed'); // } // } else { // $this.removeClass('znav-revealed'); // } // previousScroll = currentScroll; // }); $('#znav-container #navbarNavDropdown ul.navbar-nav .dropdown').each(function(){ $this = $(this); $this.parent('li').addClass('has-dropdown'); }); $('#znav-container #navbarNavDropdown ul.navbar-nav .megamenu').each(function(){ $this = $(this); $this.parent('li').addClass('has-megamenu'); }); $('.has-dropdown > a, .has-megamenu > a').on('click', function(){ $this = $(this).parent(); $this.each(function(){ $this.toggleClass('z-active'); }); }); // menuAim Started if($.fn.menuAim){ $("ul.dropdown").menuAim({ activate: function(row){ $(row).children('ul.dropdown').addClass("opened"); }, deactivate: function(row){ $(row).children('ul.dropdown').removeClass("opened"); }, exitMenu: function() { return true } });// End of menuAim } } }); //////////////////////////////////////// // // Hamburger Trigger // //////////////////////////////////////// $(document).ready(function(){ if($('.hamburger').length){ var $hamburger = $(".hamburger"); $hamburger.on("click", function(e) { $hamburger.toggleClass("is-active"); // Do something else, like open/close menu // Click event off .. Doesn't work if($('.is-active').is(':animated')){ $('.navbar-toggler').off('click', function(){ return; }); } }); } }); /////////////// On page scroll for #id targets $(document).ready(function($){ $('a[href*=\\#]:not([href=\\#])').click(function() { if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 400, 'swing', function(){ }); return false; } } }); }); //////////////////////////////////////// // // Tabs // //////////////////////////////////////// $(document).ready(function(){ if($('.tabs, .navs').length){ // Function for active tab indicator change /////////////////////////////////////////// function updateIncicator($indicator, $tabs, $tabnavCurrentItem){ var left = $tabnavCurrentItem.position().left, right = $tabs.children('.nav-bar').outerWidth() - (left+$tabnavCurrentItem.outerWidth()); $indicator.css({ left: left, right: right }); return; } $('.tabs, .navs').each(function(){ var $tabs = $(this), $tabnavCurrentItem = $tabs.children('.nav-bar').children('.nav-bar-item.active'); $tabs.children('.nav-bar').append('
'); var $indicator = $tabs.children('.nav-bar').children(".indicator"), $tabnavCurrentItem = $tabs.children('.nav-bar').children('.nav-bar-item.active'); $preIndex = $tabnavCurrentItem.index(); updateIncicator($indicator, $tabs, $tabnavCurrentItem); $tabs.children('.nav-bar').children('.nav-bar-item').click(function(){ var $tabnavCurrentItem = $(this), $currentIndex = $tabnavCurrentItem.index(), $tabContent = $tabs.children('.tab-contents').children().eq($currentIndex); $tabnavCurrentItem.siblings().removeClass('active'); $tabnavCurrentItem.addClass('active'); $tabContent.siblings().removeClass('active'); $tabContent.addClass('active'); // Indicator Transition //////////////////////// updateIncicator($indicator, $tabs, $tabnavCurrentItem); if(($currentIndex - $preIndex) <= 0){ $('.indicator').addClass('transition-reverse'); }else{ $('.indicator').removeClass('transition-reverse'); }; $preIndex = $currentIndex; }); $(window).on('resize', function(){ updateIncicator($indicator, $tabs, $tabs.children('.nav-bar').children('.nav-bar-item.active')); }); }); } }); //////////////////////////////////////// // // Parallax Background // //////////////////////////////////////// $(document).ready(function(){ if(!$('[class^=gsap-]').length){ if($('.parallax').length){ var rellax = new Rellax('.parallax', {center: false}); } } }); //////////////////////////////////////// // // Youtube Background // //////////////////////////////////////// $(document).ready(function(){ if($('.youtube-background').length){ $('.youtube-background').each(function(){ var $this = $(this); $(this).YTPlayer({ containment: $this.parent(".background-holder"), showControls: false }); }); } }); //////////////////////////////////////// // // Tooltips // //////////////////////////////////////// // $(document).ready(function(){ // $('[data-toggle="tooltip"]').tooltip(); // }); //////////////////////////////////////// // // Flex slider // //////////////////////////////////////// $(document).ready(function(){ if($('.flexslider').length){ var flexSliderZanimPlay = function(slider){ if($(slider).find('*[data-zanim-timeline]').length == 0) return; $(slider).find('*[data-zanim-timeline].flex-active-slide').zanimation(zanimationDefaults).play(); } var flexSliderZanimKill = function(slider){ if($(slider).find('*[data-zanim-timeline]').length == 0) return; $(slider).find('*[data-zanim-timeline]').zanimation(zanimationDefaults).kill(); } $('.flexslider').each(function(){ var $this = $(this); $this.flexslider($.extend( $this.data("zflexslider") || {}, { start: function(slider){ slider.removeClass("loading"); flexSliderZanimPlay(slider); }, before: function(slider){ flexSliderZanimKill(slider); }, after: function(slider){ flexSliderZanimPlay(slider); } } )); }); } }); ///////////////////////////////////////// // // Owl Carousel // ///////////////////////////////////////// $(document).ready(function(){ if($('.owl-carousel').length){ var owlZanimPlay = function($el){ if($el.find('*[data-zanim-timeline]').length == 0) return; $el.find(".owl-item.active > *[data-zanim-timeline]").zanimation(zanimationDefaults).play(); } var owlZanimKill = function($el){ if($el.find('*[data-zanim-timeline]').length == 0) return; $el.find("*[data-zanim-timeline]").zanimation(zanimationDefaults).kill(); } $('.owl-carousel').each(function(){ var $this = $(this), options = $this.data("options") || {}; options.navText || (options.navText = ['','']); $this.owlCarousel($.extend(options || {}, { onInitialized: function(event){ owlZanimPlay($(event.target)); }, onTranslate: function(event){ owlZanimKill($(event.target)); }, onTranslated: function(event){ owlZanimPlay($(event.target)); } })); }); } }); /////////////////////////////////////// // // Forms // /////////////////////////////////////// // Choose a file /////////////////////////////////////// ( function ( document, window, index ){ var inputs = document.querySelectorAll( '.inputfile' ); Array.prototype.forEach.call( inputs, function( input ) { var label = input.nextElementSibling, labelVal = label.innerHTML; input.addEventListener( 'change', function( e ) { var fileName = ''; if( this.files && this.files.length > 1 ) fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length ); else fileName = e.target.value.split( '\\' ).pop(); if( fileName ) label.querySelector( 'span' ).innerHTML = fileName; else label.innerHTML = labelVal; }); // Firefox bug fix input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); }); input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); }); }); }( document, window, 0 )); $(document).ready(function(){ if($('.inputfile').length){ $('.inputfile + label').prepend('') }; }); /////////////////////////////////////// // Checkbox and Radio /////////////////////////////////////// if( document.createElement('svg').getAttributeNS ) { var checkbxsCheckmark = Array.prototype.slice.call( document.querySelectorAll( '.zinput.zcheckbox input[type="checkbox"]' ) ); pathDefs = { checkmark : ['M16.7,62.2c4.3,5.7,21.8,27.9,21.8,27.9L87,16'] }, animDefs = { checkmark : { speed : .2, easing : 'ease-in-out' } }; function createSVGEl( def ) { var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); if( def ) { svg.setAttributeNS( null, 'viewBox', def.viewBox ); svg.setAttributeNS( null, 'preserveAspectRatio', def.preserveAspectRatio ); } else { svg.setAttributeNS( null, 'viewBox', '0 0 100 100' ); } svg.setAttribute( 'xmlns', 'http://www.w3.org/2000/svg' ); return svg; } function controlCheckbox( el, type, svgDef ) { var svg = createSVGEl( svgDef ); el.parentNode.appendChild( svg ); if( el.checked ) { draw( el, type ); } el.addEventListener( 'change', function() { if( el.checked ) { draw( el, type ); } else { reset( el ); } } ); } checkbxsCheckmark.forEach( function( el, i ) { controlCheckbox( el, 'checkmark' ); } ); function draw( el, type ) { var paths = [], pathDef, animDef, svg = el.parentNode.querySelector( 'svg' ); pathDef = pathDefs.checkmark; animDef = animDefs.checkmark; paths.push( document.createElementNS('http://www.w3.org/2000/svg', 'path' ) ); for( var i = 0, len = paths.length; i < len; ++i ) { var path = paths[i]; svg.appendChild( path ); path.setAttributeNS( null, 'd', pathDef[i] ); var length = path.getTotalLength(); path.style.strokeDasharray = length + ' ' + length; if( i === 0 ) { path.style.strokeDashoffset = Math.floor( length ) - 1; } else path.style.strokeDashoffset = length; path.getBoundingClientRect(); path.style.transition = path.style.WebkitTransition = path.style.MozTransition = 'stroke-dashoffset ' + animDef.speed + 's ' + animDef.easing + ' ' + i * animDef.speed + 's'; path.style.strokeDashoffset = '0'; } } function reset( el ) { Array.prototype.slice.call( el.parentNode.querySelectorAll( 'svg > path' ) ).forEach( function( el ) { el.parentNode.removeChild( el ); } ); } } //////////////////////////////////////// // // Universal contact form ajax submission // //////////////////////////////////////// $(document).ready(function(){ if($('.zform').length){ $('.zform').each(function(){ var $form = $(this); $form.on('submit', function(e){ e.preventDefault(); var $submit = $form.find(":submit"), submitText = $submit.val(); $submit.val("Sending..."); $.ajax({ type: 'post', url: 'assets/php/form-processor.php', data: $(this).serialize(), // again, keep generic so this applies to any form success: function (result) { $form.find(".zform-feedback").html(result); $submit.val(submitText); $form.trigger("reset"); } }); }); }); } }); ////////////////////////////////// // // Sementic UI // ////////////////////////////////// $(document).ready(function(){ ////////////////////////////////// // Dropdown ////////////////////////////////// if($('.ui.dropdown').length){ $('.ui.dropdown').dropdown(); } ////////////////////////////////// // Accordion ////////////////////////////////// if($('.ui.accordion').length){ $('.ui.accordion').accordion({ exclusive: false }); } }); //////////////////////////////////////// // // Lightbox // //////////////////////////////////////// $(document).ready(function(){ if($('[data-lightbox]').length){ lightbox.option({ 'resizeDuration' : 400, 'wrapAround' : true, 'fadeDuration' : 300, 'imageFadeDuration' : 300 }) } }); //////////////////////////////////////// // // Video Lightbox // //////////////////////////////////////// $(document).ready(function(){ if($('.video-modal').length){ $('body').after('