1var RSContact = { 2 init: function (uniqid) { 3 var $container = jQuery("#mod-rscontact-container-" + uniqid); 4 5 $container.find("#mod-rscontact-message-" + uniqid).each(function(){ 6 var msg_len = jQuery(this).attr('maxlength'); 7 8 jQuery('<p><small id="mod-rscontact-counter-' + uniqid + '">' + Joomla.JText._('MOD_RSCONTACT_CHARACTERS_LEFT').replace('%d', msg_len) + '</small></p>').insertAfter(this); 9 10 jQuery(this).on('keyup', function(){ 11 jQuery("#mod-rscontact-counter-" + uniqid).html(Joomla.JText._('MOD_RSCONTACT_CHARACTERS_LEFT').replace('%d', RSContact.textCounter(this, msg_len))); 12 }); 13 }); 14 15 if (typeof jQuery.fn.validate === 'function') 16 { 17 $container.find("#mod-rscontact-contact-form-" + uniqid).validate(); 18 } 19 else 20 { 21 console.log('jQuery.fn.validate not found.'); 22 } 23 }, 24 25 textCounter: function (field, maxlimit) { 26 return maxlimit - field.value.length; 27 } 28} 29 30jQuery(document).ready(function() 31{ 32 if (typeof jQuery.validator === 'undefined') 33 { 34 console.log('jQuery.validator not found. Make sure jquery.validate.js is loaded.'); 35 return; 36 } 37 jQuery.validator.messages.required = Joomla.JText._('MOD_RSCONTACT_REQUIRED_ERROR'); 38 jQuery.validator.messages.minlength = jQuery.validator.format(Joomla.JText._('MOD_RSCONTACT_PLEASE_ENTER_AT_LEAST_CHARACTERS_ERROR')); 39 jQuery.validator.methods.alphanumeric = function(value, element) { 40 return this.optional ( element ) || /[a-zA-Z0-9]+$/.test( value ); 41 } 42 jQuery.validator.setDefaults({ 43 errorClass: "mod-rscontact-error", 44 labelErrorClass: "mod-rscontact-error", 45 validClass: "success", 46 ignore: ".ignore", 47 focusInvalid: true, 48 highlight: function(element, errorClass) { 49 jQuery(element).fadeIn(); 50 }, 51 rules: { 52 mod_rscontact_salutation: "required", 53 mod_rscontact_first_name: { 54 required: true, 55 minlength: 2 56 }, 57 mod_rscontact_last_name: { 58 required: true, 59 minlength: 2 60 }, 61 mod_rscontact_full_name: { 62 required: true, 63 minlength: 2 64 }, 65 mod_rscontact_email: "required", 66 mod_rscontact_address_1: { 67 required: true, 68 minlength: 2 69 }, 70 mod_rscontact_address_2: { 71 required: true, 72 minlength: 2 73 }, 74 mod_rscontact_city: { 75 required: true, 76 minlength: 2 77 }, 78 mod_rscontact_states: "required", 79 mod_rscontact_zip: { 80 required: true, 81 alphanumeric: true, 82 minlength: 2 83 }, 84 mod_rscontact_home_phone: { 85 required: true, 86 digits: true, 87 minlength: 4 88 }, 89 mod_rscontact_mobile_phone: { 90 required: true, 91 digits: true, 92 minlength: 4 93 }, 94 mod_rscontact_work_phone: { 95 required: true, 96 digits: true, 97 minlength: 4 98 }, 99 mod_rscontact_company: "required", 100 mod_rscontact_website: { 101 required: true, 102 url: true 103 }, 104 mod_rscontact_subject: { 105 required: true 106 }, 107 mod_rscontact_message: { 108 required: true, 109 minlength: 2 110 }, 111 mod_rscontact_cf1: { 112 required: true 113 }, 114 mod_rscontact_cf2: { 115 required: true 116 }, 117 mod_rscontact_cf3: { 118 required: true 119 }, 120 recaptcha_response_field: "required" 121 }, 122 messages: { 123 mod_rscontact_salutation: Joomla.JText._('MOD_RSCONTACT_SALUTATION_ERROR'), 124 mod_rscontact_first_name: { 125 required: Joomla.JText._('MOD_RSCONTACT_FIRST_NAME_ERROR'), 126 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 127 }, 128 mod_rscontact_last_name: { 129 required: Joomla.JText._('MOD_RSCONTACT_LAST_NAME_ERROR'), 130 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 131 }, 132 mod_rscontact_full_name: { 133 required: Joomla.JText._('MOD_RSCONTACT_FULL_NAME_ERROR'), 134 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 135 }, 136 mod_rscontact_email: Joomla.JText._('MOD_RSCONTACT_EMAIL_ERROR'), 137 mod_rscontact_address_1: { 138 required: Joomla.JText._('MOD_RSCONTACT_ADDRESS_1_ERROR'), 139 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 140 }, 141 mod_rscontact_address_2: { 142 required: Joomla.JText._('MOD_RSCONTACT_ADDRESS_2_ERROR'), 143 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 144 }, 145 mod_rscontact_city: { 146 required: Joomla.JText._('MOD_RSCONTACT_CITY_ERROR'), 147 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 148 }, 149 mod_rscontact_states: Joomla.JText._('MOD_RSCONTACT_STATE_ERROR'), 150 mod_rscontact_zip: { 151 required: Joomla.JText._('MOD_RSCONTACT_ZIP_ERROR'), 152 alphanumeric: Joomla.JText._('MOD_RSCONTACT_ZIP_NOT_A_ALPHANUMERIC_ERROR') 153 }, 154 mod_rscontact_home_phone: { 155 required: Joomla.JText._('MOD_RSCONTACT_HOME_PHONE_ERROR'), 156 digits: Joomla.JText._('MOD_RSCONTACT_PHONE_NOT_A_NUMBER_ERROR') 157 }, 158 mod_rscontact_mobile_phone: { 159 required: Joomla.JText._('MOD_RSCONTACT_MOBILE_PHONE_ERROR'), 160 digits: Joomla.JText._('MOD_RSCONTACT_PHONE_NOT_A_NUMBER_ERROR') 161 }, 162 mod_rscontact_work_phone: { 163 required: Joomla.JText._('MOD_RSCONTACT_WORK_PHONE_ERROR'), 164 digits: Joomla.JText._('MOD_RSCONTACT_PHONE_NOT_A_NUMBER_ERROR') 165 }, 166 mod_rscontact_company: { 167 required: Joomla.JText._('MOD_RSCONTACT_COMPANY_ERROR'), 168 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 169 }, 170 mod_rscontact_website: { 171 required: Joomla.JText._('MOD_RSCONTACT_WEBSITE_ERROR'), 172 url: Joomla.JText._('MOD_RSCONTACT_WEBSITE_ERROR'), 173 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 174 }, 175 mod_rscontact_subject: { 176 required: Joomla.JText._('MOD_RSCONTACT_SUBJECT_ERROR') 177 }, 178 mod_rscontact_message: { 179 required: Joomla.JText._('MOD_RSCONTACT_MESSAGE_ERROR'), 180 minlength: Joomla.JText._('MOD_RSCONTACT_MIN_LENGTH_ERROR') 181 }, 182 recaptcha_response_field: '' 183 },
184 submitHandler: function(validator, event) { 185 event.preventDefault(); 186 var request = [ 187 'option=com_ajax', 188 'module=rscontact', 189 'format=json' 190 ]; 191 var id = jQuery(validator).find('[name=mod_rscontact_module_id]').val(); 192 var values = jQuery(validator).serializeArray(); 193 194 var name; 195 for (var i = 0; i < values.length; i++) 196 { 197 if (values[i].name.indexOf('mod_rscontact_') === 0) 198 { 199 if (values[i].name.indexOf('[]') > -1) 200 { 201 name = 'data[' + encodeURIComponent(values[i].name.substring(0, values[i].name.length - 2)) + '][]'; 202 } 203 else 204 { 205 name = 'data[' + encodeURIComponent(values[i].name) + ']'; 206 } 207 208 request.push(name + '=' + encodeURIComponent(values[i].value)) 209 } 210 else 211 { 212 request.push(encodeURIComponent(values[i].name) + '=' + encodeURIComponent(values[i].value)) 213 } 214 } 215 216 jQuery(validator).find('#mod-rscontact-submit-btn-' + id).attr("disabled", "disabled"); 217 jQuery(validator).find('.icon').removeAttr('class').addClass('icon icon-refresh rstpl-rotating'); 218 219 jQuery.ajax({ 220 type : 'POST', 221 data : request.join('&'), 222 success: function (json){ 223 var response = {}; 224 if (json.success === false) 225 { 226 response.status = 0; 227 response.message = typeof json.message !== 'undefined' ? json.message : ''; 228 } 229 else 230 { 231 if (typeof json === 'object') 232 { 233 if (typeof json.data === 'object') 234 { 235 response = json.data; 236 } 237 } 238 } 239 240 if(response.status == 0) { 241 jQuery('#mod-rscontact-error-msg-' + id).hide().html('<div class="alert alert-error alert-danger">' + response.message + '</div>').fadeIn().delay(1000).fadeOut(5000); 242 jQuery(validator).find('#mod-rscontact-submit-btn-' + id).removeAttr("disabled"); 243 jQuery(validator).find('.icon').removeAttr('class').addClass('icon icon-envelope'); 244 } 245 246 if(response.status == 1){ 247 jQuery(validator).nextAll('#mod-rscontact-msg-' + id).hide().html('<div class="alert alert-success">' + response.message + '</div>').delay(500).fadeIn(); 248 if(response.warnings.length > 0){ 249 jQuery(validator).nextAll('#mod-rscontact-warning-msg-' + id).hide().html('<div class="alert alert-warning"></div>').delay(500).fadeIn(); 250 jQuery(validator).find('.icon').removeAttr('class').addClass('icon icon-envelope'); 251 jQuery.each(response.warnings, function(i, value) { 252 jQuery(".alert-warning").append(value + '<br />'); 253 }); 254 } 255 256 jQuery(validator).fadeOut(500, function(){ 257 jQuery(this).remove(); 258 }) ; 259 jQuery('html, body').animate({ 260 scrollTop: jQuery(validator).offset().top-10 261 }, 2000); 262 } 263 }, 264 error: function (response) { 265 response = JSON.parse(response); 266 jQuery(validator).find('#mod-rscontact-error-msg-' + id).hide().html('<div class="alert alert-error alert-danger">' + response.message + '</div>').fadeIn().delay(2000).fadeOut(5000); 267 jQuery(validator).find('.icon').removeAttr('class').addClass('icon icon-envelope'); 268 } 269 }); 270 return false; 271 } 272 }); 273});
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.