class AMALayout.EmailSuggestion constructor: () -> @domains = [ 'msn.com' 'bellsouth.net' 'telus.net' 'telusplanet.net' 'comcast.net' 'optusnet.com.au' 'earthlink.net' 'qq.com' 'sky.com' 'icloud.com' 'mac.com' 'sympatico.ca' 'googlemail.com' 'att.net' 'xtra.co.nz' 'web.de' 'cox.net' 'gmail.com' 'ymail.com' 'aim.com' 'rogers.com' 'verizon.net' 'rocketmail.com' 'google.com' 'optonline.net' 'sbcglobal.net' 'aol.com' 'me.com' 'btinternet.com' 'charter.net' 'shaw.ca' 'xplore.com' 'abnorth.com' 'pentnet.net' 'canadasurf.net' 'ama.ab.ca' ] @secondLevelDomains = [ 'yahoo' 'hotmail' 'mail' 'live' 'outlook' ] @setupEvents() setupEvents: -> $('[type="email"]').on 'blur', (e) => $(e.originalEvent.target).mailcheck domains: @domains secondLevelDomains: @secondLevelDomains suggested: (element, suggestion) => text = @suggestionMarkup suggestion.address, suggestion.domain if !$('.email_hint').length $("
#{text}
").insertAfter(element).fadeIn 150 else $('.email_hint').html text empty: (element) -> $('.email_hint').html '' $(document).on 'click', '.email_hint .suggestion a.email_domain', (e) => @trackUsage() email_hint = $(e.originalEvent.target).parents('.email_hint') email = $(email_hint).prevAll('input[type=email]:last') $(email).val $('.suggestion').first().text() $('.email_hint').remove() suggestionMarkup: (address, domain) -> "Did you mean " + "" + "#{address}" + "@#{domain}" + "?" trackUsage: () -> if window.dataLayer domain = $('.email_domain').text() dataLayer.push({ "event" : "email-pick-#{domain}" })