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

Commit cc71445

Browse files
committed
Update project version
1 parent ac37290 commit cc71445

File tree

5 files changed

+51
-41
lines changed

5 files changed

+51
-41
lines changed

README.md

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

44
[![Build Status](https://travis-ci.org/10w042/email-autocomplete.svg?branch=master)](https://travis-ci.org/10w042/email-autocomplete)
@@ -20,26 +20,29 @@ See a live demo [here](http://10w042.github.io/email-autocomplete/demo/).
2020

2121
Installation
2222
------------
23+
#####Bower
24+
`bower install email-autocomplete --save`
2325

24-
To use, download the minified library into your javascripts directory. jquery.email-autocomplete.js is also available unminimized.
26+
#####Manual
27+
Download or clone this repo and copy `dist/jquery.email-autocomplete.min.js` into your javascripts directory.
2528

2629
Usage (jQuery)
2730
-----------------
2831

29-
Include jQuery and Email Autocomplete into your HTML.
32+
Just add `jquery.email-autocomplete.min.js` into your HTML, before your closing </body>.
3033

3134
```html
3235
<script src="jquery.min.js"></script>
3336
<script src="jquery.email-autocomplete.min.js"></script>
3437
```
3538

36-
You should have a text field.
39+
You should also have a email input field.
3740

3841
```html
3942
<input id="email" name="email" type="email" />
4043
```
4144

42-
Now, attach the plugin to the text field.
45+
Now, attach the plugin to the email input field.
4346

4447
```html
4548
<script>
@@ -53,11 +56,11 @@ $("#email").emailautocomplete({
5356
Styling
5457
-----------------
5558

56-
Use the following CSS to style the suggestion text color
59+
Use the following CSS to style the suggestion text color. Remember to update the classname if you've changed it to a custom one.
5760

5861
```css
59-
.eac-sugg{
60-
color:#ccc;
62+
.eac-sugg {
63+
color: #ccc;
6164
}
6265
```
6366

@@ -94,12 +97,12 @@ Author
9497
License
9598
-------
9699

97-
Copyright (c) 2014
100+
Copyright (c) 2016
98101

99102
Licensed under the MIT License.
100103

101104

102105
Known Issues:
103106
----------------
104107

105-
- On android stock browser, if "Settings > Accessibility > Scale text up and down" value is not at 100%, text width is unabled to be retrieved correctly.
108+
- On android stock browser, if "Settings > Accessibility > Scale text up and down" value is not at 100%, text width is unabled to be retrieved correctly.

demo/js/jquery.email-autocomplete.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
* jQuery Email Autocomplete - v0.0.2
3-
* A jQuery plugin that suggests and autocompletes the domain in email fields.
4-
* https://github.com/yzlow/email-autocomplete
2+
* email-autocomplete - 0.1.1
3+
* jQuery plugin that displays in-place autocomplete suggestions for email input fields.
4+
*
55
*
6-
* Made by Low Yong Zhen <[email protected]>
7-
* Under MIT License < http://yzlow.mit-license.org>
6+
* Made by Low Yong Zhen <[email protected]>
87
*/
98
"use strict";
109

@@ -16,29 +15,29 @@
1615
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"]
1716
};
1817

19-
function Plugin(elem, options) {
18+
function EmailAutocomplete(elem, options) {
2019
this.$field = $(elem);
2120
this.options = $.extend(true, {}, defaults, options); //we want deep extend
2221
this._defaults = defaults;
2322
this._domains = this.options.domains;
2423
this.init();
2524
}
2625

27-
Plugin.prototype = {
26+
EmailAutocomplete.prototype = {
2827
init: function () {
2928

3029
//shim indexOf
3130
if (!Array.prototype.indexOf) {
3231
this.doIndexOf();
3332
}
3433

35-
//get input padding,border and margin to offset text
36-
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
34+
//this will be calculated upon keyup
35+
this.fieldLeftOffset = null;
3736

3837
//wrap our field
3938
var $wrap = $("<div class='eac-input-wrap' />").css({
4039
display: this.$field.css("display"),
41-
position: "relative",
40+
position: this.$field.css("position") === 'static' ? 'relative' : this.$field.css("position"),
4241
fontSize: this.$field.css("fontSize")
4342
});
4443
this.$field.wrap($wrap);
@@ -126,6 +125,11 @@
126125
this.$suggOverlay.text(this.suggestion);
127126
this.$cval.text(this.val);
128127

128+
// get input padding, border and margin to offset text
129+
if(this.fieldLeftOffset === null){
130+
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
131+
}
132+
129133
//find width of current input val so we can offset the suggestion text
130134
var cvalWidth = this.$cval.width();
131135

@@ -175,9 +179,9 @@
175179
$.fn[pluginName] = function (options) {
176180
return this.each(function () {
177181
if (!$.data(this, "yz_" + pluginName)) {
178-
$.data(this, "yz_" + pluginName, new Plugin(this, options));
182+
$.data(this, "yz_" + pluginName, new EmailAutocomplete(this, options));
179183
}
180184
});
181185
};
182186

183-
})(jQuery, window, document);
187+
})(jQuery, window, document);

dist/jquery.email-autocomplete.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
* jQuery Email Autocomplete - v0.0.2
3-
* A jQuery plugin that suggests and autocompletes the domain in email fields.
4-
* https://github.com/yzlow/email-autocomplete
2+
* email-autocomplete - 0.1.1
3+
* jQuery plugin that displays in-place autocomplete suggestions for email input fields.
4+
*
55
*
6-
* Made by Low Yong Zhen <[email protected]>
7-
* Under MIT License < http://yzlow.mit-license.org>
6+
* Made by Low Yong Zhen <[email protected]>
87
*/
98
"use strict";
109

@@ -16,29 +15,29 @@
1615
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"]
1716
};
1817

19-
function Plugin(elem, options) {
18+
function EmailAutocomplete(elem, options) {
2019
this.$field = $(elem);
2120
this.options = $.extend(true, {}, defaults, options); //we want deep extend
2221
this._defaults = defaults;
2322
this._domains = this.options.domains;
2423
this.init();
2524
}
2625

27-
Plugin.prototype = {
26+
EmailAutocomplete.prototype = {
2827
init: function () {
2928

3029
//shim indexOf
3130
if (!Array.prototype.indexOf) {
3231
this.doIndexOf();
3332
}
3433

35-
//get input padding,border and margin to offset text
36-
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
34+
//this will be calculated upon keyup
35+
this.fieldLeftOffset = null;
3736

3837
//wrap our field
3938
var $wrap = $("<div class='eac-input-wrap' />").css({
4039
display: this.$field.css("display"),
41-
position: "relative",
40+
position: this.$field.css("position") === 'static' ? 'relative' : this.$field.css("position"),
4241
fontSize: this.$field.css("fontSize")
4342
});
4443
this.$field.wrap($wrap);
@@ -126,6 +125,11 @@
126125
this.$suggOverlay.text(this.suggestion);
127126
this.$cval.text(this.val);
128127

128+
// get input padding, border and margin to offset text
129+
if(this.fieldLeftOffset === null){
130+
this.fieldLeftOffset = (this.$field.outerWidth(true) - this.$field.width()) / 2;
131+
}
132+
129133
//find width of current input val so we can offset the suggestion text
130134
var cvalWidth = this.$cval.width();
131135

@@ -175,9 +179,9 @@
175179
$.fn[pluginName] = function (options) {
176180
return this.each(function () {
177181
if (!$.data(this, "yz_" + pluginName)) {
178-
$.data(this, "yz_" + pluginName, new Plugin(this, options));
182+
$.data(this, "yz_" + pluginName, new EmailAutocomplete(this, options));
179183
}
180184
});
181185
};
182186

183-
})(jQuery, window, document);
187+
})(jQuery, window, document);

dist/jquery.email-autocomplete.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email-autocomplete",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "jQuery plugin that displays in-place autocomplete suggestions for email input fields.",
55
"keywords": [
66
"jquery-plugin",

0 commit comments

Comments
 (0)