PageSourceSearch

https://ags116.ru/assets/components/ajaxform/js/default.js

js ags116.ru collected 2026-10-05 00:15:06 UTC 4,892 bytes, 123 lines download raw bytes

1var AjaxForm = {
2
3    initialize: function (afConfig) {
4        if (!jQuery().ajaxForm) {
5            document.write('<script src="' + afConfig['assetsUrl'] + 'js/lib/jquery.form.min.js"><\/script>');
6        }
7        if (!jQuery().jGrowl) {
8            document.write('<script src="' + afConfig['assetsUrl'] + 'js/lib/jquery.jgrowl.min.js"><\/script>');
9        }
10
11        $(document).ready(function () {
12            $.jGrowl.defaults.closerTemplate = '<div>[ ' + afConfig['closeMessage'] + ' ]</div>';
13        });
14
15        $(document).off('submit', afConfig['formSelector']).on('submit', afConfig['formSelector'], function (e) {
16            $(this).ajaxSubmit({
17                dataType: 'json',
18                data: {pageId: afConfig['pageId']},
19                url: afConfig['actionUrl'],
20                beforeSerialize: function (form) {
21                    form.find(':submit').each(function () {
22                        if (!form.find('input[type="hidden"][name="' + $(this).attr('name') + '"]').length) {
23                            $(form).append(
24                                $('<input type="hidden">').attr({
25                                    name: $(this).attr('name'),
26                                    value: $(this).attr('value')
27                                })
28                            );
29                        }
30                    })
31                },
32                beforeSubmit: function (fields, form) {
33                    //noinspection JSUnresolvedVariable
34                    if (typeof(afValidated) != 'undefined' && afValidated == false) {
35                        return false;
36                    }
37                    form.find('.error').html('');
38                    form.find('.error').removeClass('error');
39                    form.find('input,textarea,select,button').attr('disabled', true);
40                    return true;
41                },
42                success: function (response, status, xhr, form) {
43                    form.find('input,textarea,select,button').attr('disabled', false);
44                    response.form = form;
45                    $(document).trigger('af_complete', response);
46                    if (!response.success) {
47                        AjaxForm.Message.error(response.message);
48                        if (response.data) {
49                            var key, value, focused;
50                            for (key in response.data) {
51                                if (response.data.hasOwnProperty(key)) {
52                                    if (!focused) {
53                                        form.find('[name="' + key + '"]').focus();
54                                        focused = true;
55                                    }
56                                    value = response.data[key];
57                                    form.find('.error_' + key).html(value).addClass('error');
58                                    form.find('[name="' + key + '"]').addClass('error');
59                                }
60                            }
61                        }
62                    }
63                    else {
64                        AjaxForm.Message.success(response.message);
65                        form.find('.error').removeClass('error');
66                        form[0].reset();
67                        //noinspection JSUnresolvedVariable
68                        if (typeof(grecaptcha) != 'undefined') {
69                            //noinspection JSUnresolvedVariable
70                            grecaptcha.reset();
71                        }
72                    }
73                }
74            });
75            e.preventDefault();
76            return false;
77        });
78
79        $(document).on('keypress change', '.error', function () {
80            var key = $(this).attr('name');
81            $(this).removeClass('error');
82            $('.error_' + key).html('').removeClass('error');
83        });
84
85        $(document).on('reset', afConfig['formSelector'], function () {
86            $(this).find('.error').html('');
87            AjaxForm.Message.close();
88        });
89    }
90
91};
92
93
94//noinspection JSUnusedGlobalSymbols
95AjaxForm.Message = {
96    success: function (message, sticky) {
97        if (message) {
98            if (!sticky) {
99                sticky = false;
100            }
101            $.jGrowl(message, {theme: 'af-message-success', sticky: sticky});
102        }
103    },
104    error: function (message, sticky) {
105        if (message) {
106            if (!sticky) {
107                sticky = false;
108            }
109            $.jGrowl(message, {theme: 'af-message-error', sticky: sticky});
110        }
111    },
112    info: function (message, sticky) {
113        if (message) {
114            if (!sticky) {
115                sticky = false;
116            }
117            $.jGrowl(message, {theme: 'af-message-info', sticky: sticky});
118        }
119    },
120    close: function () {
121        $.jGrowl('close');
122    },
123};

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.