PageSourceSearch

https://www.fesco.ru/local/templates/.default/components/fesco/exc…/.default/script.js?178176938214051

js fesco.ru collected 2026-10-02 09:58:03 UTC 14,051 bytes, 339 lines download raw bytes

1$(function () {
2    if(typeof window.FESCO !== 'undefined') {
3        window.FESCO.requestForm = {func: {}, vars: {}};
4        var RF = window.FESCO.requestForm; // scope
5
6        RF.vars.container = $('form.js-request-form');
7
8        RF.func.checkAcceptPolicy = function () {};
9		RF.func.checReklamaPolicy = function () {};
10
11        if(RF.vars.container.length) {
12            var btnSubmit = RF.vars.container.find('[type=submit]'),
13                checkPrivacyAccept = RF.vars.container.find('[name=ACCEPT_PRIVACY_POLICY]'),
14                receiver = RF.vars.container.data('receiver');
15
16			var btnSubmit = RF.vars.container.find('[type=submit]'),
17                checkReklamaAccept = RF.vars.container.find('[name=ACCEPT_REKLAMA]'),
18                receiver = RF.vars.container.data('receiver');
19
20            RF.func.messagesRender = function(messages) {
21                messages = messages || {};
22
23                var messagesBlock = RF.vars.container.find('.js-form-messages');
24
25                if(messagesBlock) {
26                    messagesBlock.html('');
27                    if(messages.notes || messages.errors) {
28                        if(messages.notes_html) {
29                            messagesBlock.append(messages.notes_html)
30                        } else {
31                            messages.notes && $.each(messages.notes, function () {
32                                messagesBlock.append('<p class="-is-note">'+this+'</p>')
33                            });
34                        }
35                        if(messages.errors_html) {
36                            messagesBlock.append(messages.errors_html);
37                        } else {
38                            messages.errors && $.each(messages.errors, function () {
39                                messagesBlock.append('<p class="-is-error">'+this+'</p>')
40                            });
41                        }
42
43                        try {
44                            //$('body, html').scrollTop('.js-form-messages');
45                        } catch (e) {}
46
47                        messagesBlock.show();
48                    } else {
49                        messagesBlock.hide();
50                    }
51                }
52
53                if(messages.errors_fields) {
54                    $.each(messages.errors_fields, function (fieldCode, message) {
55                        try {
56                            if(fieldCode.length) {
57                                var $field = RF.vars.container.find('[name="'+fieldCode+'"]');
58                                if($field.length) {
59                                    var $wrap = $field.closest('.field');
60                                    $wrap.addClass('has-error');
61                                    $wrap.find('.text-help').html(message).show();
62                                }
63                            }
64                        } catch (e) {}
65                    });
66                }
67
68            };
69
70            RF.func.refreshForm = function () {
71                var request = $.ajax({
72                    url: receiver,
73                    method: 'POST',
74                    data: RF.vars.container.serialize().replace('submit', '')+'&refresh=Y',
75                    dataType: 'json',
76                    async: true,
77                    cache: false,
78                    timeout: 30000
79                });
80                request.done(function(response) {
81                    RF.func.messagesRender(response);
82
83                    if(response.sessid) {
84                        RF.vars.container.find('input.js-session-id').val(response.sessid);
85                    }
86                    if(response.captcha_code) {
87                        RF.vars.container.find('input.js-captcha-code').val(response.captcha_code);
88                    }
89                    if(response.captcha_img) {
90                        RF.vars.container.find('input.js-captcha-img').attr('src', response.captcha_img);
91                    }
92
93                    if(response.html) {
94                        try {
95                            RF.vars.container[0].dispatchEvent( new CustomEvent('destroy.validate') );
96                        } catch (e) {}
97                        var content = $(response.html),
98                            contentForm = content.find('form');
99                        if(contentForm.length) {
100                            RF.vars.container.html(contentForm.html());
101                        }
102                        btnSubmit = RF.vars.container.find('[type=submit]');
103                        checkPrivacyAccept = RF.vars.container.find('[name=ACCEPT_PRIVACY_POLICY]');
104                        RF.func.initFront();
105                    }
106
107                });
108            };
109
110            RF.func.checkPersonType = function () {
111                var fields = RF.vars.container.find('input[name=person_type]');
112                if(!fields.length) return false;
113                var value = '';
114                if(fields.length === 1) {
115                    // one field = hidden
116                    value = fields.val();
117                } else {
118                    fields.each(function () {
119                        var field = $(this);
120                        if(field.prop('checked')) {
121                            value = field.val();
122                        }
123                    });
124                }
125                if(value && value.length) {
126                    RF.func.refreshForm();
127                }
128                return true;
129            };
130            RF.vars.container.on('change', 'input[name=person_type]', function(e) {
131                e.preventDefault();
132                RF.func.checkPersonType();
133            });
134
135            RF.func.initFront = function () {
136                $(window).trigger('frontend');
137                window.dispatchEvent( new CustomEvent('init.mask') );
138                window.dispatchEvent( new CustomEvent('init.validate') );
139                RF.func.autocompleteInit();
140            };
141
142            RF.func.autocompleteInit = function () {
143                RF.vars.container.find('.js-autocomplete-itn').each(function () {
144                    var itnField = $(this),
145                        form = itnField.closest('form'),
146                        companyField = form.find('input.js-autocomplete-company'),
147						kppFields = form.find("input.js-company-kpp");
148
149                    if (form.length && companyField.length) {
150                        itnField.on('autocompleteselect', function( event, ui ) {
151                            if(ui.item && ui.item.company_name && !companyField.val()) {
152                                companyField.val(ui.item.company_name);
153                                companyField.trigger('refresh');
154                                itnField.trigger('refresh');
155                            }
156							if(ui.item && ui.item.kpp && !kppFields.val()) {
157                                kppFields.val(ui.item.kpp);
158                                kppFields.trigger('refresh');
159                            }
160                        });
161                    }
162                }).inputRoundOnly();
163                RF.vars.container.find('.js-autocomplete-company').each(function () {
164                    var companyField = $(this),
165                        form = companyField.closest('form'),
166                        itnField = form.find('input.js-autocomplete-itn'),
167						kppFields = form.find("input.js-company-kpp");
168
169                    if (form.length && itnField.length) {
170                        companyField.on('autocompleteselect', function( event, ui ) {
171                            if(ui.item && ui.item.itn && !itnField.val()) {
172                                itnField.val(ui.item.itn);
173                                itnField.trigger('refresh');
174                                companyField.trigger('refresh');
175                            }
176							if(ui.item && ui.item.kpp && !kppFields.val()) {
177                                kppFields.val(ui.item.kpp);
178                                kppFields.trigger('refresh');
179                            }
180                        });
181                    }
182                });
183                RF.vars.container.on('refresh', 'input[type=text]', function () { // front visual fixes
184                    var field = $(this);
185
186                    if(field.val()) {
187                        field.addClass('inp-focus').removeClass('inp-un-focus');
188                    } else {
189                        field.addClass('inp-un-focus').removeClass('inp-focus');
190                    }
191
192                    try {
193                        if(RF.vars.container[0].pristine) {
194                            setTimeout(function () {
195                                RF.vars.container[0].pristine.validate(field[0]);
196                            }, 100);
197                        }
198                    } catch (e) {}
199                });
200            };
201            RF.func.autocompleteInit();
202
203            RF.func.checkAcceptPolicy = function () {
204                if(!!checkPrivacyAccept.prop('checked')) {
205                    btnSubmit
206                        .removeAttr('data-send-disabled');
207                } else {
208                    btnSubmit
209                        .attr('data-send-disabled', true);
210                }
211            };
212            RF.func.checkAcceptPolicy();
213            checkPrivacyAccept.on('change', function () {
214                RF.func.checkAcceptPolicy();
215            });
216
217			RF.func.checReklamaPolicy = function () {
218                if(!!checkReklamaAccept.prop('checked')) {
219                    btnSubmit
220                        .removeAttr('data-send-disabled');
221                } else {
222                    btnSubmit
223                        .attr('data-send-disabled', true);
224                }
225            };
226            RF.func.checReklamaPolicy();
227            checkReklamaAccept.on('change', function () {
228                RF.func.checReklamaPolicy();
229            });
230
231            RF.vars.container.on('submit', function(e) {
232                e.preventDefault();
233
234                var hasErrors = false;
235                if(RF.vars.container.hasClass('js-validate')) {
236                    hasErrors = !!RF.vars.container.find('.has-error').length;
237                }
238
239                if(receiver && receiver.length && !hasErrors && !btnSubmit.attr('data-send-disabled')) {
240                    btnSubmit
241                        .addClass('-busy')
242                        .attr('data-send-disabled', true);
243                    var data = {};
244                    if(typeof FormData !== 'undefined') {
245                        data = new FormData(RF.vars.container[0]);
246                    } else {
247                        data = RF.vars.container.serialize();
248                    }
249
250                    var request = $.ajax({
251                        url: receiver,
252                        method: 'POST',
253                        data: data,
254                        contentType: false,
255                        processData: false,
256                        dataType: 'json',
257                        async: true,
258                        cache: false,
259                        timeout: 30000
260                    });
261                    request.done(function(response) {
262                        RF.func.checkAcceptPolicy();
263
264                        btnSubmit.removeClass('-busy');
265
266                        RF.func.messagesRender(response);
267
268                        if(response.sessid) {
269                            RF.vars.container.find('input.js-session-id').val(response.sessid);
270                        }
271                        if(response.captcha_code) {
272                            RF.vars.container.find('input.js-captcha-code').val(response.captcha_code);
273                        }
274                        if(response.captcha_img) {
275                            RF.vars.container.find('input.js-captcha-img').attr('src', response.captcha_img);
276                        }
277
278                        if(response.success && response.success === 'Y') {
279
280			    if (response.theme_code === 'service-finance-request') {
281                                if (typeof ym !== 'undefined') {
282                                    if (RF.vars.container.hasClass('contacts-feedback__form')) {
283                                        ym(44876137, 'reachGoal', 'write_to_us_send');
284                                    } else {
285                                        ym(44876137, 'reachGoal', 'request_send');
286                                    }
287                                }
288                            }
289
290			    $('.popup[data-popup="request-form-popup"]').css({'display':'flex'}).trigger('open');
291
292			    $('.popup[data-popup="request-form-popup"]').find(".message-send").html(response.notes_html+"<b>"+response.number+"</b>");
293
294                            try {
295                                RF.vars.container.trigger('reset');
296                                if(RF.vars.container[0].pristine) {
297                                    setTimeout(function () {
298                                        RF.vars.container[0].pristine.reset();
299                                    }, 500);
300                                }
301                            } catch (e) {}
302                        }
303
304						setTimeout(function () {
305                            RF.func.refreshForm();
306                        }, 1000);
307
308
309                    });
310
311                }
312
313            });
314
315            RF.vars.container.on('change', '.js-theme-code', function(e) {
316                e.preventDefault();
317
318				console.log($(this).val());
319
320				if($(this).val() == "service-finance-request"){
321					gm_counter("selected_service_contact");
322				}
323
324                if(receiver && receiver.length) {
325                    RF.func.refreshForm();
326                }
327            });
328
329			RF.vars.container.on('change', '.js-gruz_type', function(e) {
330                e.preventDefault();
331                if(receiver && receiver.length) {
332                    RF.func.refreshForm();
333                }
334            });
335
336        }
337    }
338
339});

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.