PageSourceSearch

https://www.knjizare-vulkan.rs/nb-public/themes/nbshop7_v1_1/stati…/product/NBUI_ProductFilter.js?ver=1053_3.1

js knjizare-vulkan.rs collected 2026-10-02 07:59:09 UTC 38,891 bytes, 1,194 lines download raw bytes

1function rewriteURL(newTitle, newURL){
2    window.history.pushState(newURL, newTitle, newURL);
3    window.history.replaceState(newURL, newTitle, newURL);
4    // reloadGoogleAnalyticsUniversal();
5    // gemiusReloadSkript();
6    //reloadGoogleAnaliticksCode(newURL);
7}
8
9//LM: Dodato da bi omogućili reload pri povratku na prethodnu stranu u okviru browser-a
10window.addEventListener('popstate', function (event) {
11    // samo BACK & FORTH
12    location.reload();
13});
14
15// FILTER START
16function NBFilter(form, category, sep1, sep2, pageId) {
17    this.form                   = form;
18    this.category               = category;
19    this.attributes             = new Array();
20    this.filterSizeEuIds        = new Array();
21    this.filterPricelistItems   = new Array();
22    this.filterLists            = new Array();
23    this.sep1                   = sep1;
24    this.sep2                   = sep2;
25    this.pageId                 = pageId;
26    this.pageName               = 'page-';
27    this.searchId               = 'search';
28    this.authorId               = 'f_author';
29    this.listId                 = 'listId';
30    this.pricesId               = 'prices';
31    this.distancesId            = 'distances';
32    this.infopriceId            = 'infoprice';
33    this.saleId                 = 'sale';
34    this.outletId               = 'outlet';
35    this.storeId                = 'storeId';
36    this.sizeEUId               = 'sizeEUId';
37    this.filterDiscountedProducts = 'f_discountedProducts';
38    this.filterFreeDelivery = 'f_freeDelivery';
39};
40
41NBFilter.prototype.setAttribute = function(id, value) {
42    if( typeof this.attributes[id] != "undefined" ) {
43        this.attributes[id][value] = value;
44    }else{
45        this.attributes[id] = new Array();
46        this.attributes[id][value] = value;
47    }
48};
49
50NBFilter.prototype.deleteAttribute = function(id, value) {
51    if( typeof this.attributes[id] != "undefined" ) {
52        if( typeof this.attributes[id][value] != "undefined" ) {
53            delete this.attributes[id][value];
54        }
55    }
56};
57
58NBFilter.prototype.deleteAllSelectedAttributes = function() {
59    if( typeof this.attributes != "undefined" ) {
60        this.attributes = new Array();
61    }
62};
63
64NBFilter.prototype.deleteAllRestSelectedFilter = function() {
65    this.deleteSelSizeEU();
66    this.deleteSelList(false);
67    this.deleteSelOutlet(false);
68    this.deleteSelSale(false);
69    this.deleteSelSearchText(false);
70    this.deleteSelPrice('','',false);
71};
72
73NBFilter.prototype.deleteSelSizeEU = function() {
74    $('#'+this.sizeEUId).val('');
75};
76
77NBFilter.prototype.deleteSelAttribute = function(value) {
78    //attributes
79    for (var i in this.attributes) {
80        for (var a in this.attributes[i]) {
81            if(a == value){
82                $('#'+i+'_'+value).prop('checked', false);
83                this.deleteAttribute(i, value);
84                this.loadProductForPage(0);
85                break;
86            };
87        };
88    };
89};
90
91NBFilter.prototype.deleteSelPrice = function(from, to,reloadprod) {
92    if(typeof reloadprod == 'undefined' || reloadprod){
93        this.loadProductForPage(0);
94    }
95};
96
97NBFilter.prototype.deleteSelList = function(reloadprod) {
98    $('#'+this.listId).val(0);
99    if(typeof reloadprod == 'undefined' || reloadprod){
100        this.loadProductForPage(0);
101    }
102};
103
104NBFilter.prototype.deleteSelSearchText = function(reloadprod) {
105    $('#'+this.searchId).val('');
106    if(typeof reloadprod == 'undefined' || reloadprod){
107        this.loadProductForPage(0);
108    }
109};
110
111NBFilter.prototype.deleteSelSale = function(reloadprod) {
112    $('#'+this.saleId).val('no');
113    if(typeof reloadprod == 'undefined' || reloadprod){
114        this.loadProductForPage(0);
115    }
116};
117
118NBFilter.prototype.deleteSelOutlet = function(reloadprod) {
119    $('#'+this.outletId).val('no');
120    if(typeof reloadprod == 'undefined' || reloadprod){
121        this.loadProductForPage(0);
122    }
123};
124
125NBFilter.prototype.getCategory = function() {
126    return $('#'+this.category).val();
127};
128
129NBFilter.prototype.getPage = function() {
130    return $('#'+this.pageId).val();
131};
132
133NBFilter.prototype.getSearch = function() {
134    if($('#'+this.searchId).length > 0){
135        return $('#'+this.searchId).val();
136    }
137    return "";
138};
139
140NBFilter.prototype.getAuthor = function() {
141    return $('#'+this.authorId).val();
142};
143
144NBFilter.prototype.getList = function() {
145    return $('#'+this.listId).val();
146};
147
148NBFilter.prototype.getSizeEU = function() {
149    return $('#'+this.sizeEUId).val();
150};
151
152NBFilter.prototype.getPrices = function() {
153    return $('#'+this.pricesId).val();
154};
155
156NBFilter.prototype.getDistances = function() {
157    return $('#'+this.distancesId).val();
158};
159
160NBFilter.prototype.getInfoPrice = function() {
161    return $('#'+this.infopriceId).val();
162};
163
164NBFilter.prototype.getSale = function() {
165    return $('#'+this.saleId).val();
166};
167
168NBFilter.prototype.getOutlet = function() {
169    return $('#'+this.outletId).val();
170};
171
172NBFilter.prototype.getDiscountedProducts = function() {
173    if ($('#'+this.filterDiscountedProducts).is(':checked')) {
174        return $('#'+this.filterDiscountedProducts).val();
175    }
176};
177
178NBFilter.prototype.getFreeDelivery = function() {
179    if ($('#'+this.filterFreeDelivery).is(':checked')) {
180        return $('#'+this.filterFreeDelivery).val();
181    }
182};
183
184
185NBFilter.prototype.getStartPage = function(){
186
187    startPage = 0;
188    if(typeof(startPager) != "undefined" && startPager !== null) {
189        startPage = startPager;
190    }
191
192    return startPage;
193}
194
195NBFilter.prototype.permalink = function() {
196
197    var formatArray = [];
198    var startPage = this.getStartPage();
199
200    //site and category
201    var permalink = this.getCategory();
202
203    if(permalink.substr(permalink.length - 1) != '/'){
204        permalink += '/';
205    }
206
207    var atrUrl = '';
208    for (var i in this.attributes) {
209
210        var formatSubArray = [];
211        for (var a in this.attributes[i]) {
212            formatSubArray.push(a);
213        }
214
215        if(formatSubArray.length > 0){
216            formatArray.push(formatSubArray.join(this.sep2));
217        }
218    }
219
220    atrUrl = formatArray.join(this.sep1);
221    if(atrUrl != ''){
222        permalink += atrUrl+'/';
223    }
224
225    if(this.getList() != 0 && typeof this.getList() != 'undefined'){
226        permalink += this.getList()+'/';
227    }
228
229    if(this.getPage() != '' && this.getPage() > startPage && typeof this.getPage() != 'undefined'){
230        permalink += this.pageName+this.getPage();
231    }
232
233    var customPermalink     = '';
234    var firstCustomFilter   = true;
235
236    if(this.getSizeEU() != '' && typeof this.getSizeEU() != 'undefined'){
237        if(!firstCustomFilter){customPermalink += '&';}
238        firstCustomFilter = false;
239        var sizeText = this.getSizeEU();
240        var resultTextFormatPermalinkSizeEU = sizeText.replace(/ /g, "+");
241        //customPermalink += 'sizeEU='+encodeURIComponent(resultTextFormatPermalinkSizeEU);
242        customPermalink += 'sizeEU='+resultTextFormatPermalinkSizeEU;
243    }
244
245    if(this.getSearch() != ''){
246        if(!firstCustomFilter){customPermalink += '&';}
247        firstCustomFilter = false;
248        customPermalink += this.searchId+'='+this.getSearch();
249    }
250
251    if(this.getAuthor() != ''){
252        if(!firstCustomFilter){customPermalink += '&';}
253        firstCustomFilter = false;
254        customPermalink += 'author='+this.getAuthor();
255    }
256
257    if(this.getPrices() != '' && typeof this.getPrices() != 'undefined'){
258        if(!firstCustomFilter){customPermalink += '&';}
259        firstCustomFilter = false;
260        customPermalink += this.pricesId+'='+this.getPrices();
261    }
262
263    if(this.getDistances() != '' && typeof this.getDistances() != 'undefined'){
264        if(!firstCustomFilter){customPermalink += '&';}
265        firstCustomFilter = false;
266        customPermalink += this.distancesId+'='+this.getDistances();
267    }
268
269    if(this.getInfoPrice() != '' && typeof this.getInfoPrice() != 'undefined'){
270        if(!firstCustomFilter){customPermalink += '&';}
271        firstCustomFilter = false;
272        customPermalink += this.infopriceId+'='+this.getInfoPrice();
273    }
274
275    if(this.getDiscountedProducts() != '' && typeof this.getDiscountedProducts() != 'undefined'){
276        if(!firstCustomFilter){customPermalink += '&';}
277        firstCustomFilter = false;
278        customPermalink += 'discountedProducts='+this.getDiscountedProducts();
279    }
280
281    if(this.getFreeDelivery() != '' && typeof this.getFreeDelivery() != 'undefined'){
282        if(!firstCustomFilter){customPermalink += '&';}
283        firstCustomFilter = false;
284        customPermalink += 'freeDelivery='+this.getFreeDelivery();
285    }
286
287    if(this.getSale() != 'no'){
288        //customPermalink += this.saleId+'='+this.getSale();
289        if(!firstCustomFilter){customPermalink += '&';}
290        firstCustomFilter = false;
291        customPermalink += this.saleId+'='+this.getSale();
292    }
293
294    if(this.getOutlet() != 'no'){
295        if(!firstCustomFilter){customPermalink += '&';}
296        firstCustomFilter = false;
297        customPermalink += this.outletId+'='+this.getOutlet();
298    }
299
300    if(customPermalink != ''){
301        //permalink += '/?'+customPermalink;
302        permalink += '?'+customPermalink;
303    }
304
305    //permalink = permalink.replace(/^\/|\/$/g, '').replace('/?', '?');
306
307    return permalink;
308};
309
310NBFilter.prototype.formatFilterSizeEUValue = function(sizeEuPermalink, sizeEu){
311    let isDelete = false;
312    if(!this.checkInArraySizeEUValue(sizeEuPermalink)){
313        this.filterSizeEuIds[sizeEuPermalink] = encodeURIComponent(sizeEuPermalink);
314    }else{
315        this.filterSizeEuIds[sizeEuPermalink] = 'undefined';
316    }
317    this.updateSizeEuSearchValue(isDelete);
318}
319
320NBFilter.prototype.checkInArraySizeEUValue = function(sizeEuPermalink){
321    for (key in this.filterSizeEuIds) {
322        if(this.filterSizeEuIds[key] === sizeEuPermalink){
323            return true;
324        }
325    }
326    return false;
327}
328
329NBFilter.prototype.deleteSelctedEuSize = function(sizeEuPermalink, sizeEu){
330    let isDelete = true;
331    //if(this.filterSizeEuIds.length > 0){
332        for (key in this.filterSizeEuIds) {
333            this.filterSizeEuIds[sizeEuPermalink] = 'undefined';
334        }
335    //}
336
337    this.updateSizeEuSearchValue(isDelete);
338}
339
340NBFilter.prototype.updateSizeEuSearchValue = function(isDelete = false){
341
342    let text = "";
343
344    var first = true;
345    for (key in this.filterSizeEuIds) {
346        if(first){
347            if(this.filterSizeEuIds[key] != 'undefined' && this.filterSizeEuIds[key] != -1 && this.filterSizeEuIds[key] != ''){
348                text += key;
349                first = false;
350            }
351        }else{
352            if(this.filterSizeEuIds[key] != 'undefined' && this.filterSizeEuIds[key] != -1 && this.filterSizeEuIds[key] != ''){
353                text += ","+key;
354            }
355        }
356    }
357
358    $('#'+this.sizeEUId).val(text);
359    if(isDelete) {
360        nbFilter.loadProductForPage(0);
361    } else {
362        nbFilter.initFilters('.nbf-filter-btn-apply');
363    }
364}
365
366
367NBFilter.prototype.formatFilterPriceList = function(priceFrom, priceTo, resetFilters = false){
368
369    if(resetFilters){
370        this.filterPricelistItems = [];
371    }
372
373    var priceItem = {
374        key: priceTo,
375        value: String(priceFrom)+'-'+String(priceTo)
376    };
377
378    var fined                 = false;
379    //if(this.filterPricelistItems.length > 0){
380        for (key in this.filterPricelistItems) {
381            if(this.filterPricelistItems[key].key == priceTo && this.filterPricelistItems[key].key != -1){
382                //ako je prosao kroz niz i pronasao element, onda ga obrisi
383                this.filterPricelistItems[key].key =  -1;
384                fined = true;
385            }
386        }
387    //}
388
389    if(!fined){
390        this.filterPricelistItems.push(priceItem);
391    }
392
393    this.updateFilterPricelistItems();
394}
395
396NBFilter.prototype.deleteFilterPricelistItems = function(priceFrom, priceTo){
397
398    //if(this.filterPricelistItems.length > 0){
399        for (key in this.filterPricelistItems) {
400            if(this.filterPricelistItems[key].key == priceTo && this.filterPricelistItems[key].key != -1){
401                //ako je prosao kroz niz i pronasao element, onda ga obrisi
402                this.filterPricelistItems[key].key =  -1;
403            }
404        }
405    //}
406    this.updateFilterPricelistItems(true);
407}
408
409NBFilter.prototype.deleteFilterPricelistItemsAll = function(){
410    if(typeof this.filterPricelistItems != "undefined") {
411        this.filterPricelistItems = new Array();
412        $('#'+this.pricesId).val("");
413    }
414}
415
416NBFilter.prototype.updateFilterPricelistItems = function(deleteFilter){
417
418    var text          = "";
419    var first       = true;
420
421    //if(this.filterPricelistItems.length > 0){
422        for (key in this.filterPricelistItems) {
423            if(first){
424                if(this.filterPricelistItems[key].key != 'undefined' && this.filterPricelistItems[key].key != -1 && this.filterPricelistItems[key].key != ''){
425                    text += this.filterPricelistItems[key].value;
426                    first = false;
427                }
428            }else{
429                if(this.filterPricelistItems[key].key != 'undefined' && this.filterPricelistItems[key].key != -1 && this.filterPricelistItems[key].key != ''){
430                    text += "_"+this.filterPricelistItems[key].value;
431                }
432            }
433        }
434    //}
435
436    //todo ovo proveriti da li menjamo id- jeve u hiden polja
437    $('#'+this.pricesId).val(text);
438    if (deleteFilter) {
439        nbFilter.loadProductForPage(0);
440    } else {
441        nbFilter.initFilters('.nbf-filter-btn-apply');
442    }
443};
444
445function formatFilterDiscountedProducts() {
446    const el = document.getElementById('f_discountedProducts');
447
448    el.value = el.checked ? 'yes' : 'no';
449
450    nbFilter.load_products();
451}
452function formatFilterFreeDelivery() {
453    const el = document.getElementById('f_freeDelivery');
454
455    el.value = el.checked ? 'yes' : 'no';
456
457     nbFilter.load_products();
458}
459NBFilter.prototype.formatFilterLists = function(listId){
460    this.filterLists = new Array();
461
462    if(this.filterLists.indexOf(listId) == -1 || this.filterLists[listId] == 'undefined'){
463        this.filterLists[listId] = listId;
464    }else{
465        this.filterLists[listId] = 'undefined';
466    }
467
468    this.updateFilterLists();
469}
470
471NBFilter.prototype.updateFilterLists = function(){
472
473    var text = "";
474    var first = true;
475    for (key in this.filterLists){
476        if(first){
477            if(this.filterLists[key] != 'undefined' && this.filterLists[key] != -1 && this.filterLists[key] != ''){
478                text += key;
479                first = false;}
480        }else{
481            if(this.filterLists[key] != 'undefined' && this.filterLists[key] != -1 && this.filterLists[key] != ''){
482                text += ","+key;
483            }
484        }
485    }
486
487    $('#'+this.listId).val(text);
488    nbFilter.initFilters('.nbf-filter-btn-apply');
489}
490
491NBFilter.prototype.deleteFilterListsAll = function(){
492    if( typeof this.filterLists != "undefined" ) {
493        this.filterLists = new Array();
494        $('#'+this.listId).val("");
495    }
496}
497
498NBFilter.prototype.animateScrollTop = function($element){
499    $('html, body').animate({
500        scrollTop: $element.offset().top - ($('.header').height() + 50)
501    }, 100);
502};
503
504NBFilter.prototype.loadProductForPage = function(page, scroll, backUrl) {
505    var modelNBUI_Loader = new NBUI_Loader();
506    if (typeof scroll == 'undefined') {
507        scroll = true;
508    }
509
510    if (scroll) {
511        this.animateScrollTop($(".nb-product-listing-display-grid-2"));
512    }
513
514    $('#f_page').val(page);
515
516    if ($('.nbf-filter-wrapper').length > 0 && $('.nbf-filter-wrapper').hasClass('nb-filter-open')) {
517        setTimeout(() => {
518            $('.nbf-filter-wrapper').removeClass('nb-filter-open');
519        }, 50);
520    }
521
522    modelNBUI_Loader.showLoader($('.nbf-loader-product-listing'));
523    setTimeout(()=> {
524        this.load_products(backUrl);
525        if (typeof NBUI_Popover !== 'undefined' && typeof NBUI_Popover.prototype.initAllPopovers === 'function') {
526            let modelNBUI_Popover = new NBUI_Popover();
527            modelNBUI_Popover.initAllPopovers();
528        }
529    }, 1000);
530};
531
532//Main function for loading products
533NBFilter.prototype.load_products = function(backUrl, refreshEntireProductListFleg = true, autoLoadFleg = false, loadPrevProducts = false, blockData = false, $elementLoadMore = ''){
534
535    var modelNBUI_Loader            = new NBUI_Loader();
536    var modelNBProductFilter      = new NBProductFilter();
537
538    var params                                  = $("#filter_form").serializeObject();
539    var newUrl                                  = this.permalink();
540    var $productListing                         = $('.nbf-product-listing');
541
542
543    //todo ovo izvuci u funkciju
544    var layoutsIds = [];
545    $productListing.find('.layout').each(function (){
546         layoutsIds.push($(this).data('layout-id'));
547    })
548
549    if(autoLoadFleg){
550        params.autoload = 'yes'
551    }
552
553    if(!refreshEntireProductListFleg){
554        params.refreshentireproductlist = 'no';
555    }
556
557    if(autoLoadFleg && blockData){
558        params.allLib       = -1;
559        params.typeRender   = 2;
560        params.block        = blockData.blockId;
561        params.paginationTypeAction = 'next';
562        if(loadPrevProducts){
563            params.paginationTypeAction = 'prev';
564        }
565    }else{
566        layoutsIds  = layoutsIds.toString();
567        if(layoutsIds != ""){
568            params.layoutsIds = layoutsIds;
569        }
570    }
571
572    //LM: Vraćeno na staro jer je nastao problem na Games-u.
573   // //zbog redirekcije
574   // modelNBProductFilter.urlLoad = newUrl.replace(/\/$/, "");
575   modelNBProductFilter.urlLoad = this.removeSlashFromEndOfUrl(newUrl);
576    var result = modelNBProductFilter.load(params);
577    if(result.flag){
578        if(result.ret.flag){
579
580            if(result.ret.autoLoad) {
581
582                let productListingLayoutId = 'layout'+blockData.layoutId;
583                let productListingLayout = document.getElementById(productListingLayoutId);
584                let allPruductListingLayouts = productListingLayout.querySelectorAll(".nbf-product-listing-ident");
585
586                if(loadPrevProducts){
587                    let firstProductListingLayout = allPruductListingLayouts[0];
588                    firstProductListingLayout.insertAdjacentHTML("beforebegin", result.ret.info);
589                    //$('#layout'+blockData.layoutId).prepend(result.ret.info);
590                }else{
591
592                    let lastProductListingLayout = allPruductListingLayouts[allPruductListingLayouts.length - 1];
593                    lastProductListingLayout.insertAdjacentHTML("afterend", result.ret.info);
594                    //$('#layout'+blockData.layoutId).append(result.ret.info);
595                }
596
597                //$elementLoadMore.removeClass("addingItem");
598                this.setProductListBackPosition();
599                if($elementLoadMore.length){
600                    $elementLoadMore.parents('.nbf-product-load-more').remove();
601                }
602
603            }else{
604                $productListing.html(result.ret.info);
605            }
606
607            if(typeof backUrl == 'undefined'){
608                rewriteURL('', newUrl);
609            }
610
611            this.init();
612
613            nb_custom_event_trigger('loadproductsevent', result.ret);
614        }
615    }
616
617    modelNBUI_Loader.hideLoader($('.nbf-loader-product-listing'));
618
619    return result;
620};
621
622NBFilter.prototype.removeSlashFromEndOfUrl = function(newUrl){
623    var urlEnd = newUrl.indexOf("?");
624    if(urlEnd == -1){
625        urlEnd = newUrl.length;
626    }
627    if (urlEnd > 0){
628        if (newUrl[urlEnd - 1] == "/" && nb_url_end_slash == ''){
629            newUrl = newUrl.substr(0, urlEnd-1) + newUrl.substr(urlEnd);
630        }
631    }
632    return newUrl;
633}
634
635NBFilter.prototype.setProductPosition = function($product){
636    let startPage = this.getStartPage();
637
638    // Setovanje strane pre redirekcije kako bi se na back korisnik vratio na tu stranu
639    var productPage = $product.attr('data-product-page');
640    $('#f_page').val(parseInt(productPage)+startPage);
641    var newUrl = this.permalink();
642    rewriteURL('', newUrl);
643
644    // Čuvanje proizvoda na koju treba da se fokusira strana klikom na back
645    var positionForProductCode = $product.attr('data-productcode');
646    console.log(positionForProductCode);
647    localStorage.setItem('positionForProductCode',positionForProductCode);
648}
649
650NBFilter.prototype.setProductListBackPosition = function(){
651    $(".nb-product-listing-display-grid-2 .nbf-product a").on("click", function(e) {
652        var productWrapper = $(this).closest('.nbf-product');
653        nbFilter.setProductPosition(productWrapper);
654    });
655}
656
657// Pozicioniranje na proizvod koji je otvoren pre back dugmeta
658NBFilter.prototype.getProductListBackPosition = function(){
659    setTimeout(function(){
660        var productPosition= localStorage.getItem('positionForProductCode');
661        console.log(productPosition);
662        if($(".nbf-product-listing .nbf-product[data-productcode='"+productPosition+"']").length){
663            scrollToCenter($(".nbf-product-listing .nbf-product[data-productcode='"+productPosition+"']"),50);
664
665        }
666    }, 1);
667}
668
669var scrollToCenter  = function(element, speed = 1000){
670    var elOffset = element.offset().top;
671    var elHeight = element.height();
672    var windowHeight = $(window).height();
673    var offset = elOffset;
674    if (elHeight < windowHeight) {
675        offset = elOffset - ((windowHeight / 2) - (elHeight / 2));
676    }
677    $('html, body').animate({scrollTop:offset}, speed);
678}
679
680NBFilter.prototype.getOrderTypeSearch = function (){
681
682    if($('#typesearch').length > 0){
683
684        var flag = $('#typesearch').is(':checked');
685        if(flag){
686            return 1;
687        }
688
689        return -1;
690
691    }else if($('#f_typesearch').length){
692        return $('#f_typesearch').val();
693    }
694
695    return -1;
696};
697
698NBFilter.prototype.deleteAllSelectedFilters = function (){
699    this.deleteAllSelectedAttributes();
700    this.deleteAllRestSelectedFilter();
701    this.deleteFilterPricelistItemsAll();
702    this.deleteFilterListsAll();
703    this.loadProductForPage(0);
704};
705
706//todo ovo menja naziv strane u H1 i mora da se vidi kako ce na tike da se to promeni
707NBFilter.prototype.changeHeadingTitle = function(metaObject){
708    if(typeof metaObject != 'undefined' && metaObject !==''){
709        if(metaObject.getBrandsInProductHeading > 0){
710            var headingTitleElement = $('.nb-heading-with-icon-1 .nb-title > h1 span, .nb-heading-with-icon-1 .nb-title > span');
711            var headingTitleText = metaObject.categoryHeadingTitle;
712            headingTitleElement.text(headingTitleText);
713        };
714
715        if(metaObject.getBrandsInMetaTitle > 0){
716            var metaTitle = metaObject.categoryMetaTitle;
717            $('title').text(metaTitle);
718        };
719    };
720};
721
722//set selected filter to form
723NBFilter.prototype.setFilterForm = function (cat_permalink, element) {
724    $('#f_category_permalink').val(cat_permalink);
725    nbFilter.loadProductForPage(0);
726};
727
728var nbFilter = new NBFilter('filter_form', 'f_page_url', '/', '+', 'f_page');
729
730NBFilter.prototype.initNBFilterAtributes = function(){
731
732    var filters = $('.nbf-filter-attributes');
733    filters.each(function (i, object) {
734        var element = $(this);
735        var id      = $(this).attr('nb-id');
736        var value   = $(this).attr('nb-value');
737
738        if(element.is(':checked')){
739            nbFilter.setAttribute(id, value);
740        };
741
742        element.change( function() {
743            if(element.is(':checked')){
744                nbFilter.setAttribute(id, value);
745            }else{
746                nbFilter.deleteAttribute(id, value);
747            }
748
749            nbFilter.initFilters('.nbf-filter-btn-apply');
750        });
751    });
752
753    $('input.nbf-filter-attributes').on('ifChecked', function(event){
754            nbFilter.setAttribute($(this).attr('nb-id'), $(this).attr('nb-value'));
755    });
756
757    $('input.nbf-filter-attributes').on('ifUnchecked', function(event){
758            nbFilter.deleteAttribute($(this).attr('nb-id'), $(this).attr('nb-value'));
759    });
760
761    $('#listId').change( function() {
762        if(nbFilter.getOrderTypeSearch() > 0){
763            nbFilter.loadProductForPage(0);
764        }
765    });
766
767    $('.irs').click( function() {
768        if(nbFilter.getOrderTypeSearch() > 0){
769            nbFilter.loadProductForPage(0);
770        }
771    });
772
773    $('.nbf-filter-product-search-btn').click( function() {
774        // Zakomentarisano jer se pomocu funkcije initFilters resava ovaj deo
775        // if(nbFilter.getOrderTypeSearch() > 0){
776        //     nbFilter.loadProductForPage(0);
777        // }
778        nbFilter.initFilters('.nbf-filter-btn-apply');
779    });
780};
781
782NBFilter.prototype.setSelectedDataNBFilterSizesEu = function(){
783    if($('#'+this.sizeEUId).length){
784        var sizeEUIdValue = $('#'+this.sizeEUId).val();
785        if(typeof sizeEUIdValue !== 'undefined' && sizeEUIdValue != ''){
786            var sizeEUIdArray = sizeEUIdValue.split(',');
787            $.each(sizeEUIdArray, function (index, value) {
788                nbFilter.formatFilterSizeEUValue(value, value);
789            });
790        }
791    }
792};
793
794NBFilter.prototype.initNBFilterSizesEu = function(){
795    var filters = $('.nbf-filter-sizes-eu');
796    filters.each(function (i, object) {
797        var element = $(this);
798        var id    = $(this).attr('nb-id');
799        var value = $(this).attr('nb-value');
800        element.change( function() {
801            nbFilter.formatFilterSizeEUValue(id, value);
802        });
803    });
804};
805
806NBFilter.prototype.setSelectedDataNBFilterPrices = function(){
807    if($('#'+this.pricesId).length){
808        var allPricesIdValue = $('#'+this.pricesId).val();
809        if(typeof allPricesIdValue !== 'undefined' && allPricesIdValue != ''){
810        var allPricesIdArray = allPricesIdValue.split('_');
811            $.each(allPricesIdArray, function (index, pricesIdValue) {
812                if(typeof pricesIdValue !== 'undefined' && pricesIdValue != ''){
813                    var pricesIdArray = pricesIdValue.split('-');
814                    var from        = pricesIdArray[0];
815                    var to          = pricesIdArray[1];
816                    nbFilter.formatFilterPriceList(from, to);
817                };
818            });
819        };
820    };
821};
822
823NBFilter.prototype.initNBFilterPrices = function(){
824
825    let type = $('#nbf-filter-price-ranged-type').val();
826    if(type === 'slider'){
827        this.initNBRangedFilterPrices()
828    }else{
829        this.initNBCheckboxFilterPrices()
830    }
831};
832
833NBFilter.prototype.initNBCheckboxFilterPrices = function(){
834    var filters = $('.nbf-filter-prices');
835    filters.each(function (i, object) {
836        var element = $(this);
837        var id      = $(this).attr('nb-id');
838        var valueFrom = $(this).attr('nb-value-from');
839        var valueTo   = $(this).attr('nb-value-to');
840
841        element.change( function() {
842            nbFilter.formatFilterPriceList(valueFrom, valueTo);
843            });
844    });
845};
846
847NBFilter.prototype.initNBRangedFilterPrices = function(){
848    let filtersBlock    = $('.nbf-filter-prices-range');
849    let fromInput       = filtersBlock.find('#nb_filter_price_min_input')
850    let toInput         = filtersBlock.find('#nb_filter_price_max_input')
851    let minTriggerInput = $('.nbf-filter-price-range .nbf-range-min');
852    let maxTriggerInput = $('.nbf-filter-price-range .nbf-range-max');
853
854    minTriggerInput.on('change', function () {
855        let valueFrom = fromInput.attr('value');
856        let valueTo   = toInput.attr('value')
857
858        nbFilter.formatFilterPriceList(valueFrom, valueTo, true);
859    })
860
861    maxTriggerInput.on('change', function () {
862        let valueFrom = fromInput.attr('value');
863        let valueTo   = toInput.attr('value')
864
865        nbFilter.formatFilterPriceList(valueFrom, valueTo, true);
866    })
867};
868
869NBFilter.prototype.setSelectedDataNBFilterLists = function(){
870    // if($('#'+this.listId).length){
871    //     var selectedListsId = $('#'+this.listId).val();
872    //     if(typeof selectedListsId !== 'undefined' && selectedListsId != ''){
873    //         var selectedListsIdArray = selectedListsId.split(',');
874    //         $.each(selectedListsIdArray, function (index, value) {
875    //             nbFilter.formatFilterLists(value);
876    //         });
877    //     };
878    // };
879};
880
881NBFilter.prototype.initNBFilterLists = function(){
882
883    var filters = $('.nbf-filter-lists');
884    filters.each(function (i, object) {
885        var element = $(this);
886        var id    = $(this).attr('nb-id');
887        var value = $(this).attr('nb-value');
888
889        element.change( function(e) {
890            nbFilter.formatFilterLists(value);
891        });
892    });
893};
894
895NBFilter.prototype.initDelSelectedFilter = function(){
896
897    //todo brisanje filtera na tagovima
898    var selFilters = $('.nbf-product-applied-filter-tag-list .nbf-sel-filter');
899    selFilters.each(function (i, object) {
900        if (window.NBAccessibility) {
901            modelNBAccessibility.clickWithKeyboard($(this));
902        }
903        $(this).click( function() {
904            var value   = $(this).attr('nb-value');
905            nbFilter.deleteSelAttribute(value);
906        });
907    });
908
909    //todo brisanje cene na tagovima
910    if (window.NBAccessibility) {
911        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-size-eu');
912    }
913    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-size-eu').click( function() {
914        var value = $(this).attr('nb-value');
915        nbFilter.deleteSelctedEuSize(value);
916    });
917
918    if (window.NBAccessibility) {
919        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-prices');
920    }
921    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-prices').click( function() {
922        var value       = $(this).attr('nb-value');
923        var valueArray  = value.split('_');
924        var from        = valueArray[0];
925        var to          = valueArray[1];
926        nbFilter.deleteFilterPricelistItems(from, to);
927    });
928
929    //todo brisanje liste na tagovima
930    if (window.NBAccessibility) {
931        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-list');
932    }
933    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-list').click( function() {
934        nbFilter.deleteSelList();
935    });
936
937    //todo brisanje search promenljive na tagovima
938    if (window.NBAccessibility) {
939        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-search');
940    }
941    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-search').click( function() {
942        nbFilter.deleteSelSearchText();
943    });
944
945    //todo brisanje sale promenljive na tagovima
946    if (window.NBAccessibility) {
947        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-sale');
948    }
949    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-sale').click( function() {
950        nbFilter.deleteSelSale();
951    });
952
953    //todo brisanje outlet na tagovima
954    if (window.NBAccessibility) {
955        modelNBAccessibility.clickWithKeyboard('.nbf-product-applied-filter-tag-list .nbf-sel-filter-outlet');
956    }
957    $('.nbf-product-applied-filter-tag-list .nbf-sel-filter-outlet').click( function() {
958        nbFilter.deleteSelOutlet();
959    });
960
961    if (window.NBAccessibility) {
962        modelNBAccessibility.clickWithKeyboard('.nbf-clear-filters-all');
963    }
964    $('.nbf-clear-filters-all').click( function() {
965        nbFilter.deleteAllSelectedFilters();
966    });
967};
968
969//limit, sort, type view
970NBFilter.prototype.initTableSort = function(){
971
972    $('#sort_fixed').change( function() {
973        $('#sort').val($(this).val()).change();
974    });
975
976    //call reload products
977    $('#sort').change( function() {
978        $('#f_sort').val($(this).val());
979    });
980
981    $('#limit').change( function() {
982        $('#f_limit').val($(this).val());
983    });
984
985    //init order select with cookie
986    nbFilter.initOrderSelect();
987};
988
989//sort, limit, type view save in cookie
990NBFilter.prototype.initOrderSelect = function(){
991
992    var orders = $('.nbf-filter-sort, .nbf-filter-limit');
993    orders.each(function (i) {
994        var curr = readCookie("order_"+$(this).attr('id'));
995        $(this).change( function() {
996            var name = "order_"+$(this).attr('id');
997            var value = $(this).val();
998            var newC = readCookie("order_"+$(this).attr('id'));
999            $('#f_'+$(this).attr('id')).val($(this).val());
1000            nbFilter.loadProductForPage(0,false);
1001        });
1002    });
1003
1004    const radiosSort = $('input[type="radio"][name="radio_sort"]');
1005    if(radiosSort.length > 0){
1006        radiosSort.each(function (i) {
1007            var curr = readCookie("order_"+$(this).attr('id'));
1008            $(this).change( function() {
1009                var name = "order_"+$(this).attr('id');
1010                var value = $(this).val();
1011                var newC = readCookie("order_"+$(this).attr('id'));
1012                $('#f_'+$(this).attr('id')).val($(this).val());
1013
1014                $('#f_sort').val($(this).val());
1015
1016                nbFilter.loadProductForPage(0,false);
1017            });
1018        });
1019    }
1020
1021    //nbf-filter-limit: privremeno zakomentarisano kako se ne bi narusilo postojece stanje
1022    $('.nbf-change-layout .nb-icon').click( function() {
1023        var name    = "order_typeView";
1024        var value   = $(this).attr('rel');
1025        console.log(value)
1026        createCookie(name, value, 10);
1027        var newC    = readCookie("order_typeView");
1028        nbFilter.loadProductForPage(0);
1029
1030    });
1031    
1032    //staro
1033    // $('.list-types-wrapper .nb-item').click( function() {
1034    //     var name    = "order_typeView";
1035    //     var value   = $(this).attr('rel');
1036    //     createCookie(name, value, 10);
1037    //     var newC    = readCookie("order_typeView");
1038    //     nbFilter.load_products();
1039    // });
1040    //
1041    // $('.order-element-type-search').click( function() {
1042    //
1043    //     var name    = "order_typesearch";
1044    //     var value   = $(this).attr('rel');
1045    //
1046    //     if(value == 1){
1047    //         value = -1;
1048    //     }else{
1049    //         value = 1;
1050    //     }
1051    //
1052    //     $(this).attr('rel', value);
1053    //     $(this).attr('value', value);
1054    //     createCookie(name, value, 10);
1055    //     var newC    = readCookie("order_typesearch");
1056    //     nbFilter.load_products();
1057    // });
1058}
1059
1060NBFilter.prototype.deleteCacheIphone = function () {
1061    window.onpageshow = function(event) {
1062        if (event.persisted) {
1063            window.location.reload();
1064        }
1065    };
1066};
1067
1068NBFilter.prototype.pagination = function(){
1069
1070    var prev    = $('.nbf-pagination-products .nbf-previous-page');
1071    var step    = $('.nbf-pagination-products .nbf-step-page');
1072    var next    = $('.nbf-pagination-products .nbf-next-page');
1073         
1074    var first   = $('.nbf-pagination-products .nbf-first-page');
1075    var last    = $('.nbf-pagination-products .nbf-last-page');
1076    
1077    prev.click( function() {
1078        var pagePrev = $(this).data('previous-page');
1079        nbFilter.loadProductForPage(pagePrev);
1080    });
1081
1082    step.each(function (i) {
1083        $(this).click( function() {
1084            var pageStep = $(this).data('step-page');
1085            nbFilter.loadProductForPage(pageStep);
1086        });
1087    });
1088
1089    next.click( function() {
1090        var pageNext = $(this).data('next-page');
1091        nbFilter.loadProductForPage(pageNext);
1092    });
1093    
1094    if(first.length > 0){
1095        first.click( function() {
1096            var pageFirst = $(this).data('first-page');
1097            nbFilter.loadProductForPage(pageFirst);
1098        });
1099    }
1100    
1101    if(last.length > 0){
1102        last.click( function() {
1103            var pageLast = $(this).data('last-page');
1104            nbFilter.loadProductForPage(pageLast);
1105        });
1106    }
1107
1108};
1109
1110 NBFilter.prototype.autoLoadPagination = function(goToPage, totalPages, flagLoadPrevProducts = false, blockData = false, $elementLoadMode = ''){
1111    var modelNBUI_Loader            = new NBUI_Loader();
1112
1113    setTimeout(function (){
1114        $('#f_page').val(parseInt(goToPage));
1115
1116        //$elementLoadMode.addClass('addingItem');
1117        // modelNBUI_Loader.showLoader($('.nbf-loader-product-listing'));
1118
1119        nbFilter.load_products(0, false, true, flagLoadPrevProducts, blockData, $elementLoadMode);
1120    },0)
1121
1122 }
1123
1124NBFilter.prototype.loadModePagination = function(){
1125    if($(".nbf-product-load-more-btn").length > 0){
1126        $(".nbf-product-load-more-btn").click( function(e) {
1127            e.preventDefault();
1128            $(this).addClass('active')
1129
1130            var thisElement = $(this);
1131
1132            var pageNumber          = thisElement.data('button-page-number');
1133            var pagesCount          = thisElement.data('pages-count');
1134            var loadPrevProducts    = thisElement.data('load-prev-products');
1135            var elementBlock        = thisElement.parents('.product-listing-display-grid-2');
1136            var elementBlock        = thisElement.parents('.nbf-product-listing-ident');
1137
1138            let blockData = {};
1139
1140            blockData.pageId              = elementBlock.data('site-page-id');
1141            blockData.layoutId            = elementBlock.data('layout-id');
1142            blockData.sitePageBlockId     = elementBlock.data('parent-block-id');
1143            blockData.blockId             = elementBlock.data('block-id');
1144            blockData.position            = elementBlock.data('block-position');
1145            blockData.secretKey           = ""; //elementBlock.data('block-public-key');
1146
1147            if(blockData.position == ""){
1148                blockData.position = 1;
1149            }
1150
1151            blockData.block               = blockData.pageId+':'+blockData.layoutId+':'+blockData.blockId+":"+blockData.position+':'+blockData.secretKey;
1152
1153            nbFilter.autoLoadPagination(pageNumber, pagesCount, loadPrevProducts, blockData, thisElement);
1154        });
1155    };
1156};
1157
1158NBFilter.prototype.initFilters = function (elementSelector) {
1159    let button          = $(elementSelector+':visible');
1160
1161    if (button.length > 0 && nbFilter.getOrderTypeSearch() == -1) {
1162        button.off('click.nbFilter').on('click.nbFilter', function (e) {
1163            e.preventDefault();
1164            nbFilter.loadProductForPage(0);
1165        });
1166    } else {
1167        nbFilter.loadProductForPage(0);
1168    }
1169}
1170
1171NBFilter.prototype.init = function (){
1172    this.initTableSort();
1173    this.initNBFilterAtributes();
1174    this.initNBFilterSizesEu();
1175    this.initNBFilterPrices();
1176    this.initNBFilterLists();
1177    this.initDelSelectedFilter();
1178    this.pagination();
1179    this.loadModePagination();
1180};
1181
1182$(document).ready(function(){
1183    //filteri init
1184    nbFilter.init();
1185    nbFilter.setSelectedDataNBFilterSizesEu();
1186    nbFilter.setSelectedDataNBFilterPrices();
1187    nbFilter.setSelectedDataNBFilterLists();
1188
1189    if (performance.navigation.type == 2) {
1190        nbFilter.setProductListBackPosition();
1191        nbFilter.getProductListBackPosition();
1192    }
1193
1194});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.