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