Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
Merge branch '0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
yongzhenlow committed Aug 11, 2014
2 parents 1242f90 + c5818a5 commit c1f2050
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 59 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jquery.email-autocomplete.js
jquery.email-autocomplete.js v0.1.0
=========

[![Build Status](https://travis-ci.org/10w042/email-autocomplete.svg?branch=master)](https://travis-ci.org/10w042/email-autocomplete)
Expand All @@ -10,11 +10,13 @@ What does it do?

When your user types in "user@gm", the plugin will suggest for e.g. "[email protected]", based on the first result from a list of predefined email domains.

![diagram](https://raw.github.com/yzlow/email-autocomplete/master/doc_assets/example.png)
![diagram](https://raw.github.com/10w042/email-autocomplete/master/doc_assets/example.png)

Press the tab-key, or simply click on the suggestion to automatically fill in the rest of the domain. (or tap on the suggestion for mobile users.)

See a live demo [here](http://yzlow.github.io/email-autocomplete/demo/).
You can also use the right arrow key.

See a live demo [here](http://10w042.github.io/email-autocomplete/demo/).

Installation
------------
Expand Down Expand Up @@ -64,27 +66,25 @@ Domains

Email Autocomplete has its own default domains if the `domains` option isn't provided.

* gmail.com
* googlemail.com
* yahoo.com
* google.com
* yahoo.co.uk
* hotmail.com
* gmail.com
* me.com
* aol.com
* mac.com
* hotmail.co.uk
* live.com
* comcast.net
* googlemail.com
* msn.com
* hotmail.co.uk
* yahoo.co.uk
* facebook.com
* verizon.net
* comcast.net
* sbcglobal.net
* verizon.net
* facebook.com
* outlook.com
* att.net
* gmx.com
* mail.com
* outlook.com
* icloud.com
* me.com
* mac.com
* aol.com

Author
-------
Expand Down
33 changes: 19 additions & 14 deletions demo/js/jquery.email-autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery Email Autocomplete - v0.0.2
* A jQuery plugin that suggests and autocompletes the domain in email fields.
*
* https://github.com/yzlow/email-autocomplete
*
* Made by Low Yong Zhen <[email protected]>
* Under MIT License < http://yzlow.mit-license.org>
Expand All @@ -13,7 +13,7 @@
var pluginName = "emailautocomplete";
var defaults = {
suggClass: "eac-sugg",
domains: ["yahoo.com" ,"google.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"mail.com" ,"outlook.com" ,"icloud.com"]
domains: ["yahoo.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"outlook.com" ,"icloud.com"]
};

function Plugin(elem, options) {
Expand All @@ -32,11 +32,6 @@
this.doIndexOf();
}

//bind handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("blur.eac", $.proxy(this.autocomplete, this));

//get input padding,border and margin to offset text
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;

Expand Down Expand Up @@ -73,8 +68,18 @@
position: "absolute",
top: 0,
left: 0
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
}).insertAfter(this.$field);

//bind events and handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("keydown.eac", $.proxy(function(e){
if(e.which === 39 || e.which === 9){
this.autocomplete();
}
}, this));

this.$suggOverlay.on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
},

suggest: function (str) {
Expand All @@ -96,12 +101,12 @@
},

autocomplete: function () {
if(typeof this.suggestion === "undefined"){
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
return false;
}
this.$field.val(this.val + this.suggestion);
this.$suggOverlay.html("");
this.$cval.html("");
this.$suggOverlay.text("");
this.$cval.text("");
},

/**
Expand All @@ -112,14 +117,14 @@
this.suggestion = this.suggest(this.val);

if (!this.suggestion.length) {
this.$suggOverlay.html("");
this.$suggOverlay.text("");
} else {
e.preventDefault();
}

//update with new suggestion
this.$suggOverlay.html(this.suggestion);
this.$cval.html(this.val);
this.$suggOverlay.text(this.suggestion);
this.$cval.text(this.val);

//find width of current input val so we can offset the suggestion text
var cvalWidth = this.$cval.width();
Expand Down
33 changes: 19 additions & 14 deletions dist/jquery.email-autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery Email Autocomplete - v0.0.2
* A jQuery plugin that suggests and autocompletes the domain in email fields.
*
* https://github.com/yzlow/email-autocomplete
*
* Made by Low Yong Zhen <[email protected]>
* Under MIT License < http://yzlow.mit-license.org>
Expand All @@ -13,7 +13,7 @@
var pluginName = "emailautocomplete";
var defaults = {
suggClass: "eac-sugg",
domains: ["yahoo.com" ,"google.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"mail.com" ,"outlook.com" ,"icloud.com"]
domains: ["yahoo.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"outlook.com" ,"icloud.com"]
};

function Plugin(elem, options) {
Expand All @@ -32,11 +32,6 @@
this.doIndexOf();
}

//bind handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("blur.eac", $.proxy(this.autocomplete, this));

//get input padding,border and margin to offset text
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;

Expand Down Expand Up @@ -73,8 +68,18 @@
position: "absolute",
top: 0,
left: 0
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
}).insertAfter(this.$field);

//bind events and handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("keydown.eac", $.proxy(function(e){
if(e.which === 39 || e.which === 9){
this.autocomplete();
}
}, this));

this.$suggOverlay.on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
},

suggest: function (str) {
Expand All @@ -96,12 +101,12 @@
},

autocomplete: function () {
if(typeof this.suggestion === "undefined"){
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
return false;
}
this.$field.val(this.val + this.suggestion);
this.$suggOverlay.html("");
this.$cval.html("");
this.$suggOverlay.text("");
this.$cval.text("");
},

/**
Expand All @@ -112,14 +117,14 @@
this.suggestion = this.suggest(this.val);

if (!this.suggestion.length) {
this.$suggOverlay.html("");
this.$suggOverlay.text("");
} else {
e.preventDefault();
}

//update with new suggestion
this.$suggOverlay.html(this.suggestion);
this.$cval.html(this.val);
this.$suggOverlay.text(this.suggestion);
this.$cval.text(this.val);

//find width of current input val so we can offset the suggestion text
var cvalWidth = this.$cval.width();
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.email-autocomplete.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions email-autocomplete.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "A jQuery plugin that suggests and autocompletes the domain in email fields.",
"keywords": [
"autocomplete",
"typeahead",
"suggestion",
"domain",
"email",
Expand All @@ -21,6 +22,7 @@
"url": " http://yzlow.mit-license.org"
}
],
"homepage": "https://github.com/yzlow/email-autocomplete",
"dependencies": {
"jquery": ">=1.7"
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"keywords": [
"autocomplete",
"suggestion",
"typeahead",
"domain",
"email",
"field"
Expand Down
31 changes: 18 additions & 13 deletions src/jquery.email-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
var pluginName = "emailautocomplete";
var defaults = {
suggClass: "eac-sugg",
domains: ["yahoo.com" ,"google.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"mail.com" ,"outlook.com" ,"icloud.com"]
domains: ["yahoo.com" ,"hotmail.com" ,"gmail.com" ,"me.com" ,"aol.com" ,"mac.com" ,"live.com" ,"comcast.net" ,"googlemail.com" ,"msn.com" ,"hotmail.co.uk" ,"yahoo.co.uk" ,"facebook.com" ,"verizon.net" ,"sbcglobal.net" ,"att.net" ,"gmx.com" ,"outlook.com" ,"icloud.com"]
};

function Plugin(elem, options) {
Expand All @@ -24,11 +24,6 @@
this.doIndexOf();
}

//bind handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("blur.eac", $.proxy(this.autocomplete, this));

//get input padding,border and margin to offset text
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;

Expand Down Expand Up @@ -65,8 +60,18 @@
position: "absolute",
top: 0,
left: 0
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
}).insertAfter(this.$field);

//bind events and handlers
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));

this.$field.on("keydown.eac", $.proxy(function(e){
if(e.which === 39 || e.which === 9){
this.autocomplete();
}
}, this));

this.$suggOverlay.on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
},

suggest: function (str) {
Expand All @@ -88,12 +93,12 @@
},

autocomplete: function () {
if(typeof this.suggestion === "undefined"){
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
return false;
}
this.$field.val(this.val + this.suggestion);
this.$suggOverlay.html("");
this.$cval.html("");
this.$suggOverlay.text("");
this.$cval.text("");
},

/**
Expand All @@ -104,14 +109,14 @@
this.suggestion = this.suggest(this.val);

if (!this.suggestion.length) {
this.$suggOverlay.html("");
this.$suggOverlay.text("");
} else {
e.preventDefault();
}

//update with new suggestion
this.$suggOverlay.html(this.suggestion);
this.$cval.html(this.val);
this.$suggOverlay.text(this.suggestion);
this.$cval.text(this.val);

//find width of current input val so we can offset the suggestion text
var cvalWidth = this.$cval.width();
Expand Down

0 comments on commit c1f2050

Please sign in to comment.