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}; 124 125function(e) { 126 $(this).ajaxSubmit({ 127 dataType: 'json', 128 data: { 129 pageId: afConfig['pageId'] 130 }, 131 url: afConfig['actionUrl'], 132 beforeSerialize: function(form) { 133 form.find(':submit').each(function() { 134 if (!form.find('input[type="hidden"][name="' + $(this).attr('name') + '"]').length) { 135 $(form).append( 136 $('<input type="hidden">').attr({ 137 name: $(this).attr('name'), 138 value: $(this).attr('value') 139 }) 140 ); 141 } 142 }) 143 }, 144 beforeSubmit: function(fields, form) { 145 //noinspection JSUnresolvedVariable 146 if (typeof(afValidated) != 'undefined' && afValidated == false) { 147 return false; 148 } 149 form.find('.error').html(''); 150 form.find('.error').removeClass('error'); 151 form.find('input,textarea,select,button').attr('disabled', true); 152 return true; 153 }, 154 success: function(response, status, xhr, form) { 155 form.find('input,textarea,select,button').attr('disabled', false); 156 response.form = form; 157 $(document).trigger('af_complete', response); 158 if (!response.success) { 159 AjaxForm.Message.error(response.message); 160 if (response.data) { 161 var key, value, focused; 162 for (key in response.data) { 163 if (response.data.hasOwnProperty(key)) { 164 if (!focused) { 165 form.find('[name="' + key + '"]').focus(); 166 focused = true; 167 } 168 value = response.data[key]; 169 form.find('.error_' + key).html(value).addClass('error'); 170 form.find('[name="' + key + '"]').addClass('error'); 171 } 172 } 173 } 174 } else { 175 AjaxForm.Message.success(response.message); 176 form.find('.error').removeClass('error'); 177 form[0].reset(); 178 //noinspection JSUnresolvedVariable 179 if (typeof(grecaptcha) != 'undefined') { 180 //noinspection JSUnresolvedVariable 181 grecaptcha.reset(); 182 } 183 } 184 } 185 }); 186 e.preventDefault(); 187 return false; 188}
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.