(function ($) { "use strict"; /* |-------------------------------------------------------------------------- | Template Name: Nischinto | Author: Laralink | Developer: Tamjid Bin Murtoza; | Version: 1.0.0 |-------------------------------------------------------------------------- |-------------------------------------------------------------------------- | TABLE OF CONTENTS: |-------------------------------------------------------------------------- | | 1. Placeholder | 2. Dynamic Background | 3. Mobile Menu | 4. Sticky Header | 5. One Page Navigation | 6. Isotop Initialize | 7. Back To Top | 8. Footer Sticky | 9. Slick Slider | 10. Progress Bar | 11. Pricing Table | 12. Ajax Contact Form And Appointment | 13. Mailchimp start | 14. Modal Video | 15. Light Gallery | 16. Tamjid Counter | 17. Ripple | 18. Tabs | 19. Accordian | 20. Before After Slider | */ /*-------------------------------------------------------------- Scripts initialization --------------------------------------------------------------*/ $.exists = function (selector) { return $(selector).length > 0; }; $(window).on("load", function () { $(window).trigger("scroll"); $(window).trigger("resize"); preloaderSetup(); isotopInit(); }); $(document).on("ready", function () { $(window).trigger("resize"); dynamicBackground(); isotopInit(); backToTop(); stickyFooter(); formValidation(); appointmentForm(); slickInit(); progressBarInit(); pricingTableInit(); stickyHeader(); onePageNavigation(); mobileMenu(); mailchimpInit(); modalVideo(); lightGallery(); counterInit(); rippleInit(); new WOW().init(); tabs(); accordianSetup(); beforeAfterSlider(); if ($.exists('.player')) { $('.player').YTPlayer(); } if ($.exists('#udate')) { $('#udate').datepicker(); } if ($.exists('.st_select1')) { $(".st_select1").select2({ placeholder: function () { $(this).data('placeholder'); }, }); } }); $(window).on("resize", function () { isotopInit(); stickyFooter(); beforeAfterSlider(); }); $(window).on("scroll", function () { stickyHeader(); }); /*-------------------------------------------------------------- 1. Placeholder --------------------------------------------------------------*/ function preloaderSetup() { $(".st-perloader").fadeOut(); $("st-perloader-in").delay(150).fadeOut("slow"); } /*-------------------------------------------------------------- 2. Dynamic Background --------------------------------------------------------------*/ function dynamicBackground() { // Background images $('.st-dynamic-bg').each(function () { var src = $(this).attr('data-src'); $(this).css({ 'background-image': 'url(' + src + ')' }); }); } /*-------------------------------------------------------------- 3. Mobile Menu --------------------------------------------------------------*/ function mobileMenu() { $('.st-nav').append(''); $('.menu-item-has-children').append(''); $('.st-munu-toggle').on('click', function () { $(this).toggleClass("st-toggle-active").siblings('.st-nav-list').slideToggle(); }); $('.st-munu-dropdown-toggle').on('click', function () { $(this).toggleClass('active').siblings('ul').slideToggle(); }); // $('.st-smooth-move').on('click', function() { // $('.st-onepage-nav').slideUp(); // $('.st-munu-toggle').removeClass('st-toggle-active'); // }) // Sidebar Header $('.st-site-header.st-style2').parents('body').addClass('st-get-sidebar'); $(".btn-menu").click(function () { $('.st-onepage-nav').slideUp(); $('.st-munu-toggle').removeClass('st-toggle-active'); }); } /*-------------------------------------------------------------- 4. Sticky Header --------------------------------------------------------------*/ function stickyHeader() { var scroll = $(window).scrollTop(); if (scroll >= 10) { $('.st-sticky-header').addClass('st-sticky-active'); } else { $('.st-sticky-header').removeClass('st-sticky-active'); } } /*-------------------------------------------------------------- 5. One Page Navigation --------------------------------------------------------------*/ function onePageNavigation() { // Click To Go Top $('.st-smooth-move').on('click', function () { var thisAttr = $(this).attr('href'); if ($(thisAttr).length) { var scrollPoint = $(thisAttr).offset().top - 10; $('body,html').animate({ scrollTop: scrollPoint }, 800); } return false; }); // One Page Active Class var topLimit = 300, ultimateOffset = 200; $('.st-onepage-nav').each(function () { var $this = $(this), $parent = $this.parent(), current = null, $findLinks = $this.find("a"); function getHeader(top) { var last = $findLinks.first(); if (top < topLimit) { return last; } for (var i = 0; i < $findLinks.length; i++) { var $link = $findLinks.eq(i), href = $link.attr("href"); if (href.charAt(0) === "#" && href.length > 1) { var $anchor = $(href).first(); if ($anchor.length > 0) { var offset = $anchor.offset(); if (top < offset.top - ultimateOffset) { return last; } last = $link; } } } return last; } $(window).on("scroll", function () { var top = window.scrollY, height = $this.outerHeight(), max_bottom = $parent.offset().top + $parent.outerHeight(), bottom = top + height + ultimateOffset; var $current = getHeader(top); if (current !== $current) { $this.find(".active").removeClass("active"); $current.addClass("active"); current = $current; } }); }); } /*-------------------------------------------------------------- 6. Isotop Initialize --------------------------------------------------------------*/ function isotopInit() { if ($.exists('.st-isotop')) { $('.st-isotop').isotope({ itemSelector: '.st-isotop-item', transitionDuration: '0.60s', percentPosition: true, masonry: { columnWidth: '.st-grid-sizer' } }); /* Active Class of Portfolio*/ $('.st-isotop-filter ul li').on('click', function (event) { $(this).siblings('.active').removeClass('active'); $(this).addClass('active'); event.preventDefault(); }); /*=== Portfolio filtering ===*/ $('.st-isotop-filter ul').on('click', 'a', function () { var filterElement = $(this).attr('data-filter'); $(this).parents('.st-isotop-filter').next().isotope({ filter: filterElement }); }); } } /*-------------------------------------------------------------- 7. Back To Top --------------------------------------------------------------*/ function backToTop() { $('#st-backtotop').on('click', function (e) { e.preventDefault(); $('html,body').animate({ scrollTop: 0 }, 1000); }); } /*-------------------------------------------------------------- 8. Footer Sticky --------------------------------------------------------------*/ function stickyFooter() { // Sticky Footer var footerHeight = ($('.st-sticky-footer').height()); var windowHeight = $(window).height(); var footerHeightPx = footerHeight + 'px'; $('.st-content').css("margin-bottom", footerHeightPx); } /*-------------------------------------------------------------- 9. Slick Slider --------------------------------------------------------------*/ function slickInit() { $('.st-slider').each(function () { // Slick Variable var $ts = $(this).find('.slick-container'); var $slickActive = $(this).find('.slick-wrapper'); var $sliderNumber = $(this).siblings('.slider-number'); // Auto Play var autoPlayVar = parseInt($ts.attr('data-autoplay'), 10); // Auto Play Time Out var autoplaySpdVar = 3000; if (autoPlayVar > 1) { autoplaySpdVar = autoPlayVar; autoPlayVar = 1; } // Slide Change Speed var speedVar = parseInt($ts.attr('data-speed'), 10); // Slider Loop var loopVar = Boolean(parseInt($ts.attr('data-loop'), 10)); // Slider Center var centerVar = Boolean(parseInt($ts.attr('data-center'), 10)); // Pagination var paginaiton = $(this).children().hasClass('pagination'); // Slide Per View var slidesPerView = $ts.attr('data-slides-per-view'); if (slidesPerView == 1) { slidesPerView = 1; } if (slidesPerView == 'responsive') { var slidesPerView = parseInt($ts.attr('data-add-slides'), 10); var lgPoint = parseInt($ts.attr('data-lg-slides'), 10); var mdPoint = parseInt($ts.attr('data-md-slides'), 10); var smPoint = parseInt($ts.attr('data-sm-slides'), 10); var xsPoing = parseInt($ts.attr('data-xs-slides'), 10); } // Fade Slider var fadeVar = parseInt($($ts).attr('data-fade-slide')); (fadeVar === 1) ? (fadeVar = true) : (fadeVar = false); // Slick Active Code $slickActive.slick({ infinite: true, autoplay: autoPlayVar, dots: paginaiton, centerPadding: '0', speed: speedVar, infinite: loopVar, autoplaySpeed: autoplaySpdVar, centerMode: centerVar, fade: fadeVar, prevArrow: $(this).find('.slick-arrow-left'), nextArrow: $(this).find('.slick-arrow-right'), appendDots: $(this).find('.pagination'), slidesToShow: slidesPerView, responsive: [{ breakpoint: 1600, settings: { slidesToShow: lgPoint } }, { breakpoint: 1200, settings: { slidesToShow: mdPoint } }, { breakpoint: 992, settings: { slidesToShow: smPoint } }, { breakpoint: 768, settings: { slidesToShow: xsPoing } } ] }); }) } /*-------------------------------------------------------------- 10. Progress Bar --------------------------------------------------------------*/ function progressBarInit() { $('.st-progressbar').each(function () { var progressPercentage = $(this).data('progress') + "%"; $(this).find('.st-progressbar-in').css('width', progressPercentage); }); } /*-------------------------------------------------------------- 11. Pricing Table --------------------------------------------------------------*/ function pricingTableInit() { $('.st-pricing-table.st-style1').hover( function () { $('.st-pricing-table.st-style1').addClass('st-active'); $(this).removeClass('st-active'); }, function () { $('.st-pricing-table.st-style1').removeClass('st-active') } ) } /*-------------------------------------------------------------- 12. Ajax Contact Form And Appointment --------------------------------------------------------------*/ // Contact Form function formValidation() { if ($.exists('#contact-form #submit')) { $('#st-alert').hide(); $('#contact-form #submit').on('click', function () { var name = $('#name').val(); var subject = $('#subject').val(); var phone = $('#phone').val(); var email = $('#email').val(); var msg = $('#msg').val(); var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!regex.test(email)) { $('#st-alert').fadeIn().html('