var css_assets=document.createElement("style");css_assets.type="text/css";css_assets.id="appZaawansowaneFiltry";css_assets.textContent=`.app-filters .boxhead { margin-bottom: 0; padding: 4px 15px; border-bottom: 1px solid #d8d8d8; } .app-filters .boxhead span { font-size: 15px; color: #333333; margin-top: 0; } .app-filters .innerbox { display: block !important; background: #ffffff; padding: 0 !important; } .app-filters .innerbox .mx-filter { margin-bottom: 0 !important; padding-bottom: 0 !important; background: #ffffff !important; width: 100%; } .app-filters .innerbox .mx-filter.multimode-active li a img { display: none; } .app-filters .innerbox .mx-filter.border { border-bottom: 1px solid #d8d8d8; } .app-filters .innerbox .mx-filter.border:last-child { border-bottom: none; padding-bottom: 4px; } .app-filters .innerbox .mx-filter .mx-filter-head { width: 100%; display: grid; grid-template-columns: 1fr 10px; grid-gap: 0 10px; padding: 15px 15px 10px 15px; } .app-filters .innerbox .mx-filter.expandable .mx-filter-head { cursor: pointer; } .app-filters .innerbox .mx-filter .mx-filter-head h5, .app-filters .innerbox .mx-filter .mx-filter-head span { margin: 0 !important; font-size: 15px !important; color: #333333 !important; padding: 0 !important; border: none !important; } .app-filters .innerbox .mx-filter .mx-filter-head span.expand { font-size: 18px; font-weight: 600; color: #333333; } .app-filters .innerbox .mx-filter > ul .mx-container { padding: 0 15px 15px 15px !important; display: grid; height: auto; border: none; text-align: left; } .app-filters .innerbox .mx-filter > ul { width: auto !important; height: auto; border: none; text-align: left; margin: 0; padding: 0 !important; } .app-filters .innerbox .mx-filter > ul.all-visible .mx-container li.none { display: list-item !important; } .app-filters .innerbox .mx-filter > ul.all-visible .mx-container li.showmore { display: none !important; } .app-filters .innerbox .mx-filter.expandable > ul { display: none; grid-gap: 0 15px; box-sizing: content-box !important; margin-bottom: 0 !important; } .column-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } .column-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } .column-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } .column-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; } .column-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; } .column-7 { grid-template-columns: repeat(7, minmax(0, 1fr)) !important; } .column-8 { grid-template-columns: repeat(8, minmax(0, 1fr)) !important; } .column-9 { grid-template-columns: repeat(9, minmax(0, 1fr)) !important; } .column-10 { grid-template-columns: repeat(10, minmax(0, 1fr)) !important; } .column-11 { grid-template-columns: repeat(11, minmax(0, 1fr)) !important; } .column-12 { grid-template-columns: repeat(12, minmax(0, 1fr)) !important; } .app-filters.multimode .innerbox .mx-filter ul li::before { display: none; } .app-filters .innerbox .mx-filter ul li { margin: 5px 0 0 0 !important; background: #ffffff !important; object-fit: contain; } .app-filters .innerbox .mx-filter ul li.selected { padding: 0 !important; line-height: 24px !important; display: list-item !important; } .app-filters .innerbox .mx-filter ul li.selected::before { display: none !important; } .app-filters .innerbox .mx-filter ul li.showmore { grid-column: 1/-1; border: none !important; margin-top: 0 !important; color: #fb5642 !important; padding-left: 5px; } .app-filters .innerbox .mx-filter ul li.really-hidden { display: list-item !important; } .app-filters .innerbox .mx-filter ul li a, .app-filters .innerbox .mx-filter ul li a span, .app-filters .innerbox .mx-filter ul li a em { /*background: #ffffff !important;*/ color: #333333 !important; font-size: 14px !important; display: inline-block !important; } .app-filters .innerbox .mx-filter ul li a:focus { outline: none; } .app-filters .innerbox .mx-filter ul li a img { margin: 0 5px 0 5px !important; display: inline-block; } .app-filters .innerbox .mx-filter#filter_rate ul li { margin-top: 10px; } .app-filters .innerbox .mx-filter#filter_rate ul li a { display: grid; grid-template-columns: repeat(7, 1fr); justify-content: center; align-items: center; grid-gap: 5px; } .app-filters .innerbox .mx-filter#filter_rate ul li a img.px1 { grid-row: 1; grid-column: 1; margin: 0 !important; justify-self: center; } .app-filters .innerbox .mx-filter#filter_rate ul li a em { text-align: center; } .app-filters .innerbox .mx-filter#filter_rate ul li a span { display: none; } .app-filters .innerbox .mx-filter ul .mx-container { grid-template-columns: 100%; } .app-filters .innerbox .mx-filter ul li.priceinput { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 15px; padding-top: 0 !important; } .app-filters .innerbox .mx-filter ul li.priceinput input { margin-bottom: 0 !important; width: 100%; padding: 0 15px; } .app-filters .innerbox .mx-filter ul li.priceinput span.fromto { display: none !important; } .app-filters .innerbox .mx-filter ul li.priceinput .bottombuttons { margin-top: 0; grid-column: 1/3; } .app-filters .innerbox .mx-filter ul li.priceinput button.btn { border: none; width: 100%; padding: 5px 15px; margin: 0 !important; background: #971112; box-sizing: border-box; } .app-filters .innerbox .mx-filter ul li.priceinput button.btn span { text-transform: initial; font-size: 14px; color: #333333; } .app-filters .mx-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 15px; padding: 15px; background: #ffffff; } .app-filters .mx-buttons.one-grid { grid-template-columns: 100%; } .app-filters .mx-buttons button { transition: 0.5s; padding: 6px; } .app-filters .mx-buttons button span { text-transform: initial; } .app-filters .mx-buttons button.multimode-button { background: #971112; border-color: #971112; } .app-filters .mx-buttons button.multimode-button span { color: #ffffff; font-size: 16px; } .app-filters .mx-buttons button.reset-button { background: #000000; border-color: #000000; } .app-filters .mx-buttons button.reset-button.inactive { cursor: default; opacity: 0.7; } .app-filters .mx-buttons button.reset-button span { color: #ffffff; font-size: 16px; } @media (min-width: 768px) { .app-filters.filters-desktop { display: block !important; } .app-filters.filters-mobile { display: none !important; } } @media (max-width: 767px) { .app-filters.filters-desktop { display: none !important; } .app-filters.filters-mobile { display: block !important; } .centercol .app-filters { margin-top: 35px; padding-top: 0 !important; } .app-filters { background: #ffffff !important; margin-bottom: 0; } .app-filters:not(.mx-widget) { background: none !important; } .app-filters .boxhead { display: none; } .app-filters .innerbox .mx-filter { flex-basis: 100% !important; } .app-filters .mx-filter-list_container { width: 100%; } .app-filters button.mx-button { border: none; border-bottom: 1px solid; width: 100%; padding: 11px 15px; box-shadow: none !important; height: auto !important; } .app-filters.mx-widget button.mx-button.show-sort { border: none; } .app-filters.mx-widget button.mx-button.show-sort h5 { text-align: left; width: 100% !important; justify-self: start !important; margin: 0 !important; } .app-filters .mx-sort-list_container { width: 100%; margin-bottom: 15px; } .app-filters .mx-sort-list_container button.mx-button.show-sort { background: #ffffff; border-color: #000000; color: #000000; cursor: default; } .app-filters .mx-sort-list_container.expandable button.mx-button.show-sort { display: grid; grid-template-columns: 1fr 10px; grid-gap: 0 10px; cursor: pointer; } .app-filters .mx-sort-list_container button.mx-button.show-sort h5, .app-filters .mx-sort-list_container button.mx-button.show-sort span.expand { color: #000000; font-size: 16px; text-transform: initial; } .app-filters .mx-sort-list_container button.mx-button.show-sort h5 { margin-top: 0; margin-bottom: 0; width: calc(100% - 20px); justify-self: end; } .app-filters .mx-sort-list_container button.mx-button.show-sort span.expand { font-size: 18px; font-weight: 600; line-height: 21px; } .app-filters .mx-sort-list_container .sort-list { display: none; border: 1px solid #ffffff; background: #ffffff; border-top: none; padding: 5px 0; } .app-filters .mx-sort-list_container:not(.expandable) .sort-list { display: block !important; } .app-filters .mx-sort-list_container .sort-list a.mx-sort { display: block; padding: 5px 15px; color: #000000; font-size: 16px; } .app-filters.mx-widget .mx-sort-list_container .sort-list a.mx-sort { padding: 5px !important; } .app-filters .mx-sort-list_container .sort-list a.mx-sort:focus { outline: none; } .app-filters .mx-sort-list_container .sort-list a.mx-sort.active { font-weight: 600; } .app-filters .mx-filter-list_container button.mx-button.show-filters { background: #ffffff; border-color: #333333; color: #333333; display: grid; grid-template-columns: 1fr 10px; grid-gap: 0 10px; opacity: 1 !important; } .app-filters .mx-filter-list_container button.mx-button.show-filters h5, .app-filters .mx-filter-list_container button.mx-button.show-filters span.expand { color: #333333; font-size: 14px; text-transform: initial; margin: 0 !important; } .app-filters .mx-filter-list_container button.mx-button.show-filters h5 { width: calc(100% - 20px); justify-self: end; } .app-filters .mx-filter-list_container button.mx-button.show-filters span.expand { font-size: 18px; font-weight: 600; line-height: 21px; } .app-filters:not(.mx-widget) .mx-filter-list_container .filter-list { display: none; background: #ffffff; } .app-filters.fx-widget .mx-filter-list_container .filter-list .innerbox { height: auto !important; } .app-filters.mx-widget { position: fixed; width: 80% !important; top: 0; height: 100%; margin-top: 0 !important; z-index: 9999999999; background-color: #ffffff; margin-top: 0 !important; padding-top: 0 !important; } .app-filters.mx-widget.widget-left { left: -80%; border-right: 2px solid #ffffff; transition: 0.5s left; } .app-filters.mx-widget.widget-left.widget-opened { left: 0 !important; } .app-filters.mx-widget.widget-right { right: -80%; border-left: 2px solid #ffffff; transition: 0.5s right; } .app-filters.mx-widget.widget-right.widget-opened { right: 0 !important; } .app-filters.mx-widget button.show-filters { position: absolute; text-align: right; top: 200px; display: flex; align-items: center; justify-content: center; width: 30px; height: 120px; border: 1px solid #d8d8d8; background: #ffffff; transition: none; padding: 0 !important; opacity: 1 !important; } .app-filters.mx-widget.widget-left button.show-filters { right: calc(-2px - 30px); border-top-right-radius: 20px; border-bottom-right-radius: 20px; } .app-filters.mx-widget.widget-right button.show-filters { left: calc(-2px - 30px); border-top-left-radius: 20px; border-bottom-left-radius: 20px; } .app-filters.mx-widget button.show-filters span { color: #333333; font-size: 14px; text-transform: initial; } .app-filters.mx-widget.widget-left button.show-filters span { writing-mode: vertical-lr; } .app-filters.mx-widget.widget-right button.show-filters span { writing-mode: vertical-lr; rotate: 180deg; } .app-filters.mx-widget .mx-filter-list_container { height: 100%; overflow: auto; } .app-filters.mx-widget .mx-filter-list_container::-webkit-scrollbar { background: #ffffff; width: 3px; } .app-filters.mx-widget .mx-filter-list_container::-webkit-scrollbar-thumb { background: #333333; } .app-filters.mx-widget .mx-sort-list_container { background: #ffffff; } .app-filters.mx-widget .mx-sort-list_container .mx-filter-head h5 { font-size: 16px !important; color: #000000 !important; padding: 0 !important; } .app-filters.mx-widget .mx-sort-list_container .mx-filter-head span.expand { color: #000000 !important; } .app-filters.mx-widget .mx-sort-list_container ul.sort-list a { font-size: 16px; color: #000000; } .app-filters .mx-buttons button.multimode-button { background: #971112; border-color: #971112; } .app-filters .mx-buttons button.multimode-button span { color: #ffffff; font-size: 16px; } .app-filters .mx-buttons button.reset-button { background: #000000; border-color: #000000; } .app-filters .mx-buttons button.reset-button span { color: #ffffff; font-size: 16px; } }`;document.getElementsByTagName("head")[0].appendChild(css_assets);jQuery(function($){let config={"active":"1","button_font_size":"14","button_font_color":"#333333","button_bg_color":"#ffffff","widget_font_color":"#111111","widget_borders":"1","widget_border_color":"#d8d8d8","widget_border_thickness":"1","button_position":"200","widget_button_width":"120","widget_button_height":"30","widget_bg_color":"#ffffff","widget_type":"1","atr_show":"1","show_moreless_buttons":"0","moreless_buttons_color":"#fb5642","headers_font_size":"15","desktop_active":"1","desktop_atr_show":"1","desktop_multimode":"1","desktop_multimode-button_size":"16","desktop_multimode-button_color":"#ffffff","desktop_multimode-button_background":"#971112","desktop_multimode-showCategoryFilter":"0","desktop_reset-button_show":"1","desktop_reset-button_size":"16","desktop_reset-button_color":"#ffffff","desktop_reset-button_background":"#000000","mobile_active":"1","mobile_multimode":"1","mobile_multimode-button_size":"16","mobile_multimode-button_color":"#ffffff","mobile_multimode-button_background":"#971112","mobile_multimode-showCategoryFilter":"0","mobile_reset-button_show":"1","mobile_reset-button_size":"16","mobile_reset-button_color":"#ffffff","mobile_reset-button_background":"#000000","mobile_container":"","mobile_sort":"1","mobile_sort-button_size":"16","mobile_sort-button_color":"#000000","mobile_sort-button_background":"#ffffff","__translatable_fields":[],"shop_id":21};let translations={"widget_text":{"__default":"Filtry","pl_PL":"Filtruj"},"more_button":{"__default":"wi\u0119cej","pl_PL":"wi\u0119cej"},"less_button":{"__default":"mniej","pl_PL":"mniej"},"mobile_sort-button_text":{"__default":"Sortowanie","pl_PL":"Sortowanie"},"multimode-button_text":{"__default":"Filtruj","pl_PL":"Zaakceptuj"},"reset-button_text":{"__default":"Wyczy\u015b\u0107 filtry","pl_PL":"Wyczy\u015b\u0107"}};let char_plus="+";let char_minus="−";if(config.shop_id==308){char_plus='';char_minus='';} $.fn.extend({toggleText:function(a,b){if(config.shop_id==308){return this.html(this.html()==b?a:b);} else{return this.text(this.text()==b?a:b);}}});let appFilters={checkIfModulePresent:function(){if($("#box_filter").length){return true;} return false;},getCurrentDevice:function(){let width=window.innerWidth;if(width<=767){return"mobile";} else{return"desktop";}},checkIfCurrentDeviceActive:function(current_device){let searched_value=current_device+"_active";if(parseInt(config[searched_value])){return true;} return false;},generateAppForCurrentDevice:function(current_device,filter_module){let helpers=this.helpers;let generateForDesktop=(module_code,parent_container,module_index)=>{module_code.addClass('filters-desktop');helpers.generateFilterHeads(module_code,parseInt(config.desktop_atr_show));if(parseInt(config.desktop_multimode)){helpers.enableMultimode(module_code,current_device);module_code.find('#filter_price .bottombuttons').remove();} else{helpers.showSelectedOnFilterClick(module_code);} if(parseInt(config['desktop_reset-button_show'])){helpers.enableReset(module_code,current_device);} helpers.countButtons(module_code);if(module_index>0&&parent_container.find(`> *:nth-child(${module_index})`).length){module_code.insertAfter(parent_container.find(`> *:nth-child(${module_index})`));} else{parent_container.prepend(module_code);} if(!parseInt(config.desktop_atr_show)){setTimeout(function(){helpers.applyGrids(false);},1);} $(document).trigger("appZaawansowaneFiltry:desktopReady");};let generateForMobile=(module_code)=>{module_code.addClass('filters-mobile');let widget_type=parseInt(config.widget_type);helpers.generateFilterHeads(module_code,parseInt(config.atr_show));helpers.wrapWithWidgetOrList(module_code,widget_type);if(parseInt(config.mobile_sort)){helpers.enableSorting(module_code,widget_type);} if(parseInt(config.mobile_multimode)){helpers.enableMultimode(module_code);module_code.find('#filter_price .bottombuttons').remove();} else{helpers.showSelectedOnFilterClick(module_code);} if(parseInt(config['mobile_reset-button_show'])){helpers.enableReset(module_code);} helpers.countButtons(module_code);let localization=helpers.getMobileLocalization();localization.prepend(module_code);if(!parseInt(config.atr_show)){setTimeout(function(){helpers.applyGrids(true);},1);} $(document).trigger("appZaawansowaneFiltry:mobileReady");};var filter_module_clone=filter_module.clone(true,false);var filter_module_index=filter_module.index();var filter_parent_container=filter_module.parents("div[class*='s-grid']");filter_module_clone.addClass('app-filters');if(filter_module_clone.find('.multiselect').length){helpers.convertFromMultiselect(filter_module_clone);} else{filter_module_clone.find('.group-filter').addClass('mx-filter');} if(filter_module_clone.find('#filter_price').length){helpers.remakePriceInputs(filter_module_clone);} if(current_device=='desktop'){generateForDesktop(filter_module_clone,filter_parent_container,filter_module_index);} else if(current_device=='mobile'){generateForMobile(filter_module_clone);} else{console.warn("[Zaawansowane Filtry Mobile + Desktop] Nieznane urządzenie!");} helpers.manageMoreLessButtons(filter_module_clone);if(parseInt(config.widget_borders)){filter_module_clone.find('.mx-filter').addClass('border');}},helpers:{convertFromMultiselect:function(object){object.find('.multiselect').each(function(){$(this).off();$(this).removeClass('multiselect').addClass('group group-filter mx-filter');let group_name=$(this).find("> span").text().split(":")[0].trim();$(this).prepend(`
${group_name}
`).find('> span').remove();});},generateFilterHeads:function(object,flag_show_tabs){object.find('.mx-filter').each(function(){let currentFilter=$(this);if(!currentFilter.find("h5").length){currentFilter.find("> span").wrap('
');} else{currentFilter.find('h5').wrap('
');} currentFilter.find("> ul").append('
');var detached_filters=currentFilter.find("> ul li").detach();currentFilter.find("> ul .mx-container").append(detached_filters);if(!flag_show_tabs){return true;} currentFilter.find('.mx-filter-head').append(`${char_plus}`);currentFilter.addClass('expandable').on('click','.mx-filter-head',function(){currentFilter.find('> ul').toggleClass('expanded');currentFilter.find('span.expand').toggleText(char_plus,char_minus);if(currentFilter.find('> ul').is(':visible')){currentFilter.find('> ul').slideUp(500);} else{currentFilter.find('> ul').slideDown({start:function(){$(this).css('display','grid');}},500);}});});},remakePriceInputs:function(object,flag_enable_rangeSlider=false){let priceFrom_text=object.find('li.priceinput span.fromto')[0].innerText.trim();let priceTo_text=object.find('li.priceinput span.fromto')[1].innerText.trim();object.find('li.priceinput span.fromto, li.priceinput br').remove();object.find('li.priceinput input').slice(0,1).addClass('price-input mx-from').attr('placeholder',priceFrom_text);object.find('li.priceinput input').slice(1,2).addClass('price-input mx-to').attr('placeholder',priceTo_text);object.find('li.priceinput').on('click','button.btn',function(){let priceFrom=parseFloat(object.find('li.priceinput input').slice(0,1).val().replace(",","."));let priceTo=parseFloat(object.find('li.priceinput input').slice(1,2).val().replace(",","."));let old_module=$("#box_filter:not(.app-filters)");if(!isNaN(priceFrom)||!isNaN(priceTo)){if(!isNaN(priceFrom)){old_module.find('li.priceinput input').slice(0,1).val(priceFrom).trigger('change');} if(!isNaN(priceTo)){old_module.find('li.priceinput input').slice(1,2).val(priceTo).trigger('change');} old_module.find('li.priceinput button.btn').trigger('click');}});if(flag_enable_rangeSlider){}},manageMoreLessButtons:function(object){if(!parseInt(config.show_moreless_buttons)){$(".mx-filter ul").addClass('all-visible');return;} let show_less_text=this.getTranslation("less_button");let show_more_text=this.getTranslation("more_button");$(".mx-filter").each(function(){let currentFilter=$(this);currentFilter.find('li.showmore').on('click',function(){currentFilter.find('li.none').toggleClass('really-hidden');$(this).toggleText(show_more_text,show_less_text);});});},determineCurrentSortType:function(url=window.location.href){let page_number=this.getPageNumber();let url_part=url.split(`/${page_number}/default/`)[1];if(typeof url_part==="undefined"){return 1;} let sort_id=url_part.slice(0,1);return sort_id;},getPageNumber:function(){if(!$("ul.paginator").length){return 1;} let page_number=parseInt($(".innerbox .paginator .selected").text());return page_number;},getBaseURL:function(mode="no_sort"){let sort_id=this.determineCurrentSortType();let page_number=this.getPageNumber();let current_url=window.location.href.split(`/${page_number}/default/${sort_id}`)[0];let current_url_formatted=current_url;if(current_url_formatted.includes('?')){current_url_formatted=current_url.split('?')[0];} if(current_url.includes(`/${page_number}`)&&!current_url.includes('default')&&page_number>1){current_url_formatted=current_url_formatted.replace(`/${page_number}`,'');} if(current_url.includes('?url')){current_url_formatted=current_url_formatted.replace('/phot','');} if(mode==="sort"){return`${current_url_formatted}/${page_number}/default/${sort_id}`;} return`${current_url_formatted}`;},getBaseURLParameters:function(){let params_array=[];let sort_id=this.determineCurrentSortType();let page_number=this.getPageNumber();let current_url=window.location.href.split(`/${page_number}/default/${sort_id}/`);if(current_url.length==1){return[];} let present_filters=current_url[1].split('/');for(let param_index in present_filters){param_index=parseInt(param_index);let param=present_filters[param_index];if(param.length==1||!isNaN(param)){continue;} if(param.includes('news')||param.includes('promotion')){params_array.push(`${param}/0`);} else if(param.includes('priceto')||param.includes('pricefrom')){let price_value=present_filters[param_index+1];params_array.push(`${param}/${price_value}`);} else{params_array.push(`${param}/1`);}} return params_array;},enableMultimode:function(object,current_device="mobile"){if(!object.find(".mx-filter li a[data-link-part]").length){console.error("[Zaawansowane Filtry Mobile + Desktop] Brak atrybutu data-link-part w pliku boxes/filter/box.tpl! Tryb multiwyboru nieaktywny. Skontaktuj się z Maxsote w celu naprawy błędu.");return false;} let checkIfInArray=(array=[],attribute)=>{if(typeof attribute==='undefined'){return array;} if(attribute.includes('pricefrom')||attribute.includes('priceto')){let attribute_name=attribute.split('/')[0];let attribute_index=array.findIndex(element=>element.includes(attribute_name));if(attribute_index!==-1){if(attribute==array[attribute_index]){array.splice(attribute_index,1);} else{array[attribute_index]=attribute;}} else{array.push(attribute);}} else if(array.includes(attribute)){array.splice(array.indexOf(attribute),1);} else{array.push(attribute);} return array;};let generateURL=(selected_filters)=>{let sort_id=this.determineCurrentSortType();let new_url=this.getBaseURL()+`/1/default/${sort_id}/`;for(let filter_id in selected_filters){let filter_values=selected_filters[filter_id];for(let filter of filter_values){new_url+=`${filter}/`;}} return new_url;};let config_optionName=`${current_device}_multimode-showCategoryFilter`;if(parseInt(config[config_optionName])){object.find('.mx-filter#filter, .mx-filter[id*=filter_category]').addClass('multimode-active');} else{object.find('.mx-filter#filter, .mx-filter[id*=filter_category]').hide();} let selectedFilters={};object.addClass('multimode').find('.mx-filter:not(#filter, [id*=filter_category])').each(function(){let currentFilterGroup=$(this);let currentFilterGroup_id=currentFilterGroup.attr('id');if(!currentFilterGroup.find('ul').children().length){return true;} if($(this).find('li.selected').length){$(this).find(".mx-filter-head span.expand").toggleText(char_plus,char_minus);$(this).find('ul').addClass('expanded').css('display','grid');} selectedFilters[currentFilterGroup_id]=[];currentFilterGroup.find("ul li").each(function(){let currentFilter=$(this);let filter_link_part=currentFilter.find('a').attr('data-link-part');if(currentFilter.hasClass('selected')){if(currentFilterGroup_id==='filter_price'&&(filter_link_part.includes('pricefrom')&&filter_link_part.includes('priceto'))){let new_filter_link_part=filter_link_part.split('/');selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],`${new_filter_link_part[0]}/${new_filter_link_part[1]}`);selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],`${new_filter_link_part[2]}/${new_filter_link_part[3]}`);} else{selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],filter_link_part);}} currentFilter.on('click','a',function(event){event.preventDefault();currentFilter.toggleClass('selected');if(filter_link_part.includes('pricefrom')&&filter_link_part.includes('priceto')){filter_link_part_array=filter_link_part.split('/');let prices=[];prices.push(`${filter_link_part_array[0]}/${filter_link_part_array[1]}`);prices.push(`${filter_link_part_array[2]}/${filter_link_part_array[3]}`);for(let price of prices){selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],price);} return true;} selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],filter_link_part);});if(currentFilterGroup_id==='filter_price'){currentFilterGroup.off('change');currentFilterGroup.on('change','input.price-input',function(){let name='';if($(this).hasClass('mx-from')){name='pricefrom';} else if($(this).hasClass('mx-to')){name='priceto';} let value=parseFloat($(this).val().replace(".",","));selectedFilters[currentFilterGroup_id]=checkIfInArray(selectedFilters[currentFilterGroup_id],`${name}/${value}`);});}});});if(!object.find('.mx-buttons').length){if(current_device=="mobile"){object.find('.mx-filter-list_container .filter-list').append("
");} else{object.append("
");}} let multimode_button_text=this.getTranslation('multimode-button_text');object.find('.mx-buttons').append(``).on('click','button.multimode-button',function(){window.location.href=generateURL(selectedFilters);});},showSelectedOnFilterClick:function(object){object.find('.mx-filter li').each(function(){let currentFilter=$(this);currentFilter.on('click','a',function(){currentFilter.toggleClass('selected');});});},enableReset:function(object,current_device="mobile"){let $this=this;if(!object.find('.mx-buttons').length){if(current_device=="mobile"){object.find('.mx-filter-list_container .filter-list').append("
");} else{object.append("
");}} let reset_button_text=this.getTranslation('reset-button_text');object.find('.mx-buttons').append(``).on('click','button.reset-button',function(){if($(this).hasClass('inactive')){return true;} let sort_id=$this.determineCurrentSortType();if(sort_id>1){window.location.replace(`${$this.getBaseURL()}/${$this.getPageNumber()}/default/${sort_id}`);} else{window.location.replace($this.getBaseURL());}});let params=$this.getBaseURLParameters();let params_count=params.length;if(params_count==0){object.find('button.reset-button').addClass('inactive');return;} object.find('button.reset-button span').text(reset_button_text+` (${params_count})`);},countButtons:function(object){if(object.find('.mx-buttons').children().length==1){object.find('.mx-buttons').addClass('one-grid');} else if(object.find('.mx-buttons').children().length==0){object.find('.mx-buttons').hide();}},getTranslation:function(var_name,current_lang=Shop.lang.name){if(!(current_lang in translations[var_name])){translation=translations[var_name]['pl_PL'];} else{translation=translations[var_name][current_lang];} return translation;},wrapWithWidgetOrList:function(object,widget_type){let widget_text=this.getTranslation('widget_text');if(widget_type==1||widget_type==4){object.find('> div').wrapAll("
");object.find('.mx-filter-list_container > div').wrapAll("
");object.find('.mx-filter-list_container').prepend(`
`).on('click','button.show-filters',function(){$(this).toggleClass('list-visible').find('span.expand').toggleText(char_plus,char_minus);$(".filter-list").slideToggle(500);});} else if(widget_type==2||widget_type==3){let widget_side="left";if(widget_type==3){widget_side="right";} object.addClass(`mx-widget widget-${widget_side}`).find('> div').wrapAll("
");object.append(``).on('click','button.show-filters',function(){object.toggleClass('widget-opened');});}},enableSorting:function(object,widget_type){let $this=this;if(!$(".sort-and-view select.gotourl").length&&!$(".sort-and-view .products-sort-container").length){console.warn("[Zaawansowane filtry mobile + desktop] Moduł sortowania wyłączony, pomijanie generowania listy.");return;} let page_number=this.getPageNumber();let sort_node=null;let flag_vogue=false;if($(".sort-and-view select.gotourl").length){sort_node=".sort-and-view select.gotourl option";} else if($(".sort-and-view .sortlinks").length==2){flag_vogue=true;sort_node=".sort-and-view .sortlinks";} else if($(".sort-and-view .products-sort-container").length){sort_node=".sort-and-view .products-sort-container a";} let sort_list={};$(sort_node).each(function(){let filter_name=null;let url=null;if(!flag_vogue){filter_name=$(this).text();if($(".sort-and-view select.gotourl").length){url=$(this).attr('value').split(`/${page_number}/default/`);} else if($(".sort-and-view .products-sort-options").length){url=$(this).attr('href').split(`/${page_number}/default/`);} if(url.length==1){sort_list[filter_name]=`/${page_number}/default/1`;} else{if(url[1].length>1){let filter_parameter=url[1].split('/')[0];sort_list[filter_name]=(`/${page_number}/default/${filter_parameter}`);} else{sort_list[filter_name]=`/${page_number}/default/${url[1]}`;}}} else{$(this).find('a').each(function(){filter_name=`${$(this).contents().get(0).nodeValue} ${$(this).find('span').text()}`;filter_name=$(this).text();url=$(this).attr('href').split(`/${page_number}/default/`);if(url.length==1){sort_list[filter_name]=`/${page_number}/default/1`;} else{if(url[1].length>1){let filter_parameter=url[1].split('/')[0];sort_list[filter_name]=(`/${page_number}/default/${filter_parameter}`);} else{sort_list[filter_name]=`/${page_number}/default/${url[1]}`;}}});}});if(Object.keys(sort_list).length<=1){console.warn("[Zaawansowane filtry mobile + desktop] Brak innych opcji sortowania, pomijanie generowania listy.");return;} let currentSortIsActive=(sort_url)=>{let current_sort_id=parseInt(sort_url[sort_url.length-1]);let url_sort_id=parseInt($this.determineCurrentSortType());if(current_sort_id==url_sort_id){return true;} return false;} let mobile_sort_button_text=this.getTranslation('mobile_sort-button_text');let base_url=$this.getBaseURL("sort");let url_parameters=$this.getBaseURLParameters();let sort_html="";let prepend_location="";if(widget_type==1||widget_type==4){sort_html=`
`;} else if(widget_type==2||widget_type==3){prepend_location=".innerbox";sort_html=`
`;} if(prepend_location.length){object.find(prepend_location).prepend(sort_html);} else{object.prepend(sort_html);} object.find('.mx-sort-list_container.expandable').on('click','button.show-sort',function(){$(this).toggleClass('list-visible').find('span.expand').toggleText(char_plus,char_minus);object.find('.sort-list').slideToggle(500);});let target_node=object.find('.mx-sort-list_container .sort-list');for(let sort_name in sort_list){let sort_url=sort_list[sort_name];let current_sort_url;if(url_parameters.length==0&&!base_url.includes('default')){current_sort_url=`${base_url}${sort_url}`;if(sort_url.includes('/default/1')){target_node.append(`${sort_name}`);} else{target_node.append(`${sort_name}`);}} else if(url_parameters.length==0&&base_url.includes('default')){let mod_base_url=base_url.split(`/${page_number}/default/`)[0];current_sort_url=`${mod_base_url}${sort_url}`;target_node.append(`${sort_name}`);} else if(url_parameters.length>0){let mod_base_url=base_url.split(`/${page_number}/default/`)[0];current_sort_url=`${mod_base_url}${sort_url}/${url_parameters.join('/')}`;target_node.append(`${sort_name}`);}}},getMobileLocalization:function(){if(parseInt(config.widget_type)==4){if($(config.mobile_container).length){return $(config.mobile_container);} else{console.warn("[Zaawansowane Filtry Mobile + Desktop] Wskazany selektor kontenera nie został znaleziony! Umieszczanie modułu filtrów w domyślnej lokalizacji.");return $(".s-row .centercol");}} return $(".s-row .centercol");},applyGrids:function(flag_mobile){if(window.location.href.includes("marko.pl")&&!window.location.href.includes("?mx_test"))return;if(flag_mobile){var filter_width=$(".mx-filter-list_container").width();} else{var filter_width=$(".app-filters .innerbox").width();} if($(".app-filters .filter-list").css('display')==='none'&&(parseInt(config.widget_type)==1||parseInt(config.widget_type)==4)&&flag_mobile){$(".app-filters .filter-list").show();} $(".app-filters").find('.mx-filter').each(function(){let currentFilter=$(this);let biggest_attribute_width=0;currentFilter.find('ul li:not(.showmore)').each(function(){let current_attribute_width=$(this).find('a').outerWidth()+10;if(current_attribute_width>biggest_attribute_width){biggest_attribute_width=current_attribute_width;}});let max_columns=filter_width / biggest_attribute_width|0;let attribute_count=currentFilter.find('ul li:not(.showmore)').length;if(max_columns>attribute_count){max_columns=attribute_count}});if($(".app-filters .filter-list").css('display')!=='none'&&(parseInt(config.widget_type)==1||parseInt(config.widget_type)==4)&&flag_mobile){$(".app-filters .filter-list").hide();}}},init:function(){var $this=this;if(!$this.checkIfModulePresent()){return false;} let initialized_views={'desktop':false,'mobile':false};var filter_module=$("#box_filter:not(.app-filters)");filter_module.hide();$(window).on('resize',function(){let current_device=$this.getCurrentDevice();if($this.checkIfCurrentDeviceActive(current_device)&&!initialized_views[current_device]){initialized_views[current_device]=true;$this.generateAppForCurrentDevice(current_device,filter_module);} else if(!$this.checkIfCurrentDeviceActive(current_device)){filter_module.removeAttr('style');} if(initialized_views.desktop&&initialized_views.mobile){filter_module.remove();}}).trigger('resize');}};appFilters.init();});