This repository has been archived by the owner on Jan 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
@@ -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 | ||
------------ | ||
|
@@ -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 | ||
------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
@@ -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) { | ||
|
@@ -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; | ||
|
||
|
@@ -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) { | ||
|
@@ -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(""); | ||
}, | ||
|
||
/** | ||
|
@@ -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(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
@@ -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) { | ||
|
@@ -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; | ||
|
||
|
@@ -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) { | ||
|
@@ -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(""); | ||
}, | ||
|
||
/** | ||
|
@@ -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(); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"keywords": [ | ||
"autocomplete", | ||
"suggestion", | ||
"typeahead", | ||
"domain", | ||
"email", | ||
"field" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters