1window.Global = window.Global || {}; 2window.Global.FormSubmit = window.Global.FormSubmit || {}; 3 4if (typeof jQuery == "undefined") { 5 throw "this page is missing the jquery javascript library."; 6} 7 8var fmgjQuery = jQuery; 9 10(function ($) { 11 $.extend(Global.FormSubmit, { 12 "init": function () { 13 $("form#newsletterSignup :disabled").removeAttr("disabled"); 14 $("form#newsletterSignup button.disabled").removeClass("disabled"); 15 $("form#newsletterSignup").submit(Global.FormSubmit.submit); 16 }, 17 "submit": function () { 18 var form = $(this); 19 form.find(".loading").show(); 20 form.find(".msg.formError").hide(); 21 form.find(".msg.formSuccess").hide(); 22 23 var formData = form.serialize().concat("&IsNotSpam=true"); 24 25 form.find("input").attr("disabled", "disabled"); 26 form.find("button[type='submit']").attr("disabled", "disabled").addClass("disabled"); 27 28 var url = this.action + "?" + formData; 29 30 $.getJSON(url + "&callback=?", function (data) { 31 if (data.success) { 32 form.find("input").filter(":visible").val(""); 33 form.find(".msg.formSuccess").show(); 34 } else { 35 if (typeof data.message != "undefined") { 36 form.find(".msg.formError").html(data.message).show(); 37 } 38 } 39 40 form.find(".loading").hide(); 41 form.find(":disabled").removeAttr("disabled"); 42 form.find("button[type='submit']").removeClass("disabled"); 43 }); 44 45 return false; 46 } 47 }); 48 49 $(function () { 50 $("form.contactForm").submit(function () { 51 var form = $(this); 52 form.validate(); 53 if (form.valid() === false) return false; 54 55 var url = this.action + "?" + form.serialize() + "&isNotSpam=true"; 56 57 form.find(".loading").show(); 58 form.find(".msg.formError").hide(); 59 form.find(".msg.formSuccess").hide(); 60 form.find(".submit").attr("disabled", true).addClass("disabled"); 61 62 $.getJSON(url + "&callback=?", function (e) { 63 form.find(".loading").hide(); 64 if (e.success) { 65 form.find(".msg.formSuccess").show(); 66 form.find(".submit").hide(); 67 } 68 else { 69 form.find(".msg.formError").show(); 70 form.find(".submit").removeAttr("disabled").removeClass("disabled"); 71 72 if (e.robot) { 73 alert(e.message); 74 } 75 } 76 }); 77 return false; 78 }); 79 80 $("form.requestPrivacyForm").submit(function () { 81 var form = $(this); 82 form.validate(); 83 if (form.valid() === false) return false; 84 85 var url = this.action + "?" + form.serialize() + "&isNotSpam=true"; 86 87 form.find(".loading").show(); 88 form.find(".msg.formError").hide(); 89 form.find(".msg.formSuccess").hide(); 90 form.find(".submit").attr("disabled", true).addClass("disabled"); 91 92 $.getJSON(url + "&callback=?", function (e) { 93 form.find(".loading").hide(); 94 if (e.success) { 95 form.find(".msg.formSuccess").show(); 96 form.find(".submit").hide(); 97 } 98 else { 99 form.find(".msg.formError").show(); 100 form.find(".submit").removeAttr("disabled").removeClass("disabled"); 101 102 if (e.robot) { 103 alert(e.message); 104 } 105 } 106 }); 107 108 return false; 109 }); 110 111 $("form.c-referralCampaign-form").submit(function () { 112 var form = $(this); 113 form.validate(); 114 if (form.valid() === false) return false; 115 116 var url = this.action + "?" + form.serialize() + "&isNotSpam=true"; 117 118 form.find(".o-circle__loading-animation").show(); 119 form.find('.c-referral__form').addClass('u-opacity-40'); 120 form.find(".msg.formError").hide(); 121 form.find(".msg.formSuccess").hide(); 122 form.find(".submit").attr("disabled", true).addClass("disabled"); 123 124 $.getJSON(url + "&callback=?", function (data) { 125 form.find(".o-circle__loading-animation").hide(); 126 if (data.success) { 127 form.hide(); 128 $().append('.c-referral__container'); 129 $('.c-referral__success').show(); 130 131 $('.c-referral__download').click(function () { 132 window.location = $(this).data('contenturl'); 133 }); 134 } 135 else { 136 form.find('.c-referral__form').removeClass('u-opacity-40'); 137 $('<div class="u-submission__error"><i class="c-icn__remove-x js-msg__close"></i> Sorry. We are unable to process your request at this time.</div>').prependTo('.c-referralCampaign-form'); 138 $(".u-submission__error").show(); 139 140 $('.js-msg__close').click(function () { 141 142 $(this).parent().slideUp("normal", function () { 143 $(this).remove(); 144 }); 145 }); 146 //form[0].reset(); 147 form.find(".submit").removeAttr("disabled").removeClass("disabled"); 148 149 if (data.robot) { 150 alert(data.message); 151 } 152 } 153 }); 154 155 return false;
156 }); 157 158 // Regular expression for phone matching was taken from FMG.ContactService.IsPhoneValid so that everything matches properly. 159 jQuery.validator.addMethod("phoneUS", function (phone_number, element) { 160 phone_number = phone_number.replace(/\s+/g, ""); 161 return this.optional(element) || phone_number.length > 9 && 162 phone_number.match(/^(\+?1 ?[_\-\*/\\,\.]? ?)?\(?[2-9a-zA-Z][0-9a-zA-Z]{2}\)? ?[_\-\*/\\,\.]? ?[0-9a-zA-Z]{3} ?[_\-\*/\\,\.]? ?[0-9a-zA-Z]{4}[ a-wyzA-WYZ]{0,5}( ?(x|e|ex|ext)\.? ?\d{1,7})?$/); 163 }, "Please enter a valid phone number"); 164 165 jQuery.validator.addMethod("require_from_group", function (value, element, options) { 166 var validator = this; 167 var minRequired = options[0]; 168 var selector = options[1]; 169 var validOrNot = jQuery(selector, element.form).filter(function () { 170 return validator.elementValue(this); 171 }).length >= minRequired; 172 173 // remove all events in namespace require_from_group 174 jQuery(selector, element.form).off('.require_from_group'); 175 176 //add the required events to trigger revalidation if setting is enabled in the validator 177 if (this.settings.onkeyup) { 178 jQuery(selector, element.form).on({ 179 'keyup.require_from_group': function (e) { 180 jQuery(selector, element.form).valid(); 181 } 182 }); 183 } 184 185 if (this.settings.onfocusin) { 186 jQuery(selector, element.form).on({ 187 'focusin.require_from_group': function (e) { 188 jQuery(selector, element.form).valid(); 189 } 190 }); 191 } 192 193 if (this.settings.click) { 194 jQuery(selector, element.form).on({ 195 'click.require_from_group': function (e) { 196 jQuery(selector, element.form).valid(); 197 } 198 }); 199 } 200 201 if (this.settings.onfocusout) { 202 jQuery(selector, element.form).on({ 203 'focusout.require_from_group': function (e) { 204 jQuery(selector, element.form).valid(); 205 } 206 }); 207 } 208 209 return validOrNot; 210 }, jQuery.validator.format("Please fill at least {0} of these fields.")); 211 212 $('.c-referralCampaign-form').each(function () { 213 $(this).validate({ 214 groups: { 215 referralInfo: "referralPhone referralEmail" 216 }, 217 rules: { 218 referralPhone: { 219 require_from_group: [1, '.js-contact-info-group'], 220 phoneUS: { required: '.c-referral-email: blank', required: true } 221 }, 222 referralEmail: 223 { 224 require_from_group: [1, '.js-contact-info-group'], 225 email: { required: '.c-referral-phone: blank', email: true, required: true }, 226 }, 227 referredByEmail: 228 { 229 email: { email: true, required: true }, 230 } 231 }, 232 messages: { 233 referredByName: "Please enter your name", 234 referredByEmail: { 235 required: "Please enter your email", 236 email: "Your email address does not look valid" 237 }, 238 referralName: "Please enter your friend's name", 239 referralEmail: { 240 require_from_group: "Please enter your friend's email or phone number", 241 email: "Your friend's email does not look valid" 242 }, 243 referralPhone: { 244 require_from_group: "Please enter your friend's email or phone number" 245 } 246 }, 247 errorContainer: ".u-form__error", 248 errorLabelContainer: ".u-form__error ul", 249 wrapper: "li", 250 errorElement: "label" 251 }); 252 }); 253 254 }); 255 256 $(function () { 257 $("form#unsubscribe").submit(function () { 258 var form = $(this); 259 260 var url = this.action + "&isNotSpam=true"; 261 262 form.find(".loading").show(); 263 form.find(".msg.formError").hide(); 264 form.find(".msg.formSuccess").hide(); 265 form.find(".submit").attr("disabled", true).addClass("disabled"); 266 267 $.getJSON(url + "&callback=?", function (e) { 268 form.find(".loading").hide(); 269 if (e.success) { 270 form.find(".msg.formSuccess").show(); 271 } 272 else { 273 form.find(".msg.formError").show(); 274 form.find(".submit").removeAttr("disabled").removeClass("disabled"); 275 276 if (e.robot) { 277 alert(e.message); 278 } 279 } 280 }); 281 return false;
282 }); 283 }); 284 285 $(Global.FormSubmit.init); 286})(fmgjQuery);
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.