;(function ($){
"use strict";
var pxl_scroll_top;
var pxl_window_height;
var pxl_window_width;
var pxl_scroll_status='';
var pxl_last_scroll_top=0;
$(window).on('load', function (){
$(".pxl-loader").fadeOut("slow");
pxl_window_width=$(window).width();
ducatibox_header_sticky();
ducatibox_scroll_to_top();
ducatibox_quantity_icon();
ducatibox_footer_fixed();
ducatibox_blog_post_gallery();
ducatibox_panel_anchor_toggle();
ducatibox_document_click();
ducatibox_product_single_variations_att();
});
$(window).on('scroll', function (){
pxl_scroll_top=$(window).scrollTop();
pxl_window_height=$(window).height();
pxl_window_width=$(window).width();
if(pxl_scroll_top < pxl_last_scroll_top){
pxl_scroll_status='up';
}else{
pxl_scroll_status='down';
}
pxl_last_scroll_top=pxl_scroll_top;
ducatibox_header_sticky();
ducatibox_scroll_to_top();
ducatibox_footer_fixed();
});
$(document).ready(function (){
ducatibox_lightdark_switch();
var $ducatibox_menu=$('.pxl-header-elementor-main');
$ducatibox_menu.find('.pxl-menu-primary li').each(function (){
var $ducatibox_submenu=$(this).find('> ul.sub-menu');
if($ducatibox_submenu.length==1){
$(this).on('mouseover', function (){
if($ducatibox_submenu.offset().left + $ducatibox_submenu.width() > $(window).width()){
$ducatibox_submenu.addClass('pxl-sub-reverse');
}else if($ducatibox_submenu.offset().left < 0){
$ducatibox_submenu.addClass('pxl-sub-reverse');
}}).on('mouseleave', function (){
$ducatibox_submenu.removeClass('pxl-sub-reverse');
});
}});
$(window).on('load', function(){
$('#preloader').fadeOut('slow',function(){$(this).remove();});
});
$('.pxl-nav-hidden li.menu-item-has-children > a').append('<span class="pxl-menu-toggle"></span>');
$('.pxl-header-menu li.menu-item-has-children, .pxl-menu-primary li.menu-item-has-children').append('<span class="pxl-menu-toggle"></span>');
$('.pxl-menu-toggle').on('click', function (){
if(!$(this).hasClass('active')){
$(this).closest('ul').find('.pxl-menu-toggle.active').toggleClass('active');
$(this).closest('ul').find('.sub-menu.active').toggleClass('active').slideToggle();
}
$(this).toggleClass('active');
$(this).closest('.menu-item').find('> .sub-menu').toggleClass('active');
$(this).closest('.menu-item').find('> .sub-menu').slideToggle();
});
$('.pxl-nav-hidden li.menu-item-has-children > a').on('click', function(e){
var target=$(e.target);
if($(this).attr('href')==='#'&&!(target.is('.pxl-menu-toggle'))){
e.stopPropagation();
if(!$(this).find('.pxl-menu-toggle').hasClass('active')){
$(this).closest('ul').find('.pxl-menu-toggle.active').toggleClass('active');
$(this).closest('ul').find('.sub-menu.active').toggleClass('active').slideToggle();
}
$(this).find('.pxl-menu-toggle').toggleClass('active');
$(this).closest('.menu-item').find('> .sub-menu').toggleClass('active');
$(this).closest('.menu-item').find('> .sub-menu').slideToggle();
}});
$("#pxl-nav-mobile").on('click', function (){
$(this).toggleClass('active');
$('.pxl-header-menu').toggleClass('active');
});
$(".pxl-menu-close, .pxl-header-menu-backdrop").on('click', function (){
$(this).parents('.pxl-header-main').find('.pxl-header-menu').removeClass('active');
$('#pxl-nav-mobile').removeClass('active');
});
$('.pxl-type-header-clip > .elementor-container').append('<div class="pxl-header-shape"><span></span></div>');
$('.pxl-scroll-top').on('click', function (){
$('html, body').animate({scrollTop: 0}, 800);
return false;
});
$('.pxl-grid-masonry').each(function (){
var eltime=100;
var elt_inner=$(this).children().length;
var _elt=elt_inner - 1;
$(this).find('> .pxl-grid-item > .wow').each(function (index, obj){
$(this).css('animation-delay', eltime + 'ms');
if(_elt===index){
eltime=100;
_elt=_elt + elt_inner;
}else{
eltime=eltime + 60;
}});
});
$('.pxl-item--text').each(function (){
var pxl_time=0;
var pxl_item_inner=$(this).children().length;
var _elt=pxl_item_inner - 1;
$(this).find('> .pxl-text--slide > .wow').each(function (index, obj){
$(this).css('transition-delay', pxl_time + 'ms');
if(_elt===index){
pxl_time=0;
_elt=_elt + pxl_item_inner;
}else{
pxl_time=pxl_time + 80;
}});
});
$('.btn-video, .pxl-video-popup, .pxl--link-popup').magnificPopup({
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false
});
$('.images-light-box').each(function (){
$(this).magnificPopup({
delegate: 'a.light-box',
type: 'image',
gallery: {
enabled: true
},
mainClass: 'mfp-fade',
});
});
$(".pxl-search-popup-button").on('click', function (){
$('body').addClass('body-overflow');
$('#pxl-search-popup').addClass('active');
$('#pxl-search-popup .search-field').focus();
});
$("#pxl-search-popup .pxl-item--overlay, #pxl-search-popup .pxl-item--close").on('click', function (){
$('body').removeClass('body-overflow');
$('#pxl-search-popup').removeClass('active');
});
$('.comment-reply a').append('<i class="common icon-arrow-forward-ne1"></i>');
if($('#pxl-page-title-default').hasClass('pxl--parallax')){
$(this).stellar();
}
$(".pxl-link-scroll1").parents('.pxl-wapper').addClass('hidden-demo-bar');
$('.btn-nina').each(function (){
var eltime=0.045;
var elt_inner=$(this).children().length;
var _elt=elt_inner - 1;
$(this).find('> .pxl--btn-text > span').each(function (index, obj){
$(this).css('transition-delay', eltime + 's');
eltime=eltime + 0.045;
});
});
$('.btn-hover').each(function (){
$(this).on('mouseover', function (){
$(this).parents('.item-feature').find('.btn-hover').removeClass('active');
$(this).addClass('active');
});
});
$('.pxl-grid-item').each(function (){
$(this).on('mouseover', function (){
$(this).parents('.pxl-portfolio-flex .pxl-portfolio-inner').find('.pxl-grid-item').removeClass('active');
$(this).addClass('active');
});
});
$('.pxl--widget-hover').each(function (){
$(this).on('mouseover', function (){
$(this).parents('.elementor-row').find('.pxl--widget-hover').removeClass('pxl--item-active');
$(this).parents('.elementor-container').find('.pxl--widget-hover').removeClass('pxl--item-active');
$(this).addClass('pxl--item-active');
});
});
$('.pxl-recent-service .pxl-grid-item').on('mouseover', function (){
$(this).siblings('.pxl-grid-item').removeClass('active');
$(this).addClass('active');
});
$('.pxl-portfolio-recent .pxl-grid-item').on('mouseover', function (){
$(this).siblings('.pxl-grid-item').removeClass('active');
$(this).addClass('active');
});
$('.pxl-switch-button').on('mouseover', function(){
$('a, input, button, .pxl-transtion').removeClass('pxl-hover-transition');
$('.pxl-scroll-top').removeClass('pxl-hover-transition');
});
$('.pxl-parent-transition').each(function(){
$(this).find('.pxl-transtion').addClass('pxl-hover-transition');
$(this).on('mouseover', function(){
$(this).find('.pxl-transtion').addClass('pxl-hover-transition');
});
$('.pxl-switch-button').on('mouseover', function(){
$(this).find('.pxl-transtion').removeClass('pxl-hover-transition');
});
});
$('.btn-plus-text').on('mouseover', function (){
$(this).find('span').toggle(300);
});
$(".pxl-nav-button").on('click', function (){
$(this).toggleClass('active');
$(this).parent().find('.pxl-nav-wrap').toggle(400);
});
var boxEls=$('.el-bounce, .pxl-image-effect1');
$.each(boxEls, function(boxIndex, boxEl){
loopToggleClass(boxEl, 'bounce-active');
});
$('.pxl-modal-close').on('click', function (){
$(this).parent().removeClass('open').addClass('remove');
$(this).parents('body').removeClass('ov-hidden');
});
$('.btn-sign-up').on('click', function (){
$('.pxl-user-register').addClass('u-open').removeClass('u-close');
$('.pxl-user-login').addClass('u-close').removeClass('u-open');
});
$('.btn-sign-in').on('click', function (){
$('.pxl-user-register').addClass('u-close').removeClass('u-open');
$('.pxl-user-login').addClass('u-open').removeClass('u-close');
});
$('.pxl-user-have-an-account').on('click', function (){
$(this).parents('.pxl-modal-content').find('.pxl-user-register').addClass('u-close').removeClass('u-open');
$(this).parents('.pxl-modal-content').find('.pxl-user-login').addClass('u-open').removeClass('u-close');
});
$('.h-btn-user').on('click', function (){
$('.pxl-user-popup').addClass('open').removeClass('remove');
$(this).find('.pxl-user-account').toggleClass('active');
});
function loopToggleClass(el, toggleClass){
el=$(el);
let counter=0;
if(el.hasClass(toggleClass)){
waitFor(function (){
counter++;
return counter==2;
}, function (){
counter=0;
el.removeClass(toggleClass);
loopToggleClass(el, toggleClass);
}, 'Deactivate', 1000);
}else{
waitFor(function (){
counter++;
return counter==3;
}, function (){
counter=0;
el.addClass(toggleClass);
loopToggleClass(el, toggleClass);
}, 'Activate', 1000);
}}
function waitFor(condition, callback, message, time){
if(message==null||message==''||typeof message=='undefined'){
message='Timeout';
}
if(time==null||time==''||typeof time=='undefined'){
time=100;
}
var cond=condition();
if(cond){
callback();
}else{
setTimeout(function(){
console.log(message);
waitFor(condition, callback, message, time);
}, time);
}}
$('form:not(.wpcf7-form) select, .woocommerce-ordering .orderby, #pxl-sidebar-area select, .nice-select').each(function (){
$(this).niceSelect();
});
$('.wpcf7-select').each(function(){
var $this=$(this), numberOfOptions=$(this).children('option').length;
$this.addClass('pxl-select-hidden');
$this.wrap('<div class="pxl-select"></div>');
$this.after('<div class="pxl-select-higthlight"></div>');
var $styledSelect=$this.next('div.pxl-select-higthlight');
$styledSelect.text($this.children('option').eq(0).text());
var $list=$('<ul />', {
'class': 'pxl-select-options'
}).insertAfter($styledSelect);
for (var i=0; i < numberOfOptions; i++){
$('<li />', {
text: $this.children('option').eq(i).text(),
rel: $this.children('option').eq(i).val()
}).appendTo($list);
}
var $listItems=$list.children('li');
$styledSelect.on('click', function(e){
e.stopPropagation();
$('div.pxl-select-higthlight.active').not(this).each(function(){
$(this).removeClass('active').next('ul.pxl-select-options').addClass('pxl-select-lists-hide');
});
$(this).toggleClass('active');
});
$listItems.on('click', function(e){
e.stopPropagation();
$styledSelect.text($(this).text()).removeClass('active');
$this.val($(this).attr('rel'));
});
$(document).on('click', function(){
$styledSelect.removeClass('active');
});
});
$('#pxl-sidebar-area select').each(function(){
var $this=$(this), numberOfOptions=$(this).children('option').length;
$this.addClass('pxl-select-hidden');
$this.wrap('<div class="pxl-select"></div>');
$this.after('<div class="pxl-select-higthlight"></div>');
var $styledSelect=$this.next('div.pxl-select-higthlight');
$styledSelect.text($this.children('option').eq(0).text());
var $list=$('<ul />', {
'class': 'pxl-select-options'
}).insertAfter($styledSelect);
for (var i=0; i < numberOfOptions; i++){
$('<li />', {
text: $this.children('option').eq(i).text(),
rel: $this.children('option').eq(i).val()
}).appendTo($list);
}
var $listItems=$list.children('li');
$styledSelect.on('click', function(e){
e.stopPropagation();
$('div.pxl-select-higthlight.active').not(this).each(function(){
$(this).removeClass('active').next('ul.pxl-select-options').addClass('pxl-select-lists-hide');
});
$(this).toggleClass('active');
});
$listItems.on('click', function(e){
e.stopPropagation();
$styledSelect.text($(this).text()).removeClass('active');
$this.val($(this).attr('rel'));
});
$(document).on('click', function(){
$styledSelect.removeClass('active');
});
});
$('.woocommerce-LoopProduct-link.woocommerce-loop-product__link.is-featured').append('<span class="featured">Hot</span>');
$('.woocommerce-LoopProduct-link.woocommerce-loop-product__link.is-new').append('<span class="isnew">New</span>');
setTimeout(function(){
$('.md-align-center').parents('.rs-parallax-wrap').addClass('pxl-group-center');
}, 300);
$('.pxl-tabs').parents('.pxl-tab--title').addClass('pxl--hide-arrow');
var section_tab=$('.pxl-navigation-tab').parents('.elementor-section').addClass('pxl--hide-arrow');
setTimeout(function(){
var target=section_tab.find('.pxl-tabs .pxl-tabs--title');
var target_clone=target.clone()
var target_tab=target.parents('.elementor-section.pxl--hide-arrow').find('.pxl-navigation-tab');
target_tab.append(target_clone);
target_tab.find('.pxl-tab--title').on('click', function (){
$(this).parents('.elementor-section.pxl--hide-arrow').find('.pxl-navigation-tab .pxl-tab--title').toggleClass('active');
$(this).parents('.elementor-section.pxl--hide-arrow').find('.pxl-tabs .pxl-tab--title').toggleClass('active');
$(this).parents('.elementor-section.pxl--hide-arrow').find('.pxl-tabs .pxl-tab--title.active').trigger('click');
});
}, 300);
});
function ducatibox_blog_post_gallery(){
if($('.post.format-gallery').length <=0) return;
var swiper=new Swiper(".post-gallery-slider .pxl-swiper-container", {
navigation: {
nextEl: ".pxl-swiper-arrow-next",
prevEl: ".pxl-swiper-arrow-prev",
},
});
}
function ducatibox_panel_anchor_toggle(){
'use strict';
$(document).on('click','.pxl-anchor.side-panel',function(e){
e.preventDefault();
e.stopPropagation();
var target=$(this).attr('data-target');
$(this).toggleClass('cliked');
$(target).toggleClass('open');
$('body').toggleClass('side-panel-open');
setTimeout(function(){
$(document).find('.pxl-search-form input[name="s"]').focus();
$(document).find('.search-form input[name="s"]').focus();
},1000);
});
$('.pxl-menu-primary li').each(function (){
var $submenu=$(this).find('> ul.sub-menu');
if($submenu.length==1){
$(this).on('mouseover', function (){
if($submenu.offset().left + $submenu.width() > $(window).width()){
$submenu.addClass('back');
}else if($submenu.offset().left < 0){
$submenu.addClass('back');
}}, function (){
$submenu.removeClass('back');
});
}});
}
function ducatibox_document_click(){
$(document).on('click',function (e){
var target=$(e.target);
var check='.btn-nav-mobile';
if(!(target.is(check))&&target.closest('.pxl-hidden-template').length <=0&&$('body').hasClass('side-panel-open')){
$('.btn-nav-mobile').removeClass('cliked');
$('.pxl-hidden-template').removeClass('open');
$('body').removeClass('side-panel-open');
}});
$(document).on('click','.pxl-close',function(e){
e.preventDefault();
e.stopPropagation();
$(this).closest('.pxl-hidden-template').toggleClass('open');
$('.btn-nav-mobile').removeClass('cliked');
$('.pxl-anchor.side-panel').removeClass('cliked');
$('body').toggleClass('side-panel-open');
});
}
jQuery(document).ajaxComplete(function(event, xhr, settings){
ducatibox_svg_stroke();
});
function ducatibox_svg_stroke(){
var $svgElement=$('.pxl-stroke--inner .pxl-item--svg-stroke');
var $textElement=$('.pxl-stroke--inner .pxl-item-text--svg-stroke');
if($textElement.getBBox){
var bbox=$textElement[0].getBBox();
$svgElement.attr('width', bbox.width);
$svgElement.attr('height', bbox.height);
}}
function ducatibox_header_sticky(){
if($('#pxl-header-elementor').hasClass('is-sticky')){
if(pxl_scroll_top > 100){
$('.pxl-header-elementor-sticky.pxl-sticky-stb').addClass('pxl-header-fixed');
}else{
$('.pxl-header-elementor-sticky.pxl-sticky-stb').removeClass('pxl-header-fixed');
}
if(pxl_scroll_status=='up'&&pxl_scroll_top > 100){
$('.pxl-header-elementor-sticky.pxl-sticky-stt').addClass('pxl-header-fixed');
}else{
$('.pxl-header-elementor-sticky.pxl-sticky-stt').removeClass('pxl-header-fixed');
}}
$('.pxl-header-elementor-sticky').parents('body').addClass('pxl-header-sticky');
}
function ducatibox_scroll_to_top(){
if(pxl_scroll_top < pxl_window_height){
$('.pxl-scroll-top').addClass('pxl-off').removeClass('pxl-on');
}
if(pxl_scroll_top > pxl_window_height){
$('.pxl-scroll-top').addClass('pxl-on').removeClass('pxl-off');
}}
function ducatibox_lightdark_switch(){
let getMode=localStorage.getItem("mode");
const toggleButton=$(".pxl-switch-button");
var currentPath=window.location.pathname;
var isLandingPage=currentPath.endsWith("/landing/");
if(isLandingPage){
toggleButton.css("opacity", "0");
getMode="dark";
}else{
const urlParams=new URLSearchParams(window.location.search);
const colorParam=urlParams.get('color');
if(colorParam==='v-dark'||colorParam==='v-light'){
getMode=(colorParam==='v-light') ? 'light':'dark';
}}
if(getMode&&getMode==="light"){
$("body").removeClass("dark-mode");
}
if(getMode&&getMode==="dark"){
$("body").addClass("dark-mode");
}
toggleButton.on("click", function(){
$("body").toggleClass("dark-mode");
if(!$("body").hasClass("dark-mode")){
return localStorage.setItem("mode", "light");
}
localStorage.setItem("mode", "dark");
});
}
function ducatibox_footer_fixed(){
setTimeout(function(){
var h_footer=$('.pxl-footer-fixed #pxl-footer-elementor').outerHeight() - 1;
$('.pxl-footer-fixed #pxl-main').css('margin-bottom', h_footer + 'px');
}, 600);
}
function ducatibox_quantity_icon(){
$('#pxl-main .quantity').append('<span class="quantity-icon"><i class="quantity-down">-</i><i class="quantity-up">+</i></span>');
$('.quantity-up').on('click', function (){
$(this).parents('.quantity').find('input[type="number"]').get(0).stepUp();
$(this).parents('.woocommerce-cart-form').find('.actions .button').removeAttr('disabled');
});
$('.quantity-down').on('click', function (){
$(this).parents('.quantity').find('input[type="number"]').get(0).stepDown();
$(this).parents('.woocommerce-cart-form').find('.actions .button').removeAttr('disabled');
});
$('.woocommerce-cart-form .actions .button').removeAttr('disabled');
}
function ducatibox_product_single_variations_att(){
$(document).on('mousedown', '.pro-variation-select', function (e){
e.preventDefault();
var $this_var=$(this).closest('.variations'),
this_closest=$(this).closest('.pxl-variation-att-terms'),
target_hidden=$this_var.find('#'+this_closest.attr('data-id'));
var $this=$(this);
if(!$this.hasClass('custom-vari-enabled'))
return;
var target=$this.attr('data-value');
if(!target)
return;
target_hidden.val(target).change();
this_closest.find('li.pxl-vari-item').removeClass('active');
$this.parent('li').addClass('active');
});
}
$(document).ajaxComplete(function(){
ducatibox_quantity_icon();
});
})(jQuery);