var submenuWidth = "200"; var dlmenu_showmore = "1"; var dlmenu_shownumber = "10"; var dlmenu_columnHeight = "320"; var dlmenu_columnConcat = "1"; var dlmenu_padding = "30"; var dlmenu_columns = "5"; var dlmenu_wide = "true"; dlmenu_padding == "" ? 0 : dlmenu_padding; dlmenu_columns == "" ? 5 : dlmenu_columns; app_shop.fn.mobileGen = function (reverse = false) { if (reverse) { $(".nav-header").remove(); } else if (!$(".nav-header").length) { var menuList = $("aside .nav-link + ul"); $.each(menuList, function (index, val) { var navHeader = $(val).prev(); $(val).prepend('
'); $(val).find(".nav-header").prepend(navHeader.clone()); $(val) .find(".nav-header") .prepend( '' ); }); } }; app_shop.run( function () { var window_w = $(window).width(); $(".navbar-nav .isOverflow").removeClass("isOverflow"); $(".navbar-nav > .nav-item").each(function () { var place = 0; $this = $(this); place = window_w - $this.offset().left; if (place < parseInt(submenuWidth)) { $this.addClass("isOverflow"); } if (place < parseInt(submenuWidth * 2)) { $this.find(".navbar-subnav").addClass("isOverflow"); } }); $(".nav-link img.rwd-src").each(function () { $this = $(this); $this.attr("src", app_shop.fn.getRwdSrc($this)); }); if (app_shop.vars.view < 2) { if (window.matchMedia("(display-mode: standalone)").matches) { $(".nav-link").each(function (event) { if ($(this).next().is("ul")) { $(this).attr("data-href", $(this).attr("href")); $(this).attr("href", "##"); $(this).addClass("not_selectable"); } }); } } else { $(".nav-link").each(function (event) { if ($(this).attr("data-href") != "") { $(this).attr("href", $(this).attr("data-href")); $(this).removeAttr("data-href"); } $(this).removeClass("not_selectable"); }); } if (app_shop.vars.view > 2) { $("html").removeClass("filters_open").removeClass("sidebar_open"); } }, [1, 2, 3, 4], "#menu_categories" ); app_shop.run( function () { app_shop.fn.mobileGen(true); }, [3, 4], "#menu_categories" ); $(document).on("click", ".navbar-toggler", function (e) { e.preventDefault(); if ( $("html").hasClass("filters_open") || $("html").hasClass("sidebar_open") ) { $("html").removeClass("filters_open").removeClass("sidebar_open"); $('header .handler[data-item="menu_search"]').before($("#menu_search")); //przeniesienie wyszukiwarki do menu $('header .handler[data-item="menu_search"]').remove(); } else { $("html").addClass("sidebar_open"); $("#menu_search").before( '' ); if (typeof app_shop.fn.shoppingList === "object") { $('aside .setMobileGrid[data-item="#menu_navbar"]').before( $("#menu_search") ); //przeniesienie wyszukiwarki do menu } else { $('aside .setMobileGrid[data-item="#menu_navbar"]').after( $("#menu_search") ); //przeniesienie wyszukiwarki do menu } } $( "aside .navbar-subnav, aside .navbar-subsubnav, aside, #menu_settings form" ).scrollTop(0); app_shop.fn.mobileGen(); // duplicate not only-child elements and paste their to ul as first child app_shop.fn.setMobileCategories ? app_shop.fn.setMobileCategories() : ""; //zakładki w menu mobilnym return false; }); $(document).on("click", "aside .navbar-collapse .nav-link", function () { var _next = $(this).next(), _parent = $(this).parent(), _children = _next.children(); if (_next.is("ul") && app_shop.vars.view < 3) { _parent.toggleClass("nav-open"); if (_children.length === 2) _children.last().toggleClass("nav-open"); return false; } }); $(document).on("click", "aside .nav-header .nav-header__backLink", function () { var _parent = $(this).parents(".nav-open").eq(0), _ul = _parent.parents("ul").eq(0), _children = _ul.children(); _parent.removeClass("nav-open"); if (_children.length === 2) _ul.parents(".nav-open").eq(0).removeClass("nav-open"); return false; }); $(document).on( "click", ".touch header .navbar-collapse .nav-link", function (event) { var _next = $(this).next(); var _visible = _next.is(".active"); $(".nav-item ul").removeClass("active"); if ($(this).parent().parent().hasClass("navbar-nav")) { $(".navbar-subnav").removeClass("--hover"); } if ( $("#menu_navbar").parent(".wide").size() && _next.parents("ul").size() > 1 ) { return true; } if (_next.is("ul")) { if (_visible) { _next.removeClass("active"); _next.find("ul.active").removeClass("active"); _next.parents("ul").not(".navbar-nav").addClass("active"); } else { _next.addClass("active"); _next.parents("ul").not(".navbar-nav").addClass("active"); $("body").off("click.navbar"); $("body").on("click.navbar", function (event) { $(".nav-item ul").removeClass("active"); }); } if ($(this).next(".navbar-subnav").length > 0) { $(this).attr("data-visited") ? "" : (app_shop.fn.concatColumns(_next), app_shop.fn.setPositionMenu(_next)); $(this).attr("data-visited", "true"); } event.preventDefault(); return false; } } ); $(document).on( "click", ".sidebar_open header, .sidebar_open #content, .sidebar_open footer, .filters_open header, .filters_open #content, .filters_open footer", function (event) { $("html").removeClass("sidebar_open filters_open"); $(".nav-open").removeClass("nav-open"); $("#menu_settings form").removeClass("active"); $('header .handler[data-item="menu_search"]').before($("#menu_search")); //przeniesienie wyszukiwarki do menu $('header .handler[data-item="menu_search"]').remove(); app_shop.fn.setMobileCategories ? app_shop.fn.setMobileCategories() : ""; //zakładki w menu mobilnym event.preventDefault(); return false; } ); app_shop.run( function megaMenuInit() { if (dlmenu_wide) { /* event dodanie przycisku rozwin */ $("#menu_categories .nav-item.--extend").each(function () { $(this).off(); $(this).on("click", function naviShowMore(e) { e.preventDefault(); $(this).parent().toggleClass("show"); let link = $(this).find("a"); let oldTxt = link.text(); link.off(); link.text(link.attr("txt_alt")); link.attr("txt_alt", oldTxt); link.parents(".navbar-subnav").addClass("--hover"); return false; }); }); /* pokazywanie menu po akcji zwiń */ $(".navbar-subnav").on("mouseover", function () { $(".navbar-subnav").removeClass("--hover"); }); /* pokazywanie menu po akcji zwiń */ $(".no-touch .navbar-nav > .nav-item > .nav-link").on( "mouseover", function () { if ($(this).next(".navbar-subnav").length > 0) { $(this).attr("data-visited") ? "" : (app_shop.fn.concatColumns($(this).next(".navbar-subnav")), app_shop.fn.setPositionMenu($(this).next(".navbar-subnav"))); $(this).attr("data-visited", "true"); } } ); app_shop.fn.concatColumns = function (subnav) { /* laczenie elementów menu */ if ( typeof dlmenu_columnConcat != "undefined" && dlmenu_columnConcat != "" ) { let html = $("