jQuery(function($) { var translations_array_json = '{"widget_text":{"__default":"Filtry","pl_PL":"Filtry"},"more_button":{"__default":"wi\u0119cej","pl_PL":"wi\u0119cej"},"less_button":{"__default":"mniej","pl_PL":"mniej"}}'; var button_font_size = '20'; var button_font_color = '#ffffff'; var button_bg_color = '#000000'; var widget_type = '1'; var button_position = '200'; var widget_font_color = '#000000'; var widget_bg_color = '#ffffff'; var widget_borders = '1'; var widget_border_thickness = '2'; var widget_border_color = '#d8d8d8'; var atr_show = '1'; var show_moreless_buttons = '1'; var moreless_buttons_color = '#fb5642'; if ($("#box_filter").length) { translations_array = JSON.parse(translations_array_json); var link = document.createElement( "link" ); link.href = "https://mxapp2.maxserver.pl/appFiltry/filtry.css"; link.type = "text/css"; link.rel = "stylesheet"; document.getElementsByTagName( "head" )[0].appendChild(link); function APIloader() { if(!window.frontAPI) { setTimeout(APIloader, 50); } else { const current_lang = Shop.lang.name; if(!(current_lang in translations_array['widget_text'])) { widget_text = translations_array['widget_text']['__default']; } else { widget_text = translations_array['widget_text'][current_lang]; } $.fn.extend({ toggleText: function(a, b){ return this.text(this.text() == b ? a : b); } }); const showActiveAttributes = () => { var active_counter = 0; $("#box_filter.cloned .innerbox > div").each(function() { let currentAttribute = $(this); let currentAttributeName = currentAttribute.removeClass('multiselect').find("> span").text(); if (currentAttributeName.includes("(wybierz)")) { currentAttribute.find("> span").text(currentAttributeName.replace(": (wybierz)", "")); } currentAttribute.find("ul li").each(function() { if ($(this).hasClass('selected')) { active_counter++; currentAttribute.find("span.expand").toggleText("+", "‒"); currentAttribute.find("ul").css('display', 'grid'); return false; } }); }); return active_counter > 0 ? " ("+active_counter+")" : ""; } var clone_done = false; $(window).resize(function() { $("#box_filter:not(.cloned)").show(); let width = $("body").innerWidth() + (window.innerWidth - document.documentElement.clientWidth); if (width <= 767) { if (clone_done != true) { if ($(".leftcol").length) { $("#box_filter").clone(true).insertAfter(".leftcol").addClass("cloned"); } else { $("#box_filter").clone(true).prependTo(".centercol").addClass("cloned"); } $("#box_filter.cloned > .boxhead").after("
"); $(".mx-filter-popup button.filter_button").css({ "background-color": button_bg_color }); $(".mx-filter-popup button.filter_button span").css({ "color": button_font_color, "font-size": button_font_size+"px", "line-height": (parseInt(button_font_size)+2)+"px" }); $(".cloned#box_filter .innerbox > div").css({ "border-bottom": (widget_borders == 1 ? widget_border_thickness+"px solid "+widget_border_color : 'none') }); $(".cloned#box_filter .innerbox > div h5, .cloned#box_filter .innerbox > div span, .cloned#box_filter .innerbox > div li.selected, .cloned#box_filter .innerbox > div em").css({ "color": widget_font_color }); $(".cloned#box_filter .innerbox::-webkit-scrollbar-thumb").css("background", button_bg_color); $(".cloned#box_filter .innerbox, .cloned#box_filter .innerbox > div ul").css({ "background-color": widget_bg_color, 'scrollbar-color': button_bg_color + " #EDEDED" }); $(".cloned#box_filter .innerbox li.showmore, .cloned#box_filter .innerbox li.showless").css('color', moreless_buttons_color); clone_done = true; if (widget_type == 1) { $(".cloned#box_filter .mx-filter-popup .filter_button").css({ "border-bottom": (widget_borders == 1 ? widget_border_thickness+"px solid "+widget_border_color : 'none') }); $("button.filter_button").on('click', function() { $(".cloned.widget").toggleClass('mod-active'); $(this).toggleClass('opened'); $(".cloned#box_filter .innerbox").slideToggle({ start: function() { $(this).css('display', 'flex'); } }); if (atr_show == true) { if ($(".innerbox > div span.expand").length == 0) { $(".cloned#box_filter .innerbox > div h5, .cloned#box_filter .innerbox > div > span:not(.expand)").after("+"); } $(".cloned .innerbox > div").off('click mousedown').on('click', function(event) { if ($(event.target).is("h5") || $(event.target).is("span") || $(event.target).is("ul") || $(event.target).is($(this))) { $(this).find("ul").slideToggle( { start: function() { $(this).css("display", "grid"); } }); $(this).find("span.expand").toggleText("+", "‒"); } }); if ($("#box_filter li.selected").length) { $("li.selected").parent().parent().find("span.expand").text("‒"); } } else if (atr_show == false) { $(".cloned .innerbox > div").addClass("list").find("ul").css("display", "grid"); } }); } else if (widget_type == 2) { $(".cloned#box_filter").addClass("widget").css({ "position": "fixed", "z-index": "99999", "height": "100%", "width": "280px", "left": "-280px", "top": "0", "background-color": "#fff", "border-right": "4px solid "+button_bg_color }); $(".cloned#box_filter .mx-filter-popup").css({ "position": "absolute", "right": "-224px", "top": button_position+'px', "bottom": "0", "transform": "rotate(90deg) translate3d(0, 0, 0)", "transform-origin": "left bottom", "height": "55px", "width": "220px", "margin": "0", "display": "flex", "align-items": "flex-end", "justify-content": "center" }); $(".cloned#box_filter .mx-filter-popup .filter_button").css({ "border-radius": "0", "background-color": button_bg_color, "border-top-left-radius": "7px", "border-top-right-radius": "7px", "line-height": (parseInt(button_font_size)+2)+"px", "box-sizing": "content-box" }); $(".cloned#box_filter .mx-filter-popup .filter_button span").css({ "font-size": button_font_size+"px", "letter-spacing": "0.6px", 'color': button_font_color }); $(".cloned#box_filter .innerbox").css({ "background-color": widget_bg_color, "display": "block", "height": "100%" }); $("button.filter_button").on('click', function() { $(".cloned.widget").toggleClass('mod-active'); $(this).toggleClass('opened'); if ($(".cloned#box_filter").css("left") == -280+"px") { $(".cloned#box_filter, button.filter_button").css("left", "0px"); } else { $(".cloned#box_filter, button.filter_button").css("left", "-280px"); } if (atr_show == true) { if ($(".cloned#box_filter .innerbox > div span.expand").length == 0) { $(".cloned#box_filter .innerbox > div").addClass('expandable').find("h5, > span:not(.expand)").after("+"); } $(".cloned .innerbox > div").off('click mousedown').on('click', function(event) { if ($(event.target).is("h5") || $(event.target).is("span") || $(event.target).is("ul") || $(event.target).is($(this))) { var innerHeight = $(".cloned#box_filter .innerbox").height(); $(".cloned#box_filter .innerbox").css("height", innerHeight); if ($(this).find("ul").css('display') == 'none') { $(this).find("span.expand").toggleText("+", "‒"); $(this).find("ul").slideDown( { start: function() { $(this).css("display", "grid"); } }); } else { $(this).find("span.expand").toggleText("‒", "+"); $(this).find("ul").slideUp(); } } }); if ($("#box_filter li.selected").length) { $("li.selected").parent().parent().find("span.expand").text("‒"); } } else if (atr_show == false) { if ($(".cloned .innerbox > div").length) { $(".cloned .innerbox > div").addClass("list").find("ul").css("display", "grid"); } } }); } } $("#box_filter:not(.cloned)").hide(); if ($(".cloned").find("li.showmore").length) { if (show_moreless_buttons == 1) { if(!(current_lang in translations_array['more_button'])) { more_button = translations_array['more_button']['__default']; } else { more_button = translations_array['more_button'][current_lang]; } if(!(current_lang in translations_array['less_button'])) { less_button = translations_array['less_button']['__default']; } else { less_button = translations_array['less_button'][current_lang]; } $(".cloned li.showmore").text(more_button).off('click').on('click', function() { if ($(this).hasClass('showless')) { $(this).removeClass("showless").text(more_button).parent().find('.less').addClass('none').removeClass('less'); } else if ($(this).hasClass('showmore')) { $(this).addClass('showless').text(less_button).parent().find(".none").addClass('less').removeClass('none'); } }); } else { $(".cloned").find("li.none").removeClass('none'); $(".cloned").find("li.showmore").hide(); } } } }).trigger('resize'); } } APIloader(); } });