Skip to content

Commit

Permalink
Simplify email example using new data() method
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazar committed Feb 5, 2016
1 parent 61db4dd commit 69ab6ac
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,12 @@ <h2>E-mail autocomplete</h2>
<label>Type an email: <input type="email"></label>
<pre class="language-markup"><code>&lt;input type="email" /></code></pre>
<pre class="language-javascript"><code><script>new Awesomplete($('input[type="email"]'), {
list: ["@aol.com", "@att.net", "@comcast.net", "@facebook.com", "@gmail.com", "@gmx.com", "@googlemail.com", "@google.com", "@hotmail.com", "@hotmail.co.uk", "@mac.com", "@me.com", "@mail.com", "@msn.com", "@live.com", "@sbcglobal.net", "@verizon.net", "@yahoo.com", "@yahoo.co.uk"],
item: function(text, input) {
var newText = input.slice(0, input.indexOf("@")) + text;

return Awesomplete.$.create("li", {
innerHTML: newText.replace(RegExp(input.trim(), "gi"), "<mark>$&</mark>"),
"aria-selected": "false"
});
list: ["aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com", "google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com", "live.com", "sbcglobal.net"],
data: function (text, input) {
var newText = input.slice(0, input.indexOf("@")) + "@" + text;
return { title: newText, value: newText };
},
filter: function(text, input) {
return RegExp("^" + Awesomplete.$.regExpEscape(input.replace(/^.+?(?=@)/, ''), "i")).test(text);
}
filter: Awesomplete.FILTER_STARTSWITH
});</script></code></pre>
</section>

Expand Down

0 comments on commit 69ab6ac

Please sign in to comment.