Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(_, $) {
- //--------------------------------------------------------------------------
- // COUNTDOWN INIT Инициализация счетчика
- //--------------------------------------------------------------------------
- function fn_abt__yt_init_countdown(e){
- e.find('span[data-countdown]').each(function() {
- var cd = $(this);
- cd.countdown(cd.data('countdown'), function(event) {
- cd.html(event.strftime(cd.data('str')));
- });
- });
- }
- $.ceEvent('on', 'ce.commoninit', function(context) {
- fn_abt__yt_init_countdown(context);
- });
- //--------------------------------------------------------------------------
- // BANNERS - ЕСЛИ ПРОИЗОШЕЛ КЛИК ПО БАННЕРУ ОТКРЫВАЕМОГО В ПОПАПЕ
- // 1. подгружаем данные
- // 2. инициализируем попап
- //--------------------------------------------------------------------------
- $(document).on('click', 'div[class*=abyt-in-popup-]', function() {
- // подгружаем данные и инициализируем попап если еще это не сделано
- var bp_container = $(this).find("div.abt-yt-bp-container:not(.loaded)");
- if (bp_container.length){
- var link = bp_container.data('link');
- $.ceAjax('request', fn_url('abt__yt.show_banner_in_popup'), {
- method: 'get',
- data : {
- link_id : link,
- sl: _.cart_language,
- },
- hidden: true,
- callback: function(response) {
- bp_container
- .addClass('loaded')
- .html(response.data)
- // инициализация
- .popup({
- scrolllock: true,
- openelement : '.abyt-in-popup-' + link,
- closeelement : '.abyt-closer-' + link,
- transition: 'all 0.1s',
- color: 'black',
- escape: false,
- blur: false,
- outline: true,
- opacity: 0.5,
- onclose : function () {
- // если есть видео - ставим на паузу
- var player = $('#youtube-player-' + link);
- if (player.length){
- player[0].contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
- }
- },
- })
- // принудительно открываем
- .popup('show');
- $.commonInit(bp_container);
- },
- });
- }
- });
- //--------------------------------------------------------------------------
- // LOAD_MORE_PRODUCTS - Добавляем класс загрузки перед самим запросом
- //--------------------------------------------------------------------------
- var current_position = 0;
- $.ceEvent('on', 'dispatch_event_pre', function(e, jelm, processed) {
- var link = jelm.is('a') ? jelm : jelm.parent();
- if (e.type === 'click' && link.hasClass('cm-ajax') && link.data('caEventName') === 'ce.abt__yt_more_products_callback') {
- current_position = $(window).scrollTop();
- $('html').addClass('dialog-is-open');
- link.parent().addClass('load');
- $('#tygh_container').addClass('loading-more-products');
- }
- });
- //--------------------------------------------------------------------------
- // LOAD_MORE_PRODUCTS - Скрываем блок для загрузки товров
- //--------------------------------------------------------------------------
- $.ceEvent('on', 'ce.ajaxlink.done.ce.abt__yt_more_products_callback', function(e, data) {
- $(window).scrollTop(current_position);
- $('html').removeClass('dialog-is-open');
- $('.more-products-link.load').removeClass('load').hide();
- $('#tygh_container').removeClass('loading-more-products');
- });
- //--------------------------------------------------------------------------
- // Загрузка iframe youtube
- //--------------------------------------------------------------------------
- function fn_abt__yt_load_video (elm){
- var id = elm.data('banner-youtube-id'), params = elm.data('banner-youtube-params');
- elm.addClass('loaded').empty().append($('<iframe>', {
- src: 'https://www.youtube.com/embed/'+ id +'?' + params,
- frameborder: 0,
- allowfullscreen: 'true',
- allowscriptaccess: 'always',
- })
- );
- }
- //--------------------------------------------------------------------------
- // Отслеживать клики по видеобаннеру с видеоконтентом
- //--------------------------------------------------------------------------
- $(_.doc).on('click', 'a[data-content="video"]:not(.loaded),div.abyt-a-video .box:not(.loaded),div[data-banner-youtube-id]', function(e) {
- if ($(e.target).attr('data-banner-youtube-id') || $(e.target).attr('data-type')){
- var elm = $(e.target);
- if ($(e.target).attr('data-type')) elm = elm.parent();
- $(this).addClass('loaded');
- fn_abt__yt_load_video(elm);
- return false;
- }
- return true;
- });
- //--------------------------------------------------------------------------
- // для мобильных версий скролим вверх, при добавлении товара в корзину
- //--------------------------------------------------------------------------
- $(document).on('click', 'button[type=submit][name^="dispatch[checkout.add"]', function() {
- $.ceEvent('on', 'ce.notificationshow', function(notification) {
- if (document.documentElement.clientWidth <= 767){
- if (notification.find('.ty-ab__ia_joins').length){
- notification.addClass('with-ab-ia-joins');
- $('html, body').animate({scrollTop: 0}, 400);
- }
- }
- });
- });
- //--------------------------------------------------------------------------
- // Фиксация top-panel
- //--------------------------------------------------------------------------
- $.ceEvent('on', 'ce.commoninit', function(context) {
- context.find('input.cm-amount').on('change keyup', function(){
- this.style.width = (this.value.length + 1) * 11 + 'px';
- });
- var top_panel = context.find('#tygh_main_container > .tygh-top-panel'),
- header = context.find('#tygh_main_container > .tygh-header'),
- b = $('body'),
- top_panel_height = top_panel.height(),
- header_height = header.height(),
- height = top_panel_height + header_height,
- fixed = 'fixed-top';
- $(window).on('resize scroll',function(e){
- if (document.documentElement.clientWidth > 767){
- var scroll = $(window).scrollTop();
- if (scroll >= height && !b.hasClass(fixed)){
- // формируем панельку
- header.css('padding-top', top_panel_height + 'px');
- b.addClass(fixed);
- // таймер - чтобы отработала анимация в css
- window.setTimeout(function(){b.addClass('show');}, 50);
- } else if (scroll < height && b.hasClass(fixed)){
- // расформировуем панельку
- header.css('padding-top', '');
- b.removeClass(fixed + ' show menu_fixed-top');
- }
- }
- });
- if (window.innerWidth > 1124 && _.abt__yt.device === 'desktop') {
- var tabs = context.find('.ypi-dt-product-tabs');
- if (tabs.length && tabs.outerHeight() > 200) {
- var sticky = $('.yt-sticky-block');
- $(window).one('scroll', function () {
- /*$.ceAjax('request', fn_url('abt__yt.get_sticky_block'), {
- method: 'get',
- result_ids: sticky.attr('id'),
- hidden: true,
- callback: 'abt__yt.sticky_block_loaded',
- });*/
- sticky.addClass('loaded').show();
- var tabs = $('.yt-tabs-n-sticky-block-wrapper');
- $.ceEvent('on', 'ce.dialog.before_open', function (dialog_state, params) {
- if (!$('html').hasClass('dialog-is-open')) {
- var tabs_top = tabs.offset().top;
- if (tabs_top < window.scrollY + 90) {
- var tabs_bottom = tabs_top + tabs.outerHeight(true);
- var sticky_bottom = window.scrollY + sticky.outerHeight() + 90;
- var top_pos = tabs_bottom - sticky_bottom + 90;
- sticky.css({
- 'top': tabs_bottom < sticky_bottom ? top_pos + 'px' : '',
- 'position': 'fixed',
- 'left': sticky.offset().left + 'px',
- });
- $.ceEvent('one', 'ce.dialogclose', function (d, e, u) {
- setTimeout(function () {
- sticky.css({
- 'position': '',
- 'left': '',
- 'top': '',
- });
- }, 45);
- });
- }
- }
- });
- });
- /*$.ceEvent('one', 'abt__yt.sticky_block_loaded', function () {
- sticky.addClass('loaded');
- var tabs = $('.yt-tabs-n-sticky-block-wrapper');
- $.ceEvent('on', 'ce.dialog.before_open', function (dialog_state, params) {
- if (!$('html').hasClass('dialog-is-open')) {
- var tabs_top = tabs.offset().top;
- if (tabs_top < window.scrollY + 90) {
- var tabs_bottom = tabs_top + tabs.outerHeight(true);
- var sticky_bottom = window.scrollY + sticky.outerHeight() + 90;
- var top_pos = tabs_bottom - sticky_bottom + 90;
- sticky.css({
- 'top': tabs_bottom < sticky_bottom ? top_pos + 'px' : '',
- 'position': 'fixed',
- 'left': sticky.offset().left + 'px',
- });
- $.ceEvent('one', 'ce.dialogclose', function (d, e, u) {
- setTimeout(function () {
- sticky.css({
- 'position': '',
- 'left': '',
- 'top': '',
- });
- }, 45);
- });
- }
- }
- });
- });*/
- }
- }
- });
- //--------------------------------------------------------------------------
- // Горизонтальное меню
- //--------------------------------------------------------------------------
- (function(_, $){
- var container,
- menu,
- wrapper,
- show_more_btn,
- items,
- mobile_menu,
- items_widths,
- total_width,
- total_sections = 1,
- current_menu_section = 1,
- prev_width = 0;
- function show_menu_item(elem) {
- elem.removeClass('ab__menu_hidden');
- }
- function hide_menu_item(elem) {
- elem.addClass('ab__menu_hidden');
- }
- function toggle_menu_items() {
- show_more_btn.html(current_menu_section + '/' + total_sections + '<i></i>');
- var arr,
- widths = $.extend(true, [], items_widths),
- section;
- if (current_menu_section === total_sections) {
- arr = $(items.get().reverse());
- section = 1;
- widths.reverse();
- show_more_btn.addClass('last-section');
- } else {
- arr = items;
- section = current_menu_section;
- show_more_btn.removeClass('last-section');
- }
- var sum = 0;
- arr.each(function(i) {
- var $item = $(this);
- sum += widths[i];
- if (section > 1 && sum > total_width) {
- sum = widths[i];
- section -= 1;
- }
- if (section > 1 || sum > total_width) {
- hide_menu_item($item);
- } else {
- show_menu_item($item);
- }
- });
- }
- function ab__menu_init() {
- var new_width = window.innerWidth;
- if (new_width === prev_width || new_width <= 767) {
- return true;
- }
- prev_width = new_width;
- container = $('.abt_up-menu.extended');
- menu = $('.ty-menu__items', container);
- wrapper = menu.parent();
- show_more_btn = $('.abt_yp_menu-show_more', container);
- items = menu.children().filter(':not(.visible-phone)');
- mobile_menu = menu.children().filter('.visible-phone');
- if (mobile_menu.css('display') === 'none') {
- container.addClass('extended');
- var sum = 0;
- items_widths = [];
- total_width = container.innerWidth() - show_more_btn.outerWidth() - 5;
- menu.css('visibility', 'hidden');
- show_menu_item(items);
- items.css('width', 'auto');
- items.each(function(i) {
- var item = $(this);
- items_widths[i] = item.outerWidth();
- item.css('width', item.innerWidth());
- sum += items_widths[i];
- });
- menu.css('width', sum);
- total_sections = Math.ceil(sum/total_width);
- if (total_sections > 1) {
- wrapper.css('width', total_width);
- show_more_btn.css('display', 'inline-block');
- } else {
- show_more_btn.hide();
- }
- current_menu_section = _get_init_menu_section();
- toggle_menu_items();
- menu.css('visibility', 'visible');
- show_more_btn.off('click');
- show_more_btn.click(function(){
- if (current_menu_section === total_sections) {
- current_menu_section = 1;
- } else {
- current_menu_section += 1;
- }
- toggle_menu_items();
- });
- } else {
- show_menu_item(items);
- items.css('width', 'auto');
- menu.css('width', 'auto');
- wrapper.css('width', 'auto');
- container.removeClass('extended');
- }
- function _get_init_menu_section() {
- var sum = 0;
- var section = 1;
- var active_found = false;
- items.each(function() {
- if (!active_found) {
- var item = $(this);
- sum += item.outerWidth(true);
- if (sum >= total_width) {
- section++;
- sum = 0;
- }
- if (item.hasClass('ty-menu__item-active')) {
- active_found = true;
- }
- }
- });
- return active_found === true ? section : 1;
- }
- }
- $(document).ready(function(){
- setTimeout(ab__menu_init, 500);
- $(window).resize(function(){
- ab__menu_init();
- });
- if (window.addEventListener) {
- window.addEventListener('orientationchange', function() {
- ab__menu_init();
- }, false);
- }
- $.ceEvent('on', 'ce.commoninit', function(context) {
- if ($('.abt_up-menu.extended', context).length) {
- ab__menu_init();
- }
- });
- });
- })(Tygh, Tygh.$);
- //--------------------------------------------------------------------------
- // Опт цены товаров
- //--------------------------------------------------------------------------
- $(_.doc).on('click', '.ab__show_qty_discounts', function() {
- var product_id = $(this).data('caProductId');
- if (product_id !== undefined) {
- var container = $('#qty_discounts_' + product_id);
- if (container.is(':empty')) {
- $.ceAjax('request', fn_url('abt__yt.qty_discounts'), {
- method: 'get',
- data: {
- product_id: product_id,
- sl: _.cart_language,
- },
- result_ids: 'qty_discounts_' + product_id
- });
- }
- container.toggleClass('hidden');
- }
- });
- (function() {
- //--------------------------------------------------------------------------
- // Displays features at the click of a button
- //--------------------------------------------------------------------------
- $(document).on('click', '.abt-yt-show-more-features span', function() {
- var btn = $(this);
- var parent = btn.parents('.ty-grid-list__item');
- if (parent.hasClass('abt-yt-loaded-features')) {
- // if the list is displayed, then you need to hide it
- setTimeout(function(){
- parent.removeClass('abt-yt-loaded-features');
- parent.find('.uploaded-additional-features').css('display', 'none');
- }, 125);
- } else {
- // Wrapper for a complete list of features
- var featuresL= parent.find('.abt-yt-full-features-list');
- var productId = parseInt(featuresL.attr('data-product-id'));
- var categoryId = parseInt(featuresL.attr('data-main-category-id'));
- parent.find("div[id^='product_data_features_update_'] > *").addClass('initial-feature');
- parent.find('.uploaded-additional-features').css('display', 'block');
- parent.addClass('abt-yt-loaded-features');
- // if the list is already loaded && there is nothing in the data-product-id and data-main-category-id attributes -> we will not go further
- if (!parent.hasClass('loaded') && productId > 0 && categoryId > 0) {
- // Add a loading indicator
- var block_middle = parent.find('.block-middle');
- addIndicator( block_middle );
- $.ceAjax('request', fn_url('abt__yt.get_features'), {
- method: 'post',
- data: {
- product: productId,
- category: categoryId,
- existing_ids: featuresL.attr('data-existing-feature-ids'),
- sl: _.cart_language,
- },
- hidden: true,
- caching: false,
- callback: function (d) {
- block_middle.removeIndicator();
- // checking for null and undefined
- if (d.getted_features != void(0)) {
- // add the loaded class so that you no longer send ajax
- parent.addClass('loaded');
- parent.find("div[id^='product_data_features_update_']").append('<div class="uploaded-additional-features">' + d.getted_features + '</div>');
- }
- }
- });
- }
- }
- // Upload identificator
- // Adds an element the ability to remove it from the code
- // The element must have relative / fixed / absolute positioning.
- function addIndicator( elem ) {
- elem.append('<div class="abt-indicator-wrapper"><div class="abt-indicator-circle"><span></span></div></div>');
- elem.removeIndicator = function newFuncQ() {
- elem.find('.abt-indicator-wrapper').remove();
- elem.removeIndicator = false;
- }
- }
- });
- //--------------------------------------------------------------------------
- // Hover delay in the horizontal menu
- //--------------------------------------------------------------------------
- var h_menu = $('.top-menu-grid .abt_up-menu .ty-menu__items');
- if (h_menu.length) {
- var elems = h_menu.find('.ty-menu__item');
- elems.mouseenter(function(event) {
- if (event.relatedTarget !== null) {
- var $this = $(this);
- var subelem = $this.find('.ty-menu__submenu-items').css('display', 'none');
- var timeout = 250;
- setTimeout(function () {
- subelem.css('display', '');
- }, timeout);
- }
- });
- var menu_contextmenu_timeout;
- $(document).contextmenu(function (event) {
- var submenu = $('.ty-menu__submenu');
- if (submenu.is(event.target) || submenu.has(event.target).length !== 0) {
- clearTimeout(menu_contextmenu_timeout);
- var menu_elem = $(event.target).parents('.ty-menu__item');
- menu_elem.attr('tabindex', '-1').focus();
- menu_contextmenu_timeout = setTimeout(function(){
- menu_elem.blur();
- }, 1500);
- }
- });
- }
- })();
- $.ceEvent('on', 'ce.commoninit', function (context) {
- var filters_floating_btn = context.find('.cm-abt-floating-filters-btn');
- if (filters_floating_btn.length) {
- var filters_container = context.find('.ypi-filters-container');
- if (filters_container.length) {
- var main_content = filters_container.next();
- var filters_offset = filters_container.offset();
- var content_offset = main_content.offset();
- content_offset.bottom = content_offset.top + main_content.outerHeight();
- filters_offset.bottom = filters_offset.top + filters_container.height();
- filters_floating_btn.click(() => {
- filters_floating_btn.removeClass('visible');
- });
- var filters_closer = context.find('.cm-product-filters .closer');
- if (filters_closer.length) {
- filters_closer.click(() => {
- var is_filters_visible = _.abt__yt.functions.check_if_elem_on_screen(filters_offset);
- var is_main_content_visible = _.abt__yt.functions.check_if_elem_on_screen(content_offset);
- if (!is_filters_visible && is_main_content_visible) {
- filters_floating_btn.addClass('visible');
- }
- });
- }
- setTimeout(function () {
- var on_scroll = function () {
- var filters_floating_btn = context.find('.cm-abt-floating-filters-btn');
- if (filters_floating_btn.length) {
- var is_filters_visible = _.abt__yt.functions.check_if_elem_on_screen(filters_offset);
- var is_main_content_visible = _.abt__yt.functions.check_if_elem_on_screen(content_offset);
- if (!is_filters_visible && is_main_content_visible) {
- filters_floating_btn.addClass('visible');
- } else {
- filters_floating_btn.removeClass('visible');
- }
- }
- };
- $(document).on('scroll resize', on_scroll);
- on_scroll();
- }, 400);
- }
- }
- context.find('span.link-more').on('mouseover', function() {
- var _self = $(this);
- _self.prev().addClass('view');
- _self.addClass('hidden');
- });
- (function(){
- if (document.getElementsByClassName('abt-yt-search-show-only-icon').length) {
- var search_input = document.getElementById('search_input') || document.querySelector("[name='hint_q']") || document.querySelector("[name='q']");
- if (search_input !== null) {
- document.querySelector('.ty-search-magnifier').onclick = function () {
- var parent = this.parentNode;
- if (!parent.classList.contains('opened')) {
- parent.classList.add('opened');
- search_input.focus();
- return false;
- }
- };
- document.onclick = function (event) {
- var parent = search_input.parentNode;
- if (!parent.parentNode.parentNode.contains(event.target)) {
- parent.classList.remove('opened');
- }
- };
- }
- }
- })();
- context.find('.cm-ab-onclick-share').one('click', function(){
- var btn = this;
- /*$.ceAjax('request', fn_url('abt__yt.get_social_buttons'), {
- result_ids: btn.nextSibling.getAttribute('id'),
- hidden: true,
- callback: 'yt_sb_loaded'
- });*/
- });
- $.ceEvent('one', 'yt_sb_loaded', function () {
- $.ceLazyLoader('init');
- });
- });
- $(document).on('ready', function () {
- // Whether to add a block [...] to bread crumbs
- if (_.abt__yt.settings.general.breadcrumbs_view[_.abt__yt.device] === 'hide_with_btn' && window.innerWidth <= 768) {
- (function() {
- var main_content_breadcrumbs = $(".main-content-grid[class^='span']");
- var m_c_b_w = main_content_breadcrumbs.outerWidth();
- var mobile_breadcrumbs = $('.ty-breadcrumbs').css({
- 'display': 'inline-block',
- 'white-space': 'nowrap',
- });
- var m_b_w = mobile_breadcrumbs.outerWidth(true);
- if (m_b_w >= m_c_b_w) {
- mobile_breadcrumbs.addClass('long');
- }
- mobile_breadcrumbs.css({
- 'display': '',
- 'white-space': '',
- });
- })();
- }
- });
- function fn_abt_timer_menu (menu) {
- if (!menu.length || menu.hasClass('abt_inited')) {
- return;
- } else {
- menu.addClass('abt_inited');
- }
- var timer, opened_menu = null;
- menu.find('.first-lvl').hover(function () {
- var elem = $(this).children('.ty-menu__submenu').children('ul');
- clearTimeout(timer);
- timer = setTimeout(function () {
- if (opened_menu !== null) {
- opened_menu.hide();
- opened_menu = null;
- }
- opened_menu = elem.show();
- }, 100);
- });
- menu.mouseleave(function () {
- clearTimeout(timer);
- if (opened_menu !== null) {
- opened_menu.hide();
- opened_menu = null;
- }
- });
- }
- function ajax_load_menu() {
- var abtam = $('div.abtam');
- if (abtam.length){
- var ids = [];
- abtam.each(function(){
- ids.push($(this).attr('id'));
- });
- $.ceAjax('request', fn_url('abt__yt.load_menu'), {
- result_ids: ids.join(','),
- method: 'post',
- hidden: true,
- data: {
- sl: _.cart_language,
- },
- callback: function(data) {
- if (document.documentElement.clientWidth >= 768) {
- fn_abt_timer_menu($('.cm-responsive-menu'));
- }
- }
- });
- }
- }
- if (document.documentElement.clientWidth >= 768) {
- if ($('.top-menu-grid-vetrtical .ty-dropdown-box__title').hasClass('open')) {
- $('.top-menu-grid-vetrtical .ty-dropdown-box__content').removeClass('hover-zone');
- } else {
- $('.top-menu-grid-vetrtical .ty-dropdown-box__content').addClass('hover-zone');
- $('.hover-zone').hover(
- function () {
- $('body').addClass('shadow')
- },
- function () {
- $('body').removeClass('shadow')
- }
- );
- }
- $(document).ready(function () {
- // если нет меню с ajax-подгрузкой, запускаем запаздывание
- var responsive_items = $('.cm-responsive-menu');
- if (!responsive_items.length){
- fn_abt_timer_menu(responsive_items);
- }
- });
- $.ceEvent('on', 'ce.commoninit', function (context) {
- fn_abt_timer_menu($('.cm-responsive-menu', context));
- });
- }
- /* load menu */
- $(document).ready(function () {
- if (document.documentElement.clientWidth >= 768) {
- ajax_load_menu();
- } else {
- $('.top-menu').one('click', function () {
- ajax_load_menu();
- });
- }
- });
- //--------------------------------------------------------------------------
- // Фильтр товаров
- //--------------------------------------------------------------------------
- $.ceEvent('on', 'ce.commoninit', function(context) {
- var filter = context.find('.cm-horizontal-filters'),
- container = context.find('.ypi-filters-container');
- if (container.length) {
- if (filter.length && !$.contains(container, filter)) {
- filter.appendTo(container);
- filter.css('visibility', 'visible');
- $.ceEvent('trigger', 'ce.abt__filters_moved', [context]);
- } else {
- container.addClass('ypi-nofilters');
- }
- }
- // Toggle buttons
- context.find('.ypi-menu__fixed-button').on('click', function () {
- $('.ypi-menu__fixed-button').toggleClass('active');
- $('body').toggleClass('menu_fixed-top');
- });
- context.find('.closer_fixed-menu').on('click', function () {
- $('body').removeClass('menu_fixed-top');
- $('.ypi-menu__fixed-button').removeClass('active');
- });
- // Toggle vertical filters buttons
- context.find('.ypi-filters-container .ypi-white-vfbt').on('click', function () {
- $('.ty-horizontal-product-filters').toggleClass('vertical-position');
- $('.ty-horizontal-product-filters-dropdown__content').toggleClass('hidden').css('display','inline-block');
- $('.ty-horizontal-product-filters .v-filters-header').toggleClass('hidden');
- $('.ypi-filters-container .ypi-white-vfbt').toggleClass('open');
- $('body').toggleClass('body-not-scroll');
- });
- context.find('.ty-product-filters__wrapper .closer').on('click', function () {
- $('.ty-horizontal-product-filters').removeClass('vertical-position');
- $('.v-filters-header').addClass('hidden');
- $('.ty-horizontal-product-filters-dropdown__content').toggleClass('hidden').css('display','none');
- $('.ty-horizontal-product-filters-dropdown__wrapper').removeClass('open');
- $('.ypi-filters-container .ypi-white-vfbt').removeClass('open');
- $('body').removeClass('body-not-scroll');
- });
- context.find('.enable-v-filters .ypi-filters-container .ypi-white-vfbt').on('click', function () {
- $('.enable-v-filters').addClass('mobile-view');
- });
- $('.enable-v-filters .v-filter .closer').on('click', function () {
- $('.enable-v-filters').removeClass('mobile-view');
- $('.ypi-filters-container .ypi-white-vfbt').removeClass('open');
- $('body').removeClass('body-not-scroll');
- });
- // Toggle list
- context.find('.ToggleItem').on('click', function () {
- $(this).toggleClass('is-open');
- });
- });
- /* [[[ BEGIN ]]]
- * handle product filter variant checked state change
- * */
- $(document).on('change', '.cm-product-filters-checkbox:enabled', (e) => {
- const $filter_checkbox = $(e.target);
- const filter_checkbox_id = $filter_checkbox.attr('id');
- let $updated_product_filters;
- let $updated_filter_checkbox;
- let $updated_filter_checkbox__container;
- let $updated_filter_checkbox__body;
- let $core_products_found_notice;
- let $own_products_found_notice;
- let inteval_id;
- let h_corrective = 10;
- $.ceEvent('one', 'ce.ajaxdone', function (elms, data, response_text) {
- if (elms.length) {
- $.each(elms, function (key, $elem) {
- $updated_filter_checkbox = $elem.find('#' + filter_checkbox_id);
- if ($updated_filter_checkbox.length) {
- $updated_product_filters = $elem;
- if ($updated_product_filters.closest('.ut2-dropdown-outside-position').length) {
- h_corrective = -5;
- }
- if ($updated_product_filters.closest('.ut2-hz-filters').length) {
- h_corrective = 15;
- }
- $updated_filter_checkbox__container = $updated_filter_checkbox.siblings('.ty-range-slider');
- if ($updated_filter_checkbox__container.length < 1) $updated_filter_checkbox__container = $updated_filter_checkbox.closest('.cm-product-filters-checkbox-container');
- $updated_filter_checkbox__body = $updated_filter_checkbox.parents('.ty-product-filters__block, .ty-product-filters, .ty-price-slider').last();
- inteval_id = setInterval(function () {
- $core_products_found_notice = $('.ty-tooltip--filter:visible');
- if ($core_products_found_notice.length) {
- clearInterval(inteval_id);
- $core_products_found_notice.css({
- "--ut2-changed-filter-checkbox-container-top": $updated_filter_checkbox__container.get(0).getBoundingClientRect().top + $updated_filter_checkbox__container.height() / 2 + "px",
- "--ut2-changed-filter-checkbox-container-left": Tygh.language_direction === 'rtl' ? $(document).width() - $updated_filter_checkbox__body.get(0).getBoundingClientRect().left + h_corrective + "px" : $updated_filter_checkbox__body.get(0).getBoundingClientRect().right + h_corrective + "px"
- });
- }
- }, 200);
- setTimeout(function () {
- clearInterval(inteval_id);
- }, 2000);
- return false;
- }
- });
- }
- });
- });
- /* handle product filter variant checked state change
- * [[[ END ]]] */
- }(Tygh, Tygh.$));
Add Comment
Please, Sign In to add comment