1(function($) { 2 'use strict'; 3 4 var ConsultationBitrix = { 5 6 cache: { 7 $document: $(document), 8 }, 9 10 init: function() { 11 this.bindEvents(); 12 }, 13 14 bindEvents: function() { 15 var self = this; 16 17 this.cache.$document.on('ready', function() { 18 $('.consultation-form').each(function( index ){ 19 $(this).attr('id', 'webform-'+(index+1)); 20 }); 21 22 BX.addCustomEvent("onFrameDataReceived" , function(json) { 23 $('.consultation-form').each(function( index ){ 24 $(this).attr('id', 'webform-'+(index+1)); 25 }); 26 }); 27 28 /*BX.addCustomEvent('onAjaxSuccess', function() { 29 $('.consultation-form').each(function( index ){ 30 $(this).attr('id', 'webform-'+(index+1)); 31 }); 32 });*/ 33 34 self.validateForm(); 35 BX.addCustomEvent("onFrameDataReceived" , function(json) { 36 self.validateForm(); 37 }); 38 39 /*BX.addCustomEvent('onAjaxSuccess', function() { 40 self.validateForm(); 41 });*/ 42 }); 43 }, 44 45 /** 46 * Initialize Validate Form 47 * 48 * @since 1.0.0. 49 * 50 * @return {void} 51 */ 52 validateForm: function() { 53 $('.consultation-form').each(function( index ){ 54 if ($(this).hasClass('inited')) 55 return; 56 57 if ($('.consultation-form input[name="WEB_FORM_ID"]').length) { 58 var key; 59 var consultCont = {}; 60 $('.consultation-form .form-inp[data-req="required"]').each(function (index) { 61 key = $(this).attr('name'); 62 consultCont[key] = { 63 presence: { 64 message: $(this).attr('placeholder') 65 } 66 }; 67 }); 68 } 69 70 71 $('.consultation-form').on('submit', function (e) { 72 //вÑдпÑавка веб ÑоÑми аÑÐºÑ 73 e.preventDefault(); 74 var form = $(this); 75 var form_id = $(this).attr('id'); 76 var input = form.serializeObject(); 77 var validation = validate(input, consultCont, {fullMessages: false}) || []; 78 79 80 form.find('.form-inp').removeClass('not-valid'); 81 82 $.each(validation, function (index, el) { 83 form.find('input[name="' + index + '"]').addClass('not-valid'); 84 }); 85 86 87 if (validation.length !== 0) { 88 e.preventDefault(); 89 90 } else { 91 form.find('input[type="submit"]').attr('disabled', true); 92 form.find('button[type="submit"]').attr('disabled', true); 93 //var data = $('form.consultation-form').serialize(); 94 95 setTimeout(function() { 96 var input = form.serializeObject(); 97 98 $.ajax({ 99 type: 'POST', 100 url: location.href, 101 data: input, 102 dataType: "json", 103 success: function (response) { 104 if (response.ERROR_TEXT) 105 form.hide().html(SenderFlamix.get_succes_html_to_mini_loader(false, response.ERROR_TEXT)).fadeIn('slow'); 106 else 107 SenderFlamix.ajax_send(input, 'form.consultation-form#'+form_id); 108 109 form.find('input[type="submit"]').attr('disabled', false); 110 form.find('button[type="submit"]').attr('disabled', false); 111 }, 112 error: function (err) { 113 form.find('input[type="submit"]').attr('disabled', false); 114 form.find('button[type="submit"]').attr('disabled', false); 115 console.log('error'); 116 } 117 }); 118 }, 1000); 119 } 120 121 }); 122 $(this).addClass('inited'); 123 }); 124 }, 125 }; 126 127 ConsultationBitrix.init(); 128})(jQuery);
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.