PageSourceSearch

https://compbest.com.ua/vendor/application/misc.js

js compbest.com.ua collected 2026-10-05 11:12:22 UTC 29,990 bytes, 920 lines download raw bytes

1;(function ($) {
2    $.fn.reset = function () {
3        return this.each(function () {
4            if ($(this).is('form')) {
5                this.reset();
6            }
7        });
8    };
9
10    $.fn.selectRange = function (start, end) {
11        return this.each(function () {
12            if (this.setSelectionRange) {
13                this.focus();
14                this.setSelectionRange(start, end);
15            } else if (this.createTextRange) {
16                var range = this.createTextRange();
17                range.collapse(true);
18                range.moveEnd('character', end);
19                range.moveStart('character', start);
20                range.select();
21            }
22        });
23    };
24})(jQuery);
25var popup;
26function showPopup(url, width, height) {
27    if (popup != undefined && !popup.closed) {
28        popup.close();
29    }
30
31    if (width == undefined) width = 656;
32    if (height == undefined) height = 296;
33
34    var top = Math.round((screen.availHeight / 2) - (height / 2)) - 18;
35    var left = Math.round((screen.availWidth / 2) - (width / 2)) - 9;
36
37    popup = window.open(url, '', 'top=' + top + ',left=' + left + ',directories=0,location=0,menubar=0,status=0,toolbar=0,scrollbars=2,resizable=0,width=' + width + ',height=' + height + '');
38}
39
40/**
41 *
42 * @param {Array|String} search
43 * @param {Array|String} replace
44 * @param {Array|String} subject
45 * @param {Number} [count]
46 * @returns {*}
47 */
48function str_replace(search, replace, subject, count) {
49    var j = 0,
50        temp = '',
51        repl = '',
52        fl = 0,
53        f = [].concat(search),
54        r = [].concat(replace),
55        s = subject,
56        ra = Object.prototype.toString.call(r) === '[object Array]',
57        sa = Object.prototype.toString.call(s) === '[object Array]';
58    s = [].concat(s);
59    if (count) {
60        this.window[count] = 0;
61    }
62    for (var i = 0, sl = s.length; i < sl; i++) {
63        if (s[i] === '') {
64            continue;
65        }
66        for (j = 0, fl = f.length; j < fl; j++) {
67            temp = s[i] + '';
68            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
69            s[i] = (temp).split(f[j]).join(repl);
70            if (count && s[i] !== temp) {
71                this.window[count] += (temp.length - s[i].length) / f[j].length;
72            }
73        }
74    }
75    return sa ? s : s[0];
76}
77
78function l10n(key, params) {
79    var search = [],
80        replace = [];
81    search.push('{BR}');
82    replace.push('<br>');
83    search.push('{BREAK_LINE}');
84    replace.push('<br>');
85    for (var i in params) {
86        if (params.hasOwnProperty(i)) {
87            search.push(i);
88            replace.push(params[i]);
89        }
90    }
91
92
93    if (GLOBAL.l10n && GLOBAL.l10n[key]) {
94        return str_replace(search, replace, GLOBAL.l10n[key]);
95    } else {
96        sendAjax(GLOBAL.URI_PREFIX + "_widget/l10n/set/", {value: key});
97        GLOBAL.l10n[key] = key;
98    }
99    return str_replace(search, replace, key);
100}
101
102
103/**
104 *
105 * @param count
106 * @param str_1 товар
107 * @param str_2 товара
108 * @param str_3 товаров
109 * @returns {string}
110 */
111function getCountText(count, str_1, str_2, str_3) {
112    var str = "";
113    str_1 = str_1 || l10n("товар");
114    str_2 = str_2 || l10n("товара");
115    str_3 = str_3 || l10n("товаров");
116    if (count > 10 && count < 20) {
117        str = str_3 || l10n("товаров");
118    } else {
119        switch (count.toString().substr(-1)) {
120            case "1":
121                str = str_1;
122                break;
123            case "2":
124            case "3":
125            case "4":
126                str = str_2;
127                break;
128            case "5":
129            case "6":
130            case "7":
131            case "8":
132            case "9":
133            case "0":
134            default:
135                str = str_3;
136                break;
137        }
138    }
139    return str;
140}
141
142/**
143 * Отправка Ajax запроса.
144 *
145 * @param url Ссылка на скрипт-обработчик
146 * @param {Object|String|Array} [params] Параметры запроса
147 * @param {Function} [callback] Функция ответа
148 */
149function sendAjax(url, params, callback, type) {
150    type = type || 'POST';
151    if (typeof params === "function") {
152        callback = params;
153        params = {};
154    }
155    if (url.indexOf('/js/') === 0) {
156        url = '/themes/' + GLOBAL.theme + '/layout' + url;
157    }
158    return $.ajax({
159        dataType: "json",
160        type: type,
161        url: url,
162        async: true,
163        data: params,
164
165        error: function (data) {
166            var status = "ERROR",
167                response = {};
168            
169            if (data.statusText === 'abort') {
170                status = 'CANCELED';
171            }
172            
173            if (data.responseJSON && data.responseJSON.status) {
174                status = data.responseJSON.status;
175                response = data.responseJSON.response;
176            }
177
178            if (typeof callback == "function") {
179                callback(status, response);
180            }
181            $(document).trigger('afterSendAjax');
182            if (status === "HTTP_ERROR") {
183                //status, response
184                $(document).trigger('ajaxHttpError', status, response);
185            }
186        },
187
188        success: function (data) {
189            var status = data && data.status || "NOT_LOADED",
190                response = data && data.response || {};
191
192            if (data && data.debug) {
193                ajax_debug(data.debug);
194            }
195
196            if (typeof callback == "function") {
197                callback(status, response);
198            }
199            $(document).trigger('afterSendAjax');
200        }
201    });
202}
203
204function ajax_debug(debug_data) {
205
206    var debug_panel = $("#debug_panel").length !== 0 ? $("#debug_panel") : $("<div id='debug_panel' style='position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 10000;'><div class='clear'></div></div>").appendTo(document.body);
207    if (debug_data.length > 0) {
208        debug_panel.empty();
209        var template = '<div style="float: right; position: relative; margin:1px 0; border-radius: 5px 5px 5px 5px; color:#333; font-size:14px; background-color:{{bg_color}}; border:1px solid #000; padding:5px 10px 5px 10px; overflow:hidden;">' +
210            '<a href="javascript:;" onclick="$(this).parent().remove();" style="position: absolute; color: #FFF;top: 5px; right: 6px; bottom: auto; left: auto;">X</a>' +
211            '<div style="color: #E0E0E0; text-shadow: 0 1px 2px #000000; padding:5px 5px 5px 10px; margin:-5px -10px 0 -10px; background-color:#aaa; padding-right: 20px;">{{file}}<b>line:</b>{{line}}</div><pre>{{data}}</pre>' +
212            '</div>';
213
214        for (var i = 0, l = debug_data.length; i < l; ++i) {
215            var value = debug_data[i];
216            debug_panel.prepend(str_replace(['{{file}}', '{{line}}', '{{bg_color}}', '{{data}}'], [value.file, value.line, value.bg_color, value.data], template));
217        }
218    }
219}
220
221function zteel_set_message(what, type, parent, clearBeforeInsert) {
222
223    if (typeof type === "undefined" || type == '') { //Green code
224        type = "success";
225    }
226    var class_name = "session-message s-ok";
227    switch (type) {
228        case "warning":
229            class_name = "session-message s-warn";
230            break;
231        case "error":
232            class_name = "session-message s-error";
233            break;
234
235        default:
236            class_name = "session-message s-ok";
237            break;
238    }
239
240    var data = '<div class="' + class_name + '">' + what + '<a href="#" onclick="$(this).parent().remove(); return false;"></a></div>';
241    var selector = (typeof parent === "undefined" || parent === "") ? "#j-sm" : parent;
242
243    if (clearBeforeInsert === true) {
244        $(selector).empty();
245    }
246    $(selector).show().append(data);
247
248}
249
250function setCookie(name, value, expires, path, domain, secure) {
251    document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) +
252        ((expires) ? "; expires=" + expires : "") +
253        ((path) ? "; path=" + path : "") +
254        ((domain) ? "; domain=" + domain : "") +
255        ((secure) ? "; secure" : "");
256}
257function getCookie(name) {
258    var cookie = " " + document.cookie;
259    var search = " " + name + "=";
260    var setStr = null;
261    var offset = 0;
262    var end = 0;
263    if (cookie.length > 0) {
264        offset = cookie.indexOf(search);
265        if (offset != -1) {
266            offset += search.length;
267            end = cookie.indexOf(";", offset);
268            if (end == -1) {
269                end = cookie.length;
270            }
271            setStr = unescape(cookie.substring(offset, end));
272        }
273    }
274    return (setStr);
275}
276
277(function ($) {
278    $.fn.preload = function () {
279        return this.each(function () {
280            var me = $(this);
281
282            if (!me.is('img')) {
283                return;
284            }
285
286            var preload = $('<div class="tm-preload"></div>').insertBefore(me).show();
287            me.hide();
288
289            me.load(function () {
290                preload.hide();
291                me.show();
292            });
293
294        });
295    };
296})(jQuery);
297
298var ajax_link_click = function () {
299    var me = $(this),
300        place = me.data('rel');
301    if (place === undefined || place === null) {
302        place = 'replace';
303    }
304    sendAjax(this.href, null, function (status, response) {
305        if (status === 'OK') {
306            if (response.html) {
307                if (place === 'replace') {
308                    var block = $(response.html).off('click').on('click', ajax_link_click);
309                    block.insertAfter(me);
310                    me.remove();
311                } else {
312                    $(place).html(response.html);
313                }
314            } else {
315                reloadPage();
316            }
317        } else if (status === "UNAUTHORIZED") {
318            authorize_required(response.message);
319        }
320    });
321
322    return false;
323};
324
325function authorize_required(message) {
326    Modal.open('#sign-in');
327    message = message || l10n("Для добавления товара в список желаний Вам необходимо авторизироваться");
328    if (message) {
329        zteel_set_message(message, 'error', '.j-signup-info-message, .j-login-info-message', true);
330    }
331}
332
333function track_analytics_event(event_name) {
334    if (GLOBAL && GLOBAL.analytic_events) {
335        var events = GLOBAL.analytic_events;
336        for (var i = 0, l = events.length; i < l; ++i) {
337            var e = events[i];
338            if (e.name == event_name) {
339                try {
340                    e.func.call();
341                } catch (e) {
342                }
343            }
344        }
345    }
346}
347
348/**
349 *
350 * @param {String} eventName
351 * @param {Array || Object} [attributes]
352 */
353function triggerMarketingEvent(eventName, attributes) {
354    if (GLOBAL && GLOBAL.marketingEvents) {
355        var events = GLOBAL.marketingEvents;
356
357        if (events[eventName]) {
358            for (var i = 0, l = events[eventName].length; i < l; ++i) {
359                var e = events[eventName][i];
360                attributes = Array.isArray(attributes) ? attributes : [attributes];
361                
362                try {
363                    e.apply(null, attributes);
364                } catch (error) {
365                    console.log(error);
366                }
367            }
368        }
369    }
370}
371
372function openSignInModal(email) {
373    Modal.open('#sign-in');
374
375    $('a[href="#j-popup-tab-auth"]').trigger('click');
376
377    if (email) {
378        var auth = $('#j-popup-tab-auth');
379        auth.find(':input[name="user[email]"]').val(email);
380        setTimeout(function () {
381            auth.find(':input[name="user[pass]"]').focus();
382        }, 100);
383        //user[pass]
384    }
385}
386
387function priceFormat(price) {
388    return currency.wrap_html(number_format(price, GLOBAL.round_to, ".", ""));
389}
390
391function checkEmailValidity(str) {
392    return (/^([a-z0-9_\.\-]+)@([a-z0-9\.\-]+)\.([a-z]+)$/i).test(str);
393}
394
395function parseGetParams() {
396    var $_GET = {};
397    var __GET = window.location.search.substring(1).split("&");
398    for (var i = 0; i < __GET.length; i++) {
399        var getVar = __GET[i].split("=");
400        $_GET[getVar[0]] = typeof(getVar[1]) == "undefined" ? "" : getVar[1];
401    }
402    return $_GET;
403}
404function parseHashParams() {
405    var $_GET = {};
406    var __GET = window.location.hash.substring(1).split("&");
407    for (var i = 0; i < __GET.length; i++) {
408        var getVar = __GET[i].split("=");
409        $_GET[getVar[0]] = typeof(getVar[1]) == "undefined" ? "" : getVar[1];
410    }
411    return $_GET;
412}
413function changeHistory(url, params) {
414    try {
415        var params_str = [];
416        for (var key in params) {
417            if (params.hasOwnProperty(key)) {
418                var value = params[key];
419                if (key === "" || value === "") {
420                    continue;
421                }
422
423                params_str.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
424            }
425        }
426
427        params_str = params_str.length !== 0 ? '?' + params_str.join('&') : '';
428
429        history.replaceState({}, '', url + params_str);
430        reloadLangWidget();
431    } catch (e) {
432    }
433}
434function changeHashHistory(url, params) {
435    try {
436        var params_str = [];
437        for (var key in params) {
438            if (params.hasOwnProperty(key)) {
439                var value = params[key];
440                if (key === "" || value === "") {
441                    continue;
442                }
443
444                params_str.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
445            }
446        }
447
448        params_str = params_str.length !== 0 ? '#' + params_str.join('&') : '';
449        if (window.location.hash != params_str) {
450            window.location.hash = params_str;
451        }
452    } catch (e) {
453    }
454}
455
456
457function number_format(number, decimals, dec_point, thousands_sep) {  // Format a number with grouped thousands
458    var i, j, kw, kd, km;
459
460    // input sanitation & defaults
461    if (isNaN(decimals = Math.abs(decimals))) {
462        decimals = 2;
463    }
464    if (dec_point == undefined) {
465        dec_point = ",";
466    }
467    if (thousands_sep == undefined) {
468        thousands_sep = ".";
469    }
470
471    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
472
473    if ((j = i.length) > 3) {
474        j = j % 3;
475    } else {
476        j = 0;
477    }
478
479    km = (j ? i.substr(0, j) + thousands_sep : "");
480    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
481    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
482
483
484    return km + kw + kd;
485}
486//Функция которая перегружает страницу
487function reloadPage() {
488    window.location.reload();
489}
490
491function iframe_reset() {
492    $('.gallery-photo-inner iframe').each(function () {
493        var me = $(this),
494            src = me.attr('src');
495        me.attr('src', '').attr('src', src);
496
497    });
498}
499
500if (!Array.prototype.indexOf) {
501    Array.prototype.indexOf = function (value, startIndex) {
502        return jQuery.inArray(value, this, startIndex);
503    };
504}
505
506function reloadLangWidget() {
507    var containers = $('[data-widget="lang_menu"]'),
508        usedSkins = [],
509        skinsData = [{'name': 'requestedUrl', 'value': window.location.href}];
510
511    if (!containers.length) {
512        return;
513    }
514
515    containers.each(function () {
516        var skin = $(this).attr('data-skin') || 'default';
517
518        if ($.inArray(skin, usedSkins) === -1) {
519            usedSkins.push(skin);
520            skinsData.push({
521                'name': 'skins[]',
522                'value': skin
523            });
524        }
525    });
526
527    sendAjax(GLOBAL.URI_PREFIX + '_widget/lang_menu/renderMultiple', skinsData, function (status, response) {
528        if (status === 'OK') {
529            for (var i = 0, l = response.data.length; i < l; ++i) {
530                var skin = response.data[i].skin,
531                    html = $(response.data[i].html);
532
533                containers.filter('[data-skin="' + skin + '"]').replaceWith(html);
534            }
535
536            $(document.body).trigger('onLangWidgetReload', containers
536);
537        }
538    });
539}
540
541function http_build_query(data) {
542    var ret = [];
543    for (var d in data) {
544        ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]));
545    }
546    return ret.join('&');
547}
548
549function createUrl(route, params) {
550    route = route instanceof Array ? route.join('/') : route;
551
552    params = params || {};
553
554    if (route[0] == '') {
555        route = route.substr(1, route.length - 1)
556    }
557
558    var queryParams = params ? '?' + http_build_query(params) : '';
559
560    return GLOBAL.URI_PREFIX + route + GLOBAL.URI_SUFFIX + queryParams;
561}
562
563function loadHintContent(hintId, titleContainer, textContainer, callback) {
564    var link = createUrl(['_widget', 'hint', 'loadHintContent']);
565
566    sendAjax(link, {hintId: hintId}, function (status, response) {
567        if (status === 'OK') {
568            $(titleContainer).show().html(response.title);
569            $(textContainer).show().html(response.text);
570        }
571
572        callback && callback(status, response);
573    });
574}
575
576(function (Horoshop, $, u) {
577    Horoshop.Widgets = Horoshop.Widgets || {};
578
579    var hintContentLoaders = {};
580
581    Horoshop.Widgets.Hint = {
582        cache: {},
583        writeCache: function (key, data) {
584            this.cache[key] = data;
585        },
586        readCache: function (key) {
587            return this.cache[key] != undefined ? this.cache[key] : false;
588        },
589        loadHintContent: function (hintId, titleContainer, textContainer, callback) {
590            var self = this,
591                link = createUrl(['_widget', 'hint', 'loadHintContent']);
592
593            if (!this.readCache(hintId)) {
594                sendAjax(link, {hintId: hintId}, function (status, response) {
595                    if (status === 'OK') {
596                        if (response.title) {
597                            $(titleContainer).show().html(response.title);    
598                        }
599                        $(textContainer).show().html(response.text);
600                        self.writeCache(hintId, response);
601                    }
602
603                    callback && callback(status, response);
604                });
605            } else {
606                var response = this.readCache(hintId);
607
608                if (response.title) {
609                    $(titleContainer).show().html(response.title);    
610                }
611                $(textContainer).show().html(response.text);
612
613                callback && callback('OK', response);
614            }
615        },
616
617        initHintContentLoader: function (skin, inModal, hintId, paramId, index) {
618            var hintLoader = this.getHintLoader(skin, inModal);
619
620            if (hintLoader) {
621                hintLoader(hintId, paramId, index);
622            }
623        },
624
625        getHintLoader: function (skin, inModal) {
626            var key = skin + '_' + (inModal ? 'inModal' : 'inPopup');
627            if (hintContentLoaders.hasOwnProperty(key)) {
628                return hintContentLoaders[key];
629            } else if (hintContentLoaders.hasOwnProperty(skin)) {
630                return hintContentLoaders[skin];
631            } else {
632                return null;
633            }
634        },
635
636        registerHintLoader: function (skin, callback, inModal) {
637            var key = skin;
638
639            if (inModal !== u) {
640                key += '_' + (inModal ? 'inModal' : 'inPopup');
641            }
642
643            hintContentLoaders[key] = callback;
644        }
645    };
646
647    var defaultModalClickCallback = function (hintId, paramId, caller, modal, onSuccess) {
648        Horoshop.Widgets.Hint.loadHintContent(
649            hintId,
650            modal.find('.j-hint-title'),
651            modal.find('.j-hint-text'),
652            function (status, response) {
653                if (status !== 'OK') {
654                    modal.find('.j-hint-text').show().html(l10n("Ошибка загрузки подсказки"));
655                } else {
656                    caller.off('click.widget-hint');
657
658                    onSuccess && onSuccess();
659                }
660            }
661        );
662    };
663
664    Horoshop.Widgets.Hint.registerHintLoader('default', function (hintId, paramId, index) {
665        var widget = $('#widget-hint-default-' + hintId + '-' + index),
666            modal = $('#hint-popup-' + hintId + '-' + index);
667        widget.find('.product-hint-btn').on('click.widget-hint', function () {
668            defaultModalClickCallback(hintId, paramId, $(this), modal);
669
670            return false;
671        });
672    }, true);
673
674    Horoshop.Widgets.Hint.registerHintLoader('default', function (hintId, paramId, index) {
675        var widget = $('#widget-hint-default-' + hintId + '-' + index);
676        widget.find('.product-hint-btn').on('click.widget-hint', function () {
677            defaultModalClickCallback(hintId, paramId, $(this), widget);
678
679            return false;
680        });
681    }, false);
682
683    Horoshop.Widgets.Hint.registerHintLoader('filter', function (hintId, paramId, index) {
684        var widget = $('#widget-hint-filter-' + hintId + '-' + index),
685            modal = $('#filter-hint-popup-' + hintId + '-' + index);
686        widget.on('click.widget-hint', function () {
687            defaultModalClickCallback(hintId, paramId, $(this), modal);
688
689            return false;
690        });
691    }, true);
692
693    Horoshop.Widgets.Hint.registerHintLoader('filter', function (hintId, paramId, index) {
694        $('#widget-hint-filter-' + hintId + '-' + index).on('click.widget-hint', function () {
695                var $this = $(this),
696                    hintCached = Horoshop.Widgets.Hint.readCache(paramId) !== false;
697
698                defaultModalClickCallback(hintId, paramId, $this, $('[data-id="filter-tooltip-' + hintId + '-' + index + '"]'), function () {
699                    if (!hintCached) {
700                        setTimeout(function () {
701                            $this.data('hsTooltip').popperInstance.update();
702                        }, 1);
703                    }
704                });
705            });
706    }, false);
707
708    Horoshop.Widgets.Hint.registerHintLoader('mobile', function (hintId, paramId) {
709        var widget = $('#widget-hint-mobile-' + hintId),
710            modal = $('#features-hint-' + hintId);
711        widget.on('click.widget-hint', function () {
712            defaultModalClickCallback(hintId, paramId, $(this), modal, function() {
713                if (modal.find('img').length) {
714                    modal.imagesLoaded(function() {
715                        modal.data('mobile_modal').setPosition();
716                    });
717                } else {
718                    modal.data('mobile_modal').setPosition();
719                }
720            });
721        });
722
723        ModificationChange.getInstance() && ModificationChange.getInstance().attachEventHandlers({
724            'onBeforeAppendHtml': function() {
725                modal.remove();
726            }
727        });
728    });
729
730    Horoshop.Widgets.Hint.registerHintLoader('mobile-simple', function (hintId, paramId) {
731        var widget = $('#widget-hint-mobile-simple-' + hintId),
732            modal = $('#mods-hint-' + hintId);
733        widget.on('click.widget-hint', function () {
734            defaultModalClickCallback(hintId, paramId, $(this), modal, function() {
735                if (modal.find('img').length) {
736                    modal.imagesLoaded(function() {
737                        modal.data('mobile_modal').setPosition();
738                    });
739                } else {
740                    modal.data('mobile_modal').setPosition();
741                }
742            });
743        });
744
745        ModificationChange.getInstance() && ModificationChange.getInstance().attachEventHandlers({
746            'onBeforeAppendHtml': function() {
747                modal.remove();
748            }
749        });
750    });
751
752})(window.Horoshop = window.Horoshop || {}, jQuery);
753
754function initCheckoutCartEvents(selector, skin)
755{
756    AjaxCart.selector = selector;
757    AjaxCart.skin = skin;
758    AjaxCart.getInstance().attachEventHandlers({
759        'onReloadHtml' : function () {
760            change_delivery_type();
761            CheckoutModule.getInstance().reload(change_delivery_type);
762        },
763        'onInit' : function () {
764            change_delivery_type();
765        }
766    });
767
768    var deliveryComponent = CheckoutModule.getInstance().getComponentByName('Delivery');
769    var paymentComponent = CheckoutModule.getInstance().getComponentByName('Payment');
770
771    var change_delivery_type = function () {
772        onChangeDeliveryType(deliveryComponent.delivery_type, deliveryComponent.delivery_type.val());
773    };
774
775    var getTotalSum = function () {
776        var ajaxCart = AjaxCart.getInstance(),
777            delivery_select = deliveryComponent.delivery_type,
778            payment_select = paymentComponent.payment_type,
779            by_carrier = delivery_select.find(':selected').data('by-carrier') * 1,
780            deliveryPrice = by_carrier ? 0 : delivery_select.find(':selected').data('price') * 1,
781
782            paymentPrice = payment_select.find(':selected').data('price') * 1;
783
784        return ajaxCart.Cart.total.sum + deliveryPrice + paymentPrice;
785    };
786
787    var onChangeDeliveryType = function (delivery_select, value) {
788        var ajaxCart = AjaxCart.getInstance();
789        var delivery = ajaxCart.container.find('.j-delivery-price'),
790            total_sum_delivery = ajaxCart.container.find('.j-total-sum-delivery');
791
792        if (delivery_select.length && !delivery_select.parents('.j-component:first').is('[class*="disabled"]')) {
793            var option = delivery_select.find(':selected'),
794                by_carrier = option.data('by-carrier') * 1,
795                price = by_carrier ? 0 : option.data('price') * 1;
796
797            if (by_carrier) {
798                delivery.html(l10n("По тарифам перевозчика"));
799            } else {
800                delivery.html(price > 0 ? ajaxCart.priceFormat(price) : l10n("бесплатно"));
801            }
802            total_sum_delivery.html(ajaxCart.priceFormat(getTotalSum()));
803        } else {
804            delivery.html(l10n('уточняется'));
805        }
806    };
807
808    var change_payment_type = function () {
809        onChangePaymentType(paymentComponent.payment_type, paymentComponent.payment_type.val());
810    };
811
812    var onChangePaymentType = function (payment_select, value) {
813        var ajaxCart = AjaxCart.getInstance();
814        var payment = ajaxCart.container.find('.j-payment-price'),
815            payment_container = ajaxCart.container.find('.j-payment-price-container'),
816            total_sum_delivery = ajaxCart.container.find('.j-total-sum-delivery');
817
818        if (payment_select.length && !payment_select.parents('.j-component:first').is('[class*="disabled"]')) {
819            var option = payment_select.find(':selected'),
820                price = option.data('price') * 1;
821
822            if (price > 0) {
823                payment_container.removeClass('__hidden').show();
824                payment.html(ajaxCart.priceFormat(price));
825            } else {
826                payment_container.addClass('__hidden').hide();
827            }
828
829            total_sum_delivery.html(ajaxCart.priceFormat(getTotalSum()));
830        } else {
831            payment.html(0);
832            payment_container.addClass('__hidden').hide();
833        }
834    };
835
836    deliveryComponent.attachEventHandlers({
837        'changeDeliveryType': onChangeDeliveryType
838    });
839    paymentComponent.attachEventHandlers({
840        'changePaymentType': onChangePaymentType
841    });
842    change_delivery_type();
843    change_payment_type();
844}
845(function ($, window) {
846    window.horoshopReCaptcha = {
847        initialized: false,
848        forms: [],
849        submit: function (formSelector) {
850            $(formSelector).submit();
851        },
852        attach: function (formSelector, siteKey) {
853            if (this.initialized) {
854                var form = $(formSelector),
855                    submits = form.find(':input[type="submit"]');
856
857                submits.each(function () {
858                    var id = grecaptcha.render(
859                        this,
860                        {
861                            sitekey : siteKey,
862                            callback: function () {
863                                form.submit();
864                                grecaptcha.reset(id);
865                            },
866                            'error-callback': function () {
867                                console.log('error');
868                                console.log(arguments);
869                            }
870                        }
871                    );
872                    var $this = $(this);
873
874                    if ($this.is('input')) {
875                        $this.attr('type', 'button');
876                    } else {
877                        $this.removeAttr('type');
878                    }
879                });
880            } else {
881                this.forms.push([formSelector, siteKey]);
882            }
883        },
884
885        init: function () {
886            this.initialized = true;
887
888            for (var i = 0, l = this.forms.length; i < l; ++i) {
889                this.attach(this.forms[i][0], this.forms[i][1]);
890            }
891        }
892    };
893
894    window.onHoroshopReCaptchaLoaded = function () {
895        console.log('Initialized');
896        window.horoshopReCaptcha.init();
897    };
898})(jQuery, window);
899
900
901$(function () {
902    ModificationChange.getInstance() && ModificationChange.getInstance().attachEventHandlers({
903        'onAfterSubmit': function (status, response) {
904            //чтобы успел измениться url
905            setTimeout(function() {
906                triggerMarketingEvent('ajax_page_view', window.location.href);
907            }, 300);
908        }
909    });
910
911    CatalogBuilder && CatalogBuilder.attachEventHandlers({
912        'onFilterLinkClick': function ($link) {
913            triggerMarketingEvent('ajax_page_view', $link.attr('href'));
914        }
915    });
916});
917
918function init_search_widget(selector, options) {
919    window.Search.init(selector, options);
920}

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.