/*******************************************************************************************
*   ___  _          ______                     _ _                _                        *
*  / _ \| |         | ___ \                   | (_)              | |              © 2025   *
* / /_\ | | _____  _| |_/ /_ __ __ _ _ __   __| |_ _ __   __ _   | |_ ___  __ _ _ __ ___   *
* |  _  | |/ _ \ \/ / ___ \ '__/ _` | '_ \ / _` | | '_ \ / _` |  | __/ _ \/ _` | '_ ` _ \  *
* | | | | |  __/>  <| |_/ / | | (_| | | | | (_| | | | | | (_| |  | ||  __/ (_| | | | | | | *
* \_| |_/_|\___/_/\_\____/|_|  \__,_|_| |_|\__,_|_|_| |_|\__, |  \___\___|\__,_|_| |_| |_| *
*                                                         __/ |                            *
*                                                        |___/                             *
* ---------------------------------------------------------------------------------------- *
* This is commercial software, only users who have purchased a valid license and accept    *
* to the terms of the License Agreement can install and use this program.                  *
* ---------------------------------------------------------------------------------------- *
* website: https://cs-cart.alexbranding.com                                                *
*   email: info@alexbranding.com                                                           *
*******************************************************************************************/
function fn_abt__ut2_calc_cell(context){
if (fn_abt__ut2_calc_cell.timers === undefined) {
fn_abt__ut2_calc_cell.timers = [];
}
context.each((k,elem) => {
if (fn_abt__ut2_calc_cell.timers[elem]) {
clearTimeout(fn_abt__ut2_calc_cell.timers[elem]);
}
fn_abt__ut2_calc_cell.timers[elem] = setTimeout(fn_abt__ut2_calc_cell_execute, 100, $(elem));
})
}
function fn_abt__ut2_calc_cell_execute(context){
const [ctx, iteration = 0] = arguments;
$('div.grid-list:visible', context).each(function(){
var cell = $(this).find('[class*="ty-column"][data-ut2-grid="first-item"] > [class*="ut2-gl__item"]');
const height = cell.outerHeight(), width = cell.outerWidth();
if (height === 0 && iteration < 3) {
setTimeout(() => fn_abt__ut2_calc_cell(ctx, iteration + 1), 300)
return
}
$(this).css('--gl-item-height', height).css('--gl-item-width', width);
});
}
(function(_, $) {

$(document).ready(function () {
fn_abt__ut2_calc_cell($(document));
$.ceEvent('on', 'ce.commoninit', function(context) {
fn_abt__ut2_calc_cell(context);
});
$.ceEvent('on', 'ce.tab.show', function(tab_id, tabs_elm) {
fn_abt__ut2_calc_cell(tabs_elm.parent());
});
$(window).on('scroll.global', function (event) {
fn_debounced__getVerticalMenuGapWindowTopEdge($('.top-menu-grid-vetrtical.ty-dropdown-box .ty-dropdown-box__title[id]'));
fn_debounced__getHorizontalMenuGapWindowTopEdge();
});
$(window).on('resize.global', function (event) {
fn_abt__ut2_calc_cell($(document));
fn_debounced__fixStickySidebar();
fn_debounced__getVerticalMenuGapWindowTopEdge($('.top-menu-grid-vetrtical.ty-dropdown-box .ty-dropdown-box__title[id]'));
fn_debounced__getHorizontalMenuGapWindowTopEdge();
});
$(document).on('ce:combination:switch', '.top-menu-grid-vetrtical.ty-dropdown-box .ty-dropdown-box__title[id]', function (event, container, flag) {
if (flag === false) {
const $v_menu__toggler = $(this);
fn_debounced__getVerticalMenuGapWindowTopEdge($v_menu__toggler);
}
});
fn__fixStickySidebar();
$(document).on('click.global', function(event) {
let $click_target = $(event.target);
if (_.abt__ut2.device === 'desktop' && window.matchMedia('(max-width: 775px)').matches) {
if (! $click_target.closest('.ut2__horizontal-product-filters-dropdown').length ) {
$('.ty-horizontal-product-filters-dropdown__wrapper.open').trigger('click');
}
}
});
function mmqMobile_statusChanges(mmq) {
if (mmq.matches) {
$(document).on('click.toggle_cvv2_info', '.ty-cvv2-about__title', toggleCvv2Info);
} else {
if ($('.ty-cvv2-about__title').length > 0) {
$('.ty-cvv2-about__title').removeClass('js-state--payment-card-cvv2_-opened');
}
$(document).off('click.toggle_cvv2_info');
}
}
window.g_mmq__mobile.addListener(mmqMobile_statusChanges);
mmqMobile_statusChanges(window.g_mmq__mobile);
$(document).on('click.copy_sku', '.ty-sku-item .ut2_copy', function () {
window.g_fn__copySkuTextToClipboard($(this).find('.ut2--sku-text'));
});
$(document).on('click.open_search', '.js_ut2-search__opener', function () {
$(this).each(function () {
let $opener = $(this);
let $bar = $opener.closest('.ut2-search');
$bar.addClass('js_open');
$opener.siblings('.ty-search-block').addClass('js_view');
});
});
$(document).on('click.close_search', '.js_ut2-search__closeer', function () {
$(this).each(function () {
let $closeer = $(this);
let $bar = $closeer.closest('.ut2-search');
$bar.removeClass('js_open');
$closeer.parent('.ty-search-block').removeClass('js_view');
});
});
$(document).on('click.toggle_v_menu_top_item_submenu', '.ut2-v__menu .ut2-menu__item:not(.item-1st-no-drop) a.ut2-menu__link', function () {
if (window.matchMedia('(min-width: 768px) and (hover: none)').matches) {
event.preventDefault();
let $touched_link = $(this);
let $parent_item = $touched_link.closest('.ut2-menu__item');
let $parent_item__siblings = $parent_item.siblings('.ut2-menu__item');
$parent_item.addClass('js_touched');
$parent_item__siblings.removeClass('js_touched');
}
if (window.matchMedia('(max-width: 767px) and (hover: hover)').matches) {
event.preventDefault();
$(this).siblings('.ty-menu__item-toggle').removeClass('ty-menu__item-toggle-active');
}
});
$(document).on(
'click.toggle_v_menu_top_item_submenu',
'.ut2-menu__submenu__carrier.cascading .ut2-menu__2nd-item__header:not(.no-items),' +
'.ut2-menu__submenu__carrier.cascading .ut2-menu__2nd-item__header:not(.no-items) a.ut2-menu__2nd-link',
function () {
if (window.matchMedia('(min-width: 768px) and (hover: none)').matches) {
event.preventDefault();
let $touched_el = $(this);
let $parent_item = $touched_el.closest('.ut2-menu__2nd-item');
let $parent_item__siblings = $parent_item.siblings('.ut2-menu__2nd-item');
$parent_item.addClass('js_touched');
$parent_item__siblings.removeClass('js_touched');
}
});

});


window.g_fn__debounceUnderscore_fs = function (func, wait, immediate) {
let timeout;
return function executedFunction() {
const context = this;
const args = arguments;
const later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}


const fn_debounced__getVerticalMenuGapWindowTopEdge = window.g_fn__debounceUnderscore_fs(fn__getVerticalMenuGapWindowTopEdge, 400);
function fn__getVerticalMenuGapWindowTopEdge($v_menu__toggler) {
$v_menu__toggler.each(function (i) {
let $this_v_menu__toggler = $(this);
if ($this_v_menu__toggler.is(':visible')) {
let $this_v_menu__dropdown = $this_v_menu__toggler.siblings('.ty-dropdown-box__content');
if ($this_v_menu__dropdown.length) {
let $this_v_menu__dropdown__data_getter = $this_v_menu__dropdown.find('.ut2-menu');
let $this_v_menu__dropdown__offset_parent = $v_menu__toggler.offsetParent();
if ($this_v_menu__dropdown__data_getter.length && $this_v_menu__dropdown__offset_parent.length) {
let this_v_menu__dropdown__position_top = $this_v_menu__dropdown.position().top ? $this_v_menu__dropdown.position().top : $this_v_menu__dropdown__offset_parent.outerHeight();
let this_v_menu__dropdown__top_gap;
if ($this_v_menu__dropdown.is(':visible')) {
this_v_menu__dropdown__top_gap = $this_v_menu__dropdown.get(0).getBoundingClientRect().top;
} else {
this_v_menu__dropdown__top_gap = $this_v_menu__dropdown__offset_parent.get(0).getBoundingClientRect().top + this_v_menu__dropdown__position_top;
}
$this_v_menu__dropdown__data_getter.css("--ut2-v-menu-dropdown-gap-window-top-edge", this_v_menu__dropdown__top_gap + "px");
}
}
}
});
}


const fn_debounced__getHorizontalMenuGapWindowTopEdge = window.g_fn__debounceUnderscore_fs(fn__getHorizontalMenuGapWindowTopEdge, 400);
function fn__getHorizontalMenuGapWindowTopEdge() {
$('.ut2-h__menu').each(function () {
let $this_h_menu = $(this);
if ($this_h_menu.is(':visible')) {
let $this_h_menu__top_link = $this_h_menu.find('.ut2-menu__link').filter(':visible').first();
if ($this_h_menu__top_link.length) {
let $this_h_menu__dropdown = $this_h_menu__top_link.siblings('.ut2-menu__submenu');
if ($this_h_menu__dropdown.length) {
let $this_h_menu__dropdown__offset_parent = $this_h_menu__top_link.offsetParent();
if ($this_h_menu__dropdown__offset_parent.length) {
let this_h_menu__dropdown__position_top = $this_h_menu__dropdown.position().top ? $this_h_menu__dropdown.position().top : $this_h_menu__dropdown__offset_parent.outerHeight();
let this_h_menu__dropdown__top_gap = $this_h_menu__dropdown__offset_parent.get(0).getBoundingClientRect().top + this_h_menu__dropdown__position_top;
if ($this_h_menu__dropdown.is(':visible')) {
this_h_menu__dropdown__top_gap = $this_h_menu__dropdown.get(0).getBoundingClientRect().top;
} else {
this_h_menu__dropdown__top_gap = $this_h_menu__dropdown__offset_parent.get(0).getBoundingClientRect().top + this_h_menu__dropdown__position_top;
}
$this_h_menu.css("--ut2-h-menu-dropdpwn-gap-window-top-edge", this_h_menu__dropdown__top_gap + "px");
}
}
}
}
});
}


delayingHorizontalMenuDropdownOpening();
function delayingHorizontalMenuDropdownOpening() {
if (window.matchMedia('(min-width: 768px) and (hover: hover)').matches) {
$('.ut2-h__menu').each(function () {
const $this_h_menu = $(this);
const $this_h_menu__1st_items = $this_h_menu.find('.ut2-menu__item').not('.item-1st-no-drop');
const open_delay = 300;
$this_h_menu__1st_items.each(function () {
const $this_h_menu__this_1st_item = $(this);
const $this_h_menu__this_1st_submenu = $this_h_menu__this_1st_item.find('.ut2-menu__submenu__carrier');
let open_timer_id;
let close_timer_id;
let flag__open_state = false;
if ($this_h_menu__this_1st_submenu.length) {
$this_h_menu__this_1st_item.on('mouseenter', function () {
clearTimeout(close_timer_id);
if (!flag__open_state) {
open_timer_id = setTimeout(function () {
$this_h_menu__this_1st_item.addClass('js_open');
flag__open_state = true;
}, open_delay - 1);
}
}).on('mouseleave', function () {
clearTimeout(open_timer_id);
if (flag__open_state) {
close_timer_id = setTimeout(function () {
$this_h_menu__this_1st_item.removeClass('js_open');
flag__open_state = false;
}, open_delay);
}
});
}
});
});
}
}


const fn_debounced__fixStickySidebar = window.g_fn__debounceUnderscore_fs(fn__fixStickySidebar, 400);
function fn__fixStickySidebar() {
let el__product_card_sidebar = document.querySelector('.ut2-pb__right, .ut2-pb__right-wrapper');
if (_.abt__ut2.device !== 'mobile' && !window.g_mmq__mobile.matches && $(el__product_card_sidebar).length) {
let product_card_sidebar_height = $(el__product_card_sidebar).outerHeight();
let product_card_sidebar_sticky_top = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--gap-s'));
let $header = $('#tygh_main_container > .tygh-header > .header-grid');
let sticky_header_elem_height = 0;
let $spt_sticky_nav = $('.ab-spt-floating-position-after_h1');
let spt_sticky_nav_height = 0;
if ($('html').hasClass('sticky-top-panel')) {
if ($header.is('.advanced-header')) {
sticky_header_elem_height = $header.children('.top-menu-grid').outerHeight();
} else if ($header.is('.default-header')) {
sticky_header_elem_height = $header.children('.container-fluid-row:first-child').outerHeight();
} else if ($header.is('.light-header')) {
sticky_header_elem_height = $header.find('.top-menu-grid:not(.second-header-grid)').outerHeight();
}
product_card_sidebar_sticky_top = product_card_sidebar_sticky_top + sticky_header_elem_height;
}
if ($spt_sticky_nav.length) {
spt_sticky_nav_height = $spt_sticky_nav.outerHeight();
product_card_sidebar_sticky_top = product_card_sidebar_sticky_top + spt_sticky_nav_height;
}
if (product_card_sidebar_height + product_card_sidebar_sticky_top > document.documentElement.clientHeight) {
$(el__product_card_sidebar).addClass('js-mode--sticky-off');
$(el__product_card_sidebar).css("top", "unset");
} else {
$(el__product_card_sidebar).removeClass('js-mode--sticky-off');
$(el__product_card_sidebar).css("top", product_card_sidebar_sticky_top + 'px');
}
}
}


window.g_fn__copySkuTextToClipboard = function ($copied) {
if ($copied.length > 0) {
const el__copied = $copied.get(0);
let cleaned_text;
cleaned_text = el__copied.textContent || el__copied.innerText || "";
cleaned_text = cleaned_text.replace(/\r?\n|\r/g, '').trim();
if (cleaned_text) {
if ('clipboard' in navigator) {
navigator.clipboard.writeText(cleaned_text).then(() => {
openCopySuccessedAlert();
}).catch((err) => {
copyTextViaExecCommand();
});
} else {
copyTextViaExecCommand();
}
} else {
openCopyFailedAlert();
}
function copyTextViaExecCommand() {
const $utility_temp_input = $('<input type="text" readonly style="position:fixed !important; inset-inline-start:-200vw !important; inset-block-start:-200vh !important; border:0 none; padding:unset; min-width:unset; width:1px !important; min-height:unset; height:1px !important;" />');
let flag__copy_status = false;
$('body').append($utility_temp_input);
$utility_temp_input.val(cleaned_text).select();
try {
if (document.execCommand("copy")) {
flag__copy_status = true;
} else {
flag__copy_status = false;
}
} catch (err) {
flag__copy_status = false;
}
$utility_temp_input.remove();
if (flag__copy_status) {
openCopySuccessedAlert();
} else {
openCopyFailedAlert();
}
}
} else {
openCopyFailedAlert();
}
function openCopySuccessedAlert() {
$.ceNotification('show', {
title: '',
message: '<div class="js-ins--notif-content-_sku-copied">' + _.tr('abt__ut2__sku_copy_status_success') + '<div>',
type: 'N',
message_state: 'I'
});
}
function openCopyFailedAlert() {
$.ceNotification('show', {
title: '',
message: '<div class="js-ins--notif-content-_sku-copied">' + _.tr('abt__ut2__sku_copy_status_fail') + '<div>',
type: 'E',
message_state: 'I'
});
}
}


function toggleCvv2Info() {
$payment_card_cvv2_btn = $(this);
if ($payment_card_cvv2_btn.length > 0) {
$payment_card_cvv2_btn.toggleClass('js-state--payment-card-cvv2_-opened', !$payment_card_cvv2_btn.hasClass('js-state--payment-card-cvv2_-opened'));
}
}


const toggleNoScroll = (flag) =>{
setTimeout(()=>{
let enableNoScroll = flag || $('.cm-abt--ut2-toggle-scroll[id^="off_"]:visible').length > 0;
if (enableNoScroll) {
$('body').data('scroll-top', window.pageYOffset);
}
$('html').toggleClass('no-scroll', enableNoScroll);
if ($('.ut2-sp-n').hasClass('open') && enableNoScroll) {
$('body').addClass('fly-menu');
} else {
$('body').removeClass('fly-menu');
}
if (!enableNoScroll) {
let scrollTop = $('body').data('scroll-top');
window.scroll(0, scrollTop);
}
}, 0);
}

$(document).ready(function() {
$.extend(_.abt__ut2, {
functions: {
toggleNoScroll: toggleNoScroll,
in_array: function (val, arr) {
var answ = 0;
if (Array.isArray(arr)) {
answ = ~arr.indexOf(val);
} else {
answ = ~Object.keys(arr).indexOf(val);
}
return Boolean(answ);
},
detect_class_changes: function (elem, callback, add_old_val) {
var vanilla_elem = elem[0];
var observer = new MutationObserver(callback);
observer.observe(vanilla_elem, {
attributes: true,
attributeOldValue: add_old_val || false,
attributeFilter: ['class']
});
},
toggle_class_on_scrolling: function (element_to_manipulate, element_to_add_class, class_name, add_to_offset, conditions) {
var additional_offset = add_to_offset;
if (_.abt__ut2.settings.general.top_sticky_panel.enable[_.abt__ut2.device] === 'Y') {
additional_offset += $('.top-menu-grid').outerHeight();
}
$(window).on('scroll resize', function () {
var scroll_top = $(window).scrollTop() - additional_offset;
var scroll_bot = scroll_top + window.innerHeight;
var element_coords = element_to_manipulate.offset();
element_coords.bottom = element_coords.top + element_to_manipulate.outerHeight();
if (scroll_bot >= element_coords.bottom) {
if (conditions != void(0) && typeof conditions.add === 'function' && !conditions.add())
return false;
element_to_add_class.addClass(class_name);
} else {
if (conditions != void(0) && typeof conditions.remove === 'function' && !conditions.remove())
return false;
element_to_add_class.removeClass(class_name);
}
});
}
}
});
if (_.abt__ut2.settings.general.top_sticky_panel.enable[_.abt__ut2.device] === 'Y') {

$('body').data('ca-scroll-to-elm-offset', 70);
}
if (_.abt__ut2.controller === 'checkout' && _.abt__ut2.mode === 'cart') {
$('.ty-dropdown-box__title:not(.open)').addClass('__cart-page');
}
if (location.pathname !== '/'){
let menuItemClases = ':is(.ut2-menu__list, .ty-text-links)',
menuElemClases = '.ut2-menu__2nd-item__header, .ut2-menu__3rd-item, .ty-text-links__item',
activeElem = $(menuItemClases +' a[href$="'+location.pathname+'"]');
if(activeElem.length){
activeElem.parentsUntil(menuItemClases, menuElemClases).addClass('active');
activeElem.parentsUntil(menuItemClases,'.ut2-menu__2nd-item').find('.ut2-menu__2nd-item__header').addClass('active');
activeElem.parentsUntil(menuItemClases,'.ut2-menu__item').find('.ut2-menu__link').addClass('active');
}
}
});
$(document).ready(function(){
let ENABLE_STICKY_HEADER_PANEL = _.abt__ut2.settings.general.top_sticky_panel.enable[_.abt__ut2.device] === 'Y',
ENABLE_STICKY_PANEL = _.abt__ut2.settings.general.sticky_panel.enable_sticky_panel[_.abt__ut2.device] === 'Y',
ENABLE_STICKY_FC_PANEL = _.abt__ut2.settings.category.show_sticky_panel_filters_and_categories[_.abt__ut2.device] === 'Y';
var header_selector = '#tygh_main_container > .tygh-header > .header-grid > div:first-child';
var menu_selector = '#tygh_main_container > .tygh-header > .header-grid > div:last-child';
var top_panel = $('#tygh_main_container > .tygh-top-panel'),
header = $(header_selector),
menu = $(menu_selector),
b = $('body'),
h = $('.header-grid'),
t = $('.tygh-header'),
top_panel_height = top_panel.length > 0 && top_panel.is(':visible') ? top_panel.height() : 0,
menu_height = menu.length > 0 && menu.is(':visible') ? menu.height() : 0,
breadcrumbs_height = $('.ty-breadcrumbs').outerHeight(),
height = header.outerHeight();
$(':root').css({
'--top-height': `${top_panel_height}px`,
'--header-height': `${height}px`,
'--menu-height': `${menu_height}px`,
'--bc-height' : `${breadcrumbs_height}px`
});
if (ENABLE_STICKY_HEADER_PANEL) {
var fixed = 'fixed-header';
}
if (ENABLE_STICKY_PANEL) {
var sticky = 'sticky-panel';
}
if (ENABLE_STICKY_FC_PANEL) {
const fc_sticky = 'sticky-fc-panel';
const margin = ENABLE_STICKY_HEADER_PANEL ? 1 + (height || 0) : '0';
const targetElement = document.querySelector('.top-sticky-panel__filters');
if (targetElement) {
const fcObserver = new IntersectionObserver((entries) => {
entries.forEach(e => {
document.body.classList.toggle(fc_sticky, !e.isIntersecting);
});
}, {rootMargin: `-${margin + 1}px 0px 0px 0px`, threshold: 1});
fcObserver.observe(targetElement);
}
}
if (h.hasClass('advanced-header')) {
t.addClass('advanced_header');
}
if (h.hasClass('default-header')) {
t.addClass('default_header');
}
if (h.hasClass('light-header')) {
t.addClass('light_header');
}
if (h.hasClass('v2')) {
t.addClass('v2');
}
if(ENABLE_STICKY_HEADER_PANEL || ENABLE_STICKY_PANEL){
$(window).on('resize scroll', function(e) {
var scroll = $(window).scrollTop();
if(ENABLE_STICKY_HEADER_PANEL) {

if (h.hasClass('advanced-header')) {
if (Math.floor(scroll) >= (top_panel_height + height + menu_height) && !b.hasClass(fixed)) {
b.addClass(fixed);
} else if (Math.floor(scroll) < (top_panel_height + height)) {
b.removeClass(fixed);
}
}

if (h.hasClass('default-header')) {
if (Math.floor(scroll) > (top_panel_height + menu_height) && !b.hasClass(fixed)) {
b.addClass(fixed);
} else if (Math.floor(scroll) <= (top_panel_height + menu_height) && b.hasClass(fixed)) {
b.removeClass(fixed);
}
}

if (h.hasClass('light-header')) {
if (Math.floor(scroll) > (top_panel_height + menu_height) && !b.hasClass(fixed)) {
b.addClass(fixed);
} else if (Math.floor(scroll) <= (top_panel_height + menu_height) && b.hasClass(fixed)) {
b.removeClass(fixed);
}
}
}
if (ENABLE_STICKY_PANEL && !(_.abt__ut2.controller === 'checkout' && _.abt__ut2.mode === 'checkout')) {
let scroll_distance_to_toggle_bottom_sticky_panel = top_panel_height > 0 ? top_panel_height : 34;
if (Math.floor(scroll) >= scroll_distance_to_toggle_bottom_sticky_panel && !b.hasClass(sticky)) {
b.addClass(sticky);
} else if (Math.floor(scroll) < scroll_distance_to_toggle_bottom_sticky_panel && b.hasClass(sticky)) {
b.removeClass(sticky);
}
}
const bcHeightOld = $(':root').css('--bc-height');
const bcHeightNew = ($('.ty-breadcrumbs').outerHeight() || 0) +'px';
if (bcHeightNew !== bcHeightOld) $(':root').css('--bc-height', bcHeightNew);
});
}
});
let observer = false;
const initPanelHiding = $.debounce(function(){
let intersectElements = $(document).find('.ut2-pb__button.ty-product-block__button .ty-btn__add-to-cart');
if(intersectElements.length){
if(observer){
intersectElements.each((index,button) => {
observer.unobserve(button)
})
}
observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
let hideStickyAddToCart = Boolean(entry.target.classList.contains('ty-btn__add-to-cart') && (entry.isIntersecting || entry.isVisible));
$('.ut2-pb__sticky-add-to-cart').toggleClass('hidden', hideStickyAddToCart);
$('body').toggleClass('sticky-add-to-cart', !hideStickyAddToCart);
})
}, {});
intersectElements.each((index, button) => {
observer.observe(button)
})
}
}, 800);
function initStickyAddToCart(){
const stickyBtn = $('#ut2_pb__sticky_add_to_cart');
if (!stickyBtn.length) return;
const stickyBtnDocked = $('.ut2-sticky-panel__wrap .ut2-pb__sticky-add-to-cart');
if(stickyBtnDocked.get(0) !== stickyBtn.get(0)) {
stickyBtnDocked.replaceWith(stickyBtn.show()).get(0) || stickyBtn.prependTo('.ut2-sticky-panel__wrap').show();
}
initPanelHiding();
}
$.ceEvent('on', 'ce.commoninit', function(context) {
initStickyAddToCart();
let load_more_buttons = context.find('.load-more-btn');
if (load_more_buttons.length) {
$.getScript('js/addons/abt__unitheme2/components/block_load_more.js', function(){
load_more_buttons.each(function(){
this.onclick = function(){ window.ut2_load_products(this) };
});
});
}
let subscribeFooterForm = $('.ty-footer-form-block__input.cm-block-add-subscribe');
subscribeFooterForm.closest('form').on('submit', () => {
let emailErrorMessageF = $('.help-inline', subscribeFooterForm);
if (emailErrorMessageF.length) {
emailErrorMessageF.parent().append(emailErrorMessageF);
}
});
});
$.ceEvent('on', 'ce.abt__ut2_before_ajax_request', function(arguments){
let params = arguments[2];
if(params.method === 'get' &&
(
arguments[1].indexOf('block_manager.render') !== -1
||
arguments[1].indexOf('abt__ut2_load_blocks.get_block_content') !== -1
)
){
arguments[2].data = { ...arguments[2].data,
abt__ut2_initial_request:_.abt__ut2.request,
abt__ut2_assign_data:_.abt__ut2.assign_data
};
}
if(arguments[1].indexOf('geo_maps.shipping_estimation') !== -1){
arguments[2].pre_processing = function(data,params){
let product_id = params.data.product_id,
key = 'geo_maps_shipping_methods_list_' + product_id,
key_overload = key + '_overload .ty-geo-maps-shipping__popup';
if(data.html[key] !== undefined){
$('#' + key_overload)?.replaceWith(data.html[key]);
$.ceDialog('get_last')?.ceDialog('resize')
}
}
}
});
$(document).ready(function () {
if (document.documentElement.clientWidth > 768) {
var m = $('.hpo-menu');
if (m.length) {
var menu_height = m.height();
m.addClass('open-menu').find('.ty-dropdown-box__title:first').addClass('open');
var last_first_level_item = m.find('.ut2-menu__item:last-child');
var m_height = parseInt(last_first_level_item.offset().top + last_first_level_item.height());
var fixed_header = function() {
var scroll = $(window).scrollTop();
var top_panel = $('#tygh_main_container > .tygh-top-panel'),
top_panel_height = top_panel.height();
if (scroll >= m_height) {
$('.hpo-menu').removeClass('open-menu');
$('.hpo-menu > .ty-dropdown-box__title').removeClass('open');
} else {
$('body').removeClass('fixed-header').css('padding-top', '');
$('.hpo-menu').addClass('open-menu');
$('.hpo-menu > .ty-dropdown-box__title').addClass('open');
}
};
fixed_header();
$(window).scroll( fixed_header );
}
} else {
$('.ut2-menu__link[href="javascript:void(0)"]').click(function() {
var link = $(this);
var toggler = link.prev();
if (toggler.length && toggler.hasClass('ty-menu__item-toggle')) {
toggler.click();
}
});
}
(function() {
if (_.abt__ut2.settings.products.view.show_sticky_panel_add_to_cart[_.abt__ut2.device] === 'Y' && (_.abt__ut2.controller === 'products' && _.abt__ut2.mode === 'view') && $('.ty-product-block.sticky_add_to_cart').length) {
$('.menu-grid .ty-dropdown-box__title').on('click', function () {
var buttons = $('.ut2-pb__sticky_add_to_cart');
if (!buttons.hasClass('by_scroll')) {
buttons.toggleClass('hide_add_to_cart');
} else {
setTimeout(function () {
$(window).trigger('scroll');
}, 100);
}
});
}
})();
$('.ut2-pb.ut2-pb-mobile').on( "accordionbeforeactivate", function( event, { newHeader } ) {
newHeader?.parent().get(0).scrollIntoView({ behavior: 'instant', block: 'start' });
});
});
(function() {
var clicks_counter = 0;
$.ceEvent('on', 'dispatch_event_pre', function (e, jelm, processed) {
if (e.type === 'click') {


if (jelm.hasClass('cm-external-trigger') || jelm.parent('.cm-external-trigger').length) {
Array.from(document.getElementsByClassName('cm-external-triggered'), e =>{
document.getElementById('sw_'+e.closest('.cm-popup-box')?.id)?.click()
e.click();
}
);
}
}
});
}());
function ajaxDecorator(f) {
return function () {
let [method] = arguments;
if (method === 'request') {
$.ceEvent('trigger', 'ce.abt__ut2_before_ajax_request', [arguments]);
}
return f.apply(this, arguments);
}
}
$.ceAjax = ajaxDecorator($.ceAjax);
$.tools?.tooltip.addEffect('abtip', function(done){
const tip = this.getTip();
const conf = this.getConf();
if (_.abt__ut2.device !== 'desktop') {
toggleNoScroll(true);
if (!tip.has('.tooltip-content').length) {
tip.find('.tooltip-arrow').remove();
tip.removeClass('tooltip').addClass('ut2-tooltip')
.wrapInner(`<div class="tooltip-content"></div>`)
.wrapInner(`<div class="tooltip-wrap"></div>`)
.find('.tooltip-wrap')
.prepend($(`<span class="ut2-btn-close"><i class="ut2-icon-baseline-close esc" ></i></span>`)
.on('click', () => this.hide()));
}
}
tip.removeClass('hidden')
.fadeTo(conf.fadeInSpeed, conf.opacity, () => done())
.find('.tooltip-wrap')
.addClass('show');
}, function (done) {
if (_.abt__ut2.device !== 'desktop') {
toggleNoScroll(false);
this.getTip().addClass('hidden').find('.tooltip-wrap').removeClass('show');
}
this.getTip().hide();
done.call();
})
function tooltipDecorator(fn) {
return function () {
if (_.abt__ut2.settings.general.mobile_tooltip !== 'Y') return fn.apply(this, arguments)
if ((this.closest('[data-ca-dispatch],[href],.ab-hm-first-level-toggler').length) && _.abt__ut2.device !== 'desktop')
return fn.apply(this, [{
onShow() {
this.getTip().hide();
}
}, ...arguments]);
if (this.hasClass('ty-product-filters__tooltip')) return fn.apply(this, arguments);
if (!this.attr('id')?.startsWith('gdpr')) fn.apply(this, [{effect: 'abtip'}, ...arguments]);
if (_.abt__ut2.device === 'desktop') return fn.apply(this, arguments);
this.on('touchstart', function () {
const checkbox = $(this).find('input[type="checkbox"]');
checkbox.prop('checked', !checkbox.prop('checked'));
})
const $gdpr_tip = $(`#gdpr_tooltip_` + this.attr('id'));
const gdpr_tooltip = fn.apply(this, [{tip: $gdpr_tip.get(), effect: 'abtip'}], ...arguments);
$gdpr_tip.removeClass()
.addClass('ut2-tooltip hidden')
.children(':not(div)')
.remove();
$gdpr_tip.children()
.removeClass()
.addClass('tooltip-wrap')
.wrapInner(`<div class="tooltip-content"></div>`)
.prepend($(`<span class="ut2-btn-close"><i class="ut2-icon-baseline-close esc" ></i></span>`)
.on('click', () => this.data('tooltip').hide()));
return gdpr_tooltip;
}
}
$.fn.ceTooltip = tooltipDecorator($.fn.ceTooltip)
$(_.doc).on('ce:combination:switch', function(event, container, flag){
let p = container.parent();
if(p.hasClass('cm-abt--ut2-move-bottom')){
let c = p[0].classList;
c.remove('cm-abt--ut2-move-bottom', 'ty-dropdown-box', 'ty-dropdown-box2');
$('#tygh_main_container').append(container);
container.wrap("<div class='ut2-dropdown-outside-position " + c +"'></div>");
}
if (container.is('.cm-smart-position-h:visible') || container.closest('.top-grid').length) {
const id = container.attr('id');
const isRtl = document.dir === 'rtl';
const dir = isRtl ? 'right' : 'left';
const within = container.parentsUntil('.container-fluid-row').last()
container.position({
within:within.get(0),
my: `${dir} top`,
at: `${dir} bottom`,
collision: 'fit',
of: $(`#sw_${id}, #on_${id}`).get(0)
});
const tipLeft = parseInt(container.css('left')) || 'auto';
container.css({
top: '',
'--tip-left': isRtl ? 'auto' : -1 * tipLeft + 'px',
'--tip-right': isRtl ? -1 * tipLeft + 'px' : 'auto',
});
}
})
$(_.doc).on('ce:combination:switch', '.cm-abt--ut2-toggle-scroll', function (event, container, flag) {
let containerId = container[0].id;
container[0].classList.toggle('hidden', flag);
if (flag && event.target.id.startsWith('off_')){
const targetId = event.target.id.replace('off_','sw_')
_.doc.getElementById(targetId)?.classList.remove('open');
}
if (_.abt__ut2.device !== 'desktop') {
$(container).removeAttr('style');
(flag) ? $(container).removeClass('container-opened') : $(container).addClass('container-opened');
let filtersContainer = event.target.closest('.top-sticky-panel__filters');
if (filtersContainer) {
let {top} = filtersContainer.getBoundingClientRect();
let zIndex = !flag ? 1005 : '';
$('html').css('--mra-top', -top + 'px');
$(filtersContainer).css('z-index', zIndex);
}
}
toggleNoScroll(!flag);
return true;
});
$(_.doc).on('ce:combination:switch', '.ty-horizontal-product-filters-dropdown__wrapper', function (event, container, flag) {
if (_.abt__ut2.device === 'desktop' && window.matchMedia('(max-width: 775px)').matches) {
let $this_head_filter = $(this);
let $this_popup_filter = container;
let $this_filter = $this_head_filter.parent('.ut2__horizontal-product-filters-dropdown');
let $other_filters = $this_filter.siblings();
if (!flag) {
$other_filters.children('.ty-horizontal-product-filters-dropdown__wrapper.open').trigger('click');
}
$this_popup_filter.toggleClass('hidden', flag);
}
});
$(_.doc).on('change', '.cm-product-filters-checkbox:enabled', (e) => {
if (_.abt__ut2.device !== 'desktop') {
$.ceEvent('on', 'ce.ajaxdone', (elements) => {
let needElem = $('.ty-horizontal-product-filters.cm-horizontal-filters.ut2-filters')
.find('#' + $(e.target).closest('.cm-horizontal-filters-content').attr('id'));
needElem.css('transition', 'unset').addClass('container-opened');
});
}
});
$(_.doc).on('click', '.ty-horizontal-product-filters.cm-horizontal-filters.ut2-filters .ty-product-filters__reset-button', () => {
if (_.abt__ut2.device !== 'desktop') {
$('html').removeClass('no-scroll');
}
});
$.ceEvent('on', 'ce:geomap:location_set_after', function (location, $container, response, auto_detect) {
if (!response.is_detected || !$(_.body).find('.cm-warehouse-block-depends-by-location').length) {
return;
}
$('.ut2-sp-f:visible')?.click();
})
$(document).ready(function() {
$('.cm-dialog-opener.ut2-append-body').each(function () {
const $self = $(this);
const content = $(`#${$self.data('caTargetId')}`);
$self.parent().addClass('object-container');
content.length && content.appendTo($self);
});
});
$(window).on('scroll resize', () => {
$('.cm-tooltip,.ty-product-filters__tooltip').each(function (){
const tooltip = $(this).data('tooltip');
if (tooltip?.isShown()) {
tooltip.hide();
return false
}
});
});
$.ceEvent('on', 'ce.product_image_gallery.inner.beforeInit', function(ins) {
const list_type = ins.options.caProductList ?? undefined;
if (list_type) {
const type = _.abt__ut2.settings.product_list[list_type].show_gallery[_.abt__ut2.device];
ins.options.pagination = type === 'points';
ins.options.navigation = type === 'arrows';
}
})
}(Tygh, Tygh.$));
