summaryrefslogtreecommitdiffstats
path: root/index.js
diff options
context:
space:
mode:
authorLea Verou <lea@verou.me>2015-03-02 06:07:24 -0500
committerLea Verou <lea@verou.me>2015-03-02 06:08:16 -0500
commit416f91b3a94e7237b5f06af70c42d22992051441 (patch)
treea1a5180c3738b4d76fe884488feeecf5d690672e /index.js
parentef7ad86af9f74ac33eb45f497075c22e640171b6 (diff)
downloadawesomplete-416f91b3a94e7237b5f06af70c42d22992051441.zip
awesomplete-416f91b3a94e7237b5f06af70c42d22992051441.tar.gz
awesomplete-416f91b3a94e7237b5f06af70c42d22992051441.tar.bz2
Improved advanced examples section, improved email example, added tags example
Diffstat (limited to 'index.js')
-rw-r--r--index.js44
1 files changed, 12 insertions, 32 deletions
diff --git a/index.js b/index.js
index 8f51abd..f415a07 100644
--- a/index.js
+++ b/index.js
@@ -1,35 +1,15 @@
$ = Awesomplete.$;
$$ = Awesomplete.$$;
-var nav = $("nav")
-$$("section > h1").forEach(function (h1) {
- if (h1.parentNode.id) {
- $.create("a", {
- href: "#" + h1.parentNode.id,
- textContent: h1.textContent.replace(/\(.+?\)/g, ""),
- inside: nav
- });
- }
-});
-
-//email example
-var emailInput = $("#emailInput");
-var emailAwesomplete = new Awesomplete(emailInput, {
- 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"
- });
- },
- filter: function(text, input){
- var atPosition = input.indexOf("@");
- var inputIsEmail = !!~atPosition && (input.length > atPosition + 1);
- var emailPart = input.slice(input.indexOf("@"));
- var textMatchWithInput = RegExp("^" + emailPart.trim(), "i").test(text);
-
- return (inputIsEmail && textMatchWithInput);
- }
-});
+document.addEventListener("DOMContentLoaded", function() {
+ var nav = $("nav")
+ $$("section > h1").forEach(function (h1) {
+ if (h1.parentNode.id) {
+ $.create("a", {
+ href: "#" + h1.parentNode.id,
+ textContent: h1.textContent.replace(/\(.+?\)/g, ""),
+ inside: nav
+ });
+ }
+ });
+}); \ No newline at end of file