1jQuery(document).ready(function() { 2 3 initRegistrationFormValidation(); 4 5}); 6 7/** 8 * 9 */ 10function triggerCronjob() 11{ 12 jQuery.ajax({ 13 url: wav_ajax_object.ajax_url, 14 type: 'post', 15 cache: false, 16 data: { 17 action: 'wav_members_fe_ajax', 18 key: 'cronjob' 19 } 20 }); 21} 22 23/** 24 * 25 */ 26function initRegistrationFormValidation() 27{ 28 var validateDelayTimer = 0; 29 30 var $form = jQuery('form.ajax-validation'); 31 if (!$form.length) { 32 return; 33 } 34 35 var $passwordInput = $form.find('.ajax-validation[name="password"]'), 36 $passwordRepeatInput = $form.find('.ajax-validation[name="password_repeat"]'); 37 38 39 /** 40 * 41 * @param $el 42 */ 43 var validationSuccess = function($el, response) { 44 var name = $el.attr('name'); 45 46 $el.parent().removeClass('error'); 47 $el.parent().find('span.error').html(''); 48 }; 49 50 /** 51 * 52 * @param $el 53 */ 54 var validationError = function($el, response) { 55 $el.parent().addClass('error'); 56 57 for(var field in response.message) { 58 $form.find('input[name="' + field + '"]').parent().find('span.error').html(response.message[field].join('<br />')); 59 } 60 }; 61 62 /** 63 * 64 * @param response 65 */ 66 var loadValidationResponse = function(response)Â { 67 var $el = jQuery(this); 68 69 if (response.success) { 70 validationSuccess($el, response); 71 } else { 72 validationError($el, response); 73 } 74 }; 75 76 /** 77 * 78 * @param name 79 * @param values 80 */ 81 var requestValidationResponse = function($el, name, values) { 82 jQuery.ajax({ 83 url: wav_ajax_object.ajax_url, 84 type: 'post', 85 data: { 86 action: 'wav_members_fe_ajax', 87 key: 'validate', 88 name: name, 89 values: values, 90 options: $form.data('options') 91 }, 92 dataType: 'json', 93 success: loadValidationResponse.bind($el) 94 }); 95 }; 96 97 /** 98 * 99 * @param $el 100 */ 101 var validateField = function($el) { 102 var name = $el.attr('name'), 103 values = {}; 104 105 values[name] = $el.val(); 106 if (name === 'password' ||Â name === 'password_repeat') { 107 values['password'] = $passwordInput.val(); 108 values['password_repeat'] = $passwordRepeatInput.val(); 109 } 110 111 requestValidationResponse($el, name, values); 112 }; 113 114 /** 115 * 116 * @param e 117 */ 118 var onKeyUp = function(e) { 119 var $this = jQuery(e.target); 120 validateField($this); 121 }; 122 123 /** 124 * 125 * @param e 126 */ 127 var onBlur = function(e) { 128 clearTimeout(validateDelayTimer); 129 130 var $this = jQuery(e.target); 131 validateField($this); 132 }; 133 134 /** 135 * 136 * @param callback 137 * @param ms 138 * @returns {Function} 139 */ 140 function delay(callback, ms) { 141 return function() { 142 var context = this, 143 args = arguments; 144 145 clearTimeout(validateDelayTimer); 146 validateDelayTimer = setTimeout(function () { 147 callback.apply(context, args); 148 }, ms || 0); 149 }; 150 } 151 152 $form.find('.ajax-validation') 153 .on('keyup', delay(onKeyUp, 2000)) 154 .on('blur', onBlur) 155}
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.