PageSourceSearch

https://www.mango-office.ru/local/templates/mango_ru/js/custom/plugins/errors.js

js mango-office.ru collected 2026-10-01 12:07:57 UTC 3,402 bytes, 121 lines download raw bytes

1/**
2 * Created by gvammer on 13.05.16.
3 */
4
5var MESSAGE_TYPE_ERROR = 'danger';
6var MESSAGE_TYPE_SUCCESS = 'success';
7var MESSAGE_TYPE_WARNING = 'warning';
8var MESSAGE_TYPE_INFO = 'info';
9
10var ERROR_REPORTER = {
11    '$block': false,
12    'selectorPrefix': '.js-error-container',
13    'showDelay': 7000,
14    'classes': [
15        'label-danger',
16        'label-warning',
17        'label-success'
18    ],
19    'hideTimeout': false,
20    'errorStack': [],
21    'inited': false,
22    'init': function () {
23        this.$block = $(this.selectorPrefix);
24
25        $(this.selectorPrefix + '-close').click(function () {
26            ERROR_REPORTER.hideMessage();
27            return false;
28        });
29
30        this.inited = true;
31        let event = new Event('onErrorReporterInited');
32        document.dispatchEvent(event);
33    },
34    'isInited': function () {
35        return this.inited;
36    },
37    'setBlockPosition': function () {
38
39    },
40    'isModalOpened': function () {
41        return $('body').hasClass('modal-open');
42    },
43    '$getModalErrorBlock': function (notOnlyVisible) {
44        return $('.modal' + (notOnlyVisible ? '' : ':visible') + ' .js-modal-error');
45    },
46    'showMessage': function (text, type, woDelay, woTimeout) {
47        if (!type) type = MESSAGE_TYPE_ERROR;
48
49        woTimeout = woTimeout || false;
50
51        ERROR_REPORTER.hideMessage();
52
53        var err = new Error();
54
55        this.errorStack.push({
56            'text': text,
57            'type': type,
58            'stack': err.stack
59        });
60
61        this.$block.find(this.selectorPrefix + '-text').html(text).end().slideDown();
62
63        this.$block.removeClass(this.classes.join(' ')).addClass('label-' + type);
64
65        if (this.showDelay && !woDelay) {
66            if (this.hideTimeout) {
67                clearTimeout(this.hideTimeout);
68            }
69
70            if (!woTimeout) {
71                this.hideTimeout = setTimeout(function () {
72                    ERROR_REPORTER.hideMessage();
73                }, this.showDelay);
74            }
75        }
76
77        if (type === MESSAGE_TYPE_ERROR) {
78            this.log(text, err.stack);
79        }
80    },
81    'hideMessage': function () {
82        if (this.$block.is(':visible'))
83            this.$block.hide();
84
85        this.$getModalErrorBlock(true).hide();
86    },
87    'lastError': function () {
88        return this.errorStack.length && this.errorStack[this.errorStack.length - 1];
89    },
90    'log': function(text, stack, context) {
91        context = context || {};
92        if (typeof AJAX != 'undefined')
93            AJAX.send(
94                '/ajax_new/jsLogger.php',
95                {
96                    text: text,
97                    stack: stack,
98                    context: context
99                }
100            );
101    }
102};
103
104(function ($) {
105    $(function () {
106        ERROR_REPORTER.init();
107    });
108})(jQuery);
109
110var showGlobalMessages = function (errorText, type) {
111    ERROR_REPORTER.showMessage(errorText, type);
112};
113
114_alert = alert;
115alert = function(text) {
116    ERROR_REPORTER.showMessage(text);
117};
118
119alertDefaultError = function () {
120    alert('Возникла ошибка во время добавления товара. Попробуйте еще раз. Если ошибка повториться, пожалуйста, свяжитесь с нами по номеру 8 800 555 55 22 и мы обязательно вам поможем. Спасибо!"');
121};

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.