File: /storage/v4513/ivenusin/public_html/wp-content/themes/ivenus/assets/js/main.js
(function ($) {
"use strict";
// meanmenu
$('#mobile-menu').meanmenu({
meanMenuContainer: '.mobile-menu',
meanScreenWidth: "992"
});
// sticky
var wind = $(window);
var sticky = $('#sticky-header');
wind.on('scroll', function () {
var scroll = wind.scrollTop();
if (scroll < 100) {
sticky.removeClass('sticky');
} else {
sticky.addClass('sticky');
}
});
// Handle click on toggle search button
$('#toggle-search').click(function() {
$('#search-form, #toggle-search, .yith-ajaxsearchform-container #yith-ajaxsearchform').toggleClass('open');
return false;
});
// Handle click on search submit button
$('#search-form a').click(function() {
$('#search-form, #toggle-search, .yith-ajaxsearchform-container #yith-ajaxsearchform').toggleClass('open');
return true;
});
$('.yith-ajaxsearchform-container #yith-ajaxsearchform #yith-searchsubmit').click(function() {
$('#toggle-search, .yith-ajaxsearchform-container #yith-ajaxsearchform').toggleClass('open');
return true;
});
// Clicking outside the search form closes it
/*$(document).click(function(event) {
var target = $(event.target);
if (!target.is('#toggle-search') && !target.closest('#search-form').size()) {
$('#search-form, #toggle-search').removeClass('open');
}
}); */
// parallax slider
var swiper = new Swiper('.swiper-container', {
centeredSlides: true,
speed: 3000,
autoplay: {
delay: 3500,
disableOnInteraction: false,
},
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
// scrollToTop
$.scrollUp({
scrollName: 'scrollUp', // Element ID
topDistance: '300', // Distance from top before showing element (px)
topSpeed: 300, // Speed back to top (ms)
animation: 'fade', // Fade, slide, none
animationInSpeed: 200, // Animation in speed (ms)
animationOutSpeed: 200, // Animation out speed (ms)
scrollText: '<i class="far fa-long-arrow-up"></i>', // Text for element
activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
});
// AOS active
new WOW().init();
// Custom Scroll
$(".main-menu nav > ul > li .sub-menu").mCustomScrollbar({
axis:"x",
theme:"light-3",
autoExpandScrollbar:true,
advanced:{autoExpandHorizontalScroll:true}
});
/* magnificPopup video view */
$('.popup-video').magnificPopup({
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false
});
// Product Image Zoom plugin - product pages
if ( $.fn.elevateZoom ) {
$('#product-zoom').elevateZoom({
gallery:'product-zoom-gallery',
galleryActiveClass: 'active',
zoomType: "inner",
cursor: "crosshair",
zoomWindowFadeIn: 400,
zoomWindowFadeOut: 400,
responsive: true
});
// On click change thumbs active item
$('.product-gallery-item').on('click', function (e) {
$('#product-zoom-gallery').find('a').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
var ez = $('#product-zoom').data('elevateZoom');
// Open popup - product images
$('#btn-product-gallery').on('click', function (e) {
if ( $.fn.magnificPopup ) {
$.magnificPopup.open({
items: ez.getGalleryList(),
type: 'image',
gallery:{
enabled:true
},
fixedContentPos: false,
removalDelay: 600,
closeBtnInside: false
}, 0);
e.preventDefault();
}
});
}
// Quantity Input - Cart page - Product Details pages
if ( $.fn.inputSpinner ) {
$("input[type='number']").inputSpinner({
decrementButton: '<i class="fal fa-minus"></i>',
incrementButton: '<i class="fal fa-plus"></i>',
groupClass: 'input-spinner',
buttonsClass: 'btn-spinner',
buttonsWidth: '32px'
});
}
// Auto search
var options = {
data: ["iPhone", "iPhone 6", "iPhone 7", "iPhone 8", "iPhone X", "iPad", "iPad Pro", "iMac", "Macbook Pro", "Macbook Air"],
list: {
showAnimation: {
type: "fade", //normal|slide|fade
time: 400,
callback: function() {}
},
hideAnimation: {
type: "slide", //normal|slide|fade
time: 400,
callback: function() {}
},
maxNumberOfElements: 50,
match: {
enabled: true
}
}
};
$("#search-terms").easyAutocomplete(options);
owlCarousels();
// Featured Carousel
function owlCarousels($wrap, options) {
if ( $.fn.owlCarousel ) {
var owlSettings = {
items: 1,
loop: true,
margin: 0,
responsiveClass: true,
nav: true,
navText: ['<i class="fal fa-chevron-left">', '<i class="fal fa-chevron-right">'],
dots: true,
smartSpeed: 400,
autoplay: false,
autoplayTimeout: 15000
};
if (typeof $wrap == 'undefined') {
$wrap = $('body');
}
if (options) {
owlSettings = $.extend({}, owlSettings, options);
}
// Init all carousel
$wrap.find('[data-toggle="owl"]').each(function () {
var $this = $(this),
newOwlSettings = $.extend({}, owlSettings, $this.data('owl-options'));
$this.owlCarousel(newOwlSettings);
});
}
}
$('#myTabContent .nav-tabs a').click(function () {
var currentNavTabs = this;
$(this).tab('show');
$('#myTabContent1 .tab-pane').each(function(){
$(this).removeClass('show active');
});
$($(this).data("second-tab")).addClass('show active').css({'transition': 'opacity 0.15s linear;'});
});
$('#myTabContent0 .nav-tabs a').click(function () {
var currentNavTabs = this;
$(this).tab('show');
$('#myTabContent11 .tab-pane').each(function(){
$(this).removeClass('show active');
});
$($(this).data("second-tab")).addClass('show active').css({'transition': 'opacity 0.15s linear;'});
});
$('#myTabContent01 .nav-tabs a').click(function () {
var currentNavTabs = this;
$(this).tab('show');
$('#myTabContent111 .tab-pane').each(function(){
$(this).removeClass('show active');
});
$($(this).data("second-tab")).addClass('show active').css({'transition': 'opacity 0.15s linear;'});
});
// Store Pickup
if (window.location.href.indexOf('cart/?pickup=') > 0) {
$('.woocommerce-notices-wrapper').find('a.wc-forward').hide();
var product_id = parseInt(window.location.href.split('=')[1]);
console.log(typeof product_id);
if(!isNaN(product_id)) {
$("tr.cart_item").each(function(index, tr) {
var current_product_id = $(this).find("td.product-remove > a.remove").data('product_id');
if(current_product_id === product_id){
var parentDiv = $(this).find(".pickup-location-field");
parentDiv.find('small:nth-child(1)').hide();
parentDiv.find('small:nth-child(2)').show();
parentDiv.find('div:nth-child(3)').show();
}
if(window.history.replaceState){
window.history.replaceState( null, null, window.location.href );
}
});
}
}
document.addEventListener( 'wpcf7mailsent', function( event ) {
var thankyouURL = document.getElementById("thankyouURL").value;
location = thankyouURL;
}, false );
})(jQuery);