(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('' + '
%D
Days
' + '
%H
Hours
' + '
%M
Mins
' + '
%S
Secs
')); }); } /*------------------------------------------ = HOME STYLE FOUR URGENT DONATION METER -------------------------------------------*/ if ($(".meter3").length) { var $meter = $('.meter3'); $meter.appear(); $(document.body).on('appear', '.meter3', function() { var current_item = $(this); if (!current_item.hasClass('appeared')) { current_item.addClass('appeared'); $(".meter3").circleProgress({ size: 125, thickness: 7, fill: "#fff", emptyFill: "transparent", lineCap: "round", animation: { duration: 2000 } }).on('circle-animation-progress', function(event, progress, stepValue) { var $this = $(this); $this.find('span').html(Math.round(100 * stepValue) + '%'); }); } }); } /*------------------------------------------ = HOME STYLE FOUR EVENT COLCK -------------------------------------------*/ if ($("#event-clock").length) { $('#event-clock').countdown('2017/06/31', function(event) { var $this = $(this).html(event.strftime('' + '
%D
Days
' + '
%H
Hours
' + '
%M
Mins
' + '
%S
Secs
')); }); } /*------------------------------------------ = HOME STYLE FOUR CHART -------------------------------------------*/ function raisedChart() { if ($(".raised-chart").length) { var $chart = $('.raised-chart'); $chart.appear(); $(document.body).on('appear', '.raised-chart', function() { var current_item = $(this); if (!current_item.hasClass('appeared')) { current_item.addClass('appeared'); var ctx = $("#chart").get(0).getContext("2d"); var myBarChart = new Chart(ctx, { type: 'bar', data: { labels: ["WATER", "FOOD", "SHELTER", "EDUCATION", "HEALTH"], datasets: [{ backgroundColor: "#ff5c2e", fillColor: "#f20000", data: [65, 59, 80, 81, 95], borderWidth: 2, borderColor: "rgba(0,0,0, 0.1)" }] }, options: { maintainAspectRatio: false, legend: { display: false }, title: { position: "top" }, scales: { xAxes: [{ gridLines: { display:false } }], yAxes: [{ gridLines: { display:false } }] }, animation: { duration: 2500, } } }); } }); }; } raisedChart(); /*------------------------------------------ = FUNFACT -------------------------------------------*/ if ($(".fun-fact").length) { $('.counter').appear(); $(document.body).on('appear', '.counter', function(e) { var $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: 3000, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); } }); }); } /*------------------------------------------ = TESTIMONIAL SLIDER -------------------------------------------*/ if ($(".testimonials-slider").length) { $(".testimonials-slider").owlCarousel({ autoplay:true, smartSpeed:300, items:2, loop:true, autoplayHoverPause:true, margin: 30, mouseDrag: false, responsive: { 0 : { items: 1 }, 991 : { items: 1 }, 992 : { items: 2 } } }); } /*------------------------------------------ = PARTNER SLIDER -------------------------------------------*/ if ($(".partner-slider").length) { $(".partner-slider").owlCarousel({ autoplay:true, smartSpeed:300, items:4, loop:true, autoplayHoverPause:true, mouseDrag: false, dots: false, nav: true, navText: ["",""], responsive: { 0 : { items: 1 }, 400 : { items: 2 }, 600 : { items: 3 }, 992 : { items: 4 } } }); } /*========================================================================== WHEN DOCUMENT LOADING ==========================================================================*/ $(window).on('load', function() { preloader(); sortingGallery(); // home style 4 about-st2 two col equal height if ($(".about-st2").length) { setTwoColEqHeight($(".about-st2 .left-col"), $(".about-st2 .right-col")); } }); /*========================================================================== WHEN WINDOW SCROLL ==========================================================================*/ $(window).on("scroll", function() { activeMenuItem(); }); /*========================================================================== WHEN WINDOW RESIZE ==========================================================================*/ $(window).on("resize", function() { // home style 4 about-st2 two col equal height if ($(".about-st2").length) { setTwoColEqHeight($(".about-st2 .left-col"), $(".about-st2 .right-col")); } }); })(window.jQuery);