PageSourceSearch

https://foramax.hu/catalog/view/javascript/opentheme/oclayerednavigation/oclayerednavigation.js

js foramax.hu collected 2026-10-08 02:15:53 UTC 8,016 bytes, 213 lines download raw bytes

1$(document).ready(function() {
2    oclayerednavigationajax.productViewChange();
3    oclayerednavigationajax.paginationChangeAction();
4	oclayerednavigationajax.changePositionAttributes();
5});
6
7
8var oclayerednavigationajax = {
9
10    'filter' : function(filter_url) {
11
12        if (typeof filter_url !== 'string' || !filter_url.length) {
13            return false;
14        }
15
16        let paginationArray = filter_url.match(/(page=[0-9]+)/);
17        let paginationText = 'page=1';
18
19        if (Array.isArray(paginationArray) && paginationArray.length > 1) {
20            paginationText = paginationArray[1];
21        }
22
23
24        var old_route = 'route=product/category';
25        var new_route = 'route=extension/module/oclayerednavigation/category';
26        if(filter_url.search(old_route) != -1) {
27            filter_url = filter_url.replace(old_route, new_route);
28        }
29
30            var query = String(window.location.href).split('?');
31
32            var fixed = "";
33
34            var base = query[0] + "?";
35
36
37            if(query[1]){
38
39                fixed = query[1].replace(/\&?limit=[0-9]+/, '');
40                fixed = fixed.replace(/\&?sort=[a-z._]+/, '');
41                fixed = fixed.replace(/\&?order=[ASC|DESC]+/, '');
42                fixed = fixed.replace(/\&?page=[0-9]+/, '');
43
44
45            }
46            var sortAndOrderText = $('#input-sort').find(":selected").val();
47
48            var limitText = ($('#input-limit').length && $('#input-limit').find(':selected').val())
49                ? $('#input-limit').find(':selected').val()
50                : 'limit=40';
51
52            var matchesLimit = String(limitText).match(/(limit=[0-9]+)/);
53
54            var matchesSortAndOrder = sortAndOrderText.match(/(sort=[a-z._]+\&order=[ASC|DESC]+)/);
55
56            if(matchesSortAndOrder != null || matchesLimit != null || paginationText != null)
57            {
58
59
60                var sortAndOrder =  matchesSortAndOrder[0];
61
62                var limit = matchesLimit ? matchesLimit[0] : 'limit=40';
63
64                    var requestURL = base + (fixed != '' ? fixed + '&': '') + sortAndOrder + '&' + limit + '&' + paginationText;
65
66                requestURL.replace(/\?\&/, "\?");
67
68                if(requestURL) history.pushState('', '', requestURL)
69            }
70
71
72
73
74
75
76        if(filter_url.search(new_route) != -1 || filter_url.search('promotion')) {
77
78
79            $.ajax({
80                url         : filter_url,
81                type        : 'get',
82                beforeSend  : function () {
83                    $('.layered-navigation-block').show();
84                    $('.ajax-loader').show();
85                },
86                success     : function(json) {
87                    $('.filter-url').val(json['filter_action']);
88                    $('.price-url').val(json['price_action']);
89                    $('.custom-category').html(json['result_html']);
90                    $('.layered').html(json['layered_html']);
91
92                    var display = localStorage.getItem('display') || 'grid';
93                    var $customProducts = $('#content .custom-products');
94
95                    if ($customProducts.length) {
96                        $customProducts
97                            .removeClass('is-grid is-list')
98                            .addClass(display === 'list' ? 'is-list' : 'is-grid');
99                    }
100
101                    oclayerednavigationajax.paginationChangeAction();
102                    oclayerednavigationajax.productViewChange();
103                    oclayerednavigationajax.changePositionAttributes();
104                    $('.layered-navigation-block').hide();
105                    $('.ajax-loader').hide();
106
107                    setTimeout(function() {
108                        var $target = $('#content .custom-products');
109                        if ($target.length) {
110                            var top = 0;
111                            try { $('html, body').stop(true, true).animate({ scrollTop: top }, 300); } catch(e) {}
112                        }
113                    }, 80);
114                },
115                error: function (jqXHR, status, err) {
116
117                },
118                complete: function () {
119
120                }
121            });
122        }
123
124    },
125	/* change position filter-attributes */
126    'changePositionAttributes' : function() {    
127		var category = $('.filter-categories');
128        var remove = $('.filter-attribute-remove-container');
129		category.prependTo('.layered .list-group');
130		remove.prependTo('.layered .list-group');
131	},
132	/*-------------------------------------*/
133    /* Use again and update ajaxComplete from common.js */
134    'productViewChange' : function() {
135
136        // mindig lekapjuk a korábbi bindokat, így nem duplázódik
137        $(document).off('click.ocview', '#list-view');
138        $(document).off('click.ocview', '#grid-view');
139
140        // LIST VIEW
141        $(document).on('click.ocview', '#list-view', function(e) {
142            e.preventDefault();
143
144            $(this).addClass('selected active');
145            $('#grid-view').removeClass('selected active');
146
147            // (a te meglévő listás class-állítgatásaid)
148            $('#content .product-grid > .clearfix').remove();
149            $('#content .product-grid').attr('class', 'product-layout product-list clearfix');
150            $('#content .product-list .col-image').addClass('col-sm-4 col-sms-4 col-smb-12');
151            $('#content .product-list .col-des').addClass('col-sm-8 col-sms-8 col-smb-12');
152
153            // >>> EZ A LÉNYEG: wrapper class beállítás
154            $('#content .custom-products').removeClass('is-grid').addClass('is-list');
155
156            localStorage.setItem('display', 'list');
157        });
158
159        // GRID VIEW
160        $(document).on('click.ocview', '#grid-view', function(e) {
161            e.preventDefault();
162
163            $(this).addClass('selected active');
164            $('#list-view').removeClass('selected active');
165
166            cols = $('#column-right, #column-left').length;
167
168            if (cols == 2) {
169                $('#content .product-layout').attr('class', 'product-layout product-grid module-style1 col-md-6 col-sm-6 col-xs-6 two-items');
170            } else if (cols == 1) {
171                $('#content .product-layout').attr('class', 'product-layout product-grid module-style1 col-lg-3 col-md-4 col-sm-6 col-xs-6 category');
172            } else {
173                $('#content .product-layout').attr('class', 'product-layout product-grid module-style1 col-lg-3 col-md-4 col-sm-6 col-xs-6 category');
174            }
175
176            $('#content .product-grid .col-image').removeClass('col-sm-4 col-sms-4 col-smb-12');
177            $('#content .product-grid .col-des').removeClass('col-sm-8 col-sms-8 col-smb-12');
178
179            // >>> EZ A LÉNYEG: wrapper class beállítás
180            $('#content .custom-products').removeClass('is-list').addClass('is-grid');
181
182            localStorage.setItem('display', 'grid');
183        });
184
185        // inicializálás page load után is (page=2 esetén is)
186        var display = localStorage.getItem('display') || 'grid';
187        if (display === 'list') {
188            $('#list-view').trigger('click');
189        } else {
190            $('#grid-view').trigger('click');
191        }
192    },
193    
194    /* Modify pagination links */
195    paginationChangeAction: function () {
196        $('.custom-category .pagination a').each(function () {
197            var href = $(this).attr('href');
198
199            if (!href || href === '#' || href.indexOf('javascript:') === 0) {
200                return;
201            }
202
203            $(this).removeAttr('onclick');
204            $(this).off('click.ocln').on('click.ocln', function(e){
205                e.preventDefault();
206                oclayerednavigationajax.filter(href);
207            });
208
209            $(this).attr('href', 'javascript:void(0);');
210        });
211    }
212
213};

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.