PageSourceSearch

https://kimet.ru/bitrix/templates/kimet/js/custom.js

js kimet.ru collected 2026-10-05 18:28:15 UTC 11,734 bytes, 358 lines download raw bytes

1function initMaxHeight(sSelector) {
2
3    var iMaxHeight = 0;
4    
5    $(sSelector).each(function() {
6        
7        $(this).css("height", "auto");
8    });
9    
10    $(sSelector).each(function() {
11        
12        if($(this).height() > iMaxHeight) iMaxHeight = $(this).height();
13    });
14    
15    $(sSelector).each(function() {
16        
17        $(this).height(iMaxHeight);
18    });    
19}
20
21function initAjaxForms() {
22
23    $(".ajax-form").each(function() {
24
25        if(!$(this).attr("init")) {
26                                    
27            $(this).on('submit', function(e) {
28                
29                e.preventDefault();
30                var that = $(e.target);
31                var _form = that;
32                
33                var dataSerialize = new FormData(this);
34                var modalDialog = $(_form).parents('.modal');
35
36                var sURL = $(this).data("action");
37                if(!sURL) sURL = $(this).attr("action");
38
39                $.ajax({
40              
41                    url: sURL,
42                    method: "POST",
43                    data: dataSerialize,
44                    processData: false,
45                    contentType: false,
46                    success: function(data) {
47
48                        if($(_form).parents('.form-wrap').length) {
49                        
50                            $(_form).parents('.form-wrap').html(data);
51                            initAjaxForms();
52                            initSelectToggle();
53                            
54                        } else if($(_form).parents('.modal').length) {
55
56                            var bAutohide = modalDialog.data('autohide');                        
57                            
58                            if($(_form).find('.form-result').length) $(_form).find('.form-result').html(data);
59                            else $(_form).parents('.modal').html(data);
60                            
61                            if(modalDialog.find('.alert-success').length && bAutohide) {
62                            
63                                setTimeout(function() {
64                                    
65                                    modalDialog.modal('hide');
66                                    
67                                }, 1000);
68                                
69                            } else {                            
70                            
71                                initAjaxForms();
72                                initSelectToggle();
73                                initAutoComplete();
74                                initFormDateInputs();
75                            }
76                        
77                        } else if($(_form).hasClass('filter-form')) {
78                            
79                            //alert($(_form).html());
80                            $(_form).parents('.sorting-filters').parents('div:first').find('.form-result').html(data);
81                            
82                        } else {
83
84                            if($(_form).parents("div:first").find('.form-result').length) {
85                                
86                                $(_form).parents("div:first").find('.form-result').html(data);
87                                initAjaxForms();
88                                initSelectToggle();
89                                
90                            } else $(_form).find('.form-result').html(data);
91                        }
92                        
93                        initModals();
94                        initCheckbox();
95                        
96                        $('.bx-pagination li a').click(function() {
97                            
98                            $(_form).data("action", $(this).attr("href"));
99                            $(_form).submit();
100                            
101                            return false;
102                        });
103                        
104                        $(_form).data("action", "");
105                        
106                    }, 
107                    error: function(){
108                        
109                        alertForm({form: that, type: 'alert-danger', msg: 'Íå óäàëîñü îòïðàâèòü ñîîáùåíèå.'});
110                        $(_form).data("action", "");
111                    }
112              });
113              
114              return false;
115              
116            });
117            
118            $(this).attr("init", true);
119        }
120    });      
121}
122
123$(window).resize(function() {
124    initMaxHeight(".row .box-style-1");
125    initMaxHeight(".row .gallery-item");
126});
127
128function initFormDateInputs() {
129    
130    $('.input-daterange').datepicker({
131        format: "dd.mm.yyyy",
132        maxViewMode: 0,
133        todayBtn: "linked",
134        language: "ru",
135        autoclose: true,
136        toggleActive: true
137    });    
138
139    $('input.form-date-control').datepicker({
140        todayBtn: "linked",
141        language: "ru",
142        autoclose: true
143    });    
144}
145
146function initAutoCompleteItem(element) {
147    
148    $(element).autoComplete().on('autocomplete.select', function (evt, item) {
149
150        var form = $(element).parents('form:first');
151        
152        if(form.find('input[name=' + $(this).attr('name') + 'ID]').length) {
153            
154            form.find('input[name=' + $(this).attr('name') + 'ID]').val(item.value);
155        }
156        
157        if(form.find('input[data-subinput=' + $(this).attr('id') + ']').length) {
158            
159            form.find('input[data-subinput=' + $(this).attr('id') + ']').each(function() {
160                
161                subInput = this;
162                sURL = $(subInput).data('initurl');
163                sParam = $(subInput).data('subinputparam');
164                $(subInput).data('url', sURL + '?' + sParam + '=' + item.value);            
165
166                $(subInput).autoComplete("reinitInline");
167            });
168        }
169    });    
170}
171
172function initAutoComplete() {
173    
174    $('.basicAutoSelect').each(function() {
175        
176        initAutoCompleteItem(this);
177    });
178}
179
180function initModalDialog(data, bAutohide, callbackClose) {
181    
182    hModalDialog = $('<div id="modal-ajax" class="modal fade"' + (bAutohide?' data-autohide="true"':'') + '>' + data + '</div>');                        
183    hModalDialog.modal();
184
185    hModalDialog.on('hidden.bs.modal', function () { 
186        
187        $(this).remove();
188        
189    }).on('shown.bs.modal', function () { 
190        
191        initAjaxForms();
192        initSelectToggle();                    
193        //$('input:text:visible:first').focus();
194        initFormDateInputs();
195        initAutoComplete();
196        
197        grecaptcha.execute('6LcNZPcUAAAAAEdbXr5Os5llwXY346I1hj5A2OHs', { action: 'homepage' }).then(function (token) {
198            
199            $('#recaptchaAjaxResponse').val(token);
200        });
201        
202        
203    }).on('hidden.bs.modal', function () {
204        
205        if(callbackClose) eval(callbackClose);
206    });        
207}
208
209function initModals() {
210    
211    $('[data-toggle="modal"]').each(function() {
212    
213        if(!$(this).data("init")) {
214        
215            $(this).click(function(e) {
216                
217                e.preventDefault();
218                
219                var url = $(this).attr('href');
220                var callbackClose = $(this).data('callback');
221                var bAutohide = $(this).data('autohide');
222
223                if($(this).data('form') && $(this).parents('form.ajax-form').length) {
224                    
225                    url = $(this).parents('form.ajax-form').attr('action');
226                }
227                
228                if (url.indexOf('#') == 0) {
229
230                    $(url).modal('open');
231                    
232                } else {
233
234                    if($(this).data('form') && $(this).parents('form.ajax-form').length) {
235
236                        var dataSerialize = new FormData($(this).parents('form.ajax-form')[0]);
237                        
238                        $.ajax({
239                      
240                            url: url,
241                            method: "POST",
242                            data: dataSerialize,
243                            processData: false,
244                            contentType: false,
245                            success: function(data) {
246                                
247                                initModalDialog(data, bAutohide, callbackClose);
248                                
249                            }, 
250                            error: function(){
251                                
252                                alertForm({form: that, type: 'alert-danger', msg: 'Íå óäàëîñü îòïðàâèòü ñîîáùåíèå.'});
253                            }
254                        });
255                            
256                    } else {
257                    
258                        $.get(url, function(data) {
259                            
260                            initModalDialog(data, bAutohide, callbackClose);
261                            
262                        });
263                    }
264                }
265                
266                return false;
267            });            
268            
269            $(this).data("init", true);
270        }
271        
272    });
273}
274
275function initCheckbox() {
276    
277    $('.checkbox input[name=ALL]').click(function() {
278        
279        $(this).parents('table:first').find('.checkbox input[name!=ALL]').prop('checked', $(this).prop('checked'));
280    });
281}
282
283function initSelectToggle() {
284    
285    $(".select-toggle").each(function() {
286        
287        if(!$(this).attr("init")) {
288                    
289            $(this).change(function(e) {
290                
291                var that = $(e.target);
292                
293                $(this).find("option").each(function() {
294                    
295                    if($(this).attr("value") == that.val()) {
296                        
297                        $(".select-toggle-" + $(this).attr("value")).show();
298                        
299                    } else $(".select-toggle-" + $(this).attr("value")).hide();
300                });
301            });
302            
303            $(this).change();
304                        
305            $(this).attr("init", true);
306        }
307    });
308}
309
310$(document).ready(function() {
311
312    initAjaxForms();
313    initSelectToggle();    
314    initCheckbox();
315    
316    setTimeout(function() {
317        initMaxHeight(".row .box-style-1");
318        initMaxHeight(".row .gallery-item");        
319    }, 1000);
320    
321    if($(document).width() <= 991) {
322        
323        if(!$(".left-layout").hasClass("hidden")) {
324            
325            $(".left-layout").addClass("hidden");
326            $(".right-layout").addClass("left-hidden");
327        }
328        
329    } else {
330
331        if(!$(".left-layout").hasClass("hidden")) {
332            
333            $(".btn-left-menu").addClass("hidden");
334            $(".btn-close").addClass("hidden");            
335        }        
336    }
337    
338    $('form.filter-form').each(function() {
339        
340        $(this).submit();
341    });
342    
343    initAutoComplete();
344    
345    initFormDateInputs();    
346        
347    initModals();
348
349    $(".table.table-scroll-inner").each(function() {
350
351        //$(this).clone(true).appendTo($(this).parents('.table-scroll')).addClass('clone');
352    });
353    
354    $('.form-line-with-hidden-actions input[type=checkbox]').change(function() {
355        
356        $(this).parents('tr:first').find('.btn.hidden').removeClass('hidden');
357    });
358});

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.