/** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ define([ 'jquery', 'mage/smart-keyboard-handler', 'mage/mage', 'mage/ie-class-fixer', 'domReady!' ], function ($, keyboardHandler) { 'use strict'; $('.cart-summary').mage('sticky', { container: '#maincontent' }); $('.panel.header .header.links li:not(.welcome)').clone().appendTo('#store\\.links').addClass("mobile_nav_account_links"); $('#store\\.links li a').each(function () { var id = $(this).attr('id'); if (id !== undefined) { $(this).attr('id', id + '_mobile'); } }); if ($(".action.nav-toggle").is(":visible")) { let filters_count = $(".amshopby-items.items .amshopby-remove").length; let counter_html = ""; if (filters_count > 0) { counter_html = "" + filters_count + ""; } //$("" + counter_html + "").insertBefore(".header .minicart-wrapper"); $(document).on("amshopby:reload_html", function () { setTimeout(function () { if ($(".cat_filters_count").length > 0) { if ($(".amshopby-items.items .amshopby-remove").length > 0) { $(".cat_filters_count").html($(".amshopby-items.items .amshopby-remove").length) } else { $(".cat_filters_count").remove(); } } else { $(".mobie_cat_filter").html("" + $('.amshopby-items.items .amshopby-remove').length + "") } }, 100); }); if('.header.content > section.amsearch-wrapper-block'.length > 0){ if ($(".header_custom_search").length == 0) { $("").insertBefore(".header.content .minicart-wrapper"); } $('body').on('click', 'a.header_custom_search', function () { $(".amsearch-wrapper-block").toggle(); return false; }); $(document).on('click', function (e) { if ($(".amsearch-wrapper-block").is(":visible")) { if ($(e.target).closest(".amsearch-wrapper-block").length === 0) { $(".amsearch-wrapper-block").hide(); } } }); } } else { $(".header .minicart-wrapper").detach().appendTo('.nav_menu_cart'); if ($(".section-item-content.nav-sections-item-content").length > 0 ) { $(window).scroll(function () { if ($(".section-item-content.nav-sections-item-content").hasClass('scroll-to-fixed-fixed')) { if (!$(".header.content .logo").hasClass('sticky_enabled')) { $(".header.content .logo").addClass('sticky_enabled'); } } else { if ($(".header.content .logo").hasClass('sticky_enabled')) { $(".header.content .logo").removeClass('sticky_enabled'); } } }); } } if($(".header .compare.wrapper").length > 0){ $('.header .compare.wrapper').bind('DOMSubtreeModified', function(){ let counter_text = $(this).find(".counter.qty").text().replace(/[^0-9]/gi, ''); if(counter_text.length > 0){ $(this).find(".counter.qty").text(counter_text); $(".nav_menu_compare a").attr('href',$(this).find('.action.compare').attr('href')); if($(".nav_menu_compare a .counter.qty").length > 0){ $(".nav_menu_compare a .counter.qty").remove(); } $('.header .compare.wrapper .counter.qty').clone().appendTo('.nav_menu_compare a') } }); } $('body').on('click', 'a.mobie_cat_filter', function () { if ($(".block-title.filter-title strong").length > 0) { $(".block-title.filter-title strong").click(); } return false; }); $(".mobile_nav_account_links").each(function (i, j) { let nav_menu_item = $('.nav_menu_account .submenu a').eq(i); if(nav_menu_item.length > 0){ nav_menu_item.attr('href',$(this).find('a').attr('href')); nav_menu_item.find('span').text($(this).find('a').text()); } }); keyboardHandler.apply(); });