Sha256: 7d6361191ccc26b257f8521621317e0244b3e992ca4edd2401f5090be2832233

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

var domains = ['msn.com', 'bellsouth.net', 'telus.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'];

var $email = $('[type="email"]');
var $hint = $("*#email_hint");

$email.on('blur', function() {
  $(this).mailcheck({
    domains: domains,
    suggested: function(element, suggestion) {
      var text = "Did you mean <span class='suggestion'>" +
        "<span class='address'>" + suggestion.address + "</span>" +
        "@<a href='#' class='email_domain'>" + suggestion.domain +
        "</a></span>?";

      element.parent().siblings("#email_hint").html(text).fadeIn(150);
    },
    empty: function(element) {
      element.parent().siblings("#email_hint").html("");
    }
  });
});

$hint.on('click', '.email_domain', function() {
  email_hint = $(this).parents("#email_hint");
  email = $(email_hint).siblings(".input.email").find("[type='email']")

  $(email).val($(".suggestion").first().text());

  $(email_hint).fadeOut(200, function() {
    $(this).empty();
  });
  return false;
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ama_layout-2.2.9 app/assets/javascripts/ama_layout/autocorrect_email.js