1/* 2Name: View - Contact 3Written by: Okler Themes - (http://www.okler.net) 4Theme Version: 8.2.0 5*/ 6 7(function($) { 8 9 'use strict'; 10 11 /* 12 Custom Rules 13 */ 14 15 // No White Space 16 /*$.validator.addMethod("noSpace", function(value, element) { 17 if( $(element).attr('required') ) { 18 return value.search(/[a-zA-Z0-9~%.:_\-@\=()à¸-ฮะาิีุูà¹à¸°à¹à¸³à¹à¹à¹à¹à¹à¹à¹à¸±à¹à¹à¸¶à¸·Ã-žа-ÑÐ-ЯÑÐα-ÏÎ-Ω\s\u0621-\u064A\u0660-\u0669 ]/i) == 0; 19 } 20 21 return true; 22 }, 'Please fill this empty field.');*/ 23 24 /* 25 Assign Custom Rules on Fields 26 */ 27 $.validator.addClassRules({ 28 'form-control': { 29 noSpace: true 30 } 31 }); 32 33 /* 34 Contact Form: Basic 35 */ 36 $('.contact-forms').each(function(){ 37 $(this).validate({ 38 errorPlacement: function(error, element) { 39 if(element.attr('type') == 'radio' || element.attr('type') == 'checkbox') { 40 error.appendTo(element.closest('.form-group')); 41 } else if( element.is('select') && element.closest('.custom-select-1') ) { 42 error.appendTo(element.closest('.form-group')); 43 } else { 44 error.insertAfter(element); 45 } 46 }, 47 submitHandler: function(form) { 48 49 var $form = $(form), 50 $messageSuccess = $form.find('.contact-form-success'), 51 $messageError = $form.find('.contact-form-error'), 52 $submitButton = $(this.submitButton), 53 $errorMessage = $form.find('.mail-error-message'), 54 submitButtonText = $submitButton.val(); 55 56 $submitButton.val( $submitButton.data('loading-text') ? $submitButton.data('loading-text') : 'Loading...' ).attr('disabled', true); 57 58 // Fields Data 59 var formData = $form.serializeArray(), 60 data = {}; 61 62 $(formData).each(function(index, obj){ 63 data[obj.name] = obj.value; 64 }); 65 66 // Google Recaptcha v2 67 if( data["g-recaptcha-response"] != undefined ) { 68 data["g-recaptcha-response"] = $form.find('#g-recaptcha-response').val(); 69 } 70 71 // Ajax Submit 72 $.ajax({
73 type: 'POST', 74 url: $form.attr('action'), 75 data: data 76 }).always(function(data, textStatus, jqXHR) { 77 78 $errorMessage.empty().hide(); 79 80 if (data.response == 'success') { 81 82 // Uncomment the code below to redirect for a thank you page 83 // self.location = 'thank-you.html'; 84 85 $messageSuccess.removeClass('d-none'); 86 $messageError.addClass('d-none'); 87 88 // Reset Form 89 $form.find('.form-control') 90 .val('') 91 .blur() 92 .parent() 93 .removeClass('has-success') 94 .removeClass('has-danger') 95 .find('label.error') 96 .remove(); 97 98 if (($messageSuccess.offset().top - 80) < $(window).scrollTop()) { 99 $('html, body').animate({ 100 scrollTop: $messageSuccess.offset().top - 80 101 }, 300); 102 } 103 104 $form.find('.form-control').removeClass('error'); 105 106 $submitButton.val( submitButtonText ).attr('disabled', false); 107 108 return; 109 110 } else if (data.response == 'error' && typeof data.errorMessage !== 'undefined') { 111 $errorMessage.html(data.errorMessage).show(); 112 } else { 113 $errorMessage.html(data.responseText).show(); 114 } 115 116 $messageError.removeClass('d-none'); 117 $messageSuccess.addClass('d-none'); 118 119 if (($messageError.offset().top - 80) < $(window).scrollTop()) { 120 $('html, body').animate({ 121 scrollTop: $messageError.offset().top - 80 122 }, 300); 123 } 124 125 $form.find('.has-success') 126 .removeClass('has-success'); 127 128 $submitButton.val( submitButtonText ).attr('disabled', false); 129 130 }); 131 } 132 }); 133 }); 134 135 /* 136 Contact Form: Advanced 137 */ 138 $('#contactFormAdvanced').validate({ 139 onkeyup: false, 140 onclick: false, 141 onfocusout: false, 142 rules: { 143 'captcha': { 144 captcha: true 145 }, 146 'checkboxes[]': { 147 required: true 148 }, 149 'radios': { 150 required: true 151 } 152 }, 153 errorPlacement: function(error, element) { 154 if(element.attr('type') == 'radio' || element.attr('type') == 'checkbox') { 155 error.appendTo(element.closest('.form-group')); 156 } else if( element.is('select') && element.closest('.custom-select-1') ) { 157 error.appendTo(element.closest('.form-group')); 158 } else { 159 error.insertAfter(element); 160 } 161 } 162 }); 163 164 /* 165 Contact Form: reCaptcha v3 166 */ 167 $('.contact-form-recaptcha-v3').each(function(){ 168 $(this).validate({ 169 errorPlacement: function(error, element) { 170 if(element.attr('type') == 'radio' || element.attr('type') == 'checkbox') { 171 error.appendTo(element.closest('.form-group')); 172 } else if( element.is('select') && element.closest('.custom-select-1') ) { 173 error.appendTo(element.closest('.form-group')); 174 } else { 175 error.insertAfter(element); 176 } 177 }, 178 submitHandler: function(form) { 179 180 var $form = $(form), 181 $messageSuccess = $form.find('.contact-form-success'), 182 $messageError = $form.find('.contact-form-error'), 183 $submitButton = $(this.submitButton), 184 $errorMessage = $form.find('.mail-error-message'), 185 submitButtonText = $submitButton.val(); 186 187 $submitButton.val( $submitButton.data('loading-text') ? $submitButton.data('loading-text') : 'Loading...' ).attr('disabled', true); 188 189 var site_key = $('#google-recaptcha-v3').attr('src').split("render=")[1]; 190 grecaptcha.execute(site_key, {action: 'contact_us'}).then(function(token) { 191 192 // Fields Data 193 var formData = $form.serializeArray(), 194 data = {}; 195 196 $(formData).each(function(index, obj){ 197 data[obj.name] = obj.value; 198 }); 199 200 // Recaptcha v3 Token 201 data["g-recaptcha-response"] = token; 202 203 // Ajax Submit 204 $.ajax({
205 type: 'POST', 206 url: $form.attr('action'), 207 data: data 208 }).always(function(data, textStatus, jqXHR) { 209 210 $errorMessage.empty().hide(); 211 212 if (data.response == 'success') { 213 214 // Uncomment the code below to redirect for a thank you page 215 // self.location = 'thank-you.html'; 216 217 $messageSuccess.removeClass('d-none'); 218 $messageError.addClass('d-none'); 219 220 // Reset Form 221 $form.find('.form-control') 222 .val('') 223 .blur() 224 .parent() 225 .removeClass('has-success') 226 .removeClass('has-danger') 227 .find('label.error') 228 .remove(); 229 230 if (($messageSuccess.offset().top - 80) < $(window).scrollTop()) { 231 $('html, body').animate({ 232 scrollTop: $messageSuccess.offset().top - 80 233 }, 300); 234 } 235 236 $form.find('.form-control').removeClass('error'); 237 238 $submitButton.val( submitButtonText ).attr('disabled', false); 239 240 return; 241 242 } else if (data.response == 'error' && typeof data.errorMessage !== 'undefined') { 243 $errorMessage.html(data.errorMessage).show(); 244 } else { 245 $errorMessage.html(data.responseText).show(); 246 } 247 248 $messageError.removeClass('d-none'); 249 $messageSuccess.addClass('d-none'); 250 251 if (($messageError.offset().top - 80) < $(window).scrollTop()) { 252 $('html, body').animate({ 253 scrollTop: $messageError.offset().top - 80 254 }, 300); 255 } 256 257 $form.find('.has-success') 258 .removeClass('has-success'); 259 260 $submitButton.val( submitButtonText ).attr('disabled', false); 261 262 }); 263 264 }); 265 } 266 }); 267 }); 268 269}).apply(this, [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.