/home/moonrcjl/template.moontelict.com/testorest/assets/js/main.js
(function ($) {
"use strict";
var windowOn = $(window);
windowOn.on('load', function () {
wowAnimation();
});
// preloader
windowOn.on('load', function () {
$("#loading").fadeOut(500);
})
////////////////////////////////////////////////////
// 2. Back-to-top Js
var btn = $('#back-to-top');
windowOn.scroll(function () {
if (windowOn.scrollTop() > 300) {
btn.addClass('show');
} else {
btn.removeClass('show');
}
});
btn.on('click', function () {
$('html, body').animate({ scrollTop: 0 }, '300');
});
////////////////////////////////////////////////////
// 3. Sticky Js
windowOn.on('scroll', function () {
var scroll = windowOn.scrollTop();
if (scroll < 100) {
$("#mt-header-sticky").removeClass("header-sticky");
} else {
$("#mt-header-sticky").addClass("header-sticky");
}
});
// offcanvas bar
$(".mt-offcanvas-toogle").on('click', function () {
$(".mt-offcanvas").addClass("mt-offcanvas-open");
$(".mt-offcanvas-overlay").addClass("mt-offcanvas-overlay-open");
});
$(".mt-offcanvas-close-toggle,.mt-offcanvas-overlay").on('click', function () {
$(".mt-offcanvas").removeClass("mt-offcanvas-open");
$(".mt-offcanvas-overlay").removeClass("mt-offcanvas-overlay-open");
});
// Search bar
$(".mt-search-toggle").on('click', function () {
$(".mt-header-search-bar").addClass("mt-search-open");
$(".mt-offcanvas-overlay").addClass("mt-offcanvas-overlay-open");
});
$(".mt-search-close,.mt-offcanvas-overlay").on('click', function () {
$(".mt-header-search-bar").removeClass("mt-search-open");
$(".mt-offcanvas-overlay").removeClass("mt-offcanvas-overlay-open");
});
// data bg img
$("[data-background]").each(function () {
$(this).css("background-image", "url(" + $(this).attr("data-background") + ")")
})
// data bg color
$("[data-bg-color]").each(function () {
$(this).css("background-color", $(this).attr("data-bg-color"))
})
// data color
$("[data-color]").each(function () {
$(this).css("color", $(this).attr("data-color"))
})
$('.popup-image').magnificPopup({
type: 'image'
// other options
});
$('.popup-video').magnificPopup({
type: 'iframe'
// other options
});
// Service Active Item
$('.mt-service-wrapper .mt-service-item').on('mouseenter', function () {
$('.mt-service-item').removeClass('active');
$(this).addClass('active');
});
// About Active Item
$('.mt-about-3-box').on('mouseenter', function () {
$(this).addClass('active').parent().siblings().find('.mt-about-3-box').removeClass('active');
});
// grid active
if ($('.grid').length != 0) {
var $grid = $('.grid').imagesLoaded(function () {
$('.grid').isotope({
itemSelector: '.grid-item',
percentPosition: true,
masonry: {
columnWidth: 1
}
})
// filter items on button click
$('.mt-portfolio-filter').on('click', 'button', function () {
var filterValue = $(this).attr('data-filter');
$grid.isotope({ filter: filterValue });
});
//for menu active class
$('.mt-portfolio-filter button').on('click', function (event) {
$(this).siblings('.active').removeClass('active');
$(this).addClass('active');
event.preventDefault();
});
});
}
////////////////////////////////////////////////////
// 3. Swiper mtshop__category_active slider
var swiper = new Swiper(".mtshop__category_active", {
slidesPerView: 10,
spaceBetween: 30,
breakpoints: {
1300: {
slidesPerView: 8,
},
991: {
slidesPerView: 5,
},
888: {
slidesPerView: 4,
},
767: {
slidesPerView: 4,
},
575: {
slidesPerView: 3,
},
439: {
slidesPerView: 2,
},
320: {
slidesPerView: 2,
},
},
navigation: {
nextEl: ".mtshop__category-arrow-left",
prevEl: ".mtshop__category-arrow-right",
},
});
////////////////////////////////////////////////////
// 01. Swiper Js
var swiper = new Swiper(".mt-service-active", {
slidesPerView: 1,
spaceBetween: 30,
pagination: {
el: ".mtservice__pagination",
clickable: true,
},
// Navigation arrows
navigation: {
nextEl: '.mtservice__prev',
prevEl: '.mtservice__next',
},
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
992: {
slidesPerView: 2,
},
1200: {
slidesPerView: 3,
}
},
});
////////////////////////////////////////////////////
// 01. Swiper Js
var swiper = new Swiper(".mtrecipes__active", {
slidesPerView: 1.5,
spaceBetween: 30,
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
992: {
slidesPerView: 2,
},
1200: {
slidesPerView: 1.5,
}
},
});
////////////////////////////////////////////////////
// 01. Swiper Js
var swiper = new Swiper(".mtrecipes__active2", {
slidesPerView: 1.5,
spaceBetween: 30,
pagination: {
el: ".mtrecipes__pagination",
clickable: true,
},
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
992: {
slidesPerView: 2,
},
1200: {
slidesPerView: 4,
}
},
});
////////////////////////////////////////////////////
// 18. Swiper Js
var swiper = new Swiper(".mt-brand-active", {
slidesPerView: 'auto',
spaceBetween: 30,
freemode: true,
centeredSlides: true,
loop: true,
speed: 9000,
allowTouchMove: false,
autoplay: {
delay: 1,
disableOnInteraction: true,
},
});
////////////////////////////////////////////////////
// 01. Swiper Js
var swiper = new Swiper(".mt-brand-active2", {
slidesPerView: 1.5,
spaceBetween: 30,
pagination: {
el: ".mtrecipes__pagination",
clickable: true,
},
breakpoints: {
0: {
slidesPerView: 1,
},
768: {
slidesPerView: 2,
},
992: {
slidesPerView: 2,
},
1200: {
slidesPerView: 6,
}
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper(".mttestimonial__active", {
slidesPerView: 1,
spaceBetween: 30,
keyboard: {
enabled: true,
},
pagination: {
el: ".mttestimonial__pagination",
type: "fraction",
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper(".mttestimonial__active2", {
slidesPerView: 1,
spaceBetween: 30,
keyboard: {
enabled: true,
},
pagination: {
el: ".mttestimonial-pagination",
clickable: true,
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper('.mtblog__active', {
slidesPerView: 1,
spaceBetween: 24,
breakpoints: {
'1200': {
slidesPerView: 3,
},
'992': {
slidesPerView: 2,
},
'768': {
slidesPerView: 2,
},
'576': {
slidesPerView: 1,
},
'0': {
slidesPerView: 1,
},
a11y: false,
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper('.mtinstagram__active', {
slidesPerView: 1,
spaceBetween: 20,
breakpoints: {
'1200': {
slidesPerView: 6,
},
'992': {
slidesPerView: 5,
},
'768': {
slidesPerView: 4,
},
'576': {
slidesPerView: 3,
},
'0': {
slidesPerView: 2,
},
a11y: false,
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper('.mtinstagram__active2', {
slidesPerView: 1,
spaceBetween: 0,
breakpoints: {
'1200': {
slidesPerView: 6,
},
'992': {
slidesPerView: 5,
},
'768': {
slidesPerView: 4,
},
'576': {
slidesPerView: 3,
},
'0': {
slidesPerView: 2,
},
a11y: false,
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper(".mtslider__active", {
slidesPerView: 1,
spaceBetween: 30,
keyboard: {
enabled: true,
},
pagination: {
el: ".mtslider__pagination",
type: "fraction",
},
// Navigation arrows
navigation: {
nextEl: '.mtslider__prev',
prevEl: '.mtslider__next',
},
});
////////////////////////////////////////////////////
// 06. Swiper Js
var slider = new Swiper('.mtslider-active', {
slidesPerView: 1,
centeredSlides: true,
loop: true,
loopedSlides: 1,
pagination: {
el: ".mtslider-pagination",
clickable: true,
},
navigation: {
nextEl: '.mt-slider-button-next',
prevEl: '.mt-slider-button-prev',
},
});
var thumbs = new Swiper('.mtslider-active-thumb', {
slidesPerView: 3,
spaceBetween: 0,
centeredSlides: false,
centeredSlides: true,
loop: true,
slideToClickedSlide: true,
});
slider.controller.control = thumbs;
thumbs.controller.control = slider;
////////////////////////////////////////////////////
// 06. Swiper Js
var swiper = new Swiper('.mtproduct__active', {
slidesPerView: 1,
spaceBetween: 24,
breakpoints: {
'1200': {
slidesPerView: 3,
},
'992': {
slidesPerView: 2,
},
'768': {
slidesPerView: 2,
},
'576': {
slidesPerView: 1,
},
'0': {
slidesPerView: 1,
},
a11y: false,
},
pagination: {
el: ".mtproduct__pagination",
clickable: true,
},
});
// Quantity
function mt_ecommerce() {
$('.mt-cart-minus').on('click', function () {
var $input = $(this).parent().find('input');
var count = parseInt($input.val()) - 1;
count = count < 1 ? 1 : count;
$input.val(count);
$input.change();
return false;
});
$('.mt-cart-plus').on('click', function () {
var $input = $(this).parent().find('input');
$input.val(parseInt($input.val()) + 1);
$input.change();
return false;
});
$("#slider-range").slider({
range: true,
min: 0,
max: 500,
values: [75, 300],
slide: function (event, ui) {
$("#amount").val("$" + ui.values[0] + " - $" + ui.values[1]);
}
});
$("#amount").val("$" + $("#slider-range").slider("values", 0) +
" - $" + $("#slider-range").slider("values", 1));
$('.mt-checkout-payment-item label').on('click', function () {
$(this).siblings('.mt-checkout-payment-desc').slideToggle(400);
});
////////////////////////////////////////////////////
// 18. Create An Account Toggle Js
$('#cbox').on('click', function () {
$('#cbox_info').slideToggle(900);
});
////////////////////////////////////////////////////
// 19. Shipping Box Toggle Js
$('#ship-box').on('click', function () {
$('#ship-box-info').slideToggle(1000);
});
}
mt_ecommerce();
// Preloader
let preloader = document.getElementById('preloader');
if (preloader) {
window.addEventListener('load', function () {
let fadeOut = setInterval(function () {
if (!preloader.style.opacity) {
preloader.style.opacity = 1;
}
if (preloader.style.opacity > 0) {
preloader.style.opacity -= 0.1;
} else {
clearInterval(fadeOut);
preloader.remove();
}
}, 100);
});
}
////////////////////////////////////////////////////
// 08. Mouse Cursor Js
function mousecursor() {
if ($("body")) {
const e = document.querySelector(".cursor-inner"),
t = document.querySelector(".cursor-outer");
let n,
i = 0,
o = !1;
(window.onmousemove = function (s) {
o ||
(t.style.transform =
"translate(" + s.clientX + "px, " + s.clientY + "px)"),
(e.style.transform =
"translate(" + s.clientX + "px, " + s.clientY + "px)"),
(n = s.clientY),
(i = s.clientX);
}),
$("body").on("mouseenter", "a, .cursor-pointer", function () {
e.classList.add("cursor-hover");
t.classList.add("cursor-hover");
}),
$("body").on("mouseleave", "a, .cursor-pointer", function () {
($(this).is("a") && $(this).closest(".cursor-pointer").length) ||
(e.classList.remove("cursor-hover"),
t.classList.remove("cursor-hover"));
}),
(e.style.visibility = "visible"),
(t.style.visibility = "visible");
}
}
$(function () {
mousecursor();
});
////////////////////////////////////////////////////
// 09. Wow Animation Js
function wowAnimation() {
var wow = new WOW({
boxClass: 'wow',
animateClass: 'animated',
offset: 0,
mobile: false,
live: true
});
wow.init();
}
// 08. Nice Select Js
$('select').niceSelect();
////////////////////////////////////////////////////
// 10. jarallax Js
if ($('.jarallax').length) {
$('.jarallax').jarallax({
speed: 0.2,
});
}
})(jQuery);