{"version":3,"sources":["email-validate.js"],"names":["EmailValidate","elements","messages","timeout","urls","config","$","containerId","inView","init","rateLimit","setInitial","document","body","on","searchFieldId","e","search","keyup","searchBtnId","start","retryBtnId","toggleState","setTimeout","focus","ajax","type","url","getRateLimit","success","response","update","limitReason","error","handleError","dataType","limitMessage","limitReasonText","throttleLimitReached","throttle","searchCountMultiple","replace","enabled","searchCountSingle","searchCountNone","ipDailyBlock","ipMonthlyBlock","ipPermanentBlock","disable","permanent","Utilities","escapeHtml","rateLimitMessageClass","html","enable","toggleLoading","stateClass","toggleClass","toggleLoaders","removeClass","input","value","clear","val","buttonOnly","$searchButton","submittedEmailId","text","keyCode","click","blur","once","validateEmail","data","email","result","hide","show","$corrections","suggestedCorrectionsClass","isNullOrEmpty","corrections","parent","JSON","parse","each","i","append","errorPanelId","webAnalytics","event","trackEvent","removeAttr","attr","searchButtonParent","freeTrialButtonExists","find","freeTrialBtnId","length","$freeTrialBtn","clone","insertAfter","addClass","errorMessageId","unknownError","console","statusText","status","not","one","retryAfterErrorBtnId"],"mappings":"YAAC,IAAIA,gBAEDC,YACAC,YACAC,QAAS,KACTC,QAEAC,OAAQ,SAAUJ,EAAUG,EAAMF,EAAUC,GACxCH,cAAcC,SAAWA,EACzBD,cAAcI,KAAOA,EACrBJ,cAAcE,SAAWA,EACzBF,cAAcG,QAAUA,EAExBG,EAAE,WACEA,EAAE,IAAMN,cAAcC,SAASM,aAAaC,OAAOR,cAAcS,SAIzEA,KAAM,WAEFT,cAAcU,UAAUC,aAGxBL,EAAEM,SAASC,MAAMC,GAAG,2BAA4B,IAAMd,cAAcC,SAASc,cAAe,SAAUC,GAClGhB,cAAciB,OAAOC,MAAMF,KAI/BV,EAAEM,SAASC,MAAMC,GAAG,QAAS,IAAMd,cAAcC,SAASkB,YAAa,WACnEnB,cAAciB,OAAOG,UAIzBd,EAAEM,SAASC,MAAMC,GAAG,QAAS,IAAMd,cAAcC,SAASoB,WAAY,WAClErB,cAAcsB,cACdC,WAA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,EAAgB7F,EAAE,IAAMN,cAAcC,SAASgG,eAE9CF,KAEDI,EAAcC,QAAQC,YAAY,IAAMrG,cAAcC,SAASkB,aAC/DgF,EAAcjB,SAASU,WAAW,SAASU,SAAS,uBACpDhG,EAAE,IAAMN,cAAcC,SAASoB,YAAY6D,SAASoB,SAAS,UAC7DhG,EAAE,IAAMN,cAAcC,SAASc,eAAemE,SAASoB,SAAS,WAIpEhG,EAAE,IAAMN,cAAcC,SAASoB,YAAYiF,SAAS,UACpDhG,EAAE,IAAMN,cAAcC,SAASkB,aAAamF,SAAS,UAGrDhG,EAAE,IAAMN,cAAcC,SAASmD,uBAAuB8B,OAAO,eACxDoB,SAAS,sBACT3C,YAAY,cAGjB3D,cAAciB,OAAO+B,QAAQuB,OAC7BvE,cAAciB,OAAOyB,SAAU,IAIvCH,SAAU,WAENjC,EAAE,IAAMN,cAAcC,SAASmD,uBAAuB8B,OAAO,eAC5DoB,SAAS,uBACT3C,YAAY,eAGjBzB,YAAa,SAAUD,GAEnB3B,EAAE,IAAMN,cAAcC,SAASsG,gBAAgBlD,KAAKrD,cAAcE,SAASsG,cAE3EC,QAAQxE,MAAM,wBACViB,UAAUC,WAAWlB,EAAMyE,YAC3B,KAAOxD,UAAUC,WAAWlB,EAAM0E,QAAU,KAEhD3G,cAAcuD,gBACdjD,EAAE,IAAMN,cAAcC,SAASuD,YAAYoD,IAAI,YAAYhC,OAC3DtE,EAAE,IAAMN,cAAcC,SAASuF,cAAc7B,YAAY,UAEzDrD,EAAEM,SAASC,MAAMgG,IAAI,QAAS,IAAM7G,cAAcC,SAAS6G,qBAAsB,WAC7ExG,EAAE,IAAMN,cAAcC,SAASuD,YAAYoD,IAAI,YAAY/B,OAC3DvE,EAAE,IAAMN,cAAcC,SAASuF,cAAcc,SAAS,UACtDtG,cAAcS,OACdT,cAAcuD","file":"email-validate.js","sourcesContent":["var EmailValidate = {\r\n\r\n elements: {},\r\n messages: {},\r\n timeout: null,\r\n urls: {},\r\n\r\n config: function (elements, urls, messages, timeout) {\r\n EmailValidate.elements = elements;\r\n EmailValidate.urls = urls;\r\n EmailValidate.messages = messages;\r\n EmailValidate.timeout = timeout;\r\n\r\n $(function () {\r\n $(\"#\" + EmailValidate.elements.containerId).inView(EmailValidate.init);\r\n });\r\n },\r\n\r\n init: function () {\r\n // Get and set rate limit for this user\r\n EmailValidate.rateLimit.setInitial();\r\n\r\n // Search field listener (keyup)\r\n $(document.body).on(\"keyup change paste input\", \"#\" + EmailValidate.elements.searchFieldId, function (e) {\r\n EmailValidate.search.keyup(e);\r\n });\r\n\r\n // Search button listener\r\n $(document.body).on(\"click\", \"#\" + EmailValidate.elements.searchBtnId, function () {\r\n EmailValidate.search.start();\r\n });\r\n\r\n // Retry button listener\r\n $(document.body).on(\"click\", \"#\" + EmailValidate.elements.retryBtnId, function () {\r\n EmailValidate.toggleState();\r\n setTimeout(function () {\r\n $(\"#\" + EmailValidate.elements.searchFieldId).focus();\r\n }, 0);\r\n });\r\n },\r\n\r\n rateLimit: {\r\n\r\n setInitial: function () {\r\n $.ajax({\r\n type: \"POST\",\r\n url: EmailValidate.urls.getRateLimit,\r\n success: function (response) {\r\n EmailValidate.rateLimit.update(response.rateLimit, response.limitReason);\r\n },\r\n error: EmailValidate.search.handleError,\r\n dataType: \"json\",\r\n timeout: EmailValidate.timeout\r\n });\r\n },\r\n\r\n update: function (rateLimit, limitReason) {\r\n var limitMessage, limitReasonText;\r\n\r\n // Let internal users continue to search if IP blocking is the limitReason\r\n if (limitReason === \"InternalIP\") {\r\n rateLimit = 3;\r\n limitReasonText = \"(Internal IP address)\";\r\n } else if (limitReason === \"StaffRole\") {\r\n rateLimit = 3;\r\n limitReasonText = \"(Staff access)\";\r\n } else if (limitReason === \"ThrottleLimitReached\") {\r\n limitReasonText = EmailValidate.messages.throttleLimitReached;\r\n // Disable searching and highlight warning\r\n EmailValidate.search.throttle();\r\n }\r\n\r\n if (rateLimit > 1) {\r\n limitMessage = EmailValidate.messages.searchCountMultiple.replace(\"{}\", rateLimit);\r\n EmailValidate.search.enabled = true;\r\n }\r\n else if (rateLimit === 1) {\r\n limitMessage = EmailValidate.messages.searchCountSingle;\r\n EmailValidate.search.enabled = true;\r\n }\r\n else {\r\n limitMessage = EmailValidate.messages.searchCountNone;\r\n // Add messages to the limit string for particular reasons\r\n switch (limitReason) {\r\n case \"IPDailyLimit\":\r\n limitReasonText = EmailValidate.messages.ipDailyBlock;\r\n break;\r\n case \"IPMonthlyLimit\":\r\n limitReasonText = EmailValidate.messages.ipMonthlyBlock;\r\n break;\r\n case \"IPBlocked\":\r\n limitReasonText = EmailValidate.messages.ipPermanentBlock;\r\n break;\r\n }\r\n // Disable searching and highlight warning if the rateLimit is less than 1\r\n EmailValidate.search.disable.permanent();\r\n }\r\n // Update the \"searches remaining\" text\r\n if (typeof limitReasonText !== \"undefined\") {\r\n limitMessage += \"
\" + Utilities.escapeHtml(limitReasonText);\r\n }\r\n $(\".\" + EmailValidate.elements.rateLimitMessageClass).html(limitMessage);\r\n EmailValidate.search.enable();\r\n EmailValidate.toggleLoading();\r\n }\r\n },\r\n\r\n toggleState: function () {\r\n $(\".\" + EmailValidate.elements.stateClass).toggleClass(\"hidden\");\r\n },\r\n\r\n toggleLoading: function () {\r\n $(\"#\" + EmailValidate.elements.containerId).toggleLoaders();\r\n $(\".\" + EmailValidate.elements.stateClass + \".toggle-visibility\").removeClass(\"invisible\");\r\n },\r\n\r\n search: {\r\n\r\n enabled: true,\r\n\r\n input: {\r\n\r\n value: \"\",\r\n\r\n clear: function () {\r\n $(\"#\" + EmailValidate.elements.searchFieldId).val(\"\");\r\n EmailValidate.search.input.value = \"\";\r\n EmailValidate.search.enable();\r\n EmailValidate.search.disable.buttonOnly();\r\n }\r\n },\r\n\r\n keyup: function (e) {\r\n var $searchButton = $(\"#\" + EmailValidate.elements.searchBtnId);\r\n EmailValidate.search.input.value = $(\"#\" + EmailValidate.elements.searchFieldId).val();\r\n\r\n if (EmailValidate.search.enabled && EmailValidate.search.input.value !== \"\") {\r\n $(\"#\" + EmailValidate.elements.submittedEmailId).text(EmailValidate.search.input.value);\r\n EmailValidate.search.enable();\r\n\r\n // \"Submit\" the \"form\" for the user if they press Enter\r\n if (e.keyCode === 13) {\r\n $searchButton.click();\r\n }\r\n }\r\n else {\r\n EmailValidate.search.disable.buttonOnly();\r\n }\r\n },\r\n\r\n blur: function (e) {\r\n EmailValidate.search.input.value = $(\"#\" + EmailValidate.elements.searchFieldId).val();\r\n\r\n if (EmailValidate.search.enabled && EmailValidate.search.input.value !== \"\") {\r\n $(\"#\" + EmailValidate.elements.submittedEmailId).text(EmailValidate.search.input.value);\r\n EmailValidate.search.enable();\r\n\r\n // Initiate a search request\r\n EmailValidate.search.start();\r\n }\r\n else {\r\n EmailValidate.search.disable.buttonOnly();\r\n }\r\n },\r\n\r\n start: function () {\r\n if (EmailValidate.search.enabled) {\r\n\r\n EmailValidate.search.disable.once();\r\n EmailValidate.toggleLoading();\r\n \r\n $.ajax({\r\n type: \"POST\",\r\n url: EmailValidate.urls.validateEmail,\r\n data: {\r\n email: EmailValidate.search.input.value\r\n },\r\n success: function (result) {\r\n if (result.result !== \"\") {\r\n $(\"[data-status]\").hide();\r\n $(\"[data-status='\" + Utilities.escapeHtml(result.result) + \"']\").show();\r\n\r\n var $corrections = $(\".\" + EmailValidate.elements.suggestedCorrectionsClass);\r\n $corrections.html(\"\");\r\n if (!Utilities.isNullOrEmpty(result.corrections)) {\r\n var corrections = JSON.parse(result.corrections);\r\n $.each(corrections, function (i) {\r\n if (!Utilities.isNullOrEmpty(corrections[i])) {\r\n $corrections.append($(\"

\").text(Utilities.escapeHtml(corrections[i])));\r\n }\r\n });\r\n $corrections.parent().show();\r\n }\r\n else {\r\n $corrections.parent().hide();\r\n }\r\n\r\n EmailValidate.toggleState();\r\n EmailValidate.search.input.clear();\r\n\r\n // The button will re-activate when the input changes appropriately\r\n EmailValidate.search.disable.once();\r\n }\r\n else {\r\n // The rate limit was exceeded, so no result was returned\r\n $(\"[data-status]\").hide();\r\n }\r\n EmailValidate.rateLimit.update(result.rateLimit, result.limitReason);\r\n $(\"#\" + EmailValidate.elements.errorPanelId).hide();\r\n EmailValidate.search.webAnalytics();\r\n },\r\n error: EmailValidate.search.handleError,\r\n dataType: \"json\",\r\n timeout: EmailValidate.timeout\r\n });\r\n }\r\n },\r\n\r\n webAnalytics: function (event) {\r\n // Push GTM dataLayer event for successful email validation\r\n Utilities.trackEvent({\r\n 'event': 'EmailValidationDemo'\r\n });\r\n },\r\n\r\n enable: function () {\r\n if (EmailValidate.search.enabled) {\r\n $(\"#\" + EmailValidate.elements.searchFieldId).removeAttr(\"disabled\");\r\n if (EmailValidate.search.input.value !== \"\") {\r\n $(\"#\" + EmailValidate.elements.searchBtnId).removeAttr(\"disabled\");\r\n }\r\n }\r\n },\r\n\r\n disable: {\r\n\r\n once: function () {\r\n $(\"#\" + EmailValidate.elements.searchFieldId).attr(\"disabled\", \"disabled\");\r\n $(\"#\" + EmailValidate.elements.searchBtnId).attr(\"disabled\", \"disabled\");\r\n },\r\n\r\n buttonOnly: function () {\r\n $(\"#\" + EmailValidate.elements.searchBtnId).attr(\"disabled\", \"disabled\");\r\n },\r\n\r\n permanent: function () {\r\n\r\n // Check if the parent of the search button already has a free trial button\r\n var searchButtonParent = $(\"#\" + EmailValidate.elements.searchBtnId).parent();\r\n var freeTrialButtonExists = searchButtonParent.find(\"#\" + EmailValidate.elements.freeTrialBtnId).length > 0;\r\n\r\n var $freeTrialBtn = $(\"#\" + EmailValidate.elements.freeTrialBtnId);\r\n\r\n if (!freeTrialButtonExists) {\r\n // Append a clone of the free trial button to the search container if it does not exist\r\n $freeTrialBtn.clone().insertAfter(\"#\" + EmailValidate.elements.searchBtnId);\r\n $freeTrialBtn.parent().removeAttr(\"class\").addClass(\"col-sm-12 col-md-10\");\r\n $(\"#\" + EmailValidate.elements.retryBtnId).parent().addClass(\"hidden\");\r\n $(\"#\" + EmailValidate.elements.searchFieldId).parent().addClass(\"hidden\");\r\n }\r\n\r\n // Hide search field and buttons\r\n $(\"#\" + EmailValidate.elements.retryBtnId).addClass(\"hidden\");\r\n $(\"#\" + EmailValidate.elements.searchBtnId).addClass(\"hidden\");\r\n\r\n // Turn the rate limit message into an alert\r\n $(\".\" + EmailValidate.elements.rateLimitMessageClass).parent(\".help-block\")\r\n .addClass(\"alert alert-danger\")\r\n .removeClass(\"help-block\");\r\n\r\n // Disable searching\r\n EmailValidate.search.disable.once();\r\n EmailValidate.search.enabled = false;\r\n }\r\n },\r\n\r\n throttle: function() {\r\n // Turn the rate limit message into a warning\r\n $(\".\" + EmailValidate.elements.rateLimitMessageClass).parent(\".help-block\")\r\n .addClass(\"alert alert-warning\")\r\n .removeClass(\"help-block\");\r\n },\r\n\r\n handleError: function (error) {\r\n // Populate the error message\r\n $(\"#\" + EmailValidate.elements.errorMessageId).html(EmailValidate.messages.unknownError);\r\n // Log underlying error to console\r\n console.error(\"Unknown demo error - \" +\r\n Utilities.escapeHtml(error.statusText) +\r\n \" (\" + Utilities.escapeHtml(error.status) + \")\");\r\n // Show the error block and hide other content\r\n EmailValidate.toggleLoading();\r\n $(\".\" + EmailValidate.elements.stateClass).not(\".headers\").hide();\r\n $(\"#\" + EmailValidate.elements.errorPanelId).removeClass(\"hidden\");\r\n // Activate the retry button\r\n $(document.body).one(\"click\", \"#\" + EmailValidate.elements.retryAfterErrorBtnId, function () {\r\n $(\".\" + EmailValidate.elements.stateClass).not(\".headers\").show();\r\n $(\"#\" + EmailValidate.elements.errorPanelId).addClass(\"hidden\");\r\n EmailValidate.init();\r\n EmailValidate.toggleLoading();\r\n });\r\n }\r\n }\r\n\r\n};"]}