/*-------------------------- Project Name: Solatec Version: 1.0 Author: 7oorof Devloped by: Ahmed Abdallah (a.abdallah999@gmail.com) Relase Date: July 2021 ---------------------------*/ /*--------------------------- 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 15- Range Slider ----------------------------*/ $(function () { "use strict"; // Global variables var $win = $(window); /*========== Pre Loading ==========*/ setTimeout(function () { $(".preloader").remove(); }, 2000); /*========== Mobile Menu ==========*/ $('.navbar-toggler').on('click', function () { $('.navbar-collapse').addClass('menu-opened'); }) $('.close-mobile-menu').on('click', function (e) { $('.navbar-collapse').removeClass('menu-opened'); }); /*========== Sticky Navbar ==========*/ $win.on('scroll', function () { if ($win.width() >= 992) { var $navbar = $('.sticky-navbar'); if ($win.scrollTop() > 200) { $navbar.addClass('is-sticky'); } else { $navbar.removeClass('is-sticky'); } } }); /*========== Open and Close Popup ==========*/ // open Popup function openPopup(popupTriggerBtn, popup, addedClass, removedClass) { $(popupTriggerBtn).on('click', function (e) { e.preventDefault(); $(popup).toggleClass(addedClass, removedClass).removeClass(removedClass); }); } // Close Popup function closePopup(closeBtn, popup, addedClass, removedClass) { $(closeBtn).on('click', function () { $(popup).removeClass(addedClass).addClass(removedClass); }); } // close popup when clicking on an other place on the Document function closePopupFromOutside(popup, stopPropogationElement, popupTriggerBtn, removedClass, addedClass) { $(document).on('mouseup', function (e) { if (!$(stopPropogationElement).is(e.target) && !$(popupTriggerBtn).is(e.target) && $(stopPropogationElement).has(e.target).length === 0 && $(popup).has(e.target).length === 0) { $(popup).removeClass(removedClass).addClass(addedClass); } }); } openPopup('.action__btn-search', '.search-popup', 'active', 'inActive') // Open Search popup closePopup('.search-popup__close', '.search-popup', 'active', 'inActive') // Close Search popup openPopup('.action__btn-cart', '.cart-minipopup', 'active', 'inActive') // Open Search popup closePopupFromOutside('.cart-minipopup', '.cart-minipopup', '.action__btn-cart', 'active'); // close popup when clicking on an other place on the Document /*========== 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: '