(function($) { "use strict"; /*------------------------------------------ = FUNCTIONS -------------------------------------------*/ // Toggle mobile navigation function toggleMobileNavigation() { var navbar = $("#navbar"); var navLinks = $("#navbar > ul > li > a:not(.dropdown-toggle)"); var openBtn = $(".navbar-header .open-btn"); var closeBtn = $("#navbar .close-navbar"); openBtn.on("click", function() { if (!navbar.hasClass("slideInn")) { navbar.addClass("slideInn"); } return false; }) closeBtn.on("click", function() { if (navbar.hasClass("slideInn")) { navbar.removeClass("slideInn"); } return false; }) navLinks.on("click", function() { if (navbar.hasClass("slideInn")) { navbar.removeClass("slideInn"); } return false; }) } toggleMobileNavigation(); //ACTIVE CURRENT MENU WHILE SCROLLING // function for active menuitem var sections = $("section"), nav = $("#navbar"), nav_height = nav.outerHeight(), home = nav.find(" > ul > li:first"), contact = nav.find(" > ul > li:last"); function activeMenuItem() { var cur_pos = $(window).scrollTop() + 2; var bottomPosition = $(document).height() - $(window).height() - $(window).scrollTop(); sections.each(function() { var top = $(this).offset().top - nav_height, bottom = top + $(this).outerHeight(); if (cur_pos >= top && cur_pos <= bottom) { nav.find("> ul > li > a").parent().removeClass("current"); nav.find("a[href='#" + $(this).attr('id') + "']").parent().addClass("current"); } else if (cur_pos === 2) { nav.find("> ul > li > a").parent().removeClass("current"); home.addClass("current"); } if (bottomPosition === 0) { nav.find("> ul > li > a").parent().removeClass("current"); contact.addClass("current"); } }); } // smooth-scrolling $(function() { $("#navbar > ul > li > a:not(.dropdown-toggle)").on("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 -60 }, 1000, "easeInOutExpo"); return false; } } return false; }); }); // set two coloumn height equial function setTwoColEqHeight($col1, $col2) { var firstCol = $col1, secondCol = $col2, firstColHeight = $col1.innerHeight(), secondColHeight = $col2.innerHeight(); if (firstColHeight > secondColHeight) { secondCol.css({ "height": firstColHeight + 1 + "px" }) } else { firstCol.css({ "height": secondColHeight + 1 + "px" }) } } // toggle mini cart function toggleMiniCartBtn() { var miniCartBtn = $(".mini-cart-btn"), miniCart = $(".mini-cart"); miniCart.hide(); miniCartBtn.on("click", function(e) { e.preventDefault(); miniCart.slideToggle(); return false; }) } if ($(".mini-cart-wrapper").length) { toggleMiniCartBtn(); } /*------------------------------------------ = WOW ANIMATION SETTING -------------------------------------------*/ var wow = new WOW({ boxClass: 'wow', // default animateClass: 'animated', // default offset: 0, // default mobile: true, // default live: true // default }); /*------------------------------------------ = HIDE PRELOADER -------------------------------------------*/ function preloader() { if($('.preloader').length) { $('.preloader').delay(100).fadeOut(500, function() { //active wow wow.init(); if ($(".home-style-four .hero-title").length) { var heroTitle = $(".home-style-four .hero-title"); heroTitle.addClass("active-hero-title"); } if ($(".home-style-five .main-banar .banar-title").length) { var heroTitle = $(".home-style-five .main-banar .banar-title"); heroTitle.addClass("active-banar-title"); } }); } } /*------------------------------------------ = STICKY HEADER -------------------------------------------*/ $(window).on("scroll", function() { var header = $("#header"); var mainNavigation = $("#main-navigation"); var scroll = $(window).scrollTop(); var top = $(".top-bar").innerHeight(); if ((scroll > top) && !header.hasClass("header-style-three")) { mainNavigation.addClass("sticky"); } else { mainNavigation.removeClass("sticky"); } }); if ($(".header-style-three").length) { $(window).on("scroll", function() { var mainNavigation = $("#main-navigation"); var scroll = $(window).scrollTop(); var top = $(".topbar").innerHeight(); if (scroll > top) { mainNavigation.addClass("sticky"); } else { mainNavigation.removeClass("sticky"); } }); } /*------------------------------------------ = POPUP VIDEO -------------------------------------------*/ if ($(".video-btn").length) { $(".video-btn").on("click", function(){ $.fancybox({ href: this.href, type: $(this).data("type"), 'title' : this.title, helpers : { title : { type : 'inside' }, media : {} }, beforeShow : function(){ $(".fancybox-wrap").addClass("gallery-fancybox"); } }); return false }); } /*------------------------------------------ = FUNCTION FORM SORTING GALLERY -------------------------------------------*/ function sortingGallery() { if ($(".sortable-gallery .gallery-filters").length) { var $container = $('.gallery-container'); $container.isotope({ filter:'*', animationOptions: { duration: 750, easing: 'linear', queue: false, } }); $(".gallery-filters li a").on("click", function() { $('.gallery-filters li .current').removeClass('current'); $(this).addClass('current'); var selector = $(this).attr('data-filter'); $container.isotope({ filter:selector, animationOptions: { duration: 750, easing: 'linear', queue: false, } }); return false; }); } } sortingGallery(); /*------------------------------------------ = ACTIVE GALLERY POPUP IMAGE -------------------------------------------*/ if ($(".popup-gallery").length) { $('.popup-gallery').magnificPopup({ delegate: 'a', type: 'image', gallery: { enabled: true }, zoom: { enabled: true, duration: 300, easing: 'ease-in-out', opener: function(openerElement) { return openerElement.is('img') ? openerElement : openerElement.find('img'); } } }); } /*------------------------------------------ = HOME STYLE THREE TOPBAR COUNTDOWN -------------------------------------------*/ if ($("#clock").length) { $('#clock').countdown('2017/06/31', function(event) { var $this = $(this).html(event.strftime('' + '