/*-------------------------- Project Name: Promina Version: 1.0 Author: 7oorof Devloped by: Ahmed Abdallah (a.abdallah999@gmail.com) Relase Date: June 2020 ---------------------------*/ /*--------------------------- Table of Contents -------------------- 01- Pre Loading 02- Mobile Menu 03- Sticky Navbar 04- Search Popup 05- Scroll Top Button 06- Scroll Top Button 07- Set Background-img to section 08- Add active class to accordions 09- Load More Items 10- Slick Carousel 11- Popup Video 12- CounterUp 13- NiceSelect Plugin 14- portfolio Filtering and Sorting ----------------------------*/ $(function () { "use strict"; // Global variables var $win = $(window); /*========== Pre Loading ==========*/ setTimeout(function () { $(".preloader").remove(); }, 2000); /*========== Mobile Menu ==========*/ var $navToggler = $('.navbar-toggler'); $navToggler.on('click', function () { $(this).toggleClass('actived'); }) $navToggler.on('click', function () { $('.navbar-collapse').toggleClass('menu-opened'); }) /*========== Sticky Navbar ==========*/ $win.on('scroll', function () { if ($win.width() >= 992) { var $navbar = $('.sticky-navbar'); if ($win.scrollTop() > 200) { $navbar.addClass('fixed-navbar'); } else { $navbar.removeClass('fixed-navbar'); } } }); /*========== Search Popup ==========*/ $('.search-popup-trigger').on('click', function (e) { e.preventDefault(); $('.search-popup').toggleClass('active', 'inActive').removeClass('inActive'); }); // Close Module Search $('.search__popup-close').on('click', function () { $('.search-popup').removeClass('active').addClass('inActive'); }); /*========== Scroll Top Button ==========*/ var $scrollTopBtn = $('#scrollTopBtn'); // Show Scroll Top Button $win.on('scroll', function () { if ($(this).scrollTop() > 700) { $scrollTopBtn.addClass('actived'); } else { $scrollTopBtn.removeClass('actived'); } }); // Animate Body after Clicking on Scroll Top Button $scrollTopBtn.on('click', function () { $('html, body').animate({ scrollTop: 0 }, 500); }); /*========== Set Background-img to section ==========*/ $('.bg-img').each(function () { var imgSrc = $(this).children('img').attr('src'); $(this).parent().css({ 'background-image': 'url(' + imgSrc + ')', 'background-size': 'cover', 'background-position': 'center', }); $(this).parent().addClass('bg-img'); if ($(this).hasClass('background-size-auto')) { $(this).parent().addClass('background-size-auto'); } $(this).remove(); }); /*========== Add active class to accordions ==========*/ $('.accordion__item-header').on('click', function () { $(this).parent('.accordion-item').addClass('opened'); $(this).parent('.accordion-item').siblings().removeClass('opened'); }) $('.accordion__item-title').on('click', function (e) { e.preventDefault() }); /*========== Load More Items ==========*/ function loadMore(loadMoreBtn, loadedItem) { $(loadMoreBtn).on('click', function (e) { e.preventDefault(); $(this).fadeOut(); $(loadedItem).fadeIn(); }) } loadMore('.loadMoreportfolio', '.portfolio-hidden > .portfolio-item'); /*========== Slick Carousel ==========*/ $('.slick-carousel').slick(); $('.slider-with-navs').slick({ slidesToShow: 1, slidesToScroll: 1, arrows: false, fade: true, dots: true, asNavFor: '.slider-nav' }); $('.slider-nav').slick({ slidesToShow: 2, slidesToScroll: 1, asNavFor: '.slider-with-navs', dots: false, arrows: false, focusOnSelect: true, centerMode: true, centerPadding: '50px', responsive: [{ breakpoint: 992, settings: { slidesToShow: 1, slidesToScroll: 1, } }] }); /*---------- slick Carousel with Filter ----------*/ $('#slick-filter-buttons .nav__link').on('click', function (e) { e.preventDefault(); $(this).addClass('active').siblings().removeClass('active'); var key = "." + $(this).data('value'); $('#filter-carousel').slick('slickUnfilter'); $('#filter-carousel').slick('slickFilter', key).slick('refresh'); $('#filter-carousel').slick('slickGoTo', 0); }); /*========== Popup Video ==========*/ $('.popup-video').magnificPopup({ mainClass: 'mfp-fade', removalDelay: 0, preloader: false, fixedContentPos: false, type: 'iframe', iframe: { markup: '
' + '
' + '' + '
', patterns: { youtube: { index: 'youtube.com/', id: 'v=', src: '//www.youtube.com/embed/%id%?autoplay=1' } }, srcAction: 'iframe_src', } }); $('.popup-gallery-item').magnificPopup({ type: 'image', tLoading: 'Loading image #%curr%...', mainClass: 'mfp-img-mobile', gallery: { enabled: true, navigateByImgClick: true, preload: [0, 1] }, image: { tError: 'The image #%curr% could not be loaded.' } }); /*========== counterUp ==========*/ $(".counter").counterUp({ delay: 10, time: 4000 }); /*========== NiceSelect Plugin ==========*/ $('select').niceSelect(); /*========== portfolio Filtering and Sorting ==========*/ $("#filtered-items-wrap").mixItUp(); $(".portfolio-filter li a").on("click", function (e) { e.preventDefault(); }); var contactForm = $("#contactForm"), contactResult = $('.contact-result'); contactForm.validate({ debug: false, submitHandler: function (contactForm) { $(contactResult, contactForm).html('Please Wait...'); $.ajax({ type: "POST", url: "assets/php/contact.php", data: $(contactForm).serialize(), timeout: 20000, success: function (msg) { $(contactResult, contactForm).html('').delay(3000).fadeOut(2000); }, error: $('.thanks').show() }); return false; } }); });