PageSourceSearch

https://met-72.ru/bitrix/components/altasib/feedback.form/templates/.default/form_script.js

js met-72.ru collected 2026-10-01 12:27:26 UTC 15,998 bytes, 384 lines download raw bytes

1var ALXpopup = {
2    timerId: "",
3    timerReId: "",
4    minw: 500,
5    param: "",
6    removeWindow: true,
7    fixed: false,
8    canClearBlock: false,
9    init: function (param) {
10        var oPopup = this;
11        this.param = typeof param !== 'undefined' ? param : "";
12        this.param.popupAnimation = typeof param.popupAnimation !== 'undefined' ? param.popupAnimation : ['alx-popup-show-anime1', 'alx-popup-hide-anime1', 'alx-popup-mess-show-anime1'];
13
14        if (typeof param.popupWindow != 'undefined') {
15            this.canClearBlock = typeof param.filledWithErrors !== 'undefined' ? param.filledWithErrors !== 'Y' : false;
16            $('.alx_feed_back').find("form").unbind('submit').submit(function () {
17                oPopup.send_dataAjax(this);
18                return false;
19            });
20        } else {
21            if (typeof param.cssURL !== 'undefined' && typeof param.cssURL !== 'object')
22                $('head').append("<link rel='stylesheet' type='text/css' href='" + param.cssURL + "' />");
23            else if (typeof param.cssURL == 'object')
24                for (i in param.cssURL) $('head').append("<link rel='stylesheet' type='text/css' href='" + param.cssURL[i] + "' />");
25
26            if (typeof param.objClick !== 'undefined') {
27                $(param.objClick).click(function () {
28                    oPopup.show(this);
29                });
30            }
31            this.param.data = typeof param.data !== 'undefined' ? param.data : "";
32            this.param.url = typeof param.url !== 'undefined' ? param.url : "";
33            this.param.fixed = typeof param.fixed !== 'undefined' ? param.fixed : oPopup.fixed;
34            this.param.width = typeof param.width !== 'undefined' ? param.width : oPopup.minw;
35            this.param.height = typeof param.height !== 'undefined' ? param.height : 200;
36            this.param.removeWindow = typeof param.removeWindow !== 'undefined' ? param.removeWindow : oPopup.removeWindow;
37        }
38    },
39    show: function (el) {
40        var IB_ELEMENT_ID = $(el).attr(this.param.data.ELEMENT_ID_ATTR);
41
42        if (typeof IB_ELEMENT_ID !== 'undefined')
43            this.param.data.TARGET_ELEMENT_ID = parseInt(IB_ELEMENT_ID);
44        else
45            this.param.data.TARGET_ELEMENT_ID = "";
46
47        var oPopup = this;
48        document.body.style.overflowX = 'hidden';
49        if (this.param.removeWindow)
50            $('.modal_form , .alx_fb_overlay').remove();
51        if ($('.alx-feedb-data').length < 1) {
52            $('body').append('<div class="modal_form"><span class="modal_close"><span class="modal_close__left"></span><span class="modal_close__right"></span></span><div class="alx-feedb-error"></div><div class="alx_cont_popup"></div></div><div class="alx_fb_overlay"></div>');
53            $('.alx_fb_overlay').fadeIn(400);
54            $('body').append('<div class="alx_fedb_wait"><div class="alx-feedb-loading"></div><div class="alx-feedb-loading-text">loading</div></div>');
55            $('.modal_close,.alx_fb_overlay,.modal_close_ok').click(function () { // close modal event
56                oPopup.close();
57            });
58            oPopup.timerId = setInterval(function () {
59                oPopup.update();
60            }, 200);
61            setTimeout(function () {
62                clearInterval(oPopup.timerId);
63                oPopup.show_error();
64            }, 5000);
65            oPopup.load_contentAjax();
66        }
67        else {
68            $('.alx_fb_overlay').fadeIn(400);
69            if (($(window).height() > ($('.modal_form').outerHeight() + 100)) && this.param.fixed)
70                $('.modal_form').css({
71                    'top': (($(window).height() - $('.modal_form').outerHeight()) / 2 - 50) + 'px',
72                    'marginTop': '0',
73                    'position': 'fixed',
74                    'opacity': 1
75                });
76            else
77                $('.modal_form').css({
78                    'position': 'absolute',
79                    'marginTop': $(window).scrollTop() + 100 + 'px',
80                    'top': '0',
81                    'opacity': 1
82                })
83
84            $('.modal_form').removeClass(this.param.popupAnimation[0] + ', ' + this.param.popupAnimation[1]);
85            $('.modal_form').addClass(this.param.popupAnimation[0]);
86        }
87        return true;
88    },
89    autoResize: function () {
90        var oPopup = this;
91        if ($('.alx-feedb-data').length < 1 || $('.modal_form').css('position') != 'fixed') {
92            clearInterval(oPopup.timerReId);
93            return;
94        }
95
96        if (($(window).height() > $('.modal_form').outerHeight() + 100) && this.param.fixed)
97            $('.modal_form').css({
98                'top': (($(window).height() - $('.modal_form').outerHeight()) / 2 - 50) + 'px',
99                'marginTop': '0',
100                'position': 'fixed'
101            });
102        else
103            $('.modal_form').css({'position': 'absolute', 'marginTop': $(window).scrollTop() + 100 + 'px', 'top': '0'});
104    },
105    update: function () {
106        var oPopup = this;
107        if ($('.alx-feedb-data').length < 1)
108            return;
109
110        clearInterval(oPopup.timerId);
111        var w = '';
112
113        if ((this.param.width + "").split('%').length == 1) {
114            w = (this.param.width + "").split('px');
115            var mLeft = 0 - parseInt(w[0]) / 2 + 'px';
116        } else {
117            w = (this.param.width + "").split('%');
118            var mLeft = 0 - parseInt(w[0]) / 2 + '%';
119        }
120
121        $('.modal_form').css({'marginLeft': mLeft, 'width': this.param.width});
122
123        if (($(window).height() > $('.modal_form').outerHeight() + 100) && this.param.fixed)
124            $('.modal_form').css({
125                'top': (($(window).height() - $('.modal_form').outerHeight()) / 2 - 50) + 'px',
126                'marginTop': '0',
127                'position': 'fixed'
128            });
129        else
130            $('.modal_form').css({'position': 'absolute', 'marginTop': $(window).scrollTop() + 50 + 'px', 'top': '0'});
131
132        if (typeof this.param.popupAnimation != 'undefined')
133            var animClass = this.param.popupAnimation[0];
134
135        $('.modal_form').delay(400).queue(function () {
136            $('.alx_fedb_wait').fadeOut(400, function () {
137                $(this).remove()
138            });
139            $('.modal_form').addClass(animClass);
140            $('.alx-feedb-data').addClass('alx-feedb-data-view');
141        });
142
143        if ($('.modal_form').css('z-index') < 0)
144            $('.modal_form').css({'z-index': '2001'});
145        setTimeout(function () { // for ie
146            if ($('.modal_form').css('opacity') < 1)
147                $('.modal_form').css({'opacity': 1});
148        }, 1000);
149
150        oPopup.timerReId = setInterval(function () {
151            oPopup.autoResize();
152        }, 400);
153    },
154
155    close: function () {
156        var oPopup = this;
157        var animClass = this.param.popupAnimation[1];
158        $('.alx-feedb-data').css({'maxHeight': ($(window).height() - 100) + 'px'});
159        $('.modal_form').addClass(animClass);
160        $('.alx_fb_overlay, .alx_fedb_wait, .modal_form').fadeOut(400);
161
162        setTimeout(function () {
163            if ($('.modal_form').css('z-index') > 2000)
164                $('.modal_form').css({'z-index': '-1'});
165            document.body.style.overflowX = '';
166        }, 750);
167        setTimeout(function () { // for ie
168            if ($('.modal_form').css('opacity') > 0)
169                $('.modal_form').css({'opacity': 0, 'marginTop': '-100000px'});
170            if (oPopup.removeWindow || ($('.alx-feedb-data-errorLoading').length > 1))
171                $('.modal_form, .alx_fb_overlay').remove();
172        }, 500);
173    },
174    show_error: function () {
175        var oPopup = this;
176        if ($('.alx-feedb-data').length < 1) {
177            $('.alx_cont_popup').html('<div class="alx-feedb-data alx-feedb-data-errorLoading">Loading error. Try again.<br /><a href="" onClick="ALXpopup.close(); return false" class="alx-feedb-data-close">close window</a></div>');
178            oPopup.update();
179        }
180    },
181    load_contentAjax: function () {
182        if (typeof this.param.data != 'undefined') {
183            var oPopup = this;
184
185            $.ajax({
186                type: 'POST',
187                data: this.param.data,
188                url: this.param.url,
189                async: true,
190                success: function (data) {
191                    $('.alx_cont_popup').html('<div class="alx-feedb-data alx-feedb-data-view">' + data + '</div>');
192                    $('.alx-feedb-data').find("form").submit(function () {
193                        oPopup.send_dataAjax(this);
194                        return false;
195                    });
196                }
197            });
198        }
199    },
200    reload_contentAjax: function () {
201        var oPopup = this;
202        $('body').append('<div class="alx_fedb_wait"><div class="alx-feedb-loading"></div><div class="alx-feedb-loading-text">loading</div></div>');
203	
204        $.ajax({
205            type: 'POST',
206            data: $('.alx-feedb-data').find("form").serialize(),
207            url: this.param.url,
208            async: true,
209            success: function (data) {
210                $('.alx-feedb-data').remove();
211                $('.alx_fedb_wait').remove();
212                $('.alx_cont_popup').html('<div class="alx-feedb-data">' + data + '</div>');
213                $('.alx-feedb-data').addClass('alx-feedb-data-view');
214                $('.alx-feedb-data').find("form").submit(function () {
215                    oPopup.send_dataAjax(this);
216                    return false;
217                });
218            }
219        });
220    },
221    ok_window: function (param) {
222        var oPopup = this;
223        var w = typeof param.width !== 'undefined' ? param.width : 300;
224
225        if ((w + "").split('%').length == 1) {
226            w = (w + "").split('px');
227            var mLeft = 0 - parseInt(w[0]) / 2 + 'px';
228        } else {
229            w = (w + "").split('%');
230            var mLeft = 0 - parseInt(w[0]) / 2 + '%';
231        }
232        $('.modal_form').css({'marginLeft': mLeft, 'width': w, 'position': 'fixed', 'top': '30%', 'marginTop': '0'});
233        if (typeof param.fid != 'undefined')
234            $('#alx_feed_back_' + param.fid + '.alx-feedb-data, #alx_feed_back_' + param.fid + '.alx_feed_back').empty();
235        else
236            $('.modal_form .alx-feedb-data,.alx_feed_back').empty();
237        $('.modal_close_ok').click(function () {
238            oPopup.close();
239        });
240    },
241    send_dataAjax: function (form) {
242        var oPopup = this;
243        var sID = $(form).attr('name').split('_')[2];
244        var buttonSumbit = $("#fb_close_" + sID);
245        buttonSumbit.prop("type", "button");
246        var animClass = this.param.popupAnimation[2];
247        var url = $(form).attr('action');
248
249        url = typeof url !== 'undefined' ? url : "";
250        var bTypeFD = false;
251        if (typeof FormData == 'function') {
252            var FORM_DATA = new FormData(form);
253            bTypeFD = true;
254        } else {
255            var FORM_DATA = $(form).serializeArray();
256        }
257        $.ajax({
258            url: url,
259            type: 'POST',
260            data: FORM_DATA,
261            cache: false,
262            processData: (bTypeFD ? false : true),
263            contentType: (bTypeFD ? false : 'application/x-www-form-urlencoded;charset=UTF-8'),
264            success: function (data) {
265                var sDelim = '<!--REFRESH_SECTION-->';
266                var pos = data.indexOf(sDelim);
267                var errData = data, formData = false;
268                if (pos > -1) {
269                    errData = data.substr(0, pos);
270                    formData = data.substr(pos + sDelim.length);
271                }
272
273                if (formData) {
274                    $('#alx_feed_back_' + sID + '.alx_feed_back').html(formData);
275                }
276
277                if (typeof sID != 'undefined' && $('#alx_feed_back_' + sID).siblings(".alx-feedb-error").length > 0) {
278                    //$('#alx_feed_back_' + sID).siblings(".alx-feedb-error").html(errData).addClass(animClass);
279					$('#afbf_err_' + sID).html(errData).addClass(animClass);
280                    buttonSumbit.prop("type", "submit");
281                }
282                else if (typeof sID != 'undefined' && $('#alx_feed_back_' + sID).parent().parent().siblings(".alx-feedb-error").length > 0) {
283                    $('#alx_feed_back_' + sID).parent().parent().siblings(".alx-feedb-error").html(errData).addClass(animClass);
284					buttonSumbit.prop("type", "submit");
285                }
286                else {
287                    $('.alx-feedb-error').html(errData).addClass(animClass);
288					buttonSumbit.prop("type", "submit");
289                }
290
291                if (oPopup.canClearBlock) $('#alx_feed_back_' + sID + '.alx_feed_back').empty();
292                return true;
293            }
294        });
295    }
296}
297
298function alx_addFormGroupFocus(element) {
299    var $element = $(element);
300    if (!$element.prop('disabled')) {
301        $element.parents(".afbf_item_pole").addClass("is_focused");
302    }
303}
304
305function alx_removeFormGroupFocus(element) {
306    var $element = $(element);
307    $(element).parents(".afbf_item_pole").removeClass("is_focused is_filled");
308    if ($element.val().length !== 0) {
309        $(element).parents(".afbf_item_pole").addClass("is_filled");
310    }
311}
312
313$(document).ready(function () {
314
315    $('.alx_feed_back .item_pole__captcha .afbf_name').each(function (i, elem) {
316        $(elem).next().find('input').css({'height': $(elem).height() + 'px'});
317    });
318
319    $(document).on("focus", ".afbf_item_pole .afbf_inputtext,.afbf_item_pole .afbf_textarea,.afbf_item_pole .afbf_select,.afbf_item_pole .afbf_textarea,.afbf_item_pole .afbf_file_input_add", function () {
320        alx_addFormGroupFocus(this);
321    })
322        .on("blur", ".afbf_item_pole .afbf_inputtext,.afbf_item_pole .afbf_textarea,.afbf_item_pole .afbf_select,.afbf_item_pole .afbf_textarea,.afbf_item_pole .afbf_file_input_add", function () {
323            alx_removeFormGroupFocus(this);
324        });
325});
326
327function poleError(pole) {
328    if (pole.name.split('[').length > 1) {
329        if (pole.name.split('[')[1].split('_')[0] == 'EMAIL') {
330            if (!checkEmail(pole.value)) return true;
331        }
332    }
333    if (pole.type == 'radio' || pole.type == 'checkbox') {
334        if (!pole.checked && $('[name="' + pole.name + '"]:checked').length == 0) return true;
335        else return false;
336    }
337    if (pole.value.length == 0 || !$(pole).val()) {
338        return true;
339    }
340    return false;
341}
342
343function checkEmail(email) {
344    var re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
345    return re.test(email);
346}
347
348function validateForm(form) {
349    var required_fields = form.find('.afbf_item_pole.required');
350    var email_fields = form.find('.afbf_item_pole.is_email');
351    if (required_fields.length > 0 || email_fields.length > 0) {
352        email_fields.each(function () {
353            var $this = $(this);
354            $this.find('input[name]').not('[type=hidden]').each(function () {
355                if (this.value != '' && !checkEmail(this.value)) $this.addClass('error_pole');
356                else $this.removeClass('error_pole');
357            });
358        });
359        required_fields.each(function () {
360            var $this = $(this);
361	    
362               $this.find('input[name],textarea[name],select[name]').not('[type=hidden]').each(function () {
363		   if (this.name!='g-recaptcha-response') {
364                      if (poleError(this)) $this.addClass('error_pole');
365                      else $this.removeClass('error_pole');
366		   }
367               });
368        });
369        var errorPoles = form.find('.afbf_item_pole.required.error_pole');
370        if (errorPoles.length > 0) {
371            errorPoles.eq(0).find('input,textarea').not('[type=hidden]').focus();
372            return false;
373        }
374    }
375    return true;
376}
377
378function ALX_captcha_Error() {
379    $('.item_pole__captcha').addClass('error_pole');
380}
381
382function ALX_fileError(field) {
383    field.addClass('error_fpole');
384}

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.