PageSourceSearch

https://travel-free.bg/catalog/view/theme/BurnEngine/javascript/critical.js?1415668277

js travel-free.bg collected 2026-09-24 14:09:56 UTC 11,564 bytes, 383 lines download raw bytes

1var tbUtils = {
2    bind: function(el, ev, fn) {
3        if(window.addEventListener) {
4            el.addEventListener(ev, fn, false);
5        } else if(window.attachEvent) {
6            el.attachEvent('on' + ev, fn);
7        } else {
8            el['on' + ev] = fn;
9        }
10
11        return fn;
12    },
13
14    unbind: function(el, ev, fn) {
15        if(window.removeEventListener){
16            el.removeEventListener(ev, fn, false);
17        } else if(window.detachEvent) {
18            el.detachEvent('on' + ev, fn);
19        } else {
20            elem['on' + ev] = null;
21        }
22    },
23
24    stop: function(ev) {
25        var e = ev || window.event;
26
27        e.cancelBubble = true;
28        if (e.stopPropagation) {
29            e.stopPropagation();
30        }
31    },
32
33    resizeCallBacks: [],
34    resizeContainers: [],
35
36    onSizeChange: function(fn, namespace, unbind_namespace, container_id) {
37
38        if (typeof container_id == "undefined" || !container_id) {
39            container_id = String(Math.random());
40        }
41
42        if (typeof unbind_namespace != "undefined" && !unbind_namespace && this.resizeContainers.indexOf(container_id) >= 0) {
43            return;
44        }
45
46        this.resizeContainers.push(container_id);
47
48        if (typeof namespace == "undefined" || !namespace) {
49            namespace = 'main';
50        }
51
52        if (typeof unbind_namespace == "undefined") {
53            unbind_namespace = false;
54        }
55
56        if (this.resizeCallBacks[namespace] === undefined) {
57            this.resizeCallBacks[namespace] = [];
58        }
59
60        var eventName = window.hasOwnProperty("onorientationchange") ? "orientationchange" : "resize";
61
62        if (unbind_namespace) {
63            var unbind = this.unbind;
64            Array.prototype.forEach.call(this.resizeCallBacks[namespace], function(callBack) {
65                unbind(window, eventName, callBack);
66            });
67            this.resizeCallBacks[namespace] = [];
68        }
69
70        this.resizeCallBacks[namespace].unshift(fn);
71
72        if (window.hasOwnProperty("onorientationchange")) {
73            return this.bind(window, "orientationchange", fn);
74        }
75
76        // orientation-change-polyfill
77        var currentWidth = window.outerWidth;
78        var orientationChanged = function(callBack) {
79            var newWidth = window.outerWidth;
80
81            if (newWidth !== currentWidth) {
82                currentWidth = newWidth;
83                callBack && callBack();
84            }
85        };
86
87        return this.bind(window, "resize", function() {
88            orientationChanged(fn);
89        });
90    },
91
92    onWindowLoaded: function(win, fn) {
93
94        var done = false, top = true,
95
96            doc = win.document,
97            root = doc.documentElement,
98            modern = doc.addEventListener,
99
100            add = modern ? 'addEventListener' : 'attachEvent',
101            rem = modern ? 'removeEventListener' : 'detachEvent',
102            pre = modern ? '' : 'on',
103
104            init = function(e) {
105                if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
106                (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
107                if (!done && (done = true)) fn.call(win, e.type || e);
108            },
109
110            poll = function() {
111                try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
112                init('poll');
113            };
114
115        if (doc.readyState == 'complete') fn.call(win, 'lazy');
116        else {
117            if (!modern && root.doScroll) {
118                try { top = !win.frameElement; } catch(e) { }
119                if (top) poll();
120            }
121            doc[add](pre + 'DOMContentLoaded', init, false);
122            doc[add](pre + 'readystatechange', init, false);
123            win[add](pre + 'load', init, false);
124        }
125    },
126
127    removeClass: function(el, className) {
128        if (!el) {
129            return;
130        }
131
132        if (el.classList) {
133            var classValues = className.trim().split(' ');
134
135            for (var i = 0; i < classValues.length; i++) {
136                if (el.classList.contains(classValues[i])) {
137                    el.classList.remove(classValues[i]);
138                }
139            }
140        } else {
141            el.className = el.className.replace(new RegExp('(^|\\b)' + className.trim().split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
142        }
143    },
144
145    addClass: function(el, className) {
146        if (!el) {
147            return;
148        }
149
150        if (el.classList) {
151            var classValues = className.split(' ');
152
153            for (var i = 0; i < classValues.length; i++) {
154                el.classList.add(classValues[i]);
155            }
156        } else {
157            el.className += ' ' + className;
158        }
159    },
160
161    hasClass: function(el, className) {
162        if (!el) {
163            return;
164        }
165
166        if (el.classList) {
167            el.classList.contains(className);
168        }
169        else {
170            new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
171        }
172    },
173
174    globalEval: function(code) {
175        var script = document.createElement("script");
176
177        script.text = code;
178        document.head.appendChild(script).parentNode.removeChild(script);
179    }
180};
181
182function adjustItemSize(container, responsive_params, namespace) {
183
184    var $container = typeof container == "string" ? document.querySelector(container) : container;
185
186    if (!$container) {
187        return;
188    }
189
190    var $el = $container.querySelector(".tb_grid_view");
191
192    if (!$el) {
193        return;
194    }
195
196    if (responsive_params === undefined) {
197        responsive_params = {
198            "1900": {"items_per_row": 8, "items_spacing": 30},
199            "1600": {"items_per_row": 7, "items_spacing": 30},
200            "1400": {"items_per_row": 6, "items_spacing": 30},
201            "1200": {"items_per_row": 5, "items_spacing": 30},
202            "1000": {"items_per_row": 4, "items_spacing": 30},
203            "800" : {"items_per_row": 3, "items_spacing": 30},
204            "600" : {"items_per_row": 2, "items_spacing": 30},
205            "400" : {"items_per_row": 1, "items_spacing": 20}
206        };
207    }
208
209    var responsive_keys = [],
210        current_per_row = 0;
211
212    for(var k in responsive_params) {
213        responsive_keys.push(Number(k));
214    }
215    responsive_keys.sort(function(a, b){return a-b});
216
217    function getRestrictions(c_width) {
218        var result = {};
219
220        for(var i = 0; i < responsive_keys.length; i++){
221            result = responsive_params[responsive_keys[i]];
222            if(c_width <= responsive_keys[i]) {
223                break;
224            }
225        }
226
227        return result;
228    }
229
230    var total_items = $el.childElementCount;
231
232    function responsive() {
233
234        var $wrapper        = $el.parentElement,
235            computed_style  = getComputedStyle($wrapper),
236            container_width = $wrapper.clientWidth - (parseInt(computed_style.paddingRight) + parseInt(computed_style.paddingLeft)),
237            restrictions    = getRestrictions(container_width);
238
239        if (current_per_row == restrictions.items_per_row) {
240            return;
241        }
242
243        tbUtils.removeClass($el, 'tb_size_1 tb_size_2 tb_size_3 tb_size_4 tb_size_5 tb_size_6 tb_size_7 tb_size_8 tb_multiline');
244        tbUtils.removeClass($el, 'tb_gut_0 tb_gut_10 tb_gut_20 tb_gut_30 tb_gut_40 tb_gut_50');
245        tbUtils.addClass($el, 'tb_size_' + restrictions.items_per_row + ' ' + 'tb_gut_'  + restrictions.items_spacing + (restrictions.items_per_row < total_items ? ' tb_multiline' : ''));
246
247        current_per_row = restrictions.items_per_row;
248    }
249
250    //requestAnimationFrame(responsive);
251    responsive();
252
253    if (typeof container != 'string' || !container) {
254        container = '';
255    }
256
257    tbUtils.onSizeChange(responsive, namespace, false, "adjustItemSize_" + container);
258
259    // Add layout classes
260
261    if (!$el.hasAttribute('data-nth_classes')) {
262        var last_item_indexes = [];
263
264        if (total_items > 1) {
265            [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].forEach(function(key) {
266                last_item_indexes[key] = (Math.ceil(total_items / key) - 1) * key;
267            });
268        }
269
270        [].forEach.call($el.children, function(el, i) {
271            [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].forEach(function(key) {
272                if (((i)/key) % 1 === 0) {
273                    tbUtils.addClass(el, 'clear' + key);
274                }
275            });
276
277            i++;
278
279            last_item_indexes.forEach(function(key, index) {
280                if (i > key) {
281                    tbUtils.addClass(el, 'tb_size_' + index + '_last');
282                }
283            });
284        });
285
286        $el.setAttribute('data-nth_classes', '1');
287    }
288
289}
290
291function element_query(elements, sizes, child) {
292
293    Array.prototype.forEach.call(document.querySelectorAll(elements), function(el) {
294
295        if (sizes === undefined) {
296            sizes = el.getAttribute('data-sizes');
297        }
298
299        if (!sizes) {
300            sizes = [
301                1260,
302                1040,
303                768,
304                480,
305                0
306            ];
307        }
308
309        if (typeof sizes == "string") {
310            sizes = sizes.split(",").sort(function(a, b) {
311                return b - a;
312            });
313        }
314
315        var width_detect = (function($element, sizes, child) {
316
317            var max_w = sizes[0],
318                min_w = sizes[sizes.length - 1];
319
320            return function() {
321
322                var $el = $element;
323
324                if (child !== undefined) {
325                    $el = document.querySelector('#' + $element.id + ' ' + child);
326                }
327
328                if (!$el) {
329                    return;
330                }
331
332                var computedStyle = getComputedStyle($el),
333                    width = $el.offsetWidth - parseInt(computedStyle.paddingRight) - parseInt(computedStyle.paddingLeft);
334
335                for(var i = 0; i < sizes.length; i++){
336                    if (i == 0) {
337                        if (width > sizes[i]) {
338                            tbUtils.removeClass($el, 'tb_max_w_' + max_w + ' tb_min_w_' + min_w);
339                            max_w = 0;
340                            min_w = sizes[i];
341                            tbUtils.addClass($el, 'tb_min_w_' + min_w);
342
343                            break;
344                        }
345                    } else {
346                        if (width > sizes[i] && width <= sizes[i - 1]) {
347                            tbUtils.removeClass($el, 'tb_max_w_' + max_w + ' tb_min_w_' + min_w);
348                            max_w = sizes[i - 1];
349                            min_w = sizes[i];
350                            tbUtils.addClass($el, 'tb_max_w_' + max_w + ' tb_min_w_' + min_w);
351
352                            break;
353                        }
354                    }
355                }
356            }
357
358        })(el, sizes, child);
359
360        var el_id = 'element_query_' + String(Math.random());
361        if (el.id !== undefined) {
362            if (el.id) {
363                el_id = '#' + el.id;
364            } else {
365                el_id = el.nodeName + '_' + el.className.replace(" ", "_") + "_" + String(Math.random());
366            }
367        }
368
369        width_detect();
370        tbUtils.onSizeChange(width_detect, false, false, el_id);
371    });
372}
373
374/*-global-vars-*/
375
376tbUtils.is_touch = 'ontouchstart' in window || navigator.MaxTouchPoints || navigator.msMaxTouchPoints;
377
378/*-critical-inline-scripts*/
379
380window.tbCriticalLoaded = true;
381if (window.tbBoot !== undefined) {
382    window.tbBoot();
383}

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.