1$(document).ready(function() { 2 var $stayConnectEL = $('.stay-connected'); 3 4 var stayConnectCtxObj; 5 BIOG.stayconnect = { 6 _init: function() { 7 stayConnectCtxObj = this; 8 stayConnectCtxObj._bindEvents(); 9 }, 10 11 _bindEvents: function() { 12 13 // user clicks on stay connect submit button 14 $stayConnectEL.find('.stay-connected-form-btn').on('click', stayConnectCtxObj._stayConnectSubmit); 15 16 // hide invalid email error message on input 17 $stayConnectEL.find('.stay-connected-form-email').on('keypress', stayConnectCtxObj._hideErrorMsg); 18 19 $stayConnectEL.find('.stay-connected-form-email').on('blur change', stayConnectCtxObj._validateEmailOnBlur); 20 21 }, 22 23 /** 24 * Function handler for stay connect email validation on tab-out or blur events. 25 * Entered email is checked against regex and shows error message if it doesn't match. 26 */ 27 _validateEmailOnBlur: function() { 28 let el = $(this).closest('.stay-connected').find('.stay-connected-form-email'), 29 $errorEl = $(this).closest('.stay-connected').find('.error-msg'); 30 if (stayConnectCtxObj._validateEmail(el.val(), el.attr('data-regex')) && BIOG.emailvalidationAutoSuggestion._successEmailValidation(el.val())) { 31 //hide error message, add hide class 32 $errorEl.addClass('d-none'); 33 el.removeClass('error-field'); 34 } else { 35 //show error message, remove its hidden class 36 $errorEl.removeClass('d-none'); 37 el.addClass('error-field'); 38 } 39 }, 40 41 /** 42 * Function handler for stay connect form submit button. 43 * Entered email is valid, will be redirected to path, else show error message. 44 */ 45 _stayConnectSubmit: function() { 46 var $parentEl = $(this).closest('.stay-connected'); 47 var $emailInpEl = $parentEl.find('.stay-connected-form-email'); 48 var emailRegex = $emailInpEl.attr('data-regex'); 49 var emailVal = $emailInpEl.val(); 50 var $errorEl = $parentEl.find('.error-msg'); 51 52 if (stayConnectCtxObj._validateEmail(emailVal, emailRegex)) { 53 //hide error message, add hide class 54 $errorEl.addClass('d-none'); 55 $emailInpEl.removeClass('error-field'); 56 57 if (BIOG.options.getQueryParam('eventID').length > 0) { 58 // no redirection, need to make ajax for email validation. 59 //$(document).triggerHandler("event-email-validation", [{email: emailVal}]); 60 61 //place eventId in session, so that on redirection we need eventId 62 if (sessionStorage) { 63 sessionStorage.setItem('eventID', BIOG.options.getQueryParam('eventID')); 64 var hiddenItem = $('input[name="therapeuticarea"]'); 65 if (hiddenItem.length > 0) { 66 sessionStorage.setItem('therapeuticarea', hiddenItem.val()); 67 } 68 69 } 70 } 71 // .html needs to be appended to the refpath as author enters only internal url 72 if (sessionStorage) { 73 sessionStorage.setItem('stayconnect-email', emailVal); 74 } 75 //var redirectPath = $(this).data('refpath') + '.html?email=' + emailVal; 76 //Commenting the above line and modified the redirect path as a fix for DRUN-1712 77 var redirectPath = $(this).data('refpath') + '.html'; 78 location.href = redirectPath; 79 } else { 80 //show error message, remove its hidden class 81 $errorEl.removeClass('d-none'); 82 $emailInpEl.addClass('error-field'); 83 } 84 }, 85 86 /** 87 * Function validates entered email with given regex for email address. 88 * 89 */ 90 _validateEmail: function(emailVal, regex) { 91 92 var filter = regex !== undefined ? new RegExp(regex) : /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 93 return filter.test(emailVal); 94 }, 95 96 /** 97 * Function to hide error message on input key press. 98 * 99 */ 100 _hideErrorMsg: function() { 101 var $parentEl = $(this).closest('.stay-connected'); 102 $parentEl.find('.error-msg').addClass('d-none'); 103 $parentEl.find('.stay-connected-form-email').removeClass('error-field'); 104 } 105 } 106 if ($stayConnectEL.length) { 107 BIOG.stayconnect._init(); 108 } 109});
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.