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

Commit c1f2050

Browse files
committed
Merge branch '0.1.0'
2 parents 1242f90 + c5818a5 commit c1f2050

7 files changed

+77
-59
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jquery.email-autocomplete.js
1+
jquery.email-autocomplete.js v0.1.0
22
=========
33

44
[![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?
1010

1111
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.
1212

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

1515
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.)
1616

17-
See a live demo [here](http://yzlow.github.io/email-autocomplete/demo/).
17+
You can also use the right arrow key.
18+
19+
See a live demo [here](http://10w042.github.io/email-autocomplete/demo/).
1820

1921
Installation
2022
------------
@@ -64,27 +66,25 @@ Domains
6466

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

69+
* gmail.com
70+
* googlemail.com
6771
* yahoo.com
68-
* google.com
72+
* yahoo.co.uk
6973
* hotmail.com
70-
* gmail.com
71-
* me.com
72-
* aol.com
73-
* mac.com
74+
* hotmail.co.uk
7475
* live.com
75-
* comcast.net
76-
* googlemail.com
7776
* msn.com
78-
* hotmail.co.uk
79-
* yahoo.co.uk
80-
* facebook.com
81-
* verizon.net
77+
* comcast.net
8278
* sbcglobal.net
79+
* verizon.net
80+
* facebook.com
81+
* outlook.com
8382
* att.net
8483
* gmx.com
85-
* mail.com
86-
* outlook.com
8784
* icloud.com
85+
* me.com
86+
* mac.com
87+
* aol.com
8888

8989
Author
9090
-------

demo/js/jquery.email-autocomplete.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* jQuery Email Autocomplete - v0.0.2
33
* A jQuery plugin that suggests and autocompletes the domain in email fields.
4-
*
4+
* https://github.com/yzlow/email-autocomplete
55
*
66
* Made by Low Yong Zhen <[email protected]>
77
* Under MIT License < http://yzlow.mit-license.org>
@@ -13,7 +13,7 @@
1313
var pluginName = "emailautocomplete";
1414
var defaults = {
1515
suggClass: "eac-sugg",
16-
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"]
16+
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"]
1717
};
1818

1919
function Plugin(elem, options) {
@@ -32,11 +32,6 @@
3232
this.doIndexOf();
3333
}
3434

35-
//bind handlers
36-
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
37-
38-
this.$field.on("blur.eac", $.proxy(this.autocomplete, this));
39-
4035
//get input padding,border and margin to offset text
4136
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
4237

@@ -73,8 +68,18 @@
7368
position: "absolute",
7469
top: 0,
7570
left: 0
76-
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
71+
}).insertAfter(this.$field);
72+
73+
//bind events and handlers
74+
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
75+
76+
this.$field.on("keydown.eac", $.proxy(function(e){
77+
if(e.which === 39 || e.which === 9){
78+
this.autocomplete();
79+
}
80+
}, this));
7781

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

8085
suggest: function (str) {
@@ -96,12 +101,12 @@
96101
},
97102

98103
autocomplete: function () {
99-
if(typeof this.suggestion === "undefined"){
104+
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
100105
return false;
101106
}
102107
this.$field.val(this.val + this.suggestion);
103-
this.$suggOverlay.html("");
104-
this.$cval.html("");
108+
this.$suggOverlay.text("");
109+
this.$cval.text("");
105110
},
106111

107112
/**
@@ -112,14 +117,14 @@
112117
this.suggestion = this.suggest(this.val);
113118

114119
if (!this.suggestion.length) {
115-
this.$suggOverlay.html("");
120+
this.$suggOverlay.text("");
116121
} else {
117122
e.preventDefault();
118123
}
119124

120125
//update with new suggestion
121-
this.$suggOverlay.html(this.suggestion);
122-
this.$cval.html(this.val);
126+
this.$suggOverlay.text(this.suggestion);
127+
this.$cval.text(this.val);
123128

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

dist/jquery.email-autocomplete.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* jQuery Email Autocomplete - v0.0.2
33
* A jQuery plugin that suggests and autocompletes the domain in email fields.
4-
*
4+
* https://github.com/yzlow/email-autocomplete
55
*
66
* Made by Low Yong Zhen <[email protected]>
77
* Under MIT License < http://yzlow.mit-license.org>
@@ -13,7 +13,7 @@
1313
var pluginName = "emailautocomplete";
1414
var defaults = {
1515
suggClass: "eac-sugg",
16-
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"]
16+
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"]
1717
};
1818

1919
function Plugin(elem, options) {
@@ -32,11 +32,6 @@
3232
this.doIndexOf();
3333
}
3434

35-
//bind handlers
36-
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
37-
38-
this.$field.on("blur.eac", $.proxy(this.autocomplete, this));
39-
4035
//get input padding,border and margin to offset text
4136
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
4237

@@ -73,8 +68,18 @@
7368
position: "absolute",
7469
top: 0,
7570
left: 0
76-
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
71+
}).insertAfter(this.$field);
72+
73+
//bind events and handlers
74+
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
75+
76+
this.$field.on("keydown.eac", $.proxy(function(e){
77+
if(e.which === 39 || e.which === 9){
78+
this.autocomplete();
79+
}
80+
}, this));
7781

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

8085
suggest: function (str) {
@@ -96,12 +101,12 @@
96101
},
97102

98103
autocomplete: function () {
99-
if(typeof this.suggestion === "undefined"){
104+
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
100105
return false;
101106
}
102107
this.$field.val(this.val + this.suggestion);
103-
this.$suggOverlay.html("");
104-
this.$cval.html("");
108+
this.$suggOverlay.text("");
109+
this.$cval.text("");
105110
},
106111

107112
/**
@@ -112,14 +117,14 @@
112117
this.suggestion = this.suggest(this.val);
113118

114119
if (!this.suggestion.length) {
115-
this.$suggOverlay.html("");
120+
this.$suggOverlay.text("");
116121
} else {
117122
e.preventDefault();
118123
}
119124

120125
//update with new suggestion
121-
this.$suggOverlay.html(this.suggestion);
122-
this.$cval.html(this.val);
126+
this.$suggOverlay.text(this.suggestion);
127+
this.$cval.text(this.val);
123128

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

dist/jquery.email-autocomplete.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

email-autocomplete.jquery.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "A jQuery plugin that suggests and autocompletes the domain in email fields.",
55
"keywords": [
66
"autocomplete",
7+
"typeahead",
78
"suggestion",
89
"domain",
910
"email",
@@ -21,6 +22,7 @@
2122
"url": " http://yzlow.mit-license.org"
2223
}
2324
],
25+
"homepage": "https://github.com/yzlow/email-autocomplete",
2426
"dependencies": {
2527
"jquery": ">=1.7"
2628
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"keywords": [
66
"autocomplete",
77
"suggestion",
8+
"typeahead",
89
"domain",
910
"email",
1011
"field"

src/jquery.email-autocomplete.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
var pluginName = "emailautocomplete";
66
var defaults = {
77
suggClass: "eac-sugg",
8-
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"]
8+
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"]
99
};
1010

1111
function Plugin(elem, options) {
@@ -24,11 +24,6 @@
2424
this.doIndexOf();
2525
}
2626

27-
//bind handlers
28-
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
29-
30-
this.$field.on("blur.eac", $.proxy(this.autocomplete, this));
31-
3227
//get input padding,border and margin to offset text
3328
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
3429

@@ -65,8 +60,18 @@
6560
position: "absolute",
6661
top: 0,
6762
left: 0
68-
}).insertAfter(this.$field).on("mousedown.eac touchstart.eac", $.proxy(this.autocomplete, this));
63+
}).insertAfter(this.$field);
64+
65+
//bind events and handlers
66+
this.$field.on("keyup.eac", $.proxy(this.displaySuggestion, this));
67+
68+
this.$field.on("keydown.eac", $.proxy(function(e){
69+
if(e.which === 39 || e.which === 9){
70+
this.autocomplete();
71+
}
72+
}, this));
6973

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

7277
suggest: function (str) {
@@ -88,12 +93,12 @@
8893
},
8994

9095
autocomplete: function () {
91-
if(typeof this.suggestion === "undefined"){
96+
if(typeof this.suggestion === "undefined" || this.suggestion.length < 1){
9297
return false;
9398
}
9499
this.$field.val(this.val + this.suggestion);
95-
this.$suggOverlay.html("");
96-
this.$cval.html("");
100+
this.$suggOverlay.text("");
101+
this.$cval.text("");
97102
},
98103

99104
/**
@@ -104,14 +109,14 @@
104109
this.suggestion = this.suggest(this.val);
105110

106111
if (!this.suggestion.length) {
107-
this.$suggOverlay.html("");
112+
this.$suggOverlay.text("");
108113
} else {
109114
e.preventDefault();
110115
}
111116

112117
//update with new suggestion
113-
this.$suggOverlay.html(this.suggestion);
114-
this.$cval.html(this.val);
118+
this.$suggOverlay.text(this.suggestion);
119+
this.$cval.text(this.val);
115120

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

0 commit comments

Comments
 (0)