')
.append($header.find(selector).first().clone())
.html()
: (data[selector] !== undefined) ? data[selector] : '';
});
cloneHTML = cloneHTML.replace(/
]*>/g, '');
cloneHTML = cloneHTML.replace('whb-col-1', '');
cloneHTML = cloneHTML.replace('dropdowns-loading', '');
$header.after(cloneHTML);
$header = $header.parent().find('.whb-clone');
$header.find('.whb-row').removeClass('whb-flex-equal-sides').addClass('whb-flex-flex-middle');
window.dispatchEvent(new CustomEvent('wdHeaderBuilderCloneCreated'));
}
$window.on('scroll', function() {
var after = stickAfter;
var currentScroll = woodmartThemeModule.$window.scrollTop();
var windowHeight = woodmartThemeModule.$window.height();
var documentHeight = woodmartThemeModule.$document.height();
if ($headerBanner.length > 0 && woodmartThemeModule.$body.hasClass('header-banner-display')) {
after += $headerBanner[0].offsetHeight;
}
if (!$('.close-header-banner').length && $header.hasClass('whb-scroll-stick')) {
after = stickAfter;
}
if (currentScroll > after) {
stickHeader();
} else {
unstickHeader();
}
var startAfter = 100;
if ($header.hasClass('whb-scroll-stick')) {
startAfter = 500;
}
if (isHideOnScroll) {
if (previousScroll - currentScroll > 0 && currentScroll > after) {
$header.addClass('whb-scroll-up');
$header.removeClass('whb-scroll-down');
} else if (currentScroll - previousScroll > 0 && currentScroll + windowHeight !== documentHeight && currentScroll > (after + startAfter)) {
$header.addClass('whb-scroll-down');
$header.removeClass('whb-scroll-up');
} else if (currentScroll <= after) {
$header.removeClass('whb-scroll-down');
$header.removeClass('whb-scroll-up');
} else if (currentScroll + windowHeight >= documentHeight - 5) {
$header.addClass('whb-scroll-up');
$header.removeClass('whb-scroll-down');
}
}
previousScroll = currentScroll;
});
function stickHeader() {
if (isSticked) {
return;
}
isSticked = true;
$header.addClass('whb-sticked');
menuDropdownRecalc();
}
function unstickHeader() {
if (!isSticked) {
return;
}
isSticked = false;
$header.removeClass('whb-sticked');
menuDropdownRecalc();
}
function menuDropdownRecalc() {
if (!$header.hasClass('whb-boxed')) {
return;
}
$('.wd-offsets-calculated .wd-dropdown-menu').attr('style', '');
$('.wd-offsets-calculated').removeClass('wd-offsets-calculated');
woodmartThemeModule.$window.trigger('wdHeaderBuilderStickyChanged');
}
woodmartThemeModule.$document.trigger('wdHeaderBuilderInited');
};
['wdEventStarted', 'wdUpdatedHeader'].forEach((eventName) => {
window.addEventListener(eventName, function () {
woodmartThemeModule.headerBuilder();
});
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.mobileSearchIcon = function() {
woodmartThemeModule.$body.on('click', '.wd-header-search-mobile:not(.wd-display-full-screen, .wd-display-full-screen-2)', function(e) {
e.preventDefault();
var $nav = $('.mobile-nav');
if (!$nav.hasClass('wd-opened')) {
$(this).addClass('wd-opened');
$nav.addClass('wd-opened');
$('.wd-close-side').addClass('wd-close-side-opened');
$('.mobile-nav .searchform').find('input[type="text"]').trigger('focus');
}
});
};
$(document).ready(function() {
woodmartThemeModule.mobileSearchIcon();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit', function() {
woodmartThemeModule.categoriesMenuBtns();
woodmartThemeModule.categoriesMenu();
});
jQuery.each([
'frontend/element_ready/wd_product_categories.default',
'frontend/element_ready/wd_page_title.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.categoriesMenuBtns();
woodmartThemeModule.categoriesMenu();
});
});
woodmartThemeModule.categoriesMenu = function() {
var $categories = $('.wd-nav-product-cat');
var isProcessing = false;
if (woodmartThemeModule.$window.width() > 1024) {
$categories.stop().attr('style', '');
}
var time = 200;
$categories.each(function() {
var $productCat = $(this);
var $thisCategories = $productCat.parents('.wd-nav-accordion-mb-on');
var $showCat = $thisCategories.find('wd-btn-show-cat');
var isAccordionOnMobile = $thisCategories.hasClass('wd-nav-accordion-mb-on');
var isOpened = function() {
return $productCat.hasClass('categories-opened');
};
var openCats = function() {
$showCat.addClass('wd-active');
$productCat.addClass('categories-opened').stop().slideDown(time);
woodmartThemeModule.$document.trigger('wood-images-loaded');
};
var closeCats = function() {
$showCat.removeClass('wd-active');
$productCat.removeClass('categories-opened').stop().slideUp(time);
};
$thisCategories.find('.wd-nav-opener').off('click').on('click', function(e) {
var $this = $(this);
e.preventDefault();
if (! isProcessing) {
isProcessing = true;
setTimeout(() => {
isProcessing = false;
}, time);
if ($this.closest('.has-sub').find('> ul').hasClass('child-open')) {
$this.removeClass('wd-active').closest('.has-sub').find('> ul').slideUp(time).removeClass('child-open');
} else {
$this.addClass('wd-active').closest('.has-sub').find('> ul').slideDown(time).addClass('child-open');
}
}
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
$thisCategories.find('.wd-btn-show-cat > a').off('click').on('click', function(e) {
e.preventDefault();
if (! isProcessing && isAccordionOnMobile) {
isProcessing = true;
setTimeout(() => {
isProcessing = false;
}, time);
if (isOpened($productCat)) {
closeCats();
} else {
openCats();
woodmartThemeModule.$document.trigger('wood-images-loaded');
}
}
});
$thisCategories.find('.wd-nav-product-cat a').off('click').on('click', function(e) {
if (!$(e.target).hasClass('wd-nav-opener')) {
closeCats();
$productCat.stop().attr('style', '');
}
});
});
};
woodmartThemeModule.categoriesMenuBtns = function() {
$('.wd-nav-product-cat.wd-mobile-accordion').each(function() {
var $this = $(this);
var iconDropdown = '
';
var $ulWrapper = $this.find('li > ul').parent();
var $navOpeners = $ulWrapper.find('.wd-nav-opener');
if ( ('undefined' !== typeof elementor && elementor.hasOwnProperty('$preview') && elementor.$preview.width() > 1024) || woodmartThemeModule.windowWidth > 1024 ) {
$navOpeners.remove();
return;
}
$navOpeners.remove();
$ulWrapper.addClass('has-sub').append(iconDropdown);
});
};
woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() {
woodmartThemeModule.categoriesMenuBtns();
woodmartThemeModule.categoriesMenu();
}, 300));
$(document).ready(function() {
woodmartThemeModule.categoriesMenuBtns();
woodmartThemeModule.categoriesMenu();
});
})(jQuery);
woodmartThemeModule.$document.on('wdShopPageInit', function() {
woodmartThemeModule.categoriesMenuSideHidden();
});
jQuery.each([
'frontend/element_ready/wd_product_categories.default',
'frontend/element_ready/wd_page_title.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
if ( 'function' === typeof woodmartThemeModule.closeMobileNavigation ) {
woodmartThemeModule.closeMobileNavigation();
}
woodmartThemeModule.categoriesMenuSideHidden();
});
});
woodmartThemeModule.showHideMobileTollBarButton = function() {
var categoryMenuInStartPosition = document.querySelector('.wd-nav-product-cat-wrap .wd-nav-product-cat, .page-title .wd-nav-product-cat');
var toolBarCategoriesBatton = document.querySelector('.wd-toolbar-shop-cat');
if ( ! toolBarCategoriesBatton ) {
return;
}
battonSettings = 'settings' in toolBarCategoriesBatton.dataset ? JSON.parse( toolBarCategoriesBatton.dataset.settings ) : {};
if ( ! battonSettings.hasOwnProperty('shop_categories_ancestors') || "0" === battonSettings.shop_categories_ancestors || "no" === battonSettings.shop_categories_ancestors ) {
return;
}
if ( ! categoryMenuInStartPosition ) {
toolBarCategoriesBatton.classList.add('wd-hide');
} else if ( toolBarCategoriesBatton.classList.contains('wd-hide') ) {
toolBarCategoriesBatton.classList.remove('wd-hide');
}
}
woodmartThemeModule.$document.on('pjax:beforeSend', function() {
var sideHiddenCat = document.querySelector('.wd-side-hidden-cat');
var sideHiddenCatChilds = sideHiddenCat ? sideHiddenCat.childNodes : null;
var showCatBtn = document.querySelector('.wd-nav-product-cat-wrap .wd-btn-show-cat, .page-title .wd-btn-show-cat');
var oldPlaceWrapper = showCatBtn ? showCatBtn.parentNode : null;
if ( sideHiddenCatChilds && oldPlaceWrapper ) {
for (var i = 0; i < sideHiddenCatChilds.length; i++) {
oldPlaceWrapper.appendChild(sideHiddenCatChilds[i].cloneNode(true));
}
}
});
woodmartThemeModule.categoriesMenuSideHidden = function() {
var openers = document.querySelectorAll('.wd-btn-show-cat, .wd-toolbar-shop-cat');
woodmartThemeModule.showHideMobileTollBarButton();
openers.forEach(function(opener) {
opener.addEventListener('click', function(e) {
e.preventDefault();
var sideHiddenCat = document.querySelector('.wd-side-hidden-cat');
var categoryMenu = document.querySelector('.wd-nav-product-cat');
var shopCategoriesAncestors = false;
if ( ! categoryMenu || ! ( 'sideCategories' in categoryMenu.dataset ) ) {
return;
}
if ( sideHiddenCat ) {
sideHiddenCat.remove();
sideHiddenCat = document.querySelector('.wd-side-hidden-cat');
}
var sideCategories = JSON.parse(categoryMenu.dataset.sideCategories);
if ( sideCategories.hasOwnProperty('shop_categories_ancestors') && sideCategories.shop_categories_ancestors && "0" !== sideCategories.shop_categories_ancestors && "no" !== sideCategories.shop_categories_ancestors ) {
shopCategoriesAncestors = true;
}
if ( categoryMenu && ! sideHiddenCat ) {
var newSideHiddenCat = document.createElement("div");
newSideHiddenCat.classList.add(
'mobile-nav',
'wd-side-hidden',
'wd-side-hidden-cat',
'wd-' + sideCategories.mobile_categories_position
);
if ( 'default' !== sideCategories.mobile_categories_color_scheme ) {
newSideHiddenCat.classList.add('color-scheme-' + sideCategories.mobile_categories_color_scheme);
}
if ( 'only_arrow' === sideCategories.mobile_categories_submenu_opening_action ) {
newSideHiddenCat.classList.add('wd-opener-arrow');
} else if ( 'item_and_arrow' === sideCategories.mobile_categories_submenu_opening_action ) {
newSideHiddenCat.classList.add('wd-opener-item');
}
if ('side-hidden' === sideCategories.mobile_categories_layout) {
if ( categoryMenu.classList.contains('wd-style-underline') ) {
categoryMenu.classList.remove('wd-style-underline');
}
if ( categoryMenu.classList.contains('wd-style-bg') ) {
categoryMenu.classList.remove('wd-style-bg');
}
categoryMenu.querySelectorAll('.wd-dropdown.wd-dropdown-menu').forEach(function(item) {
item.classList.remove('wd-dropdown', 'wd-dropdown-menu');
});
categoryMenu.classList.add(
'wd-nav-mobile',
'wd-layout-' + sideCategories.mobile_categories_menu_layout
);
if ( 'drilldown' === sideCategories.mobile_categories_menu_layout ) {
categoryMenu.classList.add('wd-drilldown-' + sideCategories.mobile_categories_drilldown_animation)
}
}
if ( categoryMenu.previousElementSibling && categoryMenu.previousElementSibling.classList.contains('wd-heading') ) {
newSideHiddenCat.appendChild(categoryMenu.previousElementSibling);
}
newSideHiddenCat.appendChild(categoryMenu);
document.body.appendChild(newSideHiddenCat);
sideHiddenCat = document.querySelector('.wd-side-hidden-cat');
var dropDownCats = sideHiddenCat.querySelectorAll('.wd-nav-mobile .menu-item-has-children');
var closeSideWidgets = sideHiddenCat.querySelectorAll('.login-side-opener, .close-side-widget');
if ('function' === typeof woodmartThemeModule.mobileNavigationAddOpeners && ! shopCategoriesAncestors) {
woodmartThemeModule.mobileNavigationAddOpeners(dropDownCats);
}
if ('function' === typeof woodmartThemeModule.mobileNavigationClickAction && ! shopCategoriesAncestors) {
woodmartThemeModule.mobileNavigationClickAction(sideHiddenCat);
}
if ('function' === typeof woodmartThemeModule.mobileNavigationCloseSideWidgets) {
woodmartThemeModule.mobileNavigationCloseSideWidgets( closeSideWidgets );
}
}
if (sideHiddenCat.classList.contains('wd-opened') && 'function' === typeof woodmartThemeModule.closeMobileNavigation ) {
woodmartThemeModule.closeMobileNavigation();
} else if ( 'function' === typeof woodmartThemeModule.openMobileNavigation ) {
setTimeout(function () {
var sideHiddenCatParrent = sideHiddenCat.parentNode;
if ( sideHiddenCatParrent ) {
sideHiddenCatParrent.classList.add('wd-opened');
}
woodmartThemeModule.openMobileNavigation(sideHiddenCat);
}, 10);
}
});
});
};
window.addEventListener('load',function() {
woodmartThemeModule.categoriesMenuSideHidden();
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.fullScreenMenu = function() {
$('.wd-header-fs-nav > a').on('click', function(e) {
e.preventDefault();
var $menu = $('.wd-fs-menu');
$menu.addClass('wd-opened');
$menu.trigger('wdOpenSide');
});
woodmartThemeModule.$document.on('keyup', function(e) {
if (e.keyCode === 27) {
$('.wd-fs-close').trigger('click');
}
});
$('.wd-fs-close').on('click', function() {
var $menu = $('.wd-fs-menu');
$menu.removeClass('wd-opened');
$menu.trigger('wdCloseSide');
setTimeout(function() {
$('.wd-nav-fs .menu-item-has-children').removeClass('sub-menu-open');
$('.wd-nav-fs .menu-item-has-children .wd-nav-opener').removeClass('wd-active');
}, 200);
});
$('.wd-nav-fs > .menu-item-has-children > a, .wd-nav-fs .wd-dropdown-fs-menu.wd-design-default .menu-item-has-children > a').append('
');
$('.wd-nav-fs').on('click', '.wd-nav-opener', function(e) {
e.preventDefault();
var $icon = $(this),
$parentItem = $icon.parent().parent();
if ($parentItem.hasClass('sub-menu-open')) {
$parentItem.removeClass('sub-menu-open');
$icon.removeClass('wd-active');
} else {
$parentItem.siblings('.sub-menu-open').find('.wd-nav-opener').removeClass('wd-active');
$parentItem.siblings('.sub-menu-open').removeClass('sub-menu-open');
$parentItem.addClass('sub-menu-open');
$icon.addClass('wd-active');
}
});
};
$(document).ready(function() {
woodmartThemeModule.fullScreenMenu();
});
window.addEventListener('wdUpdatedHeader', function () {
woodmartThemeModule.fullScreenMenu();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.menuDropdownsAJAX = function() {
window.addEventListener('wdEventStarted', function() {
$('.menu').has('.dropdown-load-ajax').each(function() {
var $menu = $(this);
if ($menu.hasClass('dropdowns-loading') || $menu.hasClass('dropdowns-loaded')) {
return;
}
if (woodmartThemeModule.windowWidth <= 1024) {
setTimeout(function() {
loadDropdowns($menu);
}, 500);
} else {
loadDropdowns($menu);
}
});
});
function loadDropdowns($menu) {
$menu.addClass('dropdowns-loading');
var storageKey = woodmart_settings.menu_storage_key + '_' + $menu.attr('id');
var storedData = false;
var $items = $menu.find('.dropdown-load-ajax'),
ids = [];
$items.each(function() {
var $placeholder = $(this).find('.dropdown-html-placeholder');
if ($placeholder.length > 0) {
ids.push($placeholder.data('id'));
}
});
if (woodmart_settings.ajax_dropdowns_save && woodmartThemeModule.supports_html5_storage) {
var unparsedData = localStorage.getItem(storageKey);
try {
storedData = JSON.parse(unparsedData);
}
catch (e) {
console.log('cant parse Json', e);
}
}
if (storedData) {
renderResults(storedData);
} else {
if (ids.length === 0) {
$menu.addClass('dropdowns-loaded');
$menu.removeClass('dropdowns-loading');
return;
}
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action: 'woodmart_load_html_dropdowns',
ids : ids
},
dataType: 'json',
method : 'POST',
success : function(response) {
if (response.status === 'success') {
renderResults(response.data);
if (woodmart_settings.ajax_dropdowns_save && woodmartThemeModule.supports_html5_storage) {
try {
localStorage.setItem(storageKey, JSON.stringify(response.data));
} catch (e) {}
}
} else {
console.log('loading html dropdowns returns wrong data - ', response.message);
}
},
error : function() {
console.log('loading html dropdowns ajax error');
}
});
}
function renderResults(data) {
Object.keys(data).forEach(function(id) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(data[id], function(html) {
$menu.find('[data-id="' + id + '"]').replaceWith(html);
$menu.addClass('dropdowns-loaded');
setTimeout(function() {
$menu.removeClass('dropdowns-loading');
}, 1000);
});
});
setTimeout(function() {
woodmartThemeModule.$document.trigger('wdLoadDropdownsSuccess');
}, 500);
}
}
};
$(document).ready(function() {
woodmartThemeModule.menuDropdownsAJAX();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.menuOffsets = function() {
var setOffset = function(li) {
var $dropdown = li.find(' > .wd-dropdown-menu');
var dropdownWidth = $dropdown.outerWidth();
var dropdownOffset = $dropdown.offset();
var toRight;
var viewportWidth;
var dropdownOffsetRight;
$dropdown.attr('style', '');
if (!dropdownWidth || !dropdownOffset) {
return;
}
if ($dropdown.hasClass('wd-design-full-width') || $dropdown.hasClass('wd-design-aside')) {
viewportWidth = woodmartThemeModule.$window.width();
if (woodmartThemeModule.$body.hasClass('rtl')) {
dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth;
if (dropdownOffsetRight + dropdownWidth >= viewportWidth) {
toRight = dropdownOffsetRight + dropdownWidth - viewportWidth;
$dropdown.css({
right: -toRight
});
}
} else {
if (dropdownOffset.left + dropdownWidth >= viewportWidth) {
toRight = dropdownOffset.left + dropdownWidth - viewportWidth;
$dropdown.css({
left: -toRight
});
}
}
} else if ($dropdown.hasClass('wd-design-sized') || $dropdown.hasClass('wd-design-full-height')) {
viewportWidth = woodmart_settings.site_width;
if (woodmartThemeModule.$window.width() < viewportWidth || ! viewportWidth || li.parents('.whb-header').hasClass('whb-full-width')) {
viewportWidth = woodmartThemeModule.$window.width();
}
dropdownOffsetRight = viewportWidth - dropdownOffset.left - dropdownWidth;
var extraSpace = 15;
var containerOffset = (woodmartThemeModule.$window.width() - viewportWidth) / 2;
var dropdownOffsetLeft;
var $stickyCat = $('.wd-sticky-nav');
if (woodmartThemeModule.$body.hasClass('wd-sticky-nav-enabled') && $stickyCat.length) {
extraSpace -= $stickyCat.width() / 2;
}
if (woodmartThemeModule.$body.hasClass('rtl')) {
dropdownOffsetLeft = containerOffset + dropdownOffsetRight;
if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) {
toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth;
$dropdown.css({
right: -toRight - extraSpace
});
}
} else {
dropdownOffsetLeft = dropdownOffset.left - containerOffset;
if (dropdownOffsetLeft + dropdownWidth >= viewportWidth) {
toRight = dropdownOffsetLeft + dropdownWidth - viewportWidth;
$dropdown.css({
left: -toRight - extraSpace
});
}
}
}
};
$('.wd-header-main-nav ul.menu > li, .wd-header-secondary-nav ul.menu > li, .widget_nav_mega_menu ul.menu:not(.wd-nav-vertical) > li, .wd-header-main-nav .wd-dropdown.wd-design-aside ul > li').each(function() {
var $menu = $(this);
if ($menu.hasClass('menu-item')) {
$menu = $(this).parent();
}
function recalc() {
if ($menu.hasClass('wd-offsets-calculated') || $menu.parents('.wd-design-aside').length) {
return;
}
$menu.find(' > .menu-item-has-children').each(function() {
setOffset($(this));
});
woodmartThemeModule.$document.trigger('resize.vcRowBehaviour');
$menu.addClass('wd-offsets-calculated');
}
$menu.on('mouseenter mousemove', function() {
recalc()
});
woodmartThemeModule.$window.on('wdHeaderBuilderStickyChanged', recalc);
if ('yes' === woodmart_settings.clear_menu_offsets_on_resize) {
setTimeout(function() {
woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() {
$menu.removeClass('wd-offsets-calculated');
$menu.find(' > .menu-item-has-children > .wd-dropdown-menu').attr('style', '');
}, 300));
}, 2000);
}
});
};
woodmartThemeModule.menuDropdownAside = function() {
$('.wd-nav .wd-design-aside, .wd-header-cats.wd-open-dropdown .wd-nav').each( function () {
var $links = $(this).find('.menu-item');
if (!$links.length) {
return;
}
var $firstLink = $links.first();
if (!$firstLink.hasClass('menu-item-has-children')) {
$firstLink.parents('.wd-sub-menu-wrapp').addClass('wd-empty-item');
}
$firstLink.addClass('wd-opened').find('.wd-dropdown').addClass('wd-opened');
$links.on('mouseover', function () {
var $this = $(this);
var $wrap = $this.parents('.wd-sub-menu-wrapp');
if ($this.hasClass('wd-opened')) {
return;
}
if ( $this.hasClass('item-level-1') ) {
if (!$this.hasClass('menu-item-has-children')) {
$wrap.addClass('wd-empty-item');
} else {
$wrap.removeClass('wd-empty-item');
}
}
$this.siblings().removeClass('wd-opened').find('.wd-dropdown').removeClass('wd-opened');
$this.addClass('wd-opened').find('.wd-dropdown').addClass('wd-opened');
});
});
}
window.addEventListener('wdEventStarted', function () {
setTimeout(function () {
woodmartThemeModule.menuDropdownAside();
woodmartThemeModule.menuOffsets();
}, 100);
});
window.addEventListener('wdUpdatedHeader', function () {
$('.whb-header .wd-offsets-calculated').removeClass('wd-offsets-calculated');
$('.whb-header .menu-item.wd-opened, .whb-header .wd-dropdown.wd-opened').removeClass('wd-opened');
$('.whb-header .wd-dropdown-menu').attr('style', '');
woodmartThemeModule.menuDropdownAside();
woodmartThemeModule.menuOffsets();
});
})(jQuery);
(function($) {
woodmartThemeModule.menuOverlay = function() {
var hoverSelector = '.wd-header-nav.wd-with-overlay .item-level-0.menu-item-has-children.wd-event-hover, .wd-header-cats.wd-with-overlay .item-level-0.menu-item-has-children.wd-event-hover, .wd-sticky-nav:not(.wd-opened), .wd-header-cats.wd-with-overlay.wd-event-hover, .wd-header-my-account.wd-with-overlay, .wd-header-cart.wd-with-overlay, .wd-header-search.wd-display-dropdown.wd-with-overlay';
var clickSelector = '.wd-header-nav.wd-with-overlay .item-level-0.menu-item-has-children.wd-event-click, .wd-header-cats.wd-with-overlay .item-level-0.menu-item-has-children.wd-event-click, .wd-header-cats.wd-with-overlay.wd-event-click, .wd-search-form.wd-with-overlay .wd-search-cat';
var closeSideLastAction = '';
var $side = $('.wd-close-side');
woodmartThemeModule.$document.on('mouseleave', hoverSelector, function() {
var $this = $(this);
if ( $this.parents('.wd-header-cats.wd-with-overlay.wd-event-click.wd-opened').length ) {
return;
}
$side.trigger('wdCloseSideAction', ['hide', 'hover', 'wd-location-header-sticky wd-location-header wd-location-header-cats wd-location-sticky-nav']);
});
woodmartThemeModule.$document.on('mouseenter mousemove', hoverSelector, function() {
var $this = $(this);
if ($side.hasClass('wd-close-side-opened') || woodmartThemeModule.$window.width() < 768) {
return;
}
var isInHeader = $this.parents('.whb-header').length;
var isInCloneHeader = $this.parents('.whb-clone').length;
var isInCategories = $this.hasClass('wd-sticky-nav');
var isInHeaderCategories = $this.parents('.wd-header-cats').length;
var extraClass = '';
if (isInHeader) {
if ($this.parents('.whb-sticked').length) {
extraClass = 'wd-location-header-sticky';
} else {
extraClass = 'wd-location-header';
}
if (isInHeaderCategories) {
extraClass += ' wd-location-header-cats';
}
} else if (isInCloneHeader) {
extraClass = 'wd-location-header-sticky';
} else if (isInCategories) {
extraClass = 'wd-location-sticky-nav';
}
$side.trigger('wdCloseSideAction', ['show', 'hover', extraClass]);
});
woodmartThemeModule.$document.on('click', clickSelector, function(e) {
var $item = $(this);
if ( $item.parents('.wd-header-cats.wd-with-overlay.wd-event-click.wd-opened').length || $item.parents('.wd-header-cats.wd-with-overlay.wd-event-hover').length ) {
return;
}
setTimeout(function() {
var action = ! $item.hasClass('wd-opened') ? 'hide' : 'show';
$side.trigger('wdCloseSideAction', [action, 'click']);
});
});
woodmartThemeModule.$document.on('click touchstart', '.wd-close-side.wd-location-header', function() {
$(this).removeClass('wd-location-header wd-close-side-opened');
});
$side.on('wdCloseSideAction', function( e, type, action, extraClass = 'wd-location-header' ) {
if ( 'hover' === action && 'click' === closeSideLastAction ) {
return;
}
if ( 'click' === action && 'hide' === type ) {
closeSideLastAction = '';
} else {
closeSideLastAction = action;
}
if ( 'show' === type ) {
$side.addClass('wd-close-side-opened').addClass(extraClass);
} else {
$side.removeClass('wd-close-side-opened').removeClass(extraClass);
}
});
};
['wdEventStarted', 'wdUpdatedHeader'].forEach((eventName) => {
window.addEventListener(eventName, function () {
woodmartThemeModule.menuOverlay();
});
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.menuSetUp = function() {
var hasChildClass = 'menu-item-has-children',
mainMenu = $('.wd-nav, .wd-header-cats, .wd-search-cat'),
openedClass = 'wd-opened';
$('.mobile-nav').find('ul.wd-nav-mobile').find(' > li').has('.wd-dropdown-menu').addClass(hasChildClass);
woodmartThemeModule.$document.on('click', '.wd-nav .wd-event-click > a, .wd-header-cats.wd-event-click > span, .wd-search-cat-btn', function(e) {
e.preventDefault();
var $this = $(this);
if ($this.parent().siblings().hasClass(openedClass)) {
$this.parent().siblings().removeClass(openedClass);
}
$this.parent().toggleClass(openedClass);
});
woodmartThemeModule.$document.on('click', function(e) {
var target = e.target;
if (
$('.' + openedClass).length > 0 &&
!$(target).is('.wd-event-hover') &&
!$(target).parents().is('.wd-event-hover') &&
!$(target).parents().is('.' + openedClass + '') &&
!$(target).is('.' + openedClass + '') &&
!$(target).is('.wd-sticky-nav') &&
! target.closest('.wd-cookies-popup') &&
! target.closest('.wd-fb-holder') &&
0 === $('.mfp-ready').length &&
0 === $('.pswp--open').length
) {
mainMenu.find('.wd-event-click.' + openedClass + '').removeClass(openedClass);
if (mainMenu.hasClass('wd-event-click')) {
mainMenu.removeClass(openedClass);
}
if ($(target).closest('.wd-with-overlay').length) {
return;
}
$('.wd-close-side').trigger('wdCloseSideAction', ['hide', 'click']);
}
});
if ('yes' === woodmart_settings.menu_item_hover_to_click_on_responsive) {
function menuIpadClick() {
if (woodmartThemeModule.$window.width() <= 1024) {
mainMenu.find(' > .menu-item-has-children.wd-event-hover').each(function() {
$(this).data('original-event', 'hover').removeClass('wd-event-hover').addClass('wd-event-click');
});
} else {
mainMenu.find(' > .wd-event-click').each(function() {
var $this = $(this);
if ($this.data('original-event') === 'hover') {
$this.removeClass('wd-event-click').addClass('wd-event-hover');
}
});
}
}
menuIpadClick();
woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() {
menuIpadClick();
}, 300));
}
};
['wdEventStarted', 'wdUpdatedHeader'].forEach((eventName) => {
window.addEventListener(eventName, function () {
woodmartThemeModule.menuSetUp();
});
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.menuStickyOffsets = function() {
var $stickyNav = $('.wd-sticky-nav');
var $side = $('.wd-close-side');
$('.wd-sticky-nav .wd-nav-sticky.wd-nav-vertical').each(function() {
var $menu = $(this);
$menu.on('mouseenter mousemove', function() {
if ($menu.hasClass('wd-offsets-calculated')) {
return;
}
$menu.find('> .menu-item-has-children').each(function() {
var $menuItem = $(this);
if ($menuItem.find('> .wd-dropdown.wd-design-full-height').length) {
return;
}
setOffset($menuItem);
if ($menuItem.find('> .wd-dropdown').length) {
$menuItem.find('.menu-item.menu-item-has-children').each(function() {
setOffset($(this));
});
}
});
$menu.addClass('wd-offsets-calculated');
});
if ( 'undefined' === typeof woodmart_settings.clear_menu_offsets_on_resize || 'yes' === woodmart_settings.clear_menu_offsets_on_resize) {
setTimeout(function () {
woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function () {
$menu.removeClass('wd-offsets-calculated');
$menu.find(' > .menu-item-has-children > .wd-dropdown-menu').attr('style', '');
}, 300));
}, 2000);
}
var setOffset = function(li) {
var $dropdown = li.find(' > .wd-dropdown');
var dropdownHeight = $dropdown.innerHeight();
var dropdownOffset = $dropdown.offset().top - woodmartThemeModule.$window.scrollTop();
var viewportHeight = woodmartThemeModule.$window.height();
var toTop = 0;
$dropdown.attr('style', '');
if (!dropdownHeight || !dropdownOffset) {
return;
}
if ( dropdownOffset + dropdownHeight >= viewportHeight ) {
toTop = dropdownOffset + dropdownHeight - viewportHeight;
$dropdown.css({
top: -toTop,
});
}
}
});
woodmartThemeModule.$document.on('click', '.wd-header-sticky-nav', function(e) {
e.preventDefault();
var $stickyNavBtn = $(this);
sideOpened( $stickyNavBtn, $stickyNavBtn.hasClass('wd-close-menu-mouseout') );
});
woodmartThemeModule.$document.on('mouseenter mousemove', '.wd-header-sticky-nav.wd-event-hover', function() {
sideOpened( $(this) );
});
woodmartThemeModule.$document.on('click touchstart', '.wd-close-side.wd-location-sticky-nav', function() {
closeSide();
});
function sideOpened( $stickyNavBtn, addMouseoutEvent = true ) {
$stickyNavBtn.addClass('wd-opened');
$stickyNav.addClass('wd-opened');
$side.trigger('wdCloseSideAction', ['show', 'click', 'wd-location-sticky-nav']);
if ( ! addMouseoutEvent ) {
return;
}
$stickyNav.on('mouseout', function () {
closeSide();
$stickyNav.off('mouseout');
});
}
function closeSide() {
$('.wd-header-sticky-nav').removeClass('wd-opened');
$stickyNav.removeClass('wd-opened');
$side.trigger('wdCloseSideAction', ['hide', 'click', 'wd-location-sticky-nav']);
}
};
window.addEventListener('wdEventStarted', function () {
setTimeout(function () {
woodmartThemeModule.menuStickyOffsets();
}, 100);
});
})(jQuery);
/* global woodmart_settings */
woodmartThemeModule.$document.on('wdCloseMobileMenu wdPjaxStart', function() {
woodmartThemeModule.closeMobileNavigation();
});
woodmartThemeModule.mobileNavigationClickAction = function(mobileNav) {
if (! mobileNav) {
return;
}
mobileNav.addEventListener("click", function(e) {
var currentNav = e.target.closest('.wd-nav');
if ( ! currentNav ) {
return;
}
var isDropdown = currentNav.classList.contains('wd-layout-dropdown');
var isDrilldown = currentNav.classList.contains('wd-layout-drilldown');
var isDrilldownSlide = currentNav.classList.contains('wd-drilldown-slide');
var navTabs = e.target.closest('.wd-nav-mob-tab li');
var wdNavOpener = e.target.closest('.menu-item-has-children > a');
var wdNavOpenerArrow = e.target.closest('.menu-item-has-children > .wd-nav-opener');
var currentMobileNav = e.target.closest('.mobile-nav');
var opener = 'arrow';
var parentLi;
var parentLiChildren;
var openerBtn;
if (this.classList.contains('wd-opener-item')) {
opener = 'item';
}
woodmartThemeModule.$document.trigger('wood-images-loaded');
if (navTabs) {
e.preventDefault();
if (navTabs.classList.contains('wd-active')) {
return;
}
var menuName = navTabs.dataset.menu;
var activeMobileNav = null !== currentMobileNav ? currentMobileNav.querySelector('.wd-active') : false;
if (activeMobileNav) {
activeMobileNav.classList.remove('wd-active');
}
navTabs.classList.add('wd-active');
if ( null !== currentMobileNav ) {
currentMobileNav.querySelectorAll('.wd-nav-mobile').forEach(function(wdNavMobile) {
wdNavMobile.classList.remove('wd-active');
});
if ('undefined' !== typeof menuName) {
currentMobileNav.querySelectorAll(`.mobile-${menuName}-menu`).forEach(function(wdMobileMenu) {
wdMobileMenu.classList.add('wd-active');
});
}
}
}
if (isDropdown) {
if (('item' === opener && (wdNavOpener || wdNavOpenerArrow)) || ('arrow' === opener && wdNavOpenerArrow)) {
e.preventDefault();
if ('item' === opener) {
openerBtn = wdNavOpener ? wdNavOpener : wdNavOpenerArrow;
} else {
openerBtn = wdNavOpenerArrow;
}
parentLi = openerBtn.parentNode;
parentLiChildren = Array.from(parentLi.children);
var parentNavOpener = parentLiChildren.find(function(el) {
return el.classList.contains('wd-nav-opener');
});
var submenus = parentLiChildren.filter(function(el) {
return 'UL' === el.tagName || el.classList.contains('wd-sub-menu');
});
if (parentLi.classList.contains('opener-page')) {
parentLi.classList.remove('opener-page');
if (0 !== submenus.length) {
submenus.forEach(function (submenu) {
woodmartThemeModule.slideUp(submenu, 200);
});
}
[
'.wd-dropdown-menu .container > ul',
'.wd-dropdown-menu > ul',
].forEach(function (selector) {
var slideUpNodes = parentLi.querySelectorAll(selector);
if (0 === slideUpNodes.length) {
return;
}
slideUpNodes.forEach(function (slideUpNode) {
woodmartThemeModule.slideUp(slideUpNode, 200);
});
});
if ('undefined' !== typeof parentNavOpener) {
parentNavOpener.classList.remove('wd-active');
}
} else {
parentLi.classList.add('opener-page');
if (0 !== submenus.length) {
submenus.forEach(function (submenu) {
woodmartThemeModule.slideDown(submenu, 200);
});
}
[
'.wd-dropdown-menu .container > ul',
'.wd-dropdown-menu > ul',
].forEach(function (selector) {
var slideDownNodes = parentLi.querySelectorAll(selector);
if (0 === slideDownNodes.length) {
return;
}
slideDownNodes.forEach(function (slideDownNode) {
woodmartThemeModule.slideDown( slideDownNode, 200 );
});
});
if ('undefined' !== typeof parentNavOpener) {
parentNavOpener.classList.add('wd-active');
}
}
}
} else if (isDrilldown) {
var wdNavBackLink = e.target.closest('.menu-item-has-children .wd-drilldown-back a');
var wdNavBackLinkArrow = e.target.closest('.menu-item-has-children .wd-drilldown-back .wd-nav-opener');
var parentUl;
var submenu;
if (('item' === opener && (wdNavOpener || wdNavOpenerArrow)) || ('arrow' === opener && wdNavOpenerArrow)) {
if ('item' === opener) {
openerBtn = wdNavOpener ? wdNavOpener : wdNavOpenerArrow;
} else {
openerBtn = wdNavOpenerArrow;
}
parentLi = openerBtn.parentNode;
parentUl = parentLi.closest('ul');
parentLiChildren = Array.from(parentLi.children);
submenu = parentLiChildren.find(function(el) {
return el.classList.contains('wd-sub-menu') || el.classList.contains('sub-sub-menu');
});
if ('undefined' !== typeof submenu) {
e.preventDefault();
parentLi.setAttribute( 'aria-expanded', true );
parentUl.classList.add('wd-drilldown-hide');
parentUl.classList.remove('wd-drilldown-show');
submenu.classList.add('wd-drilldown-show');
submenu.setAttribute( 'aria-expanded', false );
var drilldownBackLink = submenu.querySelector('.wd-drilldown-back a');
var drilldownBackText = drilldownBackLink.textContent;
drilldownBackText = drilldownBackText.replaceAll('\t', '');
drilldownBackText = drilldownBackText.replaceAll('\n', '');
if ( parentLi.classList.contains('item-level-0') ) {
var currentTab = null;
if ( null !== currentMobileNav ) {
currentTab = currentMobileNav.querySelector('.wd-nav-mob-tab li.wd-active .nav-link-text');
}
if ( null !== currentTab ) {
var currentTabText = currentTab.textContent;
currentTabText = currentTabText.replaceAll('\t', '');
currentTabText = currentTabText.replaceAll('\n', '');
if (! drilldownBackText.includes(currentTabText) && currentTabText.length > 0) {
drilldownBackLink.textContent = woodmart_settings.mobile_navigation_drilldown_back_to.replace('%s', currentTabText);
}
} else if ( parentLi.classList.contains('cat-item') ) {
drilldownBackLink.textContent = woodmart_settings.mobile_navigation_drilldown_back_to_categories;
} else if (! drilldownBackText.includes(woodmart_settings.mobile_navigation_drilldown_back_to_main_menu)) {
drilldownBackLink.textContent = woodmart_settings.mobile_navigation_drilldown_back_to_main_menu;
}
} else {
var parentMenuText = '';
var parentMenuLink = parentUl.closest('li').querySelector('.woodmart-nav-link');
if ( null !== parentMenuLink.querySelector('.nav-link-text') ) {
parentMenuText = parentMenuLink.querySelector('.nav-link-text').textContent;
} else if ( null !== parentMenuLink.querySelector('span') ) {
parentMenuText = parentMenuLink.querySelector('span').textContent;
} else {
parentMenuText = parentMenuLink.textContent;
}
if (! drilldownBackText.includes( parentMenuText ) && parentMenuText.length > 0) {
drilldownBackLink.textContent = woodmart_settings.mobile_navigation_drilldown_back_to.replace('%s', parentMenuText);
}
}
if ( isDrilldownSlide ) {
this.querySelector('ul.wd-active').style.height = `${submenu.offsetHeight}px`;
}
}
}
if (wdNavBackLink || wdNavBackLinkArrow) {
e.preventDefault();
var backBtn = wdNavBackLink ? wdNavBackLink : wdNavBackLinkArrow;
parentLi = backBtn.closest('.menu-item');
parentUl = parentLi.closest('ul');
parentLiChildren = Array.from(parentLi.children);
submenu = parentLiChildren.find(function(el) {
return el.classList.contains('wd-sub-menu') || el.classList.contains('sub-sub-menu');
});
parentLi.setAttribute( 'aria-expanded', false );
if ( ! parentLi.classList.contains('item-level-0') ) {
parentUl.classList.add('wd-drilldown-show');
}
parentUl.classList.remove('wd-drilldown-hide');
submenu.classList.remove('wd-drilldown-show');
submenu.setAttribute( 'aria-expanded', true );
if ( isDrilldownSlide ) {
if ( parentLi.classList.contains('item-level-0') ) {
this.querySelector('ul.wd-active').style.height = '';
} else {
this.querySelector('ul.wd-active').style.height = `${parentUl.offsetHeight}px`;
}
}
}
}
});
}
woodmartThemeModule.mobileNavigationAddOpeners = function(dropDownCats) {
dropDownCats.forEach(function(dropDownCat) {
if ( dropDownCat.querySelector(':scope > .wd-nav-opener') || dropDownCat.closest('.widget_nav_mega_menu') ) {
return;
}
var elementIcon = document.createElement('span');
elementIcon.classList.add('wd-nav-opener');
dropDownCat.appendChild(elementIcon);
});
}
woodmartThemeModule.mobileNavigationCloseSideWidgets = function(closeSideWidgets) {
if (! closeSideWidgets) {
return;
}
closeSideWidgets.forEach(function(closeSideWidget) {
closeSideWidget.addEventListener('click', function(e) {
e.preventDefault();
woodmartThemeModule.closeMobileNavigation();
});
});
}
woodmartThemeModule.openMobileNavigation = function(mobileNav) {
var closeSide = document.querySelector('.wd-close-side');
if ( mobileNav ) {
mobileNav.classList.add('wd-opened');
jQuery(mobileNav).trigger('wdOpenSide');
}
if ( closeSide ) {
closeSide.classList.add('wd-close-side-opened');
}
woodmartThemeModule.$document.trigger('wood-images-loaded');
}
woodmartThemeModule.closeMobileNavigation = function() {
var activeHeaderMobileNav = document.querySelector('.wd-header-mobile-nav.wd-opened');
var activeMobileNav = document.querySelector('.mobile-nav.wd-opened')
var activeCloseSide = document.querySelector('.wd-close-side.wd-close-side-opened');
var searchFormInput = document.querySelector('.mobile-nav .searchform input[type=text]');
if (activeHeaderMobileNav) {
activeHeaderMobileNav.classList.remove('wd-opened');
}
if (activeMobileNav) {
activeMobileNav.classList.remove('wd-opened');
jQuery(activeMobileNav).trigger('wdCloseSide');
}
if (activeMobileNav && activeCloseSide) {
activeCloseSide.classList.remove('wd-close-side-opened');
}
if (searchFormInput) {
searchFormInput.blur();
}
}
woodmartThemeModule.mobileNavigation = function() {
var dropDownCats = document.querySelectorAll('.wd-side-hidden-nav .wd-nav-mobile .menu-item-has-children');
var mobileNavs = document.querySelectorAll('.wd-side-hidden-nav');
var closeSide = document.querySelector('.wd-close-side');
var closeSideWidgets = document.querySelectorAll('.mobile-nav .login-side-opener, .mobile-nav .close-side-widget');
woodmartThemeModule.mobileNavigationAddOpeners(dropDownCats);
mobileNavs.forEach(function(mobileNav) {
woodmartThemeModule.mobileNavigationClickAction(mobileNav);
});
var openersMobileNav = document.querySelectorAll('.wd-header-mobile-nav > a');
openersMobileNav.forEach(function(openMobileNav) {
openMobileNav.addEventListener('click', openMobileNavEvent);
});
if (closeSide) {
closeSide.addEventListener('click', function(e) {
e.preventDefault();
woodmartThemeModule.closeMobileNavigation();
});
closeSide.addEventListener('touchstart', function(e) {
e.preventDefault();
woodmartThemeModule.closeMobileNavigation();
}, {passive: false});
}
woodmartThemeModule.$document.on('keyup', function(e) {
if (e.keyCode === 27) {
var mobileNavContent = document.querySelector('.wd-side-hidden-nav');
if (mobileNavContent.classList.contains('wd-opened')) {
woodmartThemeModule.closeMobileNavigation();
}
}
});
woodmartThemeModule.mobileNavigationCloseSideWidgets(closeSideWidgets);
}
function openMobileNavEvent(e) {
e.preventDefault();
var mobileNavContent = document.querySelector('.wd-side-hidden-nav');
if (mobileNavContent.classList.contains('wd-opened')) {
woodmartThemeModule.closeMobileNavigation();
} else {
this.parentNode.classList.add('wd-opened');
woodmartThemeModule.openMobileNavigation(mobileNavContent);
}
}
window.addEventListener('load',function() {
woodmartThemeModule.mobileNavigation();
});
window.addEventListener('wdUpdatedHeader',function() {
woodmartThemeModule.mobileNavigation();
});
window.addEventListener('wdHeaderBuilderCloneCreated',function() {
var openCloneMobileNav = document.querySelector('.whb-clone .wd-header-mobile-nav > a');
if (openCloneMobileNav) {
openCloneMobileNav.addEventListener('click', openMobileNavEvent);
}
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.moreCategoriesButton = function() {
$('.wd-more-cat').each(function() {
var $wrapper = $(this);
$wrapper.find('.wd-more-cat-btn a').on('click', function(e) {
e.preventDefault();
$wrapper.toggleClass('wd-show-cat');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
});
};
$(document).ready(function() {
woodmartThemeModule.moreCategoriesButton();
});
})(jQuery);
/* global woodmart_settings, woodmartThemeModule */
(function($) {
woodmartThemeModule.onePageMenu = function() {
var scrollToRow = function(hash) {
var $htmlBody = $('html, body');
var row = $('#' + hash + ', .wd-menu-anchor[data-id="' + hash + '"]');
$htmlBody.stop(true);
if (row.length < 1) {
return;
}
var position = row.offset().top;
$htmlBody.animate({
scrollTop: position - woodmart_settings.one_page_menu_offset
}, 800);
setTimeout(function() {
activeMenuItem(hash);
}, 800);
};
var activeMenuItem = function(hash) {
var itemHash;
$('.onepage-link').each(function() {
var $this = $(this);
itemHash = $this.find('> a').attr('href').split('#')[1];
if (itemHash === hash) {
$this.siblings().removeClass('current-menu-item');
$this.parents('.whb-row').find('.onepage-link').removeClass('current-menu-item');
$this.addClass('current-menu-item');
}
});
};
woodmartThemeModule.$body.on('click', '.onepage-link > a', function(e) {
var $this = $(this),
hash = $this.attr('href').split('#')[1];
if ($('#' + hash).length < 1 && $('.wd-menu-anchor[data-id="' + hash + '"]').length < 1) {
return;
}
e.stopPropagation();
e.preventDefault();
scrollToRow(hash);
// close mobile menu
$('.wd-close-side').trigger('click');
$('.wd-fs-close').trigger('click');
});
woodmartThemeModule.$window.scroll(function () {
var scroll = woodmartThemeModule.$window.scrollTop();
var $firstLint = $('.onepage-link:first');
if ( scroll < 50 && $firstLint.length ) {
activeMenuItem($firstLint.find('> a').attr('href').split('#')[1]);
}
});
if ($('.onepage-link').length > 0) {
$('.wpb-content-wrapper > :is(.vc_row, .vc_section)').waypoint(function() {
var $this = $($(this)[0].element);
var hash = $this.attr('id');
activeMenuItem(hash);
}, {offset: 150});
$('.wd-menu-anchor').waypoint(function() {
activeMenuItem($($(this)[0].element).data('id'));
}, {
offset: function() {
return $($(this)[0].element).data('offset');
}
});
if ($('body').is('[class*="elementor-"]')) {
var locationHash = window.location.hash.split('#')[1];
if (window.location.hash.length > 1) {
setTimeout(function() {
scrollToRow(locationHash);
}, 500);
}
}
}
};
$(document).ready(function() {
woodmartThemeModule.onePageMenu();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.simpleDropdown = function() {
$('.wd-search-cat').each(function() {
var dd = $(this);
var btn = dd.find('.wd-search-cat-btn');
var input = dd.find('> input');
var list = dd.find('> .wd-dropdown');
var $searchInput = dd.parent().parent().find('.s');
$searchInput.on('focus', function() {
inputPadding();
});
btn.on('click', function(e) {
e.preventDefault();
if (typeof ($.fn.devbridgeAutocomplete) != 'undefined') {
dd.siblings('[type="text"]').devbridgeAutocomplete('hide');
}
});
list.on('click', 'a', function(e) {
e.preventDefault();
var $this = $(this);
var value = $this.data('val');
var label = $this.text();
list.find('.current-item').removeClass('current-item');
$this.parent().addClass('current-item');
if (value !== 0) {
list.find('ul:not(.children) > li:first-child').show();
} else if (value === 0) {
list.find('ul:not(.children) > li:first-child').hide();
}
btn.find('span').text(label);
input.val(value);
input.closest('form.woodmart-ajax-search').find('[type="text"]').trigger('cat_selected');
dd.removeClass('wd-opened');
inputPadding();
});
function inputPadding() {
if (woodmartThemeModule.$window.width() <= 768 || $searchInput.hasClass('wd-padding-inited') || 'yes' !== woodmart_settings.search_input_padding) {
return;
}
var paddingValue = dd.innerWidth() + dd.parent().siblings('.searchsubmit').innerWidth() + 17,
padding = 'padding-right';
if (woodmartThemeModule.$body.hasClass('rtl')) {
padding = 'padding-left';
}
$searchInput.css(padding, paddingValue);
$searchInput.addClass('wd-padding-inited');
}
});
};
$(document).ready(function() {
woodmartThemeModule.simpleDropdown();
});
window.addEventListener('wdUpdatedHeader',function() {
woodmartThemeModule.simpleDropdown();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.ajaxPortfolio = function() {
if ('no' === woodmart_settings.ajax_portfolio || 'undefined' === typeof ($.fn.pjax) || woodmartThemeModule.$body.hasClass('elementor-editor-active')) {
return;
}
var ajaxLinks = '.wd-type-links .wd-nav-portfolio a, .tax-project-cat .wd-pagination a, .post-type-archive-portfolio .wd-pagination a';
woodmartThemeModule.$body.on('click', '.tax-project-cat .wd-pagination a, .post-type-archive-portfolio .wd-pagination a', function() {
scrollToTop(true);
});
woodmartThemeModule.$document.pjax(ajaxLinks, '.wd-page-content', {
timeout : woodmart_settings.pjax_timeout,
scrollTo: false,
renderCallback: function(context, html, afterRender) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) {
context.html(html);
afterRender();
woodmartThemeModule.$document.trigger('wdPortfolioPjaxComplete');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
}
});
woodmartThemeModule.$document.on('pjax:start', function() {
var $siteContent = $('.wd-content-layout');
$siteContent.removeClass('wd-loaded');
$siteContent.addClass('wd-loading');
woodmartThemeModule.$document.trigger('wdPortfolioPjaxStart');
woodmartThemeModule.$window.trigger('scroll.loaderVerticalPosition');
});
woodmartThemeModule.$document.on('pjax:end', function() {
$('.wd-content-layout').removeClass('wd-loading');
});
woodmartThemeModule.$document.on('pjax:complete', function() {
if (!woodmartThemeModule.$body.hasClass('tax-project-cat') && !woodmartThemeModule.$body.hasClass('post-type-archive-portfolio')) {
return;
}
woodmartThemeModule.$document.trigger('wood-images-loaded');
scrollToTop(false);
$('.wd-ajax-content').removeClass('wd-loading');
});
var scrollToTop = function(type) {
if (woodmart_settings.ajax_scroll === 'no' && type === false) {
return false;
}
var $scrollTo = $(woodmart_settings.ajax_scroll_class),
scrollTo = $scrollTo.offset().top - woodmart_settings.ajax_scroll_offset;
$('html, body').stop().animate({
scrollTop: scrollTo
}, 400);
};
};
$(document).ready(function() {
woodmartThemeModule.ajaxPortfolio();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdPortfolioLoadMoreLoaded wdPortfolioPjaxComplete', function () {
woodmartThemeModule.portfolioEffects();
});
$.each([
'frontend/element_ready/wd_portfolio.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.portfolioEffects();
});
});
woodmartThemeModule.portfolioEffects = function() {
if (typeof ($.fn.panr) === 'undefined') {
return;
}
$('.wd-projects .portfolio-parallax').panr({
sensitivity : 15,
scale : false,
scaleOnHover : true,
scaleTo : 1.12,
scaleDuration : 0.45,
panY : true,
panX : true,
panDuration : 0.5,
resetPanOnMouseLeave: true
});
};
$(document).ready(function() {
woodmartThemeModule.portfolioEffects();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () {
woodmartThemeModule.portfolioLoadMore();
});
$.each([
'frontend/element_ready/wd_portfolio.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.portfolioLoadMore();
});
});
woodmartThemeModule.portfolioLoadMore = function() {
if (typeof $.fn.waypoint !== 'function') {
return;
}
var waypoint = $('.wd-portfolio-load-more.load-on-scroll').waypoint(function() {
$('.wd-portfolio-load-more.load-on-scroll').trigger('click');
}, {offset: '100%'}),
process = false;
$('.wd-portfolio-load-more').on('click', function(e) {
e.preventDefault();
var $this = $(this);
if (process || $this.hasClass('no-more-posts')) {
return;
}
process = true;
var holder = $this.parent().parent().find('.wd-projects'),
source = holder.data('source'),
action = 'woodmart_get_portfolio_' + source,
ajaxurl = woodmart_settings.ajaxurl,
dataType = 'json',
method = 'POST',
timeout,
atts = holder.data('atts'),
paged = holder.data('paged');
$this.addClass('loading');
holder.addClass('wd-loading');
var data = {
atts : atts,
paged : paged,
action: action
};
if (source === 'main_loop') {
ajaxurl = $this.attr('href');
method = 'GET';
data = atts ? { atts: atts } : {};
}
$.ajax({
url : ajaxurl,
data : data,
dataType: dataType,
method : method,
success : function(data) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) {
var items = $(html);
if (items) {
if (holder.hasClass('wd-masonry')) {
holder.append(items).isotope('appended', items);
holder.imagesLoaded().progress(function() {
holder.isotope('layout');
clearTimeout(timeout);
timeout = setTimeout(function() {
waypoint = $('.wd-portfolio-load-more.load-on-scroll').waypoint(function() {
$('.wd-portfolio-load-more.load-on-scroll').trigger('click');
}, {offset: '100%'});
}, 1000);
});
} else {
holder.append(items);
}
holder.data('paged', paged + 1);
$this.attr('href', data.nextPage);
if ('yes' === woodmart_settings.load_more_button_page_url_opt && 'no' !== woodmart_settings.load_more_button_page_url && data.currentPage){
window.history.pushState('', '', data.currentPage);
}
}
woodmartThemeModule.$document.trigger('wdPortfolioLoadMoreLoaded');
woodmartThemeModule.$document.trigger('wood-images-loaded');
if (data.status === 'no-more-posts') {
$this.addClass('no-more-posts');
$this.parent().hide();
}
});
},
error : function() {
console.log('ajax error');
},
complete: function() {
$this.removeClass('loading');
holder.removeClass('wd-loading');
process = false;
}
});
});
};
$(document).ready(function() {
woodmartThemeModule.portfolioLoadMore();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () {
woodmartThemeModule.portfolioMasonryFilters();
});
$.each([
'frontend/element_ready/wd_portfolio.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.portfolioMasonryFilters();
});
});
woodmartThemeModule.portfolioMasonryFilters = function() {
var $filer = $('.wd-nav-portfolio');
$filer.on('click', 'li', function(e) {
e.preventDefault();
var $this = $(this);
var filterValue = $this.attr('data-filter');
setTimeout(function() {
woodmartThemeModule.$document.trigger('wood-images-loaded');
}, 300);
$filer.find('.wd-active').removeClass('wd-active');
$this.addClass('wd-active');
var $masonryContainer = $this.parents('.portfolio-filter').siblings('.wd-masonry.wd-projects');
if (!$masonryContainer.length) {
$masonryContainer = $('.wd-portfolio-archive .wd-masonry.wd-projects');
}
if ($masonryContainer.length) {
$masonryContainer.isotope({ filter: filterValue });
}
});
};
$(document).ready(function() {
woodmartThemeModule.portfolioMasonryFilters();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdPortfolioPjaxComplete', function () {
woodmartThemeModule.portfolioPhotoSwipe();
});
$.each([
'frontend/element_ready/wd_portfolio.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.portfolioPhotoSwipe();
});
});
woodmartThemeModule.portfolioPhotoSwipe = function() {
woodmartThemeModule.$document.on('click', '.portfolio-enlarge', function(e) {
e.preventDefault();
var $this = $(this);
var $parent = $this.parents('.wd-carousel-item');
if ($parent.length === 0) {
$parent = $this.parents('.portfolio-entry');
}
var index = $parent.index();
var items = getPortfolioImages();
woodmartThemeModule.callPhotoSwipe(index, items);
});
var getPortfolioImages = function() {
var items = [];
$('.portfolio-entry').find('figure a img').each(function() {
var $this = $(this);
items.push({
src: $this.attr('src'),
w : $this.attr('width') ? $this.attr('width') : '300',
h : $this.attr('height') ? $this.attr('height') : '300',
});
});
return items;
};
};
$(document).ready(function() {
woodmartThemeModule.portfolioPhotoSwipe();
});
})(jQuery);
woodmartThemeModule.shaders = {
matrixVertex: '' +
'attribute vec2 a_texCoord;' +
'attribute vec2 a_position;' +
'uniform mat3 u_matrix;' +
'void main() {' +
' gl_Position = vec4( ( u_matrix * vec3(a_position, 1) ).xy, 0, 1);' +
' a_texCoord;' +
'}',
sliderWithNoise:
'precision mediump float;' +
'uniform float u_time;' +
'uniform float u_progress;' +
'uniform sampler2D u_image0;' +
'uniform vec2 u_image0_size;' +
'uniform sampler2D u_image1;' +
'uniform vec2 u_image1_size;' +
'uniform vec2 u_pixels;' +
'uniform vec2 u_mouse;' +
'uniform vec2 u_uvRate;' +
'uniform float u_scale;' +
'float rand(vec2 seed) {' +
' return fract(sin(dot(seed, vec2(1.29898,7.8233))) * 4.37585453123);' +
'}' +
'float noise(vec2 position) {' +
' vec2 block_position = floor(position);' +
' float top_left_value = rand(block_position);' +
' float top_right_value = rand(block_position + vec2(1.0, 0.0));' +
' float bottom_left_value = rand(block_position + vec2(0.0, 1.0));' +
' float bottom_right_value = rand(block_position + vec2(1.0, 1.0));' +
' vec2 computed_value = smoothstep(0.0, 1.0, fract(position));' +
' return mix(top_left_value, top_right_value, computed_value.x)' +
' + (bottom_left_value - top_left_value) * computed_value.y * (1.0 - computed_value.x)' +
' + (bottom_right_value - top_right_value) * computed_value.x * computed_value.y' +
' - 0.5;' +
'}' +
'void main() {' +
' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' +
' uv.y = 1.0 - uv.y;' +
' vec2 uv2 = uv;' +
' vec2 s = u_pixels.xy/10.;' +
' vec2 i = u_image0_size/10.;' +
' float rs = s.x / s.y;' +
' float ri = i.x / i.y;' +
' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' +
' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv = uv * s / new + offset;' +
' i = u_image1_size/10.;' +
' ri = i.x / i.y;' +
' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' +
' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv2 = uv2 * s / new + offset;' +
' float delayValue = clamp(u_progress, 0., 1.);' +
' float d = distance(u_mouse*u_uvRate, uv*u_uvRate);' +
' float ppp = ((u_progress - .5) * (u_progress - .5) - .25 );' +
' vec2 uv_offset = ppp * 1.1 * vec2( noise(uv * 10.0 + sin(u_time + uv.x * 5.0)) / 10.0, noise(uv * 10.0 + cos(u_time + uv.y * 5.0)) / 10.0);' +
' uv += uv_offset;' +
' uv2 += uv_offset;' +
' uv = (uv - vec2(.5, .5)) * u_scale + 0.5;' +
' vec4 rgba1 = texture2D( u_image0, uv );' +
' vec4 rgba2 = texture2D( u_image1, uv2 );' +
' vec4 rgba = mix(rgba1, rgba2, delayValue);' +
' gl_FragColor = rgba;' +
// ' gl_FragColor = vec4(uv, 0., 1.);' +
'}',
sliderPattern:
'precision mediump float;' +
'uniform float u_time;' +
'uniform float u_progress;' +
'uniform sampler2D u_image0;' +
'uniform vec2 u_image0_size;' +
'uniform sampler2D u_image1;' +
'uniform vec2 u_image1_size;' +
'uniform sampler2D u_image2;' +
'uniform vec2 u_image2_size;' +
'uniform vec2 u_pixels;' +
'void main() {' +
' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' +
' uv.y = 1.0 - uv.y;' +
' vec2 uv2 = uv;' +
' vec2 s = u_pixels.xy/10.;' +
' vec2 i = u_image0_size/10.;' +
' float rs = s.x / s.y;' +
' float ri = i.x / i.y;' +
' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' +
' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv = uv * s / new + offset;' +
' i = u_image1_size/10.;' +
' ri = i.x / i.y;' +
' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' +
' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv2 = uv2 * s / new + offset;' +
'vec4 disp = texture2D(u_image2, uv);' +
'float effectFactor = 0.4;' +
'vec2 distortedPosition = vec2(uv.x + u_progress * (disp.r*effectFactor), uv.y);' +
'vec2 distortedPosition2 = vec2(uv.x - (1.0 - u_progress) * (disp.r*effectFactor), uv.y);' +
'vec4 _texture = texture2D(u_image0, distortedPosition);' +
'vec4 _texture2 = texture2D(u_image1, distortedPosition2);' +
'vec4 finalTexture = mix(_texture, _texture2, u_progress);' +
'gl_FragColor = finalTexture;' +
// ' gl_FragColor = vec4(uv, 0., 1.);' +
'}',
sliderWithWave:
'precision mediump float;' +
'uniform float u_time;' +
'uniform float u_progress;' +
'uniform sampler2D u_image0;' +
'uniform vec2 u_image0_size;' +
'uniform sampler2D u_image1;' +
'uniform vec2 u_image1_size;' +
'uniform vec2 u_pixels;' +
'uniform vec2 u_mouse;' +
'uniform vec2 u_uvRate;' +
'uniform float u_scale;' +
' vec2 mirrored(vec2 v) {' +
' vec2 m = mod(v,2.);' +
' return mix(m,2.0 - m, step(1.0 ,m));' +
' }' +
' float tri(float p) {' +
' return mix(p,1.0 - p, step(0.5 ,p))*2.;' +
' }' +
'void main() {' +
' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' +
' uv.y = 1.0 - uv.y;' +
' vec2 uv2 = uv;' +
' vec2 s = u_pixels.xy/10.;' + // problem on mobile devices that is why we scale the value by 10x
' vec2 i = u_image0_size.xy/10.;' + // problem on mobile devices that is why we scale the value by 10x
' float rs = s.x / s.y;' + // 0.646
' float ri = i.x / i.y;' + // 2.23
' vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, (i.y * s.x) / i.x);' + // 375. 167.9
' vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv = uv * s / new + offset;' +
' i = u_image1_size.xy/10.;' +
' ri = i.x / i.y;' +
' new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);' +
' offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;' +
' uv2 = uv2 * s / new + offset;' +
' float delayValue = u_progress*6.5 - uv.y*2. + uv.x - 3.0;' +
' vec2 accel = vec2(0.5,2.);' +
' delayValue = clamp(delayValue,0.,1.);' +
' vec2 translateValue = u_progress + delayValue*accel;' +
' vec2 translateValue1 = vec2(-0.5,1.)* translateValue;' +
' vec2 translateValue2 = vec2(-0.5,1.)* (translateValue - 1. - accel);' +
' vec2 w = sin( sin(u_time) * vec2(0,0.3) + uv.yx*vec2(0,4.))*vec2(0,0.5);' +
' vec2 xy = w*(tri(u_progress)*0.5 + tri(delayValue)*0.5);' +
' vec2 uv1 = uv + translateValue1 + xy;' +
' uv2 = uv2 + translateValue2 + xy;' +
' vec4 rgba1 = texture2D(u_image0,mirrored(uv1));' +
' vec4 rgba2 = texture2D(u_image1,mirrored(uv2));' +
' vec4 rgba = mix(rgba1,rgba2,delayValue);' +
// ' gl_FragColor = vec4(0.1,0.1,0.1, 1.);' +
' gl_FragColor = rgba;' +
'}',
hoverWave:
'precision mediump float;' +
'uniform float u_time;' +
'uniform float u_progress;' +
'uniform sampler2D u_image;' +
'uniform vec2 u_pixels;' +
'uniform vec2 u_mouse;' +
'uniform vec2 u_uvRate;' +
'uniform float u_scale;' +
'void main() {' +
' vec2 uv = gl_FragCoord.xy/u_pixels.xy;' +
' uv.y = 1.0 - uv.y;' +
' float d = distance(u_mouse*u_uvRate, uv*u_uvRate);' +
' float ppp = ((u_progress - .5) * (u_progress - .5) - .25 );' +
' float dY = sin(uv.y * 44.005 + u_time * 4.5) * 0.02 * ppp;' +
' float dX = sin(uv.x * 30.005 + u_time * 3.2) * 0.02 * ppp;' +
' if( u_progress > 0. && d < .1 ) {' +
' dX *= smoothstep( 0., .15, (.15 - d) ) * 5.;' +
' dY *= smoothstep( 0., .15, (.15 - d) ) * 5.;' +
' }' +
' uv.y += dY;' +
' uv.x += dX;' +
' gl_FragColor = texture2D(u_image, uv);' +
'}'
};
function ShaderX(options) {
var defaults = {
container : null,
sizeContainer : null,
autoPlay : true,
vertexShader : '',
fragmentShader: '',
width : 0,
height : 0,
mouseMove : false,
distImage : false
};
this.options = jQuery.extend({}, defaults, options);
this.container = this.options.container;
this.pixelRatio = window.devicePixelRatio;
this.uniforms = {};
this.time = 0;
this.progress = 0;
this.empty = true;
this.images = {};
this.texture1 = null;
this.texture2 = null;
this.resizing = false;
this.resizingTimeout = 0;
this.border = 0;
this.scale = 1;
this.drawn = false;
this.runned = false;
this.mouseX = 0;
this.mouseY = 0;
this.loadedTextures = {};
if (this.options.autoPlay) {
this.init();
}
}
ShaderX.prototype = {
init: function() {
var that = this;
window.addEventListener('resize', function() { that.resize(); });
if (this.options.autoPlay) {
this.runned = true;
this.render();
this.raf();
}
},
render: function() {
if (!this.container.classList.contains('wd-with-webgl')) {
this.createCanvas();
this.container.append(this.canvas);
this.container.classList.add('wd-with-webgl');
}
if (this.gl && ((this.progress > 0 && this.progress < 1) || !this.drawn)) {
this.renderCanvas();
this.drawn = true;
}
},
createCanvas: function() {
this.canvas = document.createElement('CANVAS');
this.gl = this.canvas.getContext('webgl');
if (!this.gl) {
console.log('WebGL is not supported');
return;
}
this.canvas.width = this.options.width * this.pixelRatio;
this.canvas.height = this.options.height * this.pixelRatio;
var vertexShader = this.createShader(this.gl.VERTEX_SHADER, this.options.vertexShader),
fragmentShader = this.createShader(this.gl.FRAGMENT_SHADER, this.options.fragmentShader);
this.program = this.createProgram(vertexShader, fragmentShader);
var positionAttributeLocation = this.gl.getAttribLocation(this.program, 'a_position');
var positionBuffer = this.gl.createBuffer();
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, positionBuffer);
var x1 = 0;
var x2 = this.options.width * this.pixelRatio;
var y1 = 0;
var y2 = this.options.height * this.pixelRatio;
var positions = [
x1,
y1,
x2,
y1,
x1,
y2,
x1,
y2,
x2,
y1,
x2,
y2
];
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(positions), this.gl.STATIC_DRAW);
// Tell Webthis.GL how to convert from clip space to pixels
this.gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);
// Clear the canvas
this.gl.clearColor(0, 0, 0, 0);
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
// Tell it to use our program (pair of shaders)
this.gl.useProgram(this.program);
// Compute the matrices
var projectionMatrix = [
2 / this.gl.canvas.width,
0,
0,
0,
-2 / this.gl.canvas.height,
0,
-1,
1,
1
];
this.addUniform('3fv', 'u_matrix', projectionMatrix);
this.addUniform('1f', 'u_flipY', 1);
this.addUniform('1f', 'u_time', 0.0);
this.addUniform('2f', 'u_pixels', [
this.options.width * this.pixelRatio,
this.options.height * this.pixelRatio
]);
this.addUniform('1f', 'u_progress', 0);
this.addUniform('2f', 'u_resolution', [
this.gl.canvas.width,
this.gl.canvas.height
]);
this.addUniform('2f', 'u_uvRate', [
1,
1
]);
this.addUniform('1f', 'u_scale', this.scale);
if (this.options.mouseMove) {
this.addUniform('2f', 'u_mouse', [
0.5,
0
]);
}
// Turn on the attribute
this.gl.enableVertexAttribArray(positionAttributeLocation);
// Tell the attribute how to get data out of positionBuffer (ARRAY_BUFFER)
var size = 2; // 2 components per iteration
var type = this.gl.FLOAT; // the data is 32bit floats
var normalize = false; // don't normalize the data
var stride = 0; // 0 = move forward size * sizeof(type) each iteration to get the next position
var offset = 0; // start at the beginning of the buffer
this.gl.vertexAttribPointer(positionAttributeLocation, size, type, normalize, stride, offset);
var texCoordLocation = this.gl.getAttribLocation(this.program, 'a_texCoord');
// set coordinates for the rectanthis.gle
var texCoordBuffer = this.gl.createBuffer();
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, texCoordBuffer);
this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
0.0,
0.0,
1.0,
0.0,
0.0,
1.0,
0.0,
1.0,
1.0,
0.0,
1.0,
1.0
]), this.gl.STATIC_DRAW);
this.gl.enableVertexAttribArray(texCoordLocation);
this.gl.vertexAttribPointer(texCoordLocation, 2, this.gl.FLOAT, false, 0, 0);
if (this.texture1) {
this.loadImageTexture(this.texture1, 0);
}
if (this.options.distImage) {
var distImage = new Image();
this.requestCORSIfNotSameOrigin(distImage, this.options.distImage);
distImage.src = this.options.distImage;
var that = this;
distImage.onload = function() {
that.loadImageTexture(distImage, 2);
};
}
},
raf: function() {
if (!this.canvas) {
return;
}
var that = this;
function animate() {
that.time += 0.03;
that.updateUniform('u_time', that.time);
if (that.options.mouseMove) {
var currentMouse = that.getUniform('u_mouse'),
currentX = currentMouse[0],
currentY = currentMouse[1];
var newX = (!currentX) ? that.mouseX : currentX + (that.mouseX - currentX) * .05,
newY = (!currentY) ? that.mouseY : currentY + (that.mouseY - currentY) * .05;
that.updateUniform('u_mouse', [
newX,
newY
]);
}
if (that.progress < 0) {
that.progress = 0;
}
if (that.progress > 1) {
that.progress = 1;
}
that.updateUniform('u_progress', that.progress);
that.updateUniform('u_scale', that.scale);
that.render();
that.requestID = window.requestAnimationFrame(animate);
}
animate();
},
resize: function() {
var that = this;
clearTimeout(this.resizingTimeout);
this.resizingTimeout = setTimeout(function() {
if (!that.canvas) {
return;
}
var displayWidth = Math.floor(that.options.sizeContainer.offsetWidth * that.pixelRatio);
var displayHeight = Math.floor(that.options.sizeContainer.offsetHeight * that.pixelRatio);
if (that.gl.canvas.width !== displayWidth || that.gl.canvas.height !== displayHeight) {
that.gl.canvas.width = displayWidth;
that.gl.canvas.height = displayHeight;
}
that.updateUniform('u_resolution', [
displayWidth,
displayHeight
]);
that.updateUniform('u_pixels', [
displayWidth,
displayHeight
]);
that.updateUniform('u_uvRate', [
1,
displayHeight / displayWidth
]);
that.gl.viewport(0, 0, displayWidth, displayHeight);
that.drawn = false;
}, 500);
},
run: function() {
if (this.runned) {
return;
}
this.runned = true;
this.render();
this.raf();
},
stop: function() {
if (!this.runned) {
return;
}
window.cancelAnimationFrame(this.requestID);
this.destroyCanvas();
this.container.find('canvas').remove();
this.container.removeClass('wd-with-webgl');
this.runned = false;
},
renderCanvas: function() {
if (this.empty) {
return false;
}
// this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
},
destroyCanvas: function() {
if (!this.gl) {
return;
}
this.canvas = null;
this.gl.getExtension('WEBGL_lose_context').loseContext();
this.gl = null;
},
createShader: function(type, source) {
var shader = this.gl.createShader(type);
this.gl.shaderSource(shader, source);
this.gl.compileShader(shader);
var success = this.gl.getShaderParameter(shader, this.gl.COMPILE_STATUS);
if (success) {
return shader;
}
console.log(this.gl.getShaderInfoLog(shader));
this.gl.deleteShader(shader);
},
createProgram: function(vertexShader, fragmentShader) {
var program = this.gl.createProgram();
this.gl.attachShader(program, vertexShader);
this.gl.attachShader(program, fragmentShader);
this.gl.linkProgram(program);
var success = this.gl.getProgramParameter(program, this.gl.LINK_STATUS);
if (success) {
return program;
}
console.log(this.gl.getProgramInfoLog(program));
this.gl.deleteProgram(program);
},
addUniform: function(type, name, value) {
var location = this.gl.getUniformLocation(this.program, name);
this.uniforms[name] = {
location: location,
type : type
};
if (value !== false) {
this.updateUniform(name, value);
}
},
updateUniform: function(name, value) {
if (!this.gl) {
return;
}
var uniform = this.uniforms[name];
switch (uniform.type) {
case '1f':
this.gl.uniform1f(uniform.location, value);
break;
case '2f':
this.gl.uniform2f(uniform.location, value[0], value[1]);
break;
case '1i':
this.gl.uniform1i(uniform.location, value);
break;
case '3fv':
this.gl.uniformMatrix3fv(uniform.location, false, value);
break;
}
},
getUniform: function(name, value) {
if (!this.gl) {
return;
}
var uniform = this.uniforms[name];
return this.gl.getUniform(this.program, uniform.location);
},
getImageId: function(src) {
var id = '';
var parts = src.split('/');
id = parts[parts.length - 3] + '-' + parts[parts.length - 2] + '-' + parts[parts.length - 1];
return id;
},
loadImage: function(src, i, callback, preload) {
var imageId = this.getImageId(src);
var image;
if (this.images[imageId]) {
image = this.images[imageId];
if (preload) {
return;
}
if (i === 0) {
this.texture1 = image;
} else if (i === 1) {
this.texture2 = image;
}
this.loadImageTexture(image, i);
this.empty = false;
this.drawn = false;
(callback) ? callback() : '';
return;
}
image = new Image();
this.requestCORSIfNotSameOrigin(image, src);
image.src = src;
var that = this;
image.onload = function() {
that.images[imageId] = image;
if (preload) {
return;
}
if (i === 0) {
that.texture1 = image;
} else {
that.texture2 = image;
}
that.loadImageTexture(image, i);
that.empty = false;
that.drawn = false;
(callback) ? callback() : '';
};
},
requestCORSIfNotSameOrigin: function(image, src) {
if ((new URL(src, window.location.href)).origin !== window.location.origin) {
image.crossOrigin = '';
}
},
loadImageTexture: function(image, i) {
if (!this.gl) {
return;
}
// Create texture
var texture;
if (this.loadedTextures[i]) {
texture = this.loadedTextures[i];
var textureID = this.gl.TEXTURE0 + i;
this.gl.activeTexture(textureID);
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
// load image to texture
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, image);
this.addUniform('1i', 'u_image' + i, i);
this.addUniform('2f', 'u_image' + i + '_size', [
image.width,
image.height
]);
} else {
texture = this.gl.createTexture();
var textureID = this.gl.TEXTURE0 + i;
this.gl.activeTexture(textureID);
this.gl.bindTexture(this.gl.TEXTURE_2D, texture);
// Set texture parameters to be able to draw any size image
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR);
this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
// load image to texture
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, this.gl.RGBA, this.gl.UNSIGNED_BYTE, image);
this.addUniform('1i', 'u_image' + i, i);
this.addUniform('2f', 'u_image' + i + '_size', [
image.width,
image.height
]);
// flip coordinates
this.updateUniform('u_flipY', -1);
}
},
replaceImage: function(src) {
var that = this;
var imageId = this.getImageId(src);
if (this.texture2) {
that.loadImageTexture(this.texture2, 0);
that.loadImageTexture(this.texture2, 1);
}
var ease = function(t) { return t * (2 - t); };
this.loadImage(src, 1, function() {
var time = 1300;
var fps = 60;
var frameTime = 1000 / fps;
var frames = time / frameTime;
var step = 1 / frames;
var requestID;
var t = 0;
function progress() {
t += step;
that.progress = ease(t);
if (that.progress >= 1) {
window.cancelAnimationFrame(requestID);
return;
}
requestID = window.requestAnimationFrame(progress);
}
that.progress = 0;
progress();
});
}
};
/* global woodmart_settings */
woodmartThemeModule.$document.on('wdSwiperCarouselInited', function () {
woodmartThemeModule.sliderDistortion();
});
woodmartThemeModule.sliderDistortion = function() {
if ('undefined' === typeof ShaderX || woodmartThemeModule.$body.hasClass('single-woodmart_slide') || ! document.querySelector('.wd-slider.wd-anim-distortion .wd-carousel.wd-initialized')) {
return;
}
document.querySelectorAll('.wd-slider.wd-anim-distortion').forEach( function ($slider) {
var $slides = $slider.querySelectorAll('.wd-carousel .wd-slide');
if ($slides.length < 2) {
return;
}
var imgSrc = getImageSrc( $slides[0] );
var imgSrc2 = getImageSrc( $slides[1] );
if ($slider.classList.contains('webgl-inited') || !imgSrc || !imgSrc2) {
return;
}
$slider.classList.add('webgl-inited');
var shaderX = new ShaderX({
container : $slider.querySelector('.wd-carousel'),
sizeContainer : $slider,
vertexShader : woodmartThemeModule.shaders.matrixVertex,
fragmentShader: woodmartThemeModule.shaders[woodmart_settings.slider_distortion_effect] ? woodmartThemeModule.shaders[woodmart_settings.slider_distortion_effect] : woodmartThemeModule.shaders.sliderWithWave,
width : $slider.offsetWidth,
height : $slider.offsetHeight,
distImage : woodmart_settings.slider_distortion_effect === 'sliderPattern' ? woodmart_settings.theme_url + '/images/dist11.jpg' : false
});
shaderX.loadImage(imgSrc, 0, function() {
$slider.classList.add('wd-canvas-loaded');
});
shaderX.loadImage(imgSrc, 1);
shaderX.loadImage(imgSrc2, 0, undefined, true);
$slider.querySelector('.wd-carousel').addEventListener('wdSlideChange', function (e) {
var activeSlide = e.target.swiper.visibleSlides[0];
imgSrc = getImageSrc( activeSlide );
if (!imgSrc) {
return;
}
shaderX.replaceImage(imgSrc);
if (activeSlide.nextElementSibling) {
imgSrc2 = getImageSrc( activeSlide.nextElementSibling);
if ( imgSrc2 ) {
shaderX.loadImage(imgSrc2, 0, undefined, true);
}
}
});
});
function getImageSrc( slide ) {
var imageSrc = slide.dataset.imageUrl;
if ( woodmartThemeModule.$window.width() <= 1024 && slide.dataset.imageUrlMd ) {
imageSrc = slide.dataset.imageUrlMd;
}
if ( woodmartThemeModule.$window.width() <= 767 && slide.dataset.imageUrlSm ) {
imageSrc = slide.dataset.imageUrlSm;
}
return imageSrc;
}
};
window.addEventListener('load',function() {
woodmartThemeModule.sliderDistortion();
});
/* global woodmart_settings */
woodmartThemeModule.abandonedCart = function() {
var init = function() {
recoverGuestCart();
}
var recoverGuestCart = function() {
var inp_email = document.querySelector('#billing_email');
if ( ! inp_email ) {
return;
}
var privacyCkeckbox = document.querySelector('#_wd_recover_guest_cart_consent');
if (privacyCkeckbox) {
privacyCkeckbox.addEventListener('change', function (e) {
e.stopPropagation();
if (e.currentTarget.checked && inp_email.value.length && isValidEmail(inp_email.value)) {
var event = new Event('change');
inp_email.dispatchEvent(event);
}
});
}
inp_email.addEventListener('change', function (e) {
var target = e.target;
var email = target.value;
if ( ! checkPrivacy() || ! isValidEmail(email)) {
return;
}
var first_name = document.querySelector('#billing_first_name');
var last_name = document.querySelector('#billing_last_name');
var phone = document.querySelector('#billing_phone');
jQuery.ajax({
url : woodmart_settings.ajaxurl,
data : {
action: 'woodmart_recover_guest_cart',
security: woodmart_settings.abandoned_cart_security,
email,
phone: phone ? phone.value : '',
first_name: first_name ? first_name.value : '',
last_name: last_name ? last_name.value : '',
currency: woodmart_settings.abandoned_cart_currency,
language: woodmart_settings.abandoned_cart_language,
},
method : 'POST',
error : function() {
console.log('Ajax error of capturing the abandoned basket of the guest');
},
});
});
};
var isValidEmail = function(email) {
const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailPattern.test(email);
}
var checkPrivacy = function() {
if ( 'no' === woodmart_settings.abandoned_cart_needs_privacy ) {
return true;
}
var privacyInput = document.querySelector('#_wd_recover_guest_cart_consent');
return privacyInput && privacyInput.checked;
};
init();
}
window.addEventListener('load', function() {
woodmartThemeModule.abandonedCart();
});
/* global woodmart_settings, woodmartThemeModule, jQuery */
(function($) {
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.addToCart();
});
});
woodmartThemeModule.addToCart = function() {
var that = this;
var timeoutNumber = 0;
var timeout;
woodmartThemeModule.$body.on('added_to_cart', function(e, data) {
if (data && (data.stop_reload || data.e_manually_triggered)) {
return false;
}
if (woodmart_settings.add_to_cart_action === 'popup') {
var html = [
'
'
].join('');
if ($.magnificPopup?.instance?.isOpen) {
$.magnificPopup.instance.st.removalDelay = 0
$.magnificPopup.close()
}
$.magnificPopup.open({
removalDelay : 600, //delay removal by X to allow out-animation
closeMarkup : woodmart_settings.close_markup,
tLoading : woodmart_settings.loading,
fixedContentPos: true,
callbacks : {
beforeOpen: function() {
this.wrap.addClass('wd-popup-added-cart-wrap');
},
},
items : {
src : '',
type: 'inline'
}
});
$('.wd-popup-added-cart').on('click', '.close-popup', function(e) {
e.preventDefault();
$.magnificPopup.close();
});
closeAfterTimeout();
} else if (woodmart_settings.add_to_cart_action === 'widget') {
clearTimeout(timeoutNumber);
var $selector = $('.whb-sticked .wd-header-cart .wd-dropdown-cart');
if ($selector.length > 0) {
$selector.addClass('wd-opened');
} else {
$('.whb-header .wd-header-cart .wd-dropdown-cart').addClass('wd-opened');
}
var $cartOpener = $('.cart-widget-opener');
if ($cartOpener.length > 0) {
$cartOpener.first().trigger('wdOpenWidgetCart');
}
timeoutNumber = setTimeout(function() {
$('.wd-dropdown-cart').removeClass('wd-opened');
}, 3500);
closeAfterTimeout();
}
woodmartThemeModule.$document.trigger('wdActionAfterAddToCart');
});
var closeAfterTimeout = function() {
if ('yes' !== woodmart_settings.add_to_cart_action_timeout) {
return false;
}
clearTimeout(timeout);
timeout = setTimeout(function() {
$('.wd-close-side').trigger('click');
$.magnificPopup.close();
}, parseInt(woodmart_settings.add_to_cart_action_timeout_number) * 1000);
};
};
$(document).ready(function() {
woodmartThemeModule.addToCart();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.addToCartAllTypes = function() {
if (woodmart_settings.ajax_add_to_cart == false) {
return;
}
woodmartThemeModule.$body.on('submit', 'form.cart', function(e) {
var $form = $(this);
var $productWrapper = $form.parents('.single-product-page');
if ($productWrapper.length === 0) {
$productWrapper = $form.parents('.product-quick-view');
}
if ($productWrapper.hasClass('product-type-external') || $productWrapper.hasClass('product-type-zakeke') || $productWrapper.hasClass('product-type-gift-card') || 'undefined' !== typeof e.originalEvent && $(e.originalEvent.submitter).hasClass('wd-buy-now-btn')) {
return;
}
if ($form.parents('.wd-sticky-btn-cart').length > 0) {
var $stickyBtnWrap = $form.parents('.wd-sticky-btn-cart');
if ($stickyBtnWrap.hasClass('wd-product-type-external')) {
return;
}
}
e.preventDefault();
var $thisbutton = $form.find('.single_add_to_cart_button'),
data = $form.serialize();
data += '&action=woodmart_ajax_add_to_cart';
if ($thisbutton.val()) {
data += '&add-to-cart=' + $thisbutton.val();
}
$thisbutton.removeClass('added not-added');
$thisbutton.addClass('loading');
// Trigger event
woodmartThemeModule.$body.trigger('adding_to_cart', [
$thisbutton,
data
]);
$.ajax({
url : woodmart_settings.ajaxurl,
data : data,
method : 'POST',
success : function(response) {
if (!response) {
return;
}
var this_page = window.location.toString();
this_page.replace('add-to-cart', 'added-to-cart');
if (response.error && response.product_url) {
window.location = response.product_url;
return;
}
// Redirect to cart option
if (woodmart_settings.cart_redirect_after_add === 'yes') {
window.location = woodmart_settings.cart_url;
} else {
$thisbutton.removeClass('loading');
var fragments = response.fragments || {};
var cart_hash = response.cart_hash;
// Block fragments class
if (fragments) {
$.each(fragments, function(key) {
$(key).addClass('updating');
});
// Replace fragments
$.each(fragments, function(key, value) {
$(key).replaceWith(value);
});
}
// Show notices
var $noticeWrapper = $('.woocommerce-notices-wrapper');
$noticeWrapper.empty();
if (response.notices && response.notices.indexOf('error') > 0) {
$noticeWrapper.append(response.notices);
$thisbutton.addClass('not-added');
woodmartThemeModule.$body.trigger('not_added_to_cart', [
fragments,
cart_hash,
$thisbutton
]);
} else {
if ('undefined' !== typeof $.fn.magnificPopup && woodmart_settings.add_to_cart_action === 'widget') {
$.magnificPopup.close();
}
// Changes button classes
$thisbutton.addClass('added');
// Trigger event so themes can refresh other areas
woodmartThemeModule.$body.trigger('added_to_cart', [
fragments,
cart_hash,
$thisbutton
]);
}
}
},
error : function() {
console.log('ajax adding to cart error');
},
complete: function() { }
});
});
woodmartThemeModule.$body.on('click', '.variations_form .wd-buy-now-btn', function(e) {
var $this = $(this);
var $addToCartBtn = $this.siblings('.single_add_to_cart_button');
if ( 'undefined' !== typeof wc_add_to_cart_variation_params && $addToCartBtn.hasClass('disabled') ) {
e.preventDefault();
if ($addToCartBtn.hasClass('wc-variation-is-unavailable') ) {
alert( wc_add_to_cart_variation_params.i18n_unavailable_text );
} else if ( $addToCartBtn.hasClass('wc-variation-selection-needed') ) {
alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text );
}
}
});
};
$(document).ready(function() {
woodmartThemeModule.addToCartAllTypes();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.ajaxFilters = function() {
if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) === 'undefined' || woodmartThemeModule.$body.hasClass('single-product') || woodmartThemeModule.$body.hasClass('elementor-editor-active') || $('.products[data-source="main_loop"]').length === 0) {
return;
}
var filtersState = false;
var isPopstateNavigation = false;
woodmartThemeModule.$document.on('pjax:popstate', function(e) {
isPopstateNavigation = true;
});
woodmartThemeModule.$document.on('pjax:end', function() {
if (isPopstateNavigation) {
woodmartThemeModule.$document.trigger('wdShopPageInit');
isPopstateNavigation = false;
}
});
woodmartThemeModule.$body.on('click', '.post-type-archive-product .products-footer .woocommerce-pagination a', function() {
scrollToTop(true);
});
woodmartThemeModule.$document.pjax(woodmart_settings.ajax_links, '.wd-page-content', {
timeout : woodmart_settings.pjax_timeout,
scrollTo : false,
renderCallback: function(context, html, afterRender) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) {
context.html(html);
afterRender();
woodmartThemeModule.$document.trigger('wdShopPageInit');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
}
});
if (woodmart_settings.price_filter_action === 'click') {
woodmartThemeModule.$document.on('click', '.widget_price_filter form .button', function() {
var form = $('.widget_price_filter form');
$.pjax({
container: '.wd-page-content',
timeout : woodmart_settings.pjax_timeout,
url : form.attr('action'),
data : form.serialize(),
scrollTo : false,
renderCallback: function(context, html, afterRender) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) {
context.html(html);
afterRender();
woodmartThemeModule.$document.trigger('wdShopPageInit');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
}
});
return false;
});
} else if (woodmart_settings.price_filter_action === 'submit') {
woodmartThemeModule.$document.on('submit', '.widget_price_filter form', function(event) {
$.pjax.submit(event, '.wd-page-content');
});
}
woodmartThemeModule.$document.on('pjax:error', function(xhr, textStatus, error) {
console.log('pjax error ' + error);
});
woodmartThemeModule.$document.on('pjax:start', function() {
var $siteContent = $('.wd-content-layout');
$siteContent.removeClass('wd-loaded');
$siteContent.addClass('wd-loading');
woodmartThemeModule.$document.trigger('wdPjaxStart');
woodmartThemeModule.$window.trigger('scroll.loaderVerticalPosition');
});
woodmartThemeModule.$document.on('pjax:complete', function() {
woodmartThemeModule.$window.off('scroll.loaderVerticalPosition');
scrollToTop(false);
woodmartThemeModule.$document.trigger('wood-images-loaded');
$('.wd-scroll-content').on('scroll', function() {
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
if (typeof woodmart_wpml_js_data !== 'undefined' && woodmart_wpml_js_data.languages) {
$.each(woodmart_wpml_js_data.languages, function(index, language) {
$('.wpml-ls-item-' + language.code + ' .wpml-ls-link').attr('href', language.url);
});
}
});
woodmartThemeModule.$document.on('pjax:beforeReplace', function() {
if ($('.filters-area').hasClass('filters-opened') && woodmart_settings.shop_filters_close === 'yes') {
filtersState = true;
woodmartThemeModule.$body.addClass('body-filters-opened');
}
});
woodmartThemeModule.$document.on('wdShopPageInit', function() {
var $siteContent = $('.wd-content-layout');
if (filtersState) {
$('.filters-area').css('display', 'block');
woodmartThemeModule.openFilters(200);
filtersState = false;
}
$siteContent.removeClass('wd-loading');
$siteContent.addClass('wd-loaded');
});
var scrollToTop = function(type) {
if (woodmart_settings.ajax_scroll === 'no' && type === false) {
return false;
}
var $scrollTo = $(woodmart_settings.ajax_scroll_class),
scrollTo = $scrollTo.offset().top - woodmart_settings.ajax_scroll_offset;
$('html, body').stop().animate({
scrollTop: scrollTo
}, 400);
};
};
$(document).ready(function() {
woodmartThemeModule.ajaxFilters();
});
})(jQuery);
(function($) {
woodmartThemeModule.cartQuantity = function() {
var timeout;
woodmartThemeModule.$document.on('change input', '.woocommerce-cart-form__cart-item .quantity .qty', function(e) {
var $input = $(this);
clearTimeout(timeout);
if ($input.val().trim() === '') {
return;
}
timeout = setTimeout(function() {
$input.parents('.woocommerce-cart-form').find('button[name=update_cart]').trigger('click');
}, 500);
});
};
$(document).ready(function() {
woodmartThemeModule.cartQuantity();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.cartWidget = function() {
var body = woodmartThemeModule.$body;
var cartWidgetSide = $('.cart-widget-side');
var closeSide = $('.wd-close-side');
body.on('click wdOpenWidgetCart', '.cart-widget-opener', function(e) {
if (!isCart() && !isCheckout()) {
e.preventDefault();
}
if (isOpened()) {
closeWidget();
} else {
setTimeout(function() {
openWidget();
}, 10);
}
});
body.on('click touchstart', '.wd-close-side', function() {
if (isOpened()) {
closeWidget();
}
});
body.on('click', '.close-side-widget', function(e) {
e.preventDefault();
if (isOpened()) {
closeWidget();
}
});
woodmartThemeModule.$document.on('keyup', function(e) {
if (e.keyCode === 27 && isOpened()) {
closeWidget();
}
});
var closeWidget = function() {
cartWidgetSide.trigger('wdCloseSide');
cartWidgetSide.removeClass('wd-opened');
closeSide.removeClass('wd-close-side-opened');
};
var openWidget = function() {
if (isCart() || isCheckout()) {
return false;
}
cartWidgetSide.trigger('wdOpenSide');
cartWidgetSide.addClass('wd-opened');
closeSide.addClass('wd-close-side-opened');
};
var isOpened = function() {
return cartWidgetSide.hasClass('wd-opened');
};
var isCart = function() {
return woodmartThemeModule.$body.hasClass('woocommerce-cart');
};
var isCheckout = function() {
return woodmartThemeModule.$body.hasClass('woocommerce-checkout');
};
};
$(document).ready(function() {
woodmartThemeModule.cartWidget();
});
window.addEventListener('wdUpdatedHeader',function() {
woodmartThemeModule.cartWidget();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdBackHistory wdShopPageInit', function () {
woodmartThemeModule.categoriesAccordion();
});
woodmartThemeModule.categoriesAccordion = function() {
if (woodmart_settings.categories_toggle === 'no') {
return;
}
var $widget = $('.widget_product_categories, .wd-product-category-filter'),
$list = $widget.find('.product-categories'),
time = 300;
$list.find('.wd-active-parent').each(function() {
var $this = $(this);
if ($this.find(' > .wd-cats-toggle').length > 0) {
return;
}
if ($this.find(' > .children').length === 0 || $this.find(' > .children > *').length === 0) {
return;
}
if ($this.hasClass('wd-active') || $this.hasClass('wd-current-active-parent')) {
$this.children().eq(0).after('
');
$this.find('> .children').addClass('list-shown');
} else {
$this.children().eq(0).after('
');
}
});
$list.on('click', '.wd-cats-toggle', function() {
var $btn = $(this);
var $subList = $btn.parent().find('> .children');
if ($subList.hasClass('list-shown')) {
$btn.removeClass('toggle-active');
$subList.stop().slideUp(time).removeClass('list-shown');
} else {
$subList.parent().parent().find('> li > .list-shown').slideUp().removeClass('list-shown');
$subList.parent().parent().find('> li > .toggle-active').removeClass('toggle-active');
$btn.addClass('toggle-active');
$subList.stop().slideDown(time).addClass('list-shown');
}
});
};
$(document).ready(function() {
woodmartThemeModule.categoriesAccordion();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit', function() {
woodmartThemeModule.categoriesDropdowns();
});
woodmartThemeModule.categoriesDropdowns = function() {
$('.dropdown_product_cat').on('change', function() {
var $this = $(this);
if ('' !== $this.val()) {
var this_page;
var home_url = woodmart_settings.home_url;
if (home_url.indexOf('?') > 0) {
this_page = home_url + '&product_cat=' + $this.val();
} else {
this_page = home_url + '?product_cat=' + $this.val();
}
location.href = this_page;
} else {
location.href = woodmart_settings.shop_url;
}
});
$('.widget_product_categories').each(function() {
var $select = $(this).find('select');
if ($().selectWoo) {
$select.selectWoo({
minimumResultsForSearch: 5,
width : '100%',
allowClear : true,
placeholder : woodmart_settings.product_categories_placeholder,
language : {
noResults: function() {
return woodmart_settings.product_categories_no_results;
}
}
});
}
});
};
$(document).ready(function() {
woodmartThemeModule.categoriesDropdowns();
});
})(jQuery);
/* global woodmart_checkout_fields */
/* global wc_address_i18n_params */
(function($) {
// wc_address_i18n_params is required to continue, ensure the object exists
if ( 'undefined' === typeof wc_address_i18n_params ) {
return false;
}
function isRequiredField( field, isRequired ) {
if ( isRequired ) {
field.find( 'label .optional' ).remove();
field.addClass( 'validate-required' );
if ( 0 === field.find( 'label .required' ).length ) {
field.find( 'label' ).append(
'
*'
);
}
} else {
field.find( 'label .required' ).remove();
field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' );
if ( field.find( 'label .optional' ).length === 0 ) {
field.find( 'label' ).append( '
(' + wc_address_i18n_params.i18n_optional_text + ')' );
}
}
}
$( document )
.on( 'country_to_state_changing', function( event, country, wrapper ) {
if ( 0 === woodmart_checkout_fields.length ) {
return;
}
let thisform = wrapper;
let locale_fields = JSON.parse( wc_address_i18n_params.locale_fields );
$.each( locale_fields, function( key, value ) {
let field = thisform.find( value );
let fieldName = field.find('[name]').attr('name');
if ( ! woodmart_checkout_fields.hasOwnProperty(fieldName) || ! woodmart_checkout_fields[fieldName].hasOwnProperty('required') ) {
return;
}
let isRequired = woodmart_checkout_fields[fieldName]['required'];
isRequiredField( field, isRequired );
});
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.checkoutQuantity = function() {
var timeout;
woodmartThemeModule.$document.on('change input', '.woocommerce-checkout-review-order-table .quantity .qty', function() {
var input = $(this);
var qtyVal = input.val();
var itemName = input.attr('name');
var itemID = itemName.substring(itemName.indexOf('[') + 1, itemName.indexOf(']') );
var maxValue = input.attr('max');
var cart_hash_key = woodmart_settings.cart_hash_key;
var fragment_name = woodmart_settings.fragment_name;
clearTimeout(timeout);
if (parseInt(qtyVal) > parseInt(maxValue)) {
qtyVal = maxValue;
}
timeout = setTimeout(function() {
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_update_cart_item',
item_id: itemID,
qty : qtyVal
},
success : function( data ) {
if (data && data.fragments) {
$.each(data.fragments, function(key, value) {
$(key).replaceWith(value);
});
if (woodmartThemeModule.supports_html5_storage) {
sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments));
localStorage.setItem(cart_hash_key, data.cart_hash);
sessionStorage.setItem(cart_hash_key, data.cart_hash);
if (data.cart_hash) {
sessionStorage.setItem('wc_cart_created', (new Date()).getTime());
}
}
woodmartThemeModule.$body.trigger( 'wc_fragments_refreshed' );
}
$('form.checkout').trigger( 'update' );
},
dataType: 'json',
method : 'GET'
});
}, 500);
});
};
$(document).ready(function() {
woodmartThemeModule.checkoutQuantity();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.checkoutRemove = function() {
woodmartThemeModule.$document.on('click', '.wd-checkout-remove-btn', function() {
$(this)
.closest('.woocommerce-checkout-review-order-table')
.append('
');
});
};
$(document).ready(function() {
woodmartThemeModule.checkoutRemove();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.commentImage = function() {
$('form.comment-form').attr('enctype', 'multipart/form-data');
var $form = $('.comment-form');
var $input = $form.find('#wd-add-img-btn');
var allowedMimes = [];
if ($input.length === 0) {
return;
}
$.each(woodmart_settings.comment_images_upload_mimes, function(index, value) {
allowedMimes.push(String(value));
});
$form.find('#wd-add-img-btn').on('change', function() {
$form.find('.wd-add-img-count').text(woodmart_settings.comment_images_added_count_text.replace('%s', this.files.length));
});
$form.on('submit', function(e) {
$form.find('.woocommerce-error').remove();
var hasLarge = false;
var hasNotAllowedMime = false;
if ($input[0].files.length > woodmart_settings.comment_images_count) {
showError(woodmart_settings.comment_images_count_text);
e.preventDefault();
}
if ($input[0].files.length <= 0 && 'yes' === woodmart_settings.single_product_comment_images_required) {
showError(woodmart_settings.comment_required_images_error_text);
e.preventDefault();
}
Array.prototype.forEach.call($input[0].files, function(file) {
var size = file.size;
var type = String(file.type);
if (size > woodmart_settings.comment_images_upload_size) {
hasLarge = true;
}
if ($.inArray(type, allowedMimes) < 0) {
hasNotAllowedMime = true;
}
});
if (hasLarge) {
showError(woodmart_settings.comment_images_upload_size_text);
e.preventDefault();
}
if (hasNotAllowedMime) {
showError(woodmart_settings.comment_images_upload_mimes_text);
e.preventDefault();
}
});
function showError(text) {
$form.prepend('
');
}
};
$(document).ready(function() {
woodmartThemeModule.commentImage();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.countProductVisits = function () {
var live_duration = 10000;
if ( 'undefined' !== typeof woodmart_settings.counter_visitor_live_duration ) {
live_duration = woodmart_settings.counter_visitor_live_duration;
}
if ('yes' === woodmart_settings.counter_visitor_ajax_update) {
woodmartThemeModule.updateCountProductVisits();
} else if ( 'yes' === woodmart_settings.counter_visitor_live_mode) {
setInterval(woodmartThemeModule.updateCountProductVisits, live_duration);
}
}
woodmartThemeModule.updateCountProductVisits = function() {
$('.wd-visits-count').each( function () {
var $this = $(this);
var productId = $this.data('product-id');
var $count = $this.find('.wd-info-number');
if ( ! productId ) {
return;
}
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_update_count_product_visits',
product_id: productId,
count : $count.text(),
},
method : 'POST',
success : function(response) {
if (response) {
$count.text(response.count);
if (response.message) {
$this.find('.wd-count-msg').text(response.message);
}
if (!response.count) {
$this.addClass('wd-hide');
} else {
$this.removeClass('wd-hide');
}
}
},
error : function() {
console.log('ajax error');
},
complete: function() {}
});
});
};
$(document).ready(function() {
woodmartThemeModule.countProductVisits();
});
})(jQuery);
(function ($) {
$.each([
'frontend/element_ready/wd_dynamic_discounts_table.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.renderDynamicDiscountsTable();
});
});
woodmartThemeModule.renderDynamicDiscountsTable = function () {
let $variation_forms = $('.variations_form');
let $dynamicDiscountsTable = $('.wd-dynamic-discounts');
let default_price_table = $dynamicDiscountsTable.html();
function reInitPricingTableRowsClick() {
$('.wd-dynamic-discounts tbody tr').each(function () {
let $row = $(this);
let min = $row.data('min');
$row.off('click').on('click', function() {
let $quantityInput = $('.quantity input.qty[name="quantity"]');
$quantityInput.val(min).trigger('change');
});
});
}
function addActiveClassToTable( $pricing_table, currentQuantityValue ) {
$pricing_table.find('tbody tr').each(function () {
let $row = $(this);
let min = $row.data('min');
let max = $row.data('max');
if ( ( ! max && min <= currentQuantityValue ) || ( min <= currentQuantityValue && currentQuantityValue <= max ) ) {
$row.addClass('wd-active');
} else {
$row.removeClass('wd-active');
}
});
}
$variation_forms.each(function () {
let $variation_form = $(this);
$variation_form
.on('show_variation', function (event, variation) {
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_update_discount_dynamic_discounts_table',
variation_id: variation.variation_id,
},
beforeSend: function () {
$dynamicDiscountsTable.find('.wd-loader-overlay').addClass('wd-loading');
},
success : ( data ) => {
var classes = $dynamicDiscountsTable.attr('class');
woodmartThemeModule.removeDuplicatedStylesFromHTML(data, function(html) {
$dynamicDiscountsTable.replaceWith( html );
$dynamicDiscountsTable = $('.wd-dynamic-discounts');
$dynamicDiscountsTable.attr('class', classes);
reInitPricingTableRowsClick();
addActiveClassToTable( $dynamicDiscountsTable, $(this).find('[name="quantity"]').val() );
$dynamicDiscountsTable.find('.wd-loader-overlay').removeClass('wd-loading');
});
},
dataType: 'json',
method : 'GET'
});
})
.on('click', '.reset_variations', function () {
$dynamicDiscountsTable.html(default_price_table);
reInitPricingTableRowsClick();
addActiveClassToTable( $('.wd-dynamic-discounts'), $(this).closest('form').find('.quantity input.qty[name="quantity"]').val() );
});
});
reInitPricingTableRowsClick();
$('.quantity input.qty[name="quantity"]').off('change').on('change', function() {
addActiveClassToTable( $dynamicDiscountsTable, $(this).val() );
});
}
$(document).ready(() => {
woodmartThemeModule.renderDynamicDiscountsTable();
});
})(jQuery);
/* global woodmart_settings, woodmartThemeModule */
woodmartThemeModule.emailSubscriptionCheckboxes = function() {
let mainCheckbox = document.querySelector('#wd_email_subscription_consent');
function init() {
if (!mainCheckbox) {
return;
}
setupEventListeners();
}
function setupEventListeners() {
mainCheckbox.addEventListener('change', updateIndividualCheckboxes);
document.querySelectorAll('.wd-email-individual-consent').forEach(function(checkbox) {
checkbox.addEventListener('change', updateMainCheckbox);
});
}
function updateIndividualCheckboxes() {
document.querySelectorAll('.wd-email-individual-consent').forEach(function(checkbox) {
checkbox.checked = mainCheckbox.checked;
if (mainCheckbox.checked) {
checkbox.disabled = false;
checkbox.value = '1';
} else {
checkbox.disabled = true;
checkbox.value = '0';
}
});
}
function updateMainCheckbox() {
if (this.checked) {
mainCheckbox.checked = true;
mainCheckbox.value = '1';
} else if (!anyChecked()) {
mainCheckbox.checked = false;
mainCheckbox.value = '0';
}
}
function anyChecked() {
let anyChecked = false;
document.querySelectorAll('.wd-email-individual-consent').forEach(function(box) {
if (box.checked) {
anyChecked = true;
}
});
return anyChecked;
}
init();
}
window.addEventListener('load', function() {
woodmartThemeModule.emailSubscriptionCheckboxes();
});
jQuery(document).on('updated_shipping_method', function() {
jQuery(document.body).trigger('wc_update_cart');
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit', function () {
woodmartThemeModule.filterDropdowns();
});
woodmartThemeModule.filterDropdowns = function() {
function init() {
$('.wd-widget-layered-nav-dropdown-form, .wd-product-category-filter-form').each(function() {
var $form = $(this);
var $select = $form.find('select');
var slug = $select.data('slug');
$select.on( 'change', function() {
var val = $(this).val();
$('input[name=filter_' + slug + ']').val(val);
});
if ($().selectWoo) {
$select.selectWoo({
placeholder : $select.data('placeholder'),
minimumResultsForSearch: 5,
width : '100%',
allowClear : !$select.attr('multiple'),
language : {
noResults: function() {
return $select.data('noResults');
}
}
}).on('select2:unselecting', function() {
$(this).data('unselecting', true);
}).on('select2:opening', function(e) {
var $this = $(this);
if ($this.data('unselecting')) {
$this.removeData('unselecting');
e.preventDefault();
}
});
$select.on('select2:selecting', handleSingleLevelCatSelecting);
}
});
$('.wd-widget-layered-nav-dropdown__submit, .wd-product-category-filter-submit').on('click', function() {
var $this = $(this);
if (!$this.siblings('select').attr('multiple') || !woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on')) {
return;
}
ajaxAction($this);
$this.prop('disabled', true);
});
$('.wd-widget-layered-nav-dropdown-form select, .wd-product-category-filter-form select').on('change', function() {
var $this = $(this);
if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on')) {
$this.parent().submit();
return;
}
if ($this.attr('multiple')) {
return;
}
ajaxAction($this);
});
}
function ajaxAction($element) {
var $form = $element.parent('.wd-widget-layered-nav-dropdown-form, .wd-product-category-filter-form');
if (!woodmartThemeModule.$body.hasClass('woodmart-ajax-shop-on') || typeof ($.fn.pjax) === 'undefined') {
return;
}
$.pjax({
container: '.wd-page-content',
timeout : woodmart_settings.pjax_timeout,
url : $form.attr('action'),
data : $form.serialize(),
scrollTo : false,
renderCallback: function(context, html, afterRender) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) {
context.html(html);
afterRender();
woodmartThemeModule.$document.trigger('wdShopPageInit');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
}
});
}
function handleSingleLevelCatSelecting(e) {
var selectedData = e.params.args.data;
var $select = $(this);
var $option = $select.find('option[value="' + selectedData.id + '"]');
var optionClass = $option.attr('class') || '';
var levelMatch = optionClass.match(/level-(\d+)/);
if (!levelMatch) return;
var currentLevel = parseInt(levelMatch[1]);
var $nextSiblings = $option.nextAll('option');
$nextSiblings.each(function() {
var cls = $(this).attr('class') || '';
var m = cls.match(/level-(\d+)/);
if (m) {
var lvl = parseInt(m[1]);
if (lvl > currentLevel) {
$(this).prop('selected', false);
} else if (lvl <= currentLevel) {
return false;
}
}
});
if (currentLevel > 0) {
var ancestors = [];
var $prevSiblings = $option.prevAll('option');
var searchLevel = currentLevel - 1;
while (searchLevel >= 0) {
var foundAncestor = false;
$prevSiblings.each(function() {
var cls = $(this).attr('class') || '';
var m = cls.match(/level-(\d+)/);
if (m) {
var lvl = parseInt(m[1]);
if (lvl === searchLevel) {
ancestors.unshift($(this));
foundAncestor = true;
return false;
}
}
});
if (!foundAncestor) {
break;
}
searchLevel--;
}
var hasDirectParentSelected = false;
if (ancestors.length > 0) {
var directParent = ancestors[ancestors.length - 1];
hasDirectParentSelected = directParent.prop('selected');
}
ancestors.forEach(function(ancestor) {
if (hasDirectParentSelected) {
if (ancestor === ancestors[ancestors.length - 1]) {
ancestor.prop('selected', false);
}
} else {
ancestor.prop('selected', false);
}
});
}
}
init();
};
$(document).ready(function() {
woodmartThemeModule.filterDropdowns();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.filtersArea = function() {
var filters = $('.filters-area'),
time = 200;
woodmartThemeModule.$body.on('click', '.open-filters', function(e) {
e.preventDefault();
if (isOpened()) {
closeFilters();
} else {
woodmartThemeModule.openFilters(time);
setTimeout(function() {
woodmartThemeModule.$document.trigger('wdFiltersOpened');
}, time);
}
});
if (woodmart_settings.shop_filters_close === 'no') {
woodmartThemeModule.$body.on('click', woodmart_settings.ajax_links, function() {
if (isOpened()) {
closeFilters();
}
});
}
var isOpened = function() {
filters = $('.filters-area');
return filters.hasClass('filters-opened');
};
var closeFilters = function() {
filters = $('.filters-area');
filters.removeClass('filters-opened');
filters.stop().slideUp(time);
};
};
woodmartThemeModule.openFilters = function(time) {
var filters = $('.filters-area');
filters.stop().slideDown(time);
setTimeout(function() {
filters.addClass('filters-opened');
woodmartThemeModule.$document.trigger('wdFiltersOpened');
woodmartThemeModule.$body.removeClass('body-filters-opened');
woodmartThemeModule.$document.trigger('wood-images-loaded');
}, time);
};
$(document).ready(function() {
woodmartThemeModule.filtersArea();
});
})(jQuery);
jQuery.each([
'frontend/element_ready/wd_cart_table.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function($wrapper) {
woodmartThemeModule.addGiftProduct();
});
});
// Update gifts table only if turned on layout builder.
function updateGiftsTable() {
var giftsWrapper = document.querySelector('.wd-fg');
if ( ! giftsWrapper ) {
return;
}
var settings = giftsWrapper.dataset.hasOwnProperty('settings') ? JSON.parse( giftsWrapper.dataset.settings ) : false;
var loaderOverlay = giftsWrapper.querySelector('.wd-loader-overlay');
if ( loaderOverlay ) {
loaderOverlay.classList.add('wd-loading');
}
jQuery.ajax({
url : woodmart_settings.ajaxurl,
data : {
action: 'woodmart_update_gifts_table',
},
method : 'POST',
success : function(response) {
if (!response) {
return;
}
if (giftsWrapper && response.hasOwnProperty('html')) {
let tempDiv = document.createElement('div');
tempDiv.innerHTML = response.html;
if ( settings && 'no' === settings.show_title) {
var titleNode = tempDiv.querySelector('.wd-el-title');
if (titleNode) {
titleNode.remove();
}
}
childNodes = tempDiv.childNodes;
if (0 === childNodes.length) {
giftsWrapper.classList.add('wd-hide');
} else {
giftsWrapper.classList.remove('wd-hide');
}
giftsWrapper.replaceChildren(...childNodes);
}
},
error : function() {
console.log('ajax update gifts table error');
},
complete: function() {
if ( loaderOverlay ) {
loaderOverlay.classList.remove('wd-loading');
}
}
});
}
jQuery( document.body ).on( 'updated_cart_totals', updateGiftsTable);
jQuery( document.body ).on( 'updated_checkout', updateGiftsTable);
woodmartThemeModule.addGiftProduct = function() {
var isCheckout = !! document.querySelector('.woocommerce-checkout');
var listenerArea = document.querySelector('.site-content .woocommerce');
if ( ! listenerArea ) {
return;
}
listenerArea.addEventListener("click", function(e) {
var addGiftButton = e.target.closest('.wd-add-gift-product');
if ( addGiftButton ) {
e.preventDefault();
var fgTableWrapper = addGiftButton.closest('.wd-fg');
var loaderOverlay = fgTableWrapper.querySelector('.wd-loader-overlay');
var productId = addGiftButton.dataset.productId;
if ( addGiftButton.classList.contains('wd-disabled') ) {
return;
}
loaderOverlay.classList.add('wd-loading');
jQuery.ajax({
url : woodmart_settings.ajaxurl,
data : {
action: 'woodmart_add_gift_product',
product_id: productId,
security: addGiftButton.dataset.security,
is_checkout: isCheckout ? '1' : '0',
},
method : 'POST',
success : function(response) {
if (!response) {
return;
}
triggerEvent = isCheckout ? 'update_checkout' : 'wc_update_cart';
jQuery(document.body).trigger(triggerEvent);
},
error : function() {
console.log('ajax adding gift to cart error');
},
complete: function() {
loaderOverlay.classList.remove('wd-loading');
}
});
}
});
}
window.addEventListener('load',function() {
woodmartThemeModule.addGiftProduct();
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.frequentlyBoughtTogether = function () {
$('form.wd-fbt-form').each( function () {
var timeout = '';
var $form = $(this);
$form.on('change', '.wd-fbt-product input, .wd-fbt-product select', function () {
var $this = $(this);
var productsID = getProductsId($form);
var mainProduct = $form.find('input[name=wd-fbt-main-product]').val();
var btn = $form.find('.wd-fbt-purchase-btn');
if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) {
return;
}
if ( 2 > Object.keys(productsID).length ) {
btn.addClass('wd-disabled');
} else {
btn.removeClass('wd-disabled');
}
var $carousel = $form.parents('.wd-fbt').find('.wd-carousel');
var index = $this.parents('.wd-fbt-product').index();
if ( 'undefined' !== typeof $carousel[0].swiper && ! $($carousel.find('.wd-carousel-item')[index]).hasClass('wd-active') ) {
if ( 1 === index && 1 < $carousel[0].swiper.slides.length ) {
index = 0;
}
if ( 'undefined' !== typeof $carousel[0].swiper.slideTo ) {
$carousel[0].swiper.slideTo(index, 500);
}
}
clearTimeout(timeout);
timeout = setTimeout(function () {
updatePrice($form, productsID);
}, 1000);
});
$form.on('change', '.wd-fbt-product select', function () {
var $this = $(this);
var productID = $this.parents('.wd-fbt-product').data('id');
var productWrapper = $this.parents('.wd-fbt').find('.wd-product[data-id=' + productID + ']');
var $img = productWrapper.find('.product-image-link > img, .product-image-link > picture > img');
var imageSrc = $this.find('option:selected').data('image-src');
var imageSrcset = $this.find('option:selected').data('image-srcset');
if ( $img.attr('srcset') ) {
if ( ! imageSrcset ) {
imageSrcset = imageSrc;
}
$img.attr('srcset', imageSrcset);
}
$img.attr('src', imageSrc);
});
$form.on('click', '.wd-fbt-purchase-btn', function (e) {
e.preventDefault();
var $this = $(this);
if ( $this.hasClass('wd-disabled') ) {
return;
}
var productsID = getProductsId($form);
var mainProduct = $form.find('input[name=wd-fbt-main-product]').val();
var bundlesId = $form.find('input[name=wd-fbt-bundle-id]').val();
if ( ! productsID || 'undefined' === typeof productsID[mainProduct] ) {
return;
}
clearTimeout(timeout);
$this.addClass('loading');
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_purchasable_fbt_products',
products_id : productsID,
main_product : mainProduct,
bundle_id : bundlesId,
},
method : 'POST',
success : function(response) {
var $noticeWrapper = $('.woocommerce-notices-wrapper');
$noticeWrapper.empty();
if (response.notices && response.notices.indexOf('error') > 0) {
$noticeWrapper.append(response.notices);
var scrollTo = $noticeWrapper.offset().top - woodmart_settings.ajax_scroll_offset;
$('html, body').stop().animate({
scrollTop: scrollTo
}, 400);
return;
}
if ('undefined' !== typeof response.fragments) {
if ('undefined' !== typeof $.fn.magnificPopup && woodmart_settings.add_to_cart_action === 'widget') {
$.magnificPopup.close();
}
$this.addClass('added');
woodmartThemeModule.$body.trigger('added_to_cart', [
response.fragments,
response.cart_hash,
''
]);
}
},
error : function() {
console.log('ajax error');
},
complete: function() {
$this.removeClass('loading');
}
});
});
});
function getProductsId($form) {
var productsID = {};
$form.find('.wd-fbt-product').each( function () {
var $this = $(this);
var $input = $(this).find('input');
var productId = $this.data('id');
var productWrapper = $form.parents('.wd-fbt');
if ( $input.length ) {
if ( $input.is(':checked') ) {
if ( $this.find('.wd-fbt-product-variation').length ) {
productsID[productId] = $this.find('.wd-fbt-product-variation select').val();
} else {
productsID[productId] = '';
}
productWrapper.find('.product.post-' + productId ).removeClass('wd-disabled-fbt');
} else if ( ! $input.parents('.wd-fbt-form').hasClass('wd-checkbox-uncheck') ) {
productWrapper.find('.product.post-' + productId).addClass('wd-disabled-fbt');
}
} else {
if ( $this.find('.wd-fbt-product-variation').length ) {
productsID[productId] = $this.find('.wd-fbt-product-variation select').val();
} else {
productsID[productId] = '';
}
}
});
return productsID;
}
function updatePrice( $wrapper, productsID ) {
var mainProduct = $wrapper.find('input[name=wd-fbt-main-product]').val();
var bundleId = $wrapper.find('input[name=wd-fbt-bundle-id]').val();
$wrapper.find('.wd-loader-overlay').addClass( 'wd-loading' );
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_update_frequently_bought_price',
products_id : productsID,
main_product: mainProduct,
bundle_id : bundleId,
},
method : 'POST',
success : function(response) {
if (response.fragments) {
$.each( response.fragments, function( key, value ) {
$( key ).replaceWith(value);
});
}
},
error : function() {
console.log('ajax error');
},
complete: function() {
$wrapper.find('.wd-loader-overlay').removeClass('wd-loading');
}
});
}
}
$(document).ready(function() {
woodmartThemeModule.frequentlyBoughtTogether();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit wdProductsTabsLoaded wdSearchFullScreenContentLoaded wdArrowsLoadProducts wdLoadMoreLoadProducts wdUpdateWishlist wdRecentlyViewedProductLoaded', function () {
woodmartThemeModule.gridQuantity();
});
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.gridQuantity();
});
});
woodmartThemeModule.gridQuantity = function() {
$('.wd-product').on('change input', '.quantity .qty', function() {
var $this = $(this);
var add_to_cart_button = $this.parent().parent().find('.add_to_cart_button');
add_to_cart_button.attr('data-quantity', $this.val());
add_to_cart_button.attr('href', '?add-to-cart=' + add_to_cart_button.attr('data-product_id') + '&quantity=' + $this.val());
});
};
$(document).ready(function() {
woodmartThemeModule.gridQuantity();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.headerCategoriesMenu = function() {
if (woodmartThemeModule.windowWidth > 1024) {
return;
}
var categories = $('.wd-header-cats'),
catsUl = categories.find('.categories-menu-dropdown'),
subCategories = categories.find('.menu-item-has-children'),
button = categories.find('.menu-opener'),
time = 200,
iconDropdown = '
';
subCategories.find('> a').before(iconDropdown);
catsUl.on('click', '.drop-category', function() {
var $this = $(this);
var sublist = $this.parent().find('> .wd-dropdown-menu, >.sub-sub-menu');
if (sublist.hasClass('child-open')) {
$this.removeClass('act-icon');
sublist.slideUp(time).removeClass('child-open');
} else {
$this.addClass('act-icon');
sublist.slideDown(time).addClass('child-open');
}
});
categories.on('click', '.menu-opener', function(e) {
e.preventDefault();
if (isOpened()) {
closeCats();
} else {
openCats();
}
});
catsUl.on('click', 'a', function() {
closeCats();
catsUl.stop().attr('style', '');
});
var isOpened = function() {
return catsUl.hasClass('categories-opened');
};
var openCats = function() {
catsUl.addClass('categories-opened').stop().slideDown(time);
};
var closeCats = function() {
catsUl.removeClass('categories-opened').stop().slideUp(time);
};
};
$(document).ready(function() {
woodmartThemeModule.headerCategoriesMenu();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('pjax:complete wdProductsTabsLoaded wdShopPageInit wdLoadMoreLoadProducts wdArrowsLoadProducts', function() {
woodmartThemeModule.imagesGalleryInLoop();
});
woodmartThemeModule.$document.on('wdRecentlyViewedProductLoaded', function() {
$('.wd-products-element .products, .wd-carousel-container.products .wd-product')
.each(function ( key, product ) {
let $product = $(this);
$product.trigger('wdImagesGalleryInLoopOn', $product);
});
});
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default',
'frontend/element_ready/wd_archive_products.default',
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.imagesGalleryInLoop();
});
});
woodmartThemeModule.imagesGalleryInLoop = function() {
function addGalleryLoopEvents( neededProduct ) {
$( neededProduct )
.on('mouseover mouseout', '.wd-product-grid-slide', function( e ) {
let $hoverSlide = $(this);
let $product = $hoverSlide.closest('.wd-product');
let $productsHolder = $product.closest('.wd-products, .wd-products .wd-carousel');
let productsGalleryAtts = $productsHolder.length > 0 && $productsHolder.data('grid-gallery') ? $productsHolder.data('grid-gallery') : {};
let grid_gallery_control = woodmart_settings.grid_gallery_control;
if ( productsGalleryAtts.hasOwnProperty( 'grid_gallery_control' ) && ( null === productsGalleryAtts.grid_gallery_control || ( 'string' === typeof productsGalleryAtts.grid_gallery_control && productsGalleryAtts.grid_gallery_control.length > 0 ) ) ) {
grid_gallery_control = productsGalleryAtts.grid_gallery_control;
}
if ( 'hover' !== grid_gallery_control || woodmartThemeModule.$window.width() <= 1024 ) {
return;
}
let $imagesIndicator = $product.find('.wd-product-grid-slider-pagin');
let $productImage = $product.find('.product-image-link > img, .product-image-link > picture > img');
let $productImageSource = $product.find('.product-image-link picture source');
let hoverImageUrl;
let hoverImageSrcSet;
let currentImagesIndicator;
if ( 'mouseover' === e.type ) {
let hoverSliderId = $hoverSlide.data('image-id');
hoverImageUrl = $hoverSlide.data('image-url');
hoverImageSrcSet = $hoverSlide.data('image-srcset');
currentImagesIndicator = $imagesIndicator.find(`[data-image-id="${hoverSliderId}"]`);
} else {
hoverImageUrl = $product.find('.wd-product-grid-slide[data-image-id="0"]').data('image-url');
hoverImageSrcSet = $product.find('.wd-product-grid-slide[data-image-id="0"]').data('image-srcset');
currentImagesIndicator = $imagesIndicator.find('[data-image-id="0"]');
}
currentImagesIndicator.siblings().removeClass('wd-active');
currentImagesIndicator.addClass('wd-active');
$productImage.attr('src', hoverImageUrl );
if ( hoverImageSrcSet ) {
$productImage.attr('srcset', hoverImageSrcSet );
$productImageSource.attr('srcset', hoverImageSrcSet );
} else if ( $productImage.attr('srcset' ) ) {
$productImage.attr('srcset', null);
$productImageSource.attr('srcset', null);
}
})
.on('click', '.wd-prev, .wd-next', function( e ) {
e.preventDefault();
let $navButton = $(this);
let $productsHolder = $navButton.closest('.wd-products, .wd-products .wd-carousel');
let productsGalleryAtts = $productsHolder.length > 0 && $productsHolder.data('grid-gallery') ? $productsHolder.data('grid-gallery') : {};
let grid_gallery_control = woodmart_settings.grid_gallery_control;
let grid_gallery_enable_arrows = woodmart_settings.grid_gallery_enable_arrows;
if ( productsGalleryAtts.hasOwnProperty( 'grid_gallery_control' ) && ( null === productsGalleryAtts.grid_gallery_control || ( 'string' === typeof productsGalleryAtts.grid_gallery_control && productsGalleryAtts.grid_gallery_control.length > 0 ) ) ) {
grid_gallery_control = productsGalleryAtts.grid_gallery_control;
}
if ( productsGalleryAtts.hasOwnProperty( 'grid_gallery_enable_arrows' ) && ( null === productsGalleryAtts.grid_gallery_enable_arrows || ( 'string' === typeof productsGalleryAtts.grid_gallery_enable_arrows && productsGalleryAtts.grid_gallery_enable_arrows.length > 0 ) ) ) {
grid_gallery_enable_arrows = productsGalleryAtts.grid_gallery_enable_arrows;
}
if ( ( woodmartThemeModule.$window.width() < 1024 && ( ! grid_gallery_enable_arrows || 'none' === grid_gallery_enable_arrows ) ) || ( woodmartThemeModule.$window.width() > 1024 && ( ! grid_gallery_control || 'arrows' !== grid_gallery_control ) ) ) {
return;
}
let $product = $navButton.closest('.wd-product');
let $productImage = $product.find('.product-image-link > img, .product-image-link > picture > img');
let $productImageSource = $product.find('.product-image-link picture source');
let $imagesList = $product.find('.wd-product-grid-slide');
let index = $imagesList.hasClass('wd-active') ? $product.find('.wd-product-grid-slide.wd-active').data('image-id') : 0;
if ( $(this).hasClass('wd-prev') ) {
index--;
} else if ( $(this).hasClass('wd-next') ) {
index++;
}
if ( -1 === index ) {
index = $imagesList.length - 1;
} else if ( $imagesList.length === index ) {
index = 0;
}
let $currentImage = $product.find(`.wd-product-grid-slide[data-image-id="${index}"]`);
let hoverImageUrl = $currentImage.data('image-url');
let hoverImageSrcSet = $currentImage.data('image-srcset');
$imagesList.removeClass('wd-active');
$currentImage.addClass('wd-active');
$productImage.attr('src', hoverImageUrl )
if ( hoverImageSrcSet ) {
$productImage.attr('srcset', hoverImageSrcSet );
$productImageSource.attr('srcset', hoverImageSrcSet );
} else if ( $productImage.attr('srcset' ) ) {
$productImage.attr('srcset', null);
$productImageSource.attr('srcset', null);
}
});
}
function removeGalleryLoopEvents( neededProduct ) {
$( neededProduct )
.off( 'mouseover mouseout', '.wd-product-grid-slide' )
.off( 'click', '.wd-prev, .wd-next' );
}
$('.wd-product')
.each(function ( key, product ) {
removeGalleryLoopEvents( product );
addGalleryLoopEvents( product );
});
woodmartThemeModule.$document
.on('wdImagesGalleryInLoopOff', '.wd-product', function( e, neededProduct = this ) {
removeGalleryLoopEvents( neededProduct );
})
.on('wdImagesGalleryInLoopOn', '.wd-product', function( e, neededProduct = this ) {
addGalleryLoopEvents( neededProduct );
});
};
$(document).ready(function() {
woodmartThemeModule.imagesGalleryInLoop();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdReplaceMainGalleryNotQuickView wdShowVariationNotQuickView wdResetVariation', function () {
setTimeout( function() {
woodmartThemeModule.initZoom();
}, 300);
});
$.each([
'frontend/element_ready/wd_single_product_gallery.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.initZoom();
});
});
woodmartThemeModule.initZoom = function() {
var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)');
if (woodmart_settings.zoom_enable !== 'yes') {
return false;
}
var zoomOptions = {
touch: false
};
if ('ontouchstart' in window) {
zoomOptions.on = 'click';
}
var $productGallery = $('.woocommerce-product-gallery');
if ($productGallery.hasClass('thumbs-position-bottom') || $productGallery.hasClass('thumbs-position-left')) {
document.querySelector('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)').addEventListener('wdSlideChange', function (e) {
var $wrapper = $mainGallery.find('.wd-carousel-item').eq(e.target.swiper.activeIndex).find('.woocommerce-product-gallery__image');
init($wrapper);
});
init($mainGallery.find('.wd-carousel-item').eq(0).find('.woocommerce-product-gallery__image'));
} else {
$mainGallery.find('.wd-carousel-item').each(function() {
var $wrapper = $(this).find('.woocommerce-product-gallery__image');
init($wrapper);
});
}
function init($wrapper) {
var image = $wrapper.find('img');
if (image.data('large_image_width') > $wrapper.width() ) {
$wrapper.trigger('zoom.destroy');
$wrapper.zoom(zoomOptions);
}
}
};
$(document).ready(function() {
woodmartThemeModule.initZoom();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.loginDropdown = function() {
if (woodmartThemeModule.windowWidth <= 1024) {
return;
}
$('.wd-dropdown-register').each(function() {
var $this = $(this),
$content = $this.find('.login-dropdown-inner');
$content.find('input[id="username"]').on('click', function() {
$this.addClass('wd-active-login').removeClass('wd-active-link');
});
$content.find('input[id="username"]').on('input', function() {
if ($this.hasClass('wd-active-login')) {
$this.removeClass('wd-active-login').addClass('wd-active-link');
}
});
$content.find('input').not('[id="username"]').on('click', function() {
$this.removeClass('wd-active-login').removeClass('wd-active-link');
});
woodmartThemeModule.$document.click(function(a) {
if ('undefined' != typeof (a.target.className.length) && a.target.className.indexOf('wd-dropdown-register') === -1 && a.target.className.indexOf('input-text') === -1) {
$this.removeClass('wd-active-login').removeClass('wd-active-link');
}
});
$('.wd-dropdown-register').on('mouseout', function() {
if ($this.hasClass('wd-active-link')) {
$this.removeClass('wd-active-link');
}
}).on('mouseleave', function() {
if ($this.hasClass('wd-active-link')) {
$this.removeClass('wd-active-link');
}
});
});
};
$(document).ready(function() {
woodmartThemeModule.loginDropdown();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit', function () {
woodmartThemeModule.loginSidebar();
});
woodmartThemeModule.loginSidebar = function() {
var body = woodmartThemeModule.$body;
var loginFormSide = $('.login-form-side');
var closeSide = $('.wd-close-side');
woodmartThemeModule.$document.on('click', '.login-side-opener', function(e) {
if (!loginFormSide.length) {
return
}
e.preventDefault();
if (isOpened()) {
closeWidget();
} else {
setTimeout(function() {
openWidget();
}, 10);
}
});
body.on('click touchstart', '.wd-close-side', function() {
if (isOpened()) {
closeWidget();
}
});
body.on('click', '.close-side-widget', function(e) {
e.preventDefault();
if (isOpened()) {
closeWidget();
}
});
woodmartThemeModule.$document.on('keyup', function(e) {
if (e.keyCode === 27 && isOpened()) {
closeWidget();
}
});
var closeWidget = function() {
loginFormSide.trigger('wdCloseSide');
loginFormSide.removeClass('wd-opened');
closeSide.removeClass('wd-close-side-opened');
};
var openWidget = function() {
loginFormSide.trigger('wdOpenSide');
loginFormSide.find('form').removeClass('hidden-form');
loginFormSide.addClass('wd-opened');
closeSide.addClass('wd-close-side-opened');
};
if (loginFormSide.find('.woocommerce-notices-wrapper > ul').length > 0) {
openWidget();
}
var isOpened = function() {
return loginFormSide.hasClass('wd-opened');
};
};
$(document).ready(function() {
woodmartThemeModule.loginSidebar();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.loginTabs = function() {
var tabs = $('.wd-register-tabs'),
btn = tabs.find('.wd-switch-to-register'),
title = $('.col-register-text h2'),
loginText = tabs.find('.login-info'),
classOpened = 'active-register',
loginLabel = btn.data('login'),
registerLabel = btn.data('register'),
loginTitleLabel = btn.data('login-title'),
registerTitleLabel = btn.data('reg-title');
btn.on('click', function(e) {
e.preventDefault();
if (isShown()) {
hideRegister();
} else {
showRegister();
}
if (woodmartThemeModule.$window.width() < 769) {
$('html, body').stop().animate({
scrollTop: tabs.offset().top - 90
}, 400);
}
});
var showRegister = function() {
tabs.addClass(classOpened);
btn.text(loginLabel);
if (loginText.length > 0) {
title.text(loginTitleLabel);
}
};
var hideRegister = function() {
tabs.removeClass(classOpened);
btn.text(registerLabel);
if (loginText.length > 0) {
title.text(registerTitleLabel);
}
};
var isShown = function() {
return tabs.hasClass(classOpened);
};
};
$(document).ready(function() {
woodmartThemeModule.loginTabs();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.miniCartQuantity = function() {
var timeout;
woodmartThemeModule.$document.on('change input', '.woocommerce-mini-cart .quantity .qty', function() {
var input = $(this);
var qtyVal = input.val();
var itemID = input.parents('.woocommerce-mini-cart-item').data('key');
var maxValue = input.attr('max');
var cart_hash_key = woodmart_settings.cart_hash_key;
var fragment_name = woodmart_settings.fragment_name;
clearTimeout(timeout);
if (parseInt(qtyVal) > parseInt(maxValue)) {
qtyVal = maxValue;
}
timeout = setTimeout(function() {
input.parents('.mini_cart_item').addClass('wd-loading');
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
action : 'woodmart_update_cart_item',
item_id: itemID,
qty : qtyVal
},
success : function(data) {
if (data && data.fragments) {
$.each(data.fragments, function(key, value) {
if ($(key).hasClass('widget_shopping_cart_content')) {
var dataItemValue = $(value).find('.woocommerce-mini-cart-item[data-key="' + itemID + '"]');
var dataFooterValue = $(value).find('.shopping-cart-widget-footer');
var $itemSelector = $(key).find('.woocommerce-mini-cart-item[data-key="' + itemID + '"]');
if (!data.cart_hash || !dataItemValue.length) {
$(key).replaceWith(value);
} else {
$itemSelector.replaceWith(dataItemValue);
$('.shopping-cart-widget-footer').replaceWith(dataFooterValue);
}
} else {
$(key.replace('_wd', '')).replaceWith(value);
}
});
if (woodmartThemeModule.supports_html5_storage) {
sessionStorage.setItem(fragment_name, JSON.stringify(data.fragments));
localStorage.setItem(cart_hash_key, data.cart_hash);
sessionStorage.setItem(cart_hash_key, data.cart_hash);
if (data.cart_hash) {
sessionStorage.setItem('wc_cart_created', (new Date()).getTime());
}
}
woodmartThemeModule.$body.trigger( 'wc_fragments_refreshed' );
}
},
dataType: 'json',
method : 'GET'
});
}, 500);
});
};
$(document).ready(function() {
woodmartThemeModule.miniCartQuantity();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.onRemoveFromCart = function() {
if ('no' === woodmart_settings.woocommerce_ajax_add_to_cart) {
return;
}
woodmartThemeModule.$document.on('click', '.widget_shopping_cart .remove', function(e) {
e.preventDefault();
$(this).parent().addClass('removing-process');
});
};
$(document).ready(function() {
woodmartThemeModule.onRemoveFromCart();
});
})(jQuery);
/* global woodmart_settings, woodmartThemeModule, jQuery */
(function($) {
woodmartThemeModule.product360Button = function() {
if ('undefined' === typeof $.fn.magnificPopup) {
return;
}
$('.product-360-button a').magnificPopup({
type : 'inline',
mainClass : 'mfp-fade',
preloader : false,
closeMarkup : woodmart_settings.close_markup,
tLoading : woodmart_settings.loading,
fixedContentPos: true,
removalDelay : 600,
callbacks : {
beforeOpen: function() {
this.wrap.addClass('wd-product-360-view-wrap');
},
open: function() {
woodmartThemeModule.$window.trigger('resize');
},
}
});
};
$(document).ready(function() {
woodmartThemeModule.product360Button();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit', function () {
woodmartThemeModule.productFilters();
});
$.each([
'frontend/element_ready/wd_product_filters.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productFilters();
});
});
woodmartThemeModule.productFilters = function() {
// Price slider init.
woodmartThemeModule.$body.on('filter_price_slider_create filter_price_slider_slide', function(event, min, max, minPrice, maxPrice, $slider) {
if ('undefined' === typeof accounting) {
return
}
var minHtml = accounting.formatMoney(min, {
symbol : woocommerce_price_slider_params.currency_format_symbol,
decimal : woocommerce_price_slider_params.currency_format_decimal_sep,
thousand : woocommerce_price_slider_params.currency_format_thousand_sep,
precision: woocommerce_price_slider_params.currency_format_num_decimals,
format : woocommerce_price_slider_params.currency_format
});
var maxHtml = accounting.formatMoney(max, {
symbol : woocommerce_price_slider_params.currency_format_symbol,
decimal : woocommerce_price_slider_params.currency_format_decimal_sep,
thousand : woocommerce_price_slider_params.currency_format_thousand_sep,
precision: woocommerce_price_slider_params.currency_format_num_decimals,
format : woocommerce_price_slider_params.currency_format
});
$slider.siblings('.filter_price_slider_amount').find('span.from').html(minHtml);
$slider.siblings('.filter_price_slider_amount').find('span.to').html(maxHtml);
var $results = $slider.parents('.wd-pf-checkboxes').find('.wd-pf-results');
var value = $results.find('.selected-value');
if (min === minPrice && max === maxPrice) {
value.remove();
} else {
if (value.length === 0) {
$results.prepend('
' + minHtml + ' - ' + maxHtml + '');
} else {
value.html(minHtml + ' - ' + maxHtml);
}
}
woodmartThemeModule.$body.trigger('price_slider_updated', [
min,
max
]);
});
$('.wd-pf-price-range .price_slider_widget').each(function() {
var $this = $(this);
var $minInput = $this.siblings('.filter_price_slider_amount').find('.min_price');
var $maxInput = $this.siblings('.filter_price_slider_amount').find('.max_price');
var minPrice = parseInt($minInput.data('min'));
var maxPrice = parseInt($maxInput.data('max'));
var currentUrlParams = new URL(window.location.href);
var currentMinPrice = parseInt(currentUrlParams.searchParams.has('min_price') ? currentUrlParams.searchParams.get('min_price') : $minInput.val());
var currentMaxPrice = parseInt(currentUrlParams.searchParams.has('max_price') ? currentUrlParams.searchParams.get('max_price') : $maxInput.val());
$('.price_slider_widget, .price_label').show();
if (isNaN(currentMinPrice)) {
currentMinPrice = minPrice;
}
if (isNaN(currentMaxPrice)) {
currentMaxPrice = maxPrice;
}
$this.slider({
range : true,
animate: true,
min : minPrice,
max : maxPrice,
values : [
currentMinPrice,
currentMaxPrice
],
create : function() {
if (currentMinPrice === minPrice && currentMaxPrice === maxPrice) {
$minInput.val('');
$maxInput.val('');
}
woodmartThemeModule.$body.trigger('filter_price_slider_create', [
currentMinPrice,
currentMaxPrice,
minPrice,
maxPrice,
$this
]);
$this.closest('.wd-pf-price-range').on('click', '.wd-pf-results li', function(e) {
var $selectedValueNode = $(this);
var $filter = $selectedValueNode.closest('.wd-pf-checkboxes');
var $activeFilterLink = $filter.find('.pf-value');
$filter.find('.min_price').val('');
$filter.find('.max_price').val('');
$filter.find('.price_slider_widget').slider('values', [$filter.find('.min_price').data('min'), $filter.find('.max_price').data('max') ]);
$selectedValueNode.remove();
if ( 0 === $activeFilterLink.length ) {
return;
}
var url = new URL($activeFilterLink.attr('href'));
url.searchParams.delete('min_price');
url.searchParams.delete('max_price');
$activeFilterLink.attr('href', url.href);
if ($activeFilterLink) {
$activeFilterLink.trigger('click');
}
});
},
slide : function(event, ui) {
if (ui.values[0] === minPrice && ui.values[1] === maxPrice) {
$minInput.val('');
$maxInput.val('');
} else {
$minInput.val(ui.values[0]);
$maxInput.val(ui.values[1]);
}
woodmartThemeModule.$body.trigger('filter_price_slider_slide', [
ui.values[0],
ui.values[1],
minPrice,
maxPrice,
$this
]);
},
change : function(event, ui) {
woodmartThemeModule.$body.trigger('price_slider_change', [
ui.values[0],
ui.values[1]
]);
}
});
});
var $forms = $('form.wd-product-filters');
var removeValue = function($mainInput, currentVal) {
if ($mainInput.length === 0) {
return;
}
var mainInputVal = $mainInput.val();
if (mainInputVal.indexOf(',') > 0) {
$mainInput.val(mainInputVal.replace(',' + currentVal, '').replace(currentVal + ',', ''));
} else {
$mainInput.val(mainInputVal.replace(currentVal, ''));
}
}
var defaultPjaxArgs = {
container : '.wd-page-content',
timeout : woodmart_settings.pjax_timeout,
scrollTo : false,
renderCallback: function(context, html, afterRender) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(html, function(html) {
context.html(html);
afterRender();
woodmartThemeModule.$document.trigger('wdShopPageInit');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
},
};
$forms.each(function(index, $form) {
$form = $($form);
var $mainSubmitButton = $form.find('.wd-pf-btn button, .wp-block-wd-button');
var $checkboxes = $form.find('.wd-pf-checkboxes');
//Label clear.
$form.on('click', '.wd-pf-results li', function(e) {
var $selectedValueNode = $(this);
var selectedValue = $selectedValueNode.data('title');
var $filter = $selectedValueNode.closest('.wd-pf-checkboxes');
var $activeFilterLink = $filter.find(`.pf-value[data-val="${selectedValue}"]`);
if ( $filter.hasClass('wd-pf-price-range') ) {
return;
}
if ( 0 === $mainSubmitButton.length ) {
$activeFilterLink.trigger('click');
} else {
var $mainInput = $filter.find('.result-input');
if ( $filter.hasClass('wd-pf-categories') ) {
$filter.closest('form.wd-product-filters').attr('action', woodmart_settings.shop_url);
}
removeValue($mainInput, selectedValue);
$activeFilterLink.closest('li').removeClass('wd-active');
$selectedValueNode.remove();
}
});
// Show dropdown on "click".
$checkboxes.each(function() {
var $this = $(this);
var $btn = $this.find('.wd-pf-title');
var multiSelect = $this.hasClass('multi_select');
$btn.on('click keyup', function(e) {
if (e.type === 'keyup' && e.keyCode !== 13) {
return;
}
var target = e.target;
if ($(target).is($btn.find('.selected-value'))) {
return;
}
if (!$this.hasClass('wd-opened')) {
$this.addClass('wd-opened');
setTimeout(function() {
woodmartThemeModule.$document.trigger('wdProductFiltersOpened');
}, 300);
} else {
close();
}
});
woodmartThemeModule.$document.on('click', function(e) {
var target = e.target;
if ($this.hasClass('wd-opened') && (multiSelect && !$(target).is($this) && !$(target).parents().is($this)) || (!multiSelect && !$(target).is($btn) && !$(target).parents().is($btn))) {
close();
}
});
var close = function() {
$this.removeClass('wd-opened');
};
});
if ( 0 === $mainSubmitButton.length ) {
// Submit form on "Dropdown select".
$form.on('click', '.wd-pf-checkboxes li > .pf-value, .filter_price_slider_amount .pf-value', function(e) {
var $priceAmount = $form.find('.filter_price_slider_amount');
if ( $priceAmount.length > 0 ) {
var $priceButton = $priceAmount.find('.pf-value');
var $minInput = $priceButton.siblings('.min_price');
var $maxInput = $priceButton.siblings('.max_price');
var $link = $priceButton.attr('href');
var url = new URL($link);
if ($minInput.length && $maxInput.length) {
if ($minInput.val()) {
url.searchParams.set($minInput.attr('name'), $minInput.val());
} else {
url.searchParams.delete($minInput.attr('name'));
}
if ($maxInput.val()) {
url.searchParams.set($maxInput.attr('name'), $maxInput.val());
} else {
url.searchParams.delete($maxInput.attr('name'));
}
$priceButton.attr('href', url.href);
}
$minInput.val('');
$maxInput.val('');
}
// Send pjax.
if ( '1' === woodmart_settings.ajax_shop && 'undefined' !== typeof ($.fn.pjax) ) {
$.pjax.click(e, defaultPjaxArgs);
}
});
} else {
// Submit form on "Button click".
$form.on('click', '.wd-pf-checkboxes li > .pf-value', function(e) {
e.preventDefault();
var $dataInput = $(this);
var $thisForm = $dataInput.closest('form.wd-product-filters');
var $li = $dataInput.parent();
var $widget = $dataInput.parents('.wd-pf-checkboxes');
var $mainInput = $widget.find('.result-input');
var $results = $widget.find('.wd-pf-results');
var multiSelect = $widget.hasClass('multi_select');
var mainInputVal = $mainInput.val();
var currentText = $dataInput.data('title');
var currentVal = $dataInput.data('val');
if (multiSelect) {
if (!$li.hasClass('wd-active')) {
if (mainInputVal === '') {
$mainInput.val(currentVal);
} else {
$mainInput.val(mainInputVal + ',' + currentVal);
}
$results.prepend('
' + currentText + '');
$li.addClass('wd-active');
} else {
removeValue($mainInput, currentVal);
$results.find('li[data-title="' + currentVal + '"]').remove();
$li.removeClass('wd-active');
}
} else {
if (!$li.hasClass('wd-active')) {
$mainInput.val(currentVal);
$results.find('.selected-value').remove();
$results.prepend('
' + currentText + '');
$li.parents('.wd-scroll-content').find('.wd-active').removeClass('wd-active');
$li.addClass('wd-active');
} else {
$mainInput.val('');
$results.find('.selected-value').remove();
$li.removeClass('wd-active');
}
}
if ( $widget.hasClass('wd-pf-categories') ) {
var url = new URL($dataInput.attr('href'));
var link = woodmart_settings.shop_url;
if ( $li.hasClass('wd-active') ) {
var link = url.origin + url.pathname;
}
$thisForm.attr('action', link);
}
});
// Send pjax.
if ( '1' === woodmart_settings.ajax_shop && 'undefined' !== typeof ($.fn.pjax) ) {
$(document)
.off('submit', 'form.wd-product-filters')
.on('submit', 'form.wd-product-filters', function(e) {
e.preventDefault();
$form = $(this);
defaultPjaxArgs.url = $form.attr('action');
defaultPjaxArgs.data = $form.find(':input[value!=""]').serialize();
$.pjax(defaultPjaxArgs);
});
} else {
$(document)
.off('submit', 'form.wd-product-filters')
.on('submit', 'form.wd-product-filters', function(e) {
$(':input', this).each(function() {
this.disabled = !($(this).val());
});
});
}
}
});
woodmartThemeModule.$document.on('click', '.wd-product-filters > a.btn', function(e) {
e.preventDefault();
$(this).parent('form').trigger('submit');
});
};
$(document).ready(function() {
woodmartThemeModule.productFilters();
});
})(jQuery);
/* global woodmartConfig, woodmartThemeModule, woodmart_settings */
(function($) {
'use strict';
woodmartThemeModule.$document.on('wdReplaceMainGallery', function() {
woodmartThemeModule.productVideoGallery();
});
$.each([
'frontend/element_ready/wd_single_product_gallery.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productVideoGallery();
});
});
woodmartThemeModule.productVideoGallery = function() {
var $mainGallery = $('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)');
var $mainGalleryWrapper = $mainGallery.parents('.woocommerce-product-gallery');
var $variation_form = $('.variations_form');
woodmartThemeModule.$document.on('click', '.wd-carousel-item.wd-with-video .wd-play-video', function (e) {
e.preventDefault();
var $button = $(this);
var $wrapper = $button.parents('.wd-carousel-item');
var $video = $wrapper.find('iframe');
if ( ! $video.length ) {
$video = $wrapper.find('video');
}
if ( $wrapper.hasClass('wd-inited') || ! $video.length ) {
return;
}
var videoScr = $video.attr('src');
if ( ! videoScr ) {
videoScr = $video.data('lazy-load');
$video.attr('src', videoScr);
}
if ( ! videoScr ) {
return;
}
if ( ! $wrapper.hasClass('wd-video-playing') ) {
$wrapper.addClass('wd-loading');
}
videoInited( videoScr, $wrapper );
});
woodmartThemeModule.$document.on('wdPhotoSwipeBeforeInited', function( event, gallery ) {
gallery.listen('initialLayout', function() {
if ( 'undefined' === typeof gallery.items || ! gallery.items ) {
return;
}
$.each( gallery.items, function ( key, item ) {
if ( 'undefined' !== typeof item.mainElement && item.mainElement.hasClass('wd-video-playing') && item.mainElement.hasClass('wd-inited') ) {
item.mainElement.find('.wd-play-video').trigger('click');
}
});
});
gallery.listen('close', function() {
if ( 'undefined' === typeof gallery.currItem.container ) {
return;
}
var $container = $(gallery.currItem.container).parents('.pswp__container');
$container.find('.pswp__item').each(function () {
var $video = $(this).find('.wd-with-video.wd-video-playing');
if ($video.length) {
$video.find('.wd-play-video').trigger('click');
}
});
});
});
if ( $mainGallery.find('.wd-carousel-item.wd-with-video').length ) {
document.querySelector('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)').addEventListener('wdSlideChange', function (e) {
var activeSlide = e.target.swiper.slides[e.target.swiper.activeIndex];
if ( activeSlide.classList.contains('wd-overlay-hidden') && ( activeSlide.classList.contains('wd-video-playing') || activeSlide.classList.contains('wd-video-design-native') && activeSlide.classList.contains('wd-video-hide-thumb') ) ) {
visibleOverlayProductInfo( 'hide' );
} else if ( $mainGalleryWrapper.hasClass('wd-hide-overlay-info') && ( ! activeSlide.classList.contains('wd-overlay-hidden') || ! activeSlide.classList.contains('wd-video-playing') ) ) {
visibleOverlayProductInfo( 'show' );
}
});
}
if ( $variation_form.length ) {
$variation_form.on('show_variation', function(e, variation) {
$mainGallery.find('.wd-carousel-item.wd-video-playing').each( function () {
var $imageWrapper = $(this);
if ( $imageWrapper.find('.wp-post-image').length || $imageWrapper.hasClass('wd-inited') ) {
$imageWrapper.find('.wd-play-video').trigger('click');
}
});
});
}
function videoInited( videoScr, $wrapper ) {
$wrapper.addClass('wd-inited');
if (videoScr.indexOf('vimeo.com') + 1) {
if ('undefined' === typeof Vimeo || 'undefined' === typeof Vimeo.Player) {
var interval;
$.getScript(woodmart_settings.vimeo_library_url, function() {
interval = setInterval(function() {
if ('undefined' !== typeof Vimeo) {
clearInterval( interval );
vimeoVideoControls( $wrapper );
}
}, 100);
});
} else {
vimeoVideoControls($wrapper);
}
} else if (videoScr.indexOf('youtube.com') + 1) {
if ('undefined' === typeof YT || 'undefined' === typeof YT.Player) {
var interval;
if ( $wrapper.hasClass('wd-video-playing') ) {
$wrapper.find('.wd-video-actions').addClass('wd-loading');
}
$.getScript('https://www.youtube.com/player_api', function() {
interval = setInterval(function() {
if ('undefined' !== typeof YT.Player) {
clearInterval( interval );
youtubeVideoControls($wrapper);
$wrapper.find('.wd-video-actions').removeClass('wd-loading');
}
}, 100);
});
} else {
youtubeVideoControls( $wrapper );
}
} else {
hostedVideoControls( $wrapper );
}
}
function youtubeVideoControls( $wrapper ) {
var $video = $wrapper.find('iframe');
var $playBtn = $wrapper.find('.wd-play-video');
var prevState;
var player = new YT.Player($video[0], {
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
function onPlayerStateChange( event ) {
if ( $wrapper.hasClass('wd-overlay-hidden') ) {
if ( event.data === YT.PlayerState.PLAYING ) {
visibleOverlayProductInfo( 'hide' );
} else if ( event.data === YT.PlayerState.PAUSED && ! $wrapper.hasClass('wd-video-design-native') ) {
visibleOverlayProductInfo( 'show' );
}
}
prevState = event.data;
}
function onPlayerReady() {
if ( $wrapper.hasClass('wd-video-muted') ) {
player.mute();
} else {
player.unMute();
}
player.setLoop(true);
$wrapper.removeClass('wd-loading');
if ( ! $wrapper.hasClass('wd-video-playing') || woodmartThemeModule.$window.width() <= 768 && $video.attr('src').indexOf('autoplay=1') && $video.attr('src').indexOf('mute=1') ) {
$wrapper.addClass('wd-video-playing');
player.playVideo();
} else {
$wrapper.removeClass('wd-video-playing');
player.pauseVideo();
}
}
$playBtn.on('click', function() {
if ( prevState === YT.PlayerState.UNSTARTED ) {
if ( 'function' === typeof player.playVideo ) {
player.playVideo();
}
return;
}
if ( $wrapper.hasClass('wd-video-playing') ) {
$wrapper.removeClass('wd-video-playing');
if ( 'function' === typeof player.pauseVideo ) {
player.pauseVideo();
}
} else {
$wrapper.addClass('wd-video-playing');
if ( 'function' === typeof player.playVideo ) {
player.playVideo();
}
}
});
}
function vimeoVideoControls( $wrapper ) {
var $video = $wrapper.find('iframe');
var $playBtn = $wrapper.find('.wd-play-video');
var player = new Vimeo.Player( $video );
player.setLoop(true);
if ( $wrapper.hasClass('wd-video-muted') ) {
player.setVolume(0);
} else {
player.setVolume(1);
}
player.on('timeupdate', function() {
if ( $wrapper.hasClass('wd-loading') ) {
$wrapper.addClass('wd-video-playing');
$wrapper.removeClass('wd-loading');
if ( $wrapper.hasClass('wd-overlay-hidden') ) {
visibleOverlayProductInfo( 'hide' );
}
}
});
if ( ! $wrapper.hasClass('wd-video-design-native') && $wrapper.hasClass('wd-overlay-hidden') ) {
player.on('pause', function() {
visibleOverlayProductInfo( 'show' );
});
}
if ( $wrapper.hasClass('wd-video-playing') ) {
player.pause();
$wrapper.removeClass('wd-video-playing');
} else {
player.play();
}
if ( $wrapper.hasClass('wd-loaded') ) {
$wrapper.addClass('wd-video-playing');
$wrapper.removeClass('wd-loading');
if ( $wrapper.hasClass('wd-overlay-hidden') ) {
visibleOverlayProductInfo( 'hide' );
}
$wrapper.removeClass('wd-loaded');
}
$playBtn.on('click', function() {
if ( $wrapper.hasClass('wd-video-playing') ) {
$wrapper.removeClass('wd-video-playing');
player.pause();
} else {
$wrapper.addClass('wd-video-playing');
player.play();
}
});
}
function hostedVideoControls( $wrapper ) {
var $video = $wrapper.find('video');
var $playBtn = $wrapper.find('.wd-play-video');
$video.on('loadedmetadata', function () {
$wrapper.removeClass('wd-loading');
$video[0].play();
$wrapper.addClass('wd-video-playing');
});
if ( $wrapper.hasClass('wd-overlay-hidden') ) {
$video.on('play', function () {
visibleOverlayProductInfo( 'hide' );
});
if ( ! $wrapper.hasClass('wd-video-design-native') ) {
$video.on('pause', function () {
visibleOverlayProductInfo( 'show' );
});
}
}
if ( $wrapper.hasClass('wd-video-muted') ) {
$video.prop('muted', true);
} else {
$video.prop('muted', false);
}
if ( $wrapper.hasClass('wd-video-playing') ) {
$video[0].pause();
$wrapper.removeClass('wd-video-playing');
} else if ( $wrapper.hasClass('wd-loaded') ) {
$wrapper.removeClass('wd-loading');
$video[0].play();
$wrapper.addClass('wd-video-playing');
}
$playBtn.on('click', function() {
if ( $wrapper.hasClass('wd-video-playing') ) {
$video[0].pause();
$wrapper.removeClass('wd-video-playing');
} else {
$wrapper.addClass('wd-video-playing');
$video[0].play();
}
});
}
function visibleOverlayProductInfo( event ) {
if ( ! $mainGallery.hasClass('wd-carousel') ) {
return;
}
if ( 'hide' === event ) {
$mainGalleryWrapper.addClass('wd-hide-overlay-info');
} else if ( 'show' === event ) {
$mainGalleryWrapper.removeClass('wd-hide-overlay-info');
}
}
};
$(document).ready(function() {
woodmartThemeModule.productVideoGallery();
});
})(jQuery);
window.addEventListener('load',function() {
if ( (document.querySelector("script[src*='googletagmanager.com']") || document.querySelector('#www-widgetapi-script') ) && document.querySelector('.woocommerce-product-gallery .wd-carousel-item.wd-with-video') ) {
const tag = document.createElement( 'script' );
tag.src = '//www.youtube.com/iframe_api';
const firstScriptTag = document.getElementsByTagName( 'script' )[0];
firstScriptTag.parentNode.insertBefore( tag, firstScriptTag );
}
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit wdUpdateWishlist wdArrowsLoadProducts wdLoadMoreLoadProducts wdProductsTabsLoaded wdSearchFullScreenContentLoaded wdArrowsLoadProducts wdBackHistory wdRecentlyViewedProductLoaded', function() {
woodmartThemeModule.productHover();
});
woodmartThemeModule.wcTabsHoverFix = function() {
$('.wc-tabs > li').on('click', function() {
woodmartThemeModule.productHover();
});
};
woodmartThemeModule.$document.on('wdProductMoreDescriptionOpen', function(event, $product) {
woodmartThemeModule.productHoverRecalc($product);
});
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productHover();
});
});
woodmartThemeModule.productHoverRecalc = function($el) {
if ($el.hasClass('wd-fade-off')) {
return;
}
var heightHideInfo = $el.find('.fade-in-block').outerHeight();
$el.find('.content-product-imagin').css({
marginBottom: -heightHideInfo
});
$el.addClass('hover-ready');
};
woodmartThemeModule.productHover = function() {
var $hoverBase = $('.wd-hover-with-fade');
var $carousel = $hoverBase.closest('.wd-carousel');
if (woodmartThemeModule.windowWidth <= 1024) {
if ( $carousel.length > 0 && $hoverBase.hasClass('wd-hover-fw-button')) {
$hoverBase.addClass('wd-fade-off');
}
$hoverBase.on('click', function(e) {
var $this = $(this);
var hoverClass = 'state-hover';
if (!$this.hasClass(hoverClass) && !$this.hasClass('wd-fade-off') && woodmart_settings.base_hover_mobile_click === 'no') {
e.preventDefault();
$('.' + hoverClass).removeClass(hoverClass);
$this.addClass(hoverClass);
}
});
woodmartThemeModule.$document.on('click touchstart', function(e) {
if ($(e.target).closest('.state-hover').length === 0) {
$('.state-hover').removeClass('state-hover');
}
});
}
$hoverBase.on('mouseenter mousemove touchstart', function() {
var $product = $(this);
var $content = $product.find('.wd-more-desc');
if ($content.hasClass('wd-height-calculated')) {
return;
}
$product.imagesLoaded(function() {
woodmartThemeModule.productHoverRecalc($product);
});
$content.addClass('wd-height-calculated');
});
function productHolderWidth($holder) {
if ($holder.data('column_width')) {
return;
}
var holderWidth = $holder.outerWidth();
var columns = $holder.data('columns');
var columnWidth = holderWidth / columns;
$holder.data('column_width', columnWidth);
}
$('.wd-products').on('mouseenter mousemove touchstart', function() {
productHolderWidth($(this));
});
$hoverBase.on('mouseenter mousemove touchstart', function() {
if (!woodmart_settings.hover_width_small) {
return;
}
var $this = $(this);
if ($this.hasClass('wd-hover-fw-button')) {
return;
}
productHolderWidth($this.parent('.wd-products'));
var columnWidth = $this.parent('.wd-products').data('column_width');
if (!columnWidth) {
return;
}
if (255 > columnWidth || woodmartThemeModule.windowWidth <= 1024) {
$this.find('.wd-add-btn').parent().addClass('wd-add-small-btn');
$this.find('.wd-add-btn').removeClass('wd-add-btn-replace').addClass('wd-action-btn wd-style-icon wd-add-cart-icon');
} else if (woodmartThemeModule.$body.hasClass('catalog-mode-on') || woodmartThemeModule.$body.hasClass('login-see-prices')) {
$this.find('.wd-bottom-actions .wd-action-btn').removeClass('wd-style-icon').addClass('wd-style-text');
}
woodmartThemeModule.$document.trigger('wdProductBaseHoverIconsResize');
});
};
$(document).ready(function() {
woodmartThemeModule.productHover();
woodmartThemeModule.wcTabsHoverFix();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.productImages = function() {
var currentImage,
$productGallery = $('.woocommerce-product-gallery'),
$mainImages = $('.woocommerce-product-gallery__wrapper'),
PhotoSwipeTrigger = '.wd-show-product-gallery-wrap > a';
if ($productGallery.hasClass('image-action-popup')) {
PhotoSwipeTrigger += ', .woocommerce-product-gallery__image > a';
}
$productGallery.on('click', '.woocommerce-product-gallery__image > a', function(e) {
e.preventDefault();
});
$productGallery.on('click', PhotoSwipeTrigger, function(e) {
e.preventDefault();
var $this = $(this);
currentImage = $this.attr('href');
var items = getProductItems();
woodmartThemeModule.callPhotoSwipe(getCurrentGalleryIndex(e), items);
});
var getCurrentGalleryIndex = function(e) {
var index = 0;
var $currentTarget = $(e.currentTarget);
if ( $currentTarget.parents('.wd-carousel-item').length ) {
index = $currentTarget.parents('.wd-carousel-item').index();
} else if ( $currentTarget.hasClass( 'woodmart-show-product-gallery' ) ) {
var wrapperGallery = $currentTarget.parents('.woocommerce-product-gallery');
if ( wrapperGallery.hasClass('thumbs-position-left') || wrapperGallery.hasClass('thumbs-position-bottom') || wrapperGallery.hasClass('thumbs-position-without') ) {
index = $currentTarget.parents('.wd-gallery-images').find('.wd-carousel-item.wd-active').index();
}
}
return index;
};
var getProductItems = function() {
var items = [];
$mainImages.find('figure a img').each(function() {
var $this = $(this);
var src = $this.attr('data-large_image'),
width = $this.attr('data-large_image_width'),
height = $this.attr('data-large_image_height'),
caption = $this.attr('data-caption');
if ( $this.parents('.wd-carousel-item.wd-with-video').length ) {
var videoContent = $this.parents('.wd-with-video')[0].outerHTML;
if ( -1 !== videoContent.indexOf('wd-inited') ) {
videoContent = videoContent.replace('wd-inited', 'wd-loaded').replace('wd-video-playing', '');
}
items.push({
html : videoContent,
mainElement: $this.parents('.wd-with-video'),
});
} else {
items.push({
src : src,
w : width,
h : height,
title: (woodmart_settings.product_images_captions === 'yes') ? caption : false
});
}
});
return items;
};
};
$(document).ready(function() {
woodmartThemeModule.productImages();
});
})(jQuery);
/* global woodmart_settings */
woodmartThemeModule.$document.on('wdReplaceMainGallery', function() {
woodmartThemeModule.productImagesGallery( true );
});
[
'frontend/element_ready/wd_single_product_gallery.default'
].forEach( function (value) {
woodmartThemeModule.wdElementorAddAction(value, function($wrapper) {
woodmartThemeModule.productImagesGallery();
$wrapper.find('.woocommerce-product-gallery').css('opacity', '1');
});
});
woodmartThemeModule.productImagesGallery = function( replaceGallery = false) {
document.querySelectorAll('.woocommerce-product-gallery').forEach( function (galleryWrapper) {
var galleryContainer = galleryWrapper.querySelector('.wd-carousel-container');
var gallery = galleryWrapper.querySelector('.woocommerce-product-gallery__wrapper:not(.quick-view-gallery)');
var thumbnails = galleryWrapper.querySelector('.wd-gallery-thumb .wd-carousel');
if (!gallery) {
return;
}
var galleryStyle = window.getComputedStyle(gallery);
var galleryDesktop = galleryStyle.getPropertyValue('--wd-col-lg') ? galleryStyle.getPropertyValue('--wd-col-lg') : galleryStyle.getPropertyValue('--wd-col');
var galleryTablet = galleryStyle.getPropertyValue('--wd-col-md') ? galleryStyle.getPropertyValue('--wd-col-md') : galleryStyle.getPropertyValue('--wd-col');
var galleryMobile = galleryStyle.getPropertyValue('--wd-col-sm') ? galleryStyle.getPropertyValue('--wd-col-sm') : galleryStyle.getPropertyValue('--wd-col');
var mainCarouselArg = {
slidesPerView : galleryDesktop,
loop : woodmart_settings.product_slider_autoplay,
centeredSlides : 'yes' === gallery.dataset.center_mode,
autoHeight : woodmart_settings.product_slider_auto_height === 'yes',
grabCursor : true,
a11y : {
enabled: true,
prevSlideMessage: woodmart_settings.swiper_prev_slide_msg,
nextSlideMessage: woodmart_settings.swiper_next_slide_msg,
firstSlideMessage: woodmart_settings.swiper_first_slide_msg,
lastSlideMessage: woodmart_settings.swiper_last_slide_msg,
paginationBulletMessage: woodmart_settings.swiper_pagination_bullet_msg,
slideLabelMessage: woodmart_settings.swiper_slide_label_msg,
},
breakpoints : {
1025: {
slidesPerView: galleryDesktop,
initialSlide : 'yes' === gallery.dataset.center_mode && galleryDesktop ? 1 : 0
},
768.98: {
slidesPerView: galleryTablet,
initialSlide : 'yes' === gallery.dataset.center_mode && galleryTablet ? 1 : 0
},
0: {
slidesPerView: galleryMobile,
initialSlide : 'yes' === gallery.dataset.center_mode && galleryMobile ? 1 : 0
}
},
slideClass : 'wd-carousel-item',
slideActiveClass : 'wd-active',
slideVisibleClass : 'wd-slide-visible',
slideNextClass : 'wd-slide-next',
slidePrevClass : 'wd-slide-prev',
slideFullyVisibleClass: 'wd-full-visible',
slideBlankClass : 'wd-slide-blank',
lazyPreloaderClass : 'wd-lazy-preloader',
containerModifierClass: 'wd-',
wrapperClass : 'wd-carousel-wrap',
on : {
slideChange: function() {
gallery.dispatchEvent(new CustomEvent('wdSlideChange', { activeIndex: this.activeIndex}));
woodmartThemeModule.$document.trigger('wood-images-loaded');
}
}
};
if ( gallery.parentElement.querySelector('.wd-btn-arrow.wd-next') ) {
mainCarouselArg.navigation = {
nextEl : gallery.parentElement.querySelector('.wd-btn-arrow.wd-next'),
prevEl : gallery.parentElement.querySelector('.wd-btn-arrow.wd-prev'),
disabledClass: 'wd-disabled',
lockClass : 'wd-lock',
hiddenClass : 'wd-hide'
};
}
if (woodmart_settings.product_slider_autoplay) {
mainCarouselArg.autoplay = {
delay: 3000,
pauseOnMouseEnter: true
};
}
if (galleryWrapper.querySelector('.wd-nav-pagin')) {
mainCarouselArg.pagination = {
el : galleryWrapper.querySelector('.wd-nav-pagin'),
dynamicBullets : galleryWrapper.querySelector('.wd-nav-pagin-wrap').classList.contains('wd-dynamic'),
type : 'bullets',
clickable : true,
bulletClass : 'wd-nav-pagin-item',
bulletActiveClass : 'wd-active',
modifierClass : 'wd-type-',
lockClass : 'wd-lock',
currentClass : 'wd-current',
totalClass : 'wd-total',
hiddenClass : 'wd-hidden',
clickableClass : 'wd-clickable',
horizontalClass : 'wd-horizontal',
verticalClass : 'wd-vertical',
paginationDisabledClass: 'wd-disabled',
renderBullet : function(index, className) {
var innerContent = '';
var label = woodmart_settings.swiper_pagination_bullet_msg.replace('{{index}}', index + 1);
if (galleryWrapper.querySelector('.wd-nav-pagin-wrap').classList.contains('wd-style-number-2')) {
innerContent = index + 1;
if ( 9 >= innerContent ) {
innerContent = '0' + innerContent;
}
}
return '
' + innerContent + '';
}
};
}
if ( thumbnails ) {
var thumbnailsWrapper = galleryWrapper.querySelector('.wd-gallery-thumb');
var thumbnailsDirection = galleryWrapper.classList.contains('thumbs-position-left') && ( woodmartThemeModule.$body.width() > 1024 || ! galleryWrapper.classList.contains('wd-thumbs-wrap') ) ? 'vertical' : 'horizontal';
if (thumbnails.children.length) {
if ( replaceGallery ) {
createThumbnails();
}
if ( 'vertical' === thumbnailsDirection && ! window.getComputedStyle(galleryWrapper).getPropertyValue('--wd-thumbs-height') && thumbnailsWrapper.offsetHeight ) {
galleryWrapper.style.setProperty('--wd-thumbs-height', thumbnailsWrapper.offsetHeight + 'px');
}
var thumbnailsStyle = window.getComputedStyle(thumbnails);
var thumbnDesktop = thumbnailsStyle.getPropertyValue('--wd-col-lg') ? thumbnailsStyle.getPropertyValue('--wd-col-lg') : 2;
var thumbnTablet = thumbnailsStyle.getPropertyValue('--wd-col-md') ? thumbnailsStyle.getPropertyValue('--wd-col-md') : 2;
var thumbnMobile = thumbnailsStyle.getPropertyValue('--wd-col-sm') ? thumbnailsStyle.getPropertyValue('--wd-col-sm') : 2;
mainCarouselArg.thumbs = {
swiper: {
el : thumbnails,
slidesPerView : thumbnDesktop,
direction : thumbnailsDirection,
autoHeight : 'horizontal' === thumbnailsDirection && woodmart_settings.product_slider_auto_height === 'yes',
id : 'wd-carousel-thumbnails',
slideClass : 'wd-carousel-item',
slideActiveClass : 'wd-active',
slideVisibleClass : 'wd-slide-visible',
slideNextClass : 'wd-slide-next',
slidePrevClass : 'wd-slide-prev',
slideFullyVisibleClass: 'wd-full-visible',
slideBlankClass : 'wd-slide-blank',
lazyPreloaderClass : 'wd-lazy-preloader',
containerModifierClass: 'wd-',
wrapperClass : 'wd-carousel-wrap',
grabCursor : true,
a11y : {
enabled: true,
prevSlideMessage: woodmart_settings.swiper_prev_slide_msg,
nextSlideMessage: woodmart_settings.swiper_next_slide_msg,
firstSlideMessage: woodmart_settings.swiper_first_slide_msg,
lastSlideMessage: woodmart_settings.swiper_last_slide_msg,
paginationBulletMessage: woodmart_settings.swiper_pagination_bullet_msg,
slideLabelMessage: woodmart_settings.swiper_slide_label_msg,
},
breakpoints : {
1025 : {
slidesPerView: thumbnDesktop
},
768.98 : {
slidesPerView: thumbnTablet
},
0 : {
slidesPerView: thumbnMobile
}
},
navigation : {
nextEl : thumbnails.nextElementSibling.querySelector('.wd-btn-arrow.wd-next'),
prevEl : thumbnails.nextElementSibling.querySelector('.wd-btn-arrow.wd-prev'),
disabledClass: 'wd-disabled',
lockClass : 'wd-lock',
hiddenClass : 'wd-hide'
},
on : {
slideChange: function() {
woodmartThemeModule.$document.trigger('wood-images-loaded');
},
resize: function (swiper) {
if (galleryWrapper.classList.contains('thumbs-position-left') && galleryWrapper.classList.contains('wd-thumbs-wrap')) {
if ( swiper.currentBreakpoint > 1024 && ! swiper.isVertical() ) {
swiper.changeDirection('vertical');
} else if (swiper.currentBreakpoint <= 1024 && ! swiper.isHorizontal() ){
swiper.changeDirection('horizontal');
}
}
}
}
},
slideThumbActiveClass : 'wd-thumb-active',
thumbsContainerClass : 'wd-thumbs'
};
}
}
if (
galleryWrapper.classList.contains('thumbs-position-without')
|| galleryWrapper.classList.contains('thumbs-position-bottom')
|| galleryWrapper.classList.contains('thumbs-position-left')
|| (
(
( ! galleryContainer.classList.contains('wd-off-md') && woodmartThemeModule.$window.width() <= 1024 && woodmartThemeModule.$window.width() > 768 )
|| ( ! galleryContainer.classList.contains('wd-off-sm') && woodmartThemeModule.$window.width() <= 768 )
)
&& (
galleryWrapper.classList.contains('thumbs-grid-bottom_combined')
|| galleryWrapper.classList.contains('thumbs-grid-bottom_combined_2')
|| galleryWrapper.classList.contains('thumbs-grid-bottom_combined_3')
|| galleryWrapper.classList.contains('thumbs-grid-bottom_column')
|| galleryWrapper.classList.contains('thumbs-grid-bottom_grid')
)
)
) {
if ('yes' === woodmart_settings.product_slider_auto_height) {
imagesLoaded(galleryWrapper, function() {
initGallery();
});
} else {
initGallery();
}
}
function initGallery() {
if ('undefined' === typeof wdSwiper) {
console.error('Swiper is not defined');
return;
}
if (thumbnails && 'undefined' !== typeof thumbnails.swiper) {
thumbnails.swiper.destroy( true, false );
}
if ('undefined' !== typeof gallery.swiper) {
gallery.swiper.destroy( true, false );
}
gallery.classList.add('wd-carousel');
woodmartThemeModule.$document.trigger('wood-images-loaded');
new wdSwiper(gallery, mainCarouselArg);
}
function createThumbnails() {
var html = '';
gallery.querySelectorAll('.woocommerce-product-gallery__image').forEach( function (imageWrapper, index) {
var imageSrc = imageWrapper.dataset.thumb;
var image = imageWrapper.querySelector('a img');
var alt = image.getAttribute('alt');
var title = image.getAttribute('title');
var classes = '';
if (!title && imageWrapper.querySelector('a picture')) {
title = imageWrapper.querySelector('a picture').getAttribute('title');
}
if (imageWrapper.querySelector('.wd-product-video')) {
classes += ' wd-with-video';
}
html += '
';
html += '

';
html += '
';
});
thumbnails.firstElementChild.innerHTML = html;
}
});
}
woodmartThemeModule.$window.on('elementor/frontend/init', function() {
if (!elementorFrontend.isEditMode()) {
return;
}
woodmartThemeModule.$window.on('resize', woodmartThemeModule.debounce(function() {
woodmartThemeModule.productImagesGallery();
}, 300));
});
window.addEventListener('load',function() {
woodmartThemeModule.productImagesGallery();
});
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdShopPageInit wdLoadMoreLoadProducts wdArrowsLoadProducts wdProductsTabsLoaded wdSearchFullScreenContentLoaded wdUpdateWishlist wdRecentlyViewedProductLoaded', function () {
woodmartThemeModule.productMoreDescription();
});
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productMoreDescription();
});
});
woodmartThemeModule.productMoreDescription = function() {
$('.wd-hover-with-fade, .wd-image-hotspot.hotspot-type-product, .wd-spot:has(.wd-spot-product)').on('mouseenter touchstart', function() {
var $content = $(this).find('.wd-more-desc');
var $inner = $content.find('.wd-more-desc-inner');
var $moreBtn = $content.find('.wd-more-desc-btn');
if ($content.hasClass('wd-more-desc-calculated')) {
return;
}
var contentHeight = $content.outerHeight();
var innerHeight = $inner.outerHeight();
var delta = innerHeight - contentHeight;
if (delta > 30) {
$moreBtn.addClass('wd-shown');
} else if (delta > 0) {
$content.css('max-height', contentHeight + delta);
}
$content.addClass('wd-more-desc-calculated');
});
woodmartThemeModule.$body.on('click', '.wd-more-desc-btn', function(e) {
e.preventDefault();
var $this = $(this);
$this.parent().addClass('wd-more-desc-full');
woodmartThemeModule.$document.trigger('wdProductMoreDescriptionOpen', [$this.parents('.wd-hover-with-fade')]);
});
};
$(document).ready(function() {
woodmartThemeModule.productMoreDescription();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.productRecentlyViewed = function() {
$('.wd-products-element .products, .wd-carousel-container.products .wd-carousel').each( function () {
var $this = $(this);
var attr = $this.data('atts');
if ( 'undefined' === typeof attr || 'undefined' === typeof attr.post_type || 'recently_viewed' !== attr.post_type || 'undefined' === typeof attr.ajax_recently_viewed || 'yes' !== attr.ajax_recently_viewed ) {
return;
}
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
attr : attr,
action: 'woodmart_get_recently_viewed_products'
},
dataType: 'json',
method : 'POST',
success : function(data) {
if (data.items) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) {
var temp = $('
').html(html);
var hasProducts = temp.find('.wd-product').length !== 0
if ( $this.hasClass('wd-carousel') && $this.parents('.wd-products-element').length ) {
if ( !hasProducts ) {
$this.parents('.wd-products-element').addClass('wd-hide')
} else {
$this.parents('.wd-products-element').removeClass('wd-hide')
}
$this.parent().replaceWith(html);
} else {
if ( !hasProducts ) {
$this.parent().addClass('wd-hide')
} else {
$this.parent().removeClass('wd-hide')
}
$this.html(html);
}
woodmartThemeModule.$document.trigger('wdRecentlyViewedProductLoaded');
woodmartThemeModule.$document.trigger('wood-images-loaded');
});
}
},
error : function() {
console.log('ajax error');
},
});
})
};
$(document).ready(function() {
woodmartThemeModule.productRecentlyViewed();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.singleProdReviews = function() {
let $reviewsTab = $('#reviews');
function getSelectedStars() {
let $activeStarRating = $('.wd-rating-summary-cont').find('.wd-active');
if ( $activeStarRating.length > 0 ) {
return $activeStarRating.find('.wd-rating-label').data('rating').toString();
}
return '';
}
function reloadReviewsWithAjax( clear = false, loaderForSummaryWrap = false ) {
let $commentList = $('.commentlist');
let attr = $commentList.length > 0 ? $commentList.data('reviews-columns') : {};
let animationTime = 50;
let data = {
action : 'woodmart_filter_review',
rating : getSelectedStars(),
product_id : $reviewsTab.data('product-id'),
order_by : 0 < $reviewsTab.find(".wd-reviews-sorting-select :checked").length ? $reviewsTab.find(".wd-reviews-sorting-select :checked").val() : 'newest',
only_images :$('#wd-with-image-checkbox').is(":checked"),
summary_criteria_ids: woodmart_settings.summary_criteria_ids,
}
if ( attr.hasOwnProperty('reviews_columns') ) {
data.reviews_columns = attr.reviews_columns;
}
if ( attr.hasOwnProperty('reviews_columns_tablet') ) {
data.reviews_columns_tablet = attr.reviews_columns_tablet;
}
if ( attr.hasOwnProperty('reviews_columns_mobile') ) {
data.reviews_columns_mobile = attr.reviews_columns_mobile;
}
if ( clear ) {
data['rating'] = '';
data['only_images'] = false;
}
$.ajax({
url : woodmart_settings.ajaxurl,
method : 'GET',
data,
beforeSend: function() {
let $commentList = $reviewsTab.find('#comments .commentlist');
$reviewsTab.find('#comments .wd-loader-overlay').addClass('wd-loading');
if ( loaderForSummaryWrap ) {
$reviewsTab.find('.wd-rating-summary-wrap .wd-loader-overlay').addClass('wd-loading');
}
$commentList.removeClass('wd-active');
$commentList.removeClass('wd-in');
},
complete: function() {
$reviewsTab.find('#comments .wd-loader-overlay').removeClass('wd-loading');
if ( loaderForSummaryWrap ) {
$reviewsTab.find('.wd-rating-summary-wrap .wd-loader-overlay').removeClass('wd-loading');
}
setTimeout(function() {
$reviewsTab.find('#comments .commentlist').addClass('wd-active');
}, animationTime);
setTimeout(function() {
$reviewsTab.find('#comments .commentlist').addClass('wd-in');
}, animationTime * 2);
},
success: function( response ) {
if ( ! data.rating ?? ! data.only_images ) {
$('.wd-reviews-sorting-clear').addClass('wd-hide');
}
if ( response.title ) {
$reviewsTab
.find('.woocommerce-Reviews-title')
.html( response.title );
}
$(document).trigger('woodmart_reviews_sorting_clear', data );
if ( response.content ) {
$reviewsTab
.find('#comments .wd-reviews-content')
.html( response.content );
}
if ( woodmartThemeModule.hasOwnProperty( 'photoswipeImages' ) && 'function' === typeof woodmartThemeModule.photoswipeImages ) {
woodmartThemeModule.photoswipeImages();
}
},
error: function( request ) {
console.error( request );
}
});
}
$reviewsTab
.off('click', '.wd-rating-summary-item')
.on('click', '.wd-rating-summary-item', function () {
if ( ! woodmart_settings.is_rating_summary_filter_enabled || $(this).hasClass( 'wd-empty' ) ) {
return;
}
$(this).siblings().removeClass('wd-active');
$(this).toggleClass('wd-active');
let selectedStars = getSelectedStars();
$(document).on('woodmart_reviews_sorting_clear', function( e, data ) {
if ( selectedStars ) {
$('.wd-reviews-sorting-clear').removeClass('wd-hide');
} else {
$('.wd-reviews-sorting-clear').addClass('wd-hide');
}
});
reloadReviewsWithAjax( false, true );
})
.off('click', '.wd-reviews-sorting-clear')
.on('click', '.wd-reviews-sorting-clear', function(e) {
e.preventDefault();
$('.wd-rating-summary-item').each(function (){
$(this).removeClass('wd-active');
});
$(document).on('woodmart_reviews_sorting_clear', function( e, data ) {
$('.wd-reviews-sorting-clear').addClass('wd-hide');
});
$('#wd-with-image-checkbox').prop( "checked", false );
reloadReviewsWithAjax( true, true );
})
.off('click', '#wd-with-image-checkbox')
.on('click', '#wd-with-image-checkbox', function() {
let checked = $(this).is(":checked");
$(document).on('woodmart_reviews_sorting_clear', function( e, data ) {
if ( checked ) {
$('.wd-reviews-sorting-clear').removeClass('wd-hide');
} else if ( 0 === data.rating.length ) {
$('.wd-reviews-sorting-clear').addClass('wd-hide');
}
});
reloadReviewsWithAjax();
})
.off('change', '.wd-reviews-sorting-select')
.on('change', '.wd-reviews-sorting-select', function() {
reloadReviewsWithAjax();
});
};
$(document).ready(function() {
woodmartThemeModule.singleProdReviews();
});
window.addEventListener('wdOpenDescHiddenTab', function(e) {
if (woodmartThemeModule.hasOwnProperty('singleProdReviews')) {
woodmartThemeModule.singleProdReviews();
}
})
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.singleProdReviewsCriteria = function() {
if ( ! woodmart_settings.is_criteria_enabled ) {
return;
}
$('#reviews')
.on('click', '.wd-review-criteria div.stars a', function ( e ) {
e.preventDefault();
let $star = $( this );
let criteriaId = $star.closest( '.comment-form-rating' ).data('criteria-id');
let $rating = $( `#${ criteriaId }` );
let $container = $star.closest( '.stars' );
$rating.val( $star.text() );
$star.siblings( 'a' ).removeClass( 'active' );
$star.addClass( 'active' );
$container.addClass( 'selected' );
})
.on('click', '#respond #submit', function() {
if ( 'yes' === woodmart_settings.reviews_criteria_rating_required ) {
let showAlert = false;
let $commentFormRatings = $('#review_form').find('.wd-review-criteria');
$commentFormRatings.each(function () {
let $commentFormRating = $(this);
let criteriaId = $commentFormRating.data('criteria-id');
let $rating = $commentFormRatings.find(`#${ criteriaId }`);
if ( ! $( $rating ).val() ) {
showAlert = true;
}
});
if ( showAlert ) {
window.alert( wc_single_product_params.i18n_required_rating_text );
return false;
}
}
});
};
$(document).ready(function() {
woodmartThemeModule.singleProdReviewsCriteria();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.singleProdReviewsLike = function () {
let $reviewsTab = $('#reviews');
$reviewsTab.on( 'click', '.wd-review-likes .wd-like, .wd-review-likes .wd-dislike', function(e) {
e.preventDefault();
if ( ! $('body').hasClass('logged-in') ) {
return;
}
let vote;
let $this = $(this);
let $voteWrapper = $this.closest('.wd-review-likes');
let commentIDAttr = $this.closest('.comment_container').attr('id');
let commentID = parseInt(commentIDAttr.substring(commentIDAttr.indexOf('-') + 1));
if ( $this.hasClass('wd-active') ) {
return;
}
$this.siblings().removeClass( 'wd-active' );
$this.addClass('wd-active');
if ( $this.hasClass('wd-like') ) {
vote = 'like';
} else if ( $this.hasClass('wd-dislike') ) {
vote = 'dislike';
}
$.ajax({
url : woodmart_settings.ajaxurl,
method : 'POST',
data : {
action: 'woodmart_comments_likes',
comment_id: commentID,
vote,
},
beforeSend: function() {
$voteWrapper.addClass('wd-adding');
},
complete: function() {
$voteWrapper.removeClass('wd-adding');
},
success: function( response ) {
let $likesWrap = $this.closest('.wd-review-likes');
if ( response.hasOwnProperty( 'likes' ) ) {
$likesWrap.find('.wd-like span').text( response.likes )
}
if ( response.hasOwnProperty( 'dislikes' ) ) {
$likesWrap.find('.wd-dislike span').text( response.dislikes )
}
},
error: function( request ) {
console.error( request );
}
});
});
}
$(document).ready(function() {
woodmartThemeModule.singleProdReviewsLike();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
woodmartThemeModule.$document.on('wdProductsTabsLoaded wdSearchFullScreenContentLoaded wdUpdateWishlist wdRecentlyViewedProductLoaded wdShopPageInit', function() {
woodmartThemeModule.productsLoadMore();
});
$.each([
'frontend/element_ready/wd_products.default',
'frontend/element_ready/wd_products_tabs.default',
'frontend/element_ready/wd_archive_products.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productsLoadMore();
});
});
woodmartThemeModule.productsLoadMore = function() {
var process = false,
intervalID;
$('.wd-products-element').each(function() {
var $this = $(this),
cache = [],
inner = $this.find('.wd-products');
if (!inner.hasClass('pagination-arrows')) {
return;
}
cache[parseInt(inner.data('paged'))] = {
items : inner.html(),
status: 'have-posts'
};
$this.find('.wd-ajax-arrows .wd-btn-arrow.wd-prev .wd-arrow-inner, .wd-ajax-arrows .wd-btn-arrow.wd-next .wd-arrow-inner').on('click', function(e) {
e.preventDefault();
var $this = $(this).parent('.wd-btn-arrow');
if (process || $this.hasClass('wd-disabled')) {
return;
}
process = true;
clearInterval(intervalID);
var holder = $this.parent().prev(),
next = $this.parent().find('.wd-btn-arrow.wd-next'),
prev = $this.parent().find('.wd-btn-arrow.wd-prev'),
atts = holder.data('atts'),
action = 'woodmart_get_products_shortcode',
ajaxurl = woodmart_settings.ajaxurl,
dataType = 'json',
method = 'POST',
paged = holder.attr('data-paged');
paged++;
if ($this.hasClass('wd-prev')) {
if (paged < 2) {
return;
}
paged = paged - 2;
}
loadProducts('arrows', atts, ajaxurl, action, dataType, method, paged, holder, $this, cache, function(data) {
var isBorderedGrid = holder.hasClass('products-bordered-grid') || holder.hasClass('products-bordered-grid-ins') || holder.hasClass('products-bordered-grid-bottom');
holder.siblings('.wd-sticky-loader').removeClass('wd-loading');
if (!isBorderedGrid) {
holder.addClass('wd-animated-products');
}
if (data.items.length) {
holder.html(data.items).attr('data-paged', paged);
holder.imagesLoaded().progress(function() {
holder.parent().trigger('recalc');
});
woodmartThemeModule.$document.trigger('wood-images-loaded');
woodmartThemeModule.$document.trigger('wdArrowsLoadProducts');
}
if (woodmartThemeModule.$window.width() < 768) {
$('html, body').stop().animate({
scrollTop: holder.offset().top - 150
}, 400);
}
if (!isBorderedGrid) {
var iter = 0;
intervalID = setInterval(function() {
holder.find('.wd-product').eq(iter).addClass('wd-animated');
iter++;
}, 100);
}
if (paged > 1) {
prev.removeClass('wd-disabled');
} else {
prev.addClass('wd-disabled');
}
if (data.status === 'no-more-posts') {
next.addClass('wd-disabled');
} else {
next.removeClass('wd-disabled');
}
});
});
});
woodmartThemeModule.clickOnScrollButton(woodmartThemeModule.shopLoadMoreBtn, false, woodmart_settings.infinit_scroll_offset);
woodmartThemeModule.$document.off('click', '.wd-products-load-more').on('click', '.wd-products-load-more', function(e) {
e.preventDefault();
if (process) {
return;
}
process = true;
var $this = $(this),
holder = $this.parents('.wd-products-element').find('.wd-products'),
source = holder.data('source'),
action = 'woodmart_get_products_' + source,
ajaxurl = woodmart_settings.ajaxurl,
dataType = 'json',
method = 'POST',
atts = holder.data('atts'),
paged = holder.data('paged');
paged++;
if (source === 'main_loop') {
ajaxurl = $(this).attr('href');
method = 'GET';
}
loadProducts('load-more', atts, ajaxurl, action, dataType, method, paged, holder, $this, [], function(data) {
if (data.items.length) {
if (holder.hasClass('grid-masonry')) {
isotopeAppend(holder, data.items);
} else {
holder.append(data.items);
}
if (data.status !== 'no-more-posts') {
holder.imagesLoaded().progress(function() {
woodmartThemeModule.clickOnScrollButton(woodmartThemeModule.shopLoadMoreBtn, true, woodmart_settings.infinit_scroll_offset);
});
}
woodmartThemeModule.$document.trigger('wood-images-loaded');
woodmartThemeModule.$document.trigger('wdLoadMoreLoadProducts');
holder.data('paged', paged);
}
if (source === 'main_loop') {
$this.attr('href', data.nextPage);
if (data.status === 'no-more-posts') {
$this.parent().hide().remove();
}
}
if (data.status === 'no-more-posts') {
$this.parent().hide();
}
});
});
var loadProducts = function(btnType, atts, ajaxurl, action, dataType, method, paged, holder, btn, cache, callback) {
var data = {
atts : atts,
paged : paged,
action : action,
woo_ajax: 1
};
if (method === 'GET') {
ajaxurl = woodmartThemeModule.removeURLParameter(ajaxurl, 'loop');
ajaxurl = woodmartThemeModule.removeURLParameter(ajaxurl, 'woo_ajax');
}
if (cache[paged]) {
holder.addClass('wd-loading');
setTimeout(function() {
callback(cache[paged]);
holder.removeClass('wd-loading');
process = false;
}, 300);
return;
}
if (btnType === 'arrows') {
holder.addClass('wd-loading').parent().addClass('wd-loading');
holder.siblings('.wd-sticky-loader').addClass('wd-loading');
}
btn.addClass('loading');
if (action === 'woodmart_get_products_main_loop') {
var loop = holder.find('.product').last().data('loop');
data = {
loop : loop,
woo_ajax: 1,
atts : atts,
};
}
$.ajax({
url : ajaxurl,
data : data,
dataType: dataType,
method : method,
success : function(data) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(data.items, function(html) {
var $resultCount = $('.woocommerce-result-count');
data.items = html;
cache[paged] = data;
callback(data);
if ('yes' === woodmart_settings.load_more_button_page_url_opt && 'no' !== woodmart_settings.load_more_button_page_url && data.currentPage){
var state = '';
var newUrl = data.currentPage + window.location.search;
if ( !!window.history.state && window.history.state.hasOwnProperty('url') ) {
window.history.state.url = newUrl;
state = window.history.state;
}
window.history.replaceState(state, '', newUrl);
$('.woocommerce-breadcrumb').replaceWith(data.breadcrumbs);
}
if ( $resultCount.length > 0 && data.hasOwnProperty('resultCount') ) {
$resultCount.replaceWith(data.resultCount);
}
});
},
error : function() {
console.log('ajax error');
},
complete: function() {
if (btnType === 'arrows') {
holder.removeClass('wd-loading').parent().removeClass('wd-loading');
}
btn.removeClass('loading');
process = false;
}
});
};
var isotopeAppend = function(el, items) {
var $items = $(items);
el.append($items).isotope('appended', $items);
el.imagesLoaded().progress(function() {
el.isotope('layout');
});
};
};
$(document).ready(function() {
woodmartThemeModule.productsLoadMore();
});
})(jQuery);
/* global woodmart_settings */
(function($) {
$.each([
'frontend/element_ready/wd_products_tabs.default'
], function(index, value) {
woodmartThemeModule.wdElementorAddAction(value, function() {
woodmartThemeModule.productsTabs();
});
});
woodmartThemeModule.productsTabs = function() {
var process = false;
$('.wd-products-tabs').each(function() {
var $this = $(this);
var $inner = $this.find('.wd-tabs-content-wrapper');
var cache = [];
var $cloneContent = $inner.find('.wd-products-element').clone().removeClass('wd-active wd-in');
if ( $cloneContent.find('.wd-carousel') ) {
$cloneContent.find('.wd-carousel').removeClass('wd-initialized');
}
cache[0] = {
html: $cloneContent.prop('outerHTML')
};
$this.find('.products-tabs-title li').on('click', function(e) {
e.preventDefault();
var $this = $(this),
atts = $this.data('atts'),
index = $this.index();
if (process || $this.hasClass('wd-active')) {
return;
}
process = true;
$inner.find('.wd-products-element').removeClass('wd-in');
setTimeout(function() {
$inner.find('.wd-products-element').addClass('wd-active');
}, 100);
loadTab(atts, index, $inner, $this, cache, function(data) {
if (data.html) {
woodmartThemeModule.removeDuplicatedStylesFromHTML(data.html, function(html) {
if ($inner.find('.wd-products-element').length) {
$inner.find('.wd-products-element').replaceWith(html);
} else {
$inner.append(html);
}
$inner.find('.wd-products-element').addClass('wd-active');
setTimeout(function() {
$inner.find('.wd-products-element').addClass('wd-in');
woodmartThemeModule.$document.trigger('wdProductsTabsLoaded');
woodmartThemeModule.$document.trigger('wood-images-loaded');
}, 200);
$this.removeClass('loading');
});
}
});
});
setTimeout(function() {
if (! $this.find('.products-tabs-title li.wd-active').length) {
$this.find('.products-tabs-title li').first().addClass('wd-active');
}
$this.addClass( 'wd-inited' );
}, 200);
});
var loadTab = function(atts, index, holder, btn, cache, callback) {
var $loader = holder.find('> .wd-sticky-loader');
btn.parent().find('.wd-active').removeClass('wd-active');
btn.addClass('wd-active');
if (cache[index]) {
setTimeout(function() {
process = false;
callback(cache[index]);
}, 300);
return;
}
$loader.addClass('wd-loading');
btn.addClass('loading');
$.ajax({
url : woodmart_settings.ajaxurl,
data : {
atts : atts,
action: 'woodmart_get_products_tab_shortcode'
},
dataType: 'json',
method : 'POST',
success : function(data) {
process = false;
cache[index] = data;
callback(data);
},
error : function() {
console.log('ajax error');
},
complete: function() {
process = false;
$loader.removeClass('wd-loading');
}
});
};
};
$(document).ready(function() {
woodmartThemeModule.productsTabs();
});
})(jQuery);
/* global woodmart_settings, woodmartThemeModule, jQuery */
(function($) {
woodmartThemeModule.productVideo = function() {
if ('undefined' === typeof $.fn.magnificPopup) {
return;
}
$('.product-video-button a').magnificPopup({
tLoading : woodmart_settings.loading,
type : 'iframe',
removalDelay : 600,
iframe : {
markup : woodmart_settings.close_markup +
'',
patterns: {
youtube: {
index: 'youtube.com/',
id : 'v=',
src : '//www.youtube.com/embed/%id%?rel=0&autoplay=1'
}
}
},
preloader : false,
fixedContentPos: true,
callbacks : {
beforeOpen: function() {
this.wrap.addClass('wd-video-popup-wrap');
},
}
});
};
$(document).ready(function() {
woodmartThemeModule.productVideo();
});
})(jQuery);
/* global woodmart_settings, woodmartThemeModule, jQuery */
woodmartThemeModule.ptSubscribeForm = function() {
var signedProducts = [];
var firstSignedProducts = [];
async function init() {
var notifierBtn = getNotifierBtn();
if (!notifierBtn) return;
if ('yes' === woodmart_settings.pt_fragments_enable) {
const ids = getProductAndVariationId();
const data = await fetchSignedProducts(ids.productId);
if (data) {
if (data.signed_variations && data.signed_variations.length > 0) {
firstSignedProducts = data.signed_variations;
} else if (data.is_signed) {
firstSignedProducts.push(ids.productId);
signedProducts.push(ids.productId);
}
notifierBtn.classList.remove('wd-disabled');
}
renderNotifierUI(notifierBtn);
} else {
var variationsForm = getVariationsForm();
if (variationsForm) {
firstSignedProducts = JSON.parse(notifierBtn.dataset.signedVariations || '[]');
}
renderNotifierUI(notifierBtn);
}
setupEventListeners();
}
/**
* Updates the notifier button UI based on current variation state.
*
* @param {HTMLElement} notifierBtn
*/
function renderNotifierUI(notifierBtn) {
const ids = getProductAndVariationId();
if (ids.variationId && firstSignedProducts.includes(ids.variationId)) {
notifierBtn.classList.remove('wd-hide');
}
}
/**
* Sets up all event listeners for notifier button, popup, and variations form.
*/
function setupEventListeners() {
var notifierBtn = getNotifierBtn();
var popupContent = getPopupContent();
var variationsForm = getVariationsForm();
if (!notifierBtn) {
return;
}
if (notifierBtn.classList.contains('wd-pt-remove')) {
notifierBtn.addEventListener('click', handleUnsubscribe);
}
if (popupContent) {
var subscribeBtn = popupContent.querySelector('.wd-pt-add');
var policyCheckInput = popupContent.querySelector('[name="wd-pt-policy-check"]');
var desiredPriceCheckInput = popupContent.querySelector('[name="wd-pt-desired-price-check"]');
var desiredPriceInput = popupContent.querySelector('[name="wd-pt-user-desired-price"]');
var closePopupBtn = popupContent.querySelector('.wd-close-popup');
subscribeBtn.addEventListener('click', handleSubscribe);
// Remove notice when magnificPopup closes.
jQuery(document).one('mfpClose', function() {
maybeClearNotices();
});
// Remove notice when policyCheckInput is checked.
if (policyCheckInput) {
const removeNoticeOnCheck = function() {
if (policyCheckInput.checked) {
maybeClearNotices(woodmart_settings.pt_policy_check_msg);
}
};
policyCheckInput.addEventListener('change', removeNoticeOnCheck);
}
if (desiredPriceCheckInput && desiredPriceInput) {
// Set desired price check input when desired price input is clicked.
desiredPriceInput.addEventListener('click', function(e) {
desiredPriceCheckInput.checked = true;
});
// Clear desired price input when desired price check input is unchecked.
desiredPriceCheckInput.addEventListener('change', function() {
if (!desiredPriceCheckInput.checked) {
desiredPriceInput.value = '';
} else {
desiredPriceInput.focus();
}
});
}
// Close popup when close button is clicked.
closePopupBtn.addEventListener('click', function(e) {
e.preventDefault();
jQuery.magnificPopup.close();
});
} else if (notifierBtn.classList.contains('wd-pt-add')) {
notifierBtn.addEventListener('click', handleSubscribe);
}
if (variationsForm) {
jQuery('.variations_form')
.off('show_variation', handleFoundVariation)
.on('show_variation', handleFoundVariation)
.off('click', '.reset_variations', handleResetVariations)
.on('click', '.reset_variations', handleResetVariations);
}
}
/**
* Handles faund variation event.
*
* @param {Event} e
* @param {Object} variation
*/
function handleFoundVariation(e, variation) {
var notifierBtn = getNotifierBtn();
var popupContent = getPopupContent();
if (!notifierBtn) {
return;
}
if (popupContent) {
updatePopupContent(variation.variation_id);
}
updateNotifierBtn(variation.variation_id);
if (variation.is_in_stock) {
notifierBtn.classList.remove('wd-hide');
} else {
notifierBtn.classList.add('wd-hide');
}
maybeClearNotices();
}
/**
* Handles reset variations event.
*
* @param {Event} e
*/
function handleResetVariations(e) {
var notifierBtn = getNotifierBtn();
notifierBtn.classList.add('wd-hide');
maybeClearNotices();
}
/**
* Handles subscribe button click event.
*
* @param {Event} e
*/
function handleSubscribe(e) {
if (this.classList.contains('wd-pt-remove')) {
return;
}
e.preventDefault();
var popupContent = getPopupContent();
if (popupContent) {
if (! validateForm()) {
return;
}
}
var ids = getProductAndVariationId();
var userEmail = getUserEmail();
var userDesiredPrice = getUserDesiredPrice();
sendNotifierForm({
action : 'woodmart_add_to_price_tracker',
security : woodmart_settings.pt_add_button_nonce,
user_email : userEmail,
product_id : ids.productId,
variation_id : ids.variationId,
desired_price : userDesiredPrice,
});
}
/**
* Handles unsubscribe button click event.
*
* @param {Event} e
*/
function handleUnsubscribe(e) {
if (!this.classList.contains('wd-pt-remove')) {
return;
}
e.preventDefault();
var ids = getProductAndVariationId();
var productId = parseInt(ids.productId);
var variationId = parseInt(ids.variationId);
sendNotifierForm({
action : 'woodmart_remove_from_price_tracker',
security : woodmart_settings.pt_remove_button_nonce,
product_id : productId,
variation_id : variationId,
});
}
/**
* Updates notifier button UI for a specific variation.
*
* @param {number} variationId
*/
function updateNotifierBtn(variationId) {
var notifierBtn = getNotifierBtn();
var popupContent = getPopupContent();
var notifierBtnLink = notifierBtn.querySelector('a');
var notifierBtnText = notifierBtnLink.querySelector('.wd-action-text');
if (firstSignedProducts.includes(variationId)) {
notifierBtnText.innerText = woodmart_settings.pt_button_text_stop_tracking;
notifierBtnLink.href = '#';
notifierBtnLink.classList.remove('added');
notifierBtn.classList.add('wd-pt-remove');
notifierBtn.classList.remove('wd-pt-add');
notifierBtn.addEventListener('click', handleUnsubscribe);
notifierBtnLink.classList.remove('wd-open-popup');
} else if (signedProducts.includes(variationId)) {
notifierBtnText.innerText = woodmart_settings.pt_button_text_watch_tracking;
notifierBtnLink.href = woodmart_settings.pt_endpoint_url;
notifierBtnLink.classList.add('added');
notifierBtn.classList.remove('wd-pt-remove');
notifierBtn.classList.remove('wd-pt-add');
notifierBtn.removeEventListener('click', handleSubscribe);
notifierBtnLink.classList.remove('wd-open-popup');
} else {
notifierBtnText.innerText = woodmart_settings.pt_button_text_not_tracking;
notifierBtn.classList.remove('wd-pt-remove');
notifierBtnLink.classList.remove('wd-open-popup');
notifierBtnLink.classList.remove('added');
if (popupContent) {
notifierBtnLink.href = '#wd-popup-pt';
notifierBtnLink.classList.add('wd-open-popup');
} else {
notifierBtnLink.href = '#';
notifierBtn.classList.add('wd-pt-add');
notifierBtn.addEventListener('click', handleSubscribe);
}
}
}
/**
* Updates popup content for a specific variation.
*
* @param {number} variationId
*/
function updatePopupContent(variationId) {
var popupContent = getPopupContent();
if (signedProducts.includes(variationId)) {
popupContent.querySelector('.wd-pt-signed').classList.remove('wd-hide');
popupContent.querySelector('.wd-pt-not-signed').classList.add('wd-hide');
} else {
popupContent.querySelector('.wd-pt-signed').classList.add('wd-hide');
popupContent.querySelector('.wd-pt-not-signed').classList.remove('wd-hide');
}
}
/**
* Updates signed products based on the current state.
*
* @param {string} state
* @param {number} productId
*/
function updateSignedProducts(state, productId) {
if ('signed' === state) {
if (!signedProducts.includes(productId)) {
signedProducts.push(productId);
}
} else if ('not-signed' === state) {
if (signedProducts.includes(productId)) {
signedProducts = signedProducts.filter(function(id) {
return id !== productId;
});
}
if (firstSignedProducts.includes(productId)) {
firstSignedProducts = firstSignedProducts.filter(function(id) {
return id !== productId;
});
}
}
}
/**
* Validates the popup form (policy checkbox).
*
* @returns {boolean}
*/
function validateForm() {
var popupContent = getPopupContent();
if (!popupContent) {
return false;
}
var policyCheckInput = popupContent.querySelector('[name="wd-pt-policy-check"]');
var desiredPriceCheckInput = popupContent.querySelector('[name="wd-pt-desired-price-check"]');
var desiredPriceInput = popupContent.querySelector('[name="wd-pt-user-desired-price"]');
var noticesAria = getNoticeAria();
if (policyCheckInput && ! policyCheckInput.checked && noticesAria) {
addNotice(noticesAria, woodmart_settings.pt_policy_check_msg, 'warning');
return false;
}
if (desiredPriceCheckInput && desiredPriceInput && desiredPriceCheckInput.checked && ! parseInt( desiredPriceInput.value ) ) {
addNotice(noticesAria, woodmart_settings.pt_desired_price_check_msg, 'warning');
return false;
}
return true;
}
/**
* Sends AJAX request to subscribe/unsubscribe and updates UI.
*
* @param {Object} data
*/
function sendNotifierForm(data) {
var popupContent = getPopupContent();
var noticesAria = getNoticeAria();
var notifierBtn = getNotifierBtn();
var notifierBtnLink = notifierBtn.querySelector('a');
var ids = getProductAndVariationId();
var productId = ids.variationId ? ids.variationId : ids.productId;
maybeClearNotices();
if (popupContent) {
var loaderOverlay = popupContent.querySelector('.wd-loader-overlay');
loaderOverlay.classList.add('wd-loading');
}
notifierBtnLink.classList.add('loading');
jQuery.ajax({
url : woodmart_settings.ajaxurl,
data,
method : 'POST',
success : function(response) {
if (!response || !response.hasOwnProperty('data')) {
return;
}
if (response.data.notice && noticesAria) {
var status = response.data.success ? 'success' : 'warning';
addNotice(noticesAria, response.data.notice, status);
}
if (response.data.state) {
updateSignedProducts(response.data.state, productId);
}
if (popupContent) {
updatePopupContent(productId);
}
updateNotifierBtn(productId);
},
error : function() {
console.error('ajax adding to price tracker error');
},
complete: function() {
if (popupContent) {
loaderOverlay = popupContent.querySelector('.wd-loader-overlay');
loaderOverlay.classList.remove('wd-loading');
}
notifierBtnLink.classList.remove('loading');
}
});
}
/**
* Fetches signed variations for a product via AJAX.
*
* @param {number|string} productId
*
* @returns {Promise