diff options
author | Alex DiLiberto <alex@alexdiliberto.com> | 2015-03-03 15:07:06 -0800 |
---|---|---|
committer | Alex DiLiberto <alex@alexdiliberto.com> | 2015-03-03 15:07:06 -0800 |
commit | 2f271891ac0cae01d2e99e1ca9fbbd554e7d3163 (patch) | |
tree | e73f5ad58b6cbeaf238783a7389a89b9c68cb1ee /awesomplete.js | |
parent | db991e1817f90d7bd5cf2ca1b25d4f4229335bd0 (diff) | |
parent | eae086fd2bdfee671fe3773b74edd4ece60a23df (diff) | |
download | awesomplete-2f271891ac0cae01d2e99e1ca9fbbd554e7d3163.zip awesomplete-2f271891ac0cae01d2e99e1ca9fbbd554e7d3163.tar.gz awesomplete-2f271891ac0cae01d2e99e1ca9fbbd554e7d3163.tar.bz2 |
Merge branch 'gh-pages' into bug-fix-keydown-ul-hidden
* gh-pages:
fix issue entering a value that doesn't exist.
Improved advanced examples section, improved email example, added tags example
remove useless if statement
Add minification via Google's Closure Compiler Service.
use string as parameter to Awesomeplete
readded position:absolute to make sure clip is working reliably
advanced examples, email example
removed all leftover legacy visually hiding methods
removed border and padding and updated clip syntax
removed the setStatus helper and moved the updating of the aria-live region directly into the goto method
changed hiddena11y property to visually-hidden class
add a live region that announces the selected item
add styles to hide only visually
Diffstat (limited to 'awesomplete.js')
-rw-r--r-- | awesomplete.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/awesomplete.js b/awesomplete.js index 43de0f9..442bfd1 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -12,8 +12,8 @@ var _ = self.Awesomplete = function (input, o) { // Setup - this.input = input; - input.setAttribute("aria-autocomplete", "list"); + this.input = $(input); + this.input.setAttribute("aria-autocomplete", "list"); o = o || {}; @@ -48,6 +48,14 @@ var _ = self.Awesomplete = function (input, o) { inside: this.container }); + this.status = $.create("span", { + className: "visually-hidden", + role: "status", + "aria-live": "assertive", + "aria-relevant": "additions", + inside: this.container + }); + // Bind events $.bind(this.input, { @@ -74,7 +82,7 @@ var _ = self.Awesomplete = function (input, o) { } }); - $.bind(this.input.form, {"submit": me.close.bind(me)}); + $.bind(this.input.form, {"submit": this.close.bind(this)}); $.bind(this.ul, {"mousedown": function(evt) { var li = evt.target; @@ -91,12 +99,12 @@ var _ = self.Awesomplete = function (input, o) { } }}); - if (input.hasAttribute("list")) { + if (this.input.hasAttribute("list")) { this.list = "#" + input.getAttribute("list"); input.removeAttribute("list"); } else { - this.list = input.getAttribute("data-list") || o.list || []; + this.list = this.input.getAttribute("data-list") || o.list || []; } _.all.push(this); @@ -174,6 +182,7 @@ _.prototype = { if (i > -1 && lis.length > 0) { lis[i].setAttribute("aria-selected", "true"); + this.status.textContent = lis[i].textContent; } }, @@ -218,7 +227,11 @@ _.prototype = { return i < me.maxItems - 1; }); - this.open(); + if (this.ul.children.length === 0) { + this.close(); + } else { + this.open(); + } } else { this.close(); |