Skip to content

Commit

Permalink
Merge branch 'gh-pages' of github.com:LeaVerou/awesomplete into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Aug 21, 2019
2 parents 27e33c3 + f8bee8d commit b6bb273
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Code Climate](https://img.shields.io/codeclimate/github/LeaVerou/awesomplete.svg)](https://codeclimate.com/github/LeaVerou/awesomplete)
[![Test Coverage](https://img.shields.io/codeclimate/coverage/github/LeaVerou/awesomplete.svg)](https://codeclimate.com/github/LeaVerou/awesomplete/coverage)

http://leaverou.github.io/awesomplete/
https://leaverou.github.io/awesomplete/

Awesomplete is an ultra lightweight, customizable, simple autocomplete widget with zero dependencies, built with modern standards for modern browsers.

Expand Down Expand Up @@ -88,10 +88,10 @@ details.

## Links

The official site for the library is at <http://leaverou.github.io/awesomplete/>.
The official site for the library is at <https://leaverou.github.io/awesomplete/>.

Documentation for the API and other topics is at
<http://leaverou.github.io/awesomplete/#api>.
<https://leaverou.github.io/awesomplete/#api>.

Created by Lea Verou and other fantastic contributors.

Expand Down
20 changes: 13 additions & 7 deletions awesomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var _ = function (input, o) {

this.input = $(input);
this.input.setAttribute("autocomplete", "off");
this.input.setAttribute("aria-expanded", "false");
this.input.setAttribute("aria-owns", "awesomplete_list_" + this.count);
this.input.setAttribute("role", "combobox");

Expand Down Expand Up @@ -76,10 +77,10 @@ var _ = function (input, o) {
if(me.opened) {
if (c === 13 && me.selected) { // Enter
evt.preventDefault();
me.select();
me.select(undefined, undefined, evt);
}
else if (c === 9 && me.selected && me.tabSelect) {
me.select();
me.select(undefined, undefined, evt);
}
else if (c === 27) { // Esc
me.close({ reason: "esc" });
Expand Down Expand Up @@ -113,7 +114,7 @@ var _ = function (input, o) {

if (li && evt.button === 0) { // Only select on left click
evt.preventDefault();
me.select(li, evt.target);
me.select(li, evt.target, evt);
}
}
}
Expand Down Expand Up @@ -180,6 +181,7 @@ _.prototype = {
return;
}

this.input.setAttribute("aria-expanded", "false");
this.ul.setAttribute("hidden", "");
this.isOpened = false;
this.index = -1;
Expand All @@ -190,6 +192,7 @@ _.prototype = {
},

open: function () {
this.input.setAttribute("aria-expanded", "true");
this.ul.removeAttribute("hidden");
this.isOpened = true;

Expand Down Expand Up @@ -266,7 +269,7 @@ _.prototype = {
}
},

select: function (selected, origin) {
select: function (selected, origin, originalEvent) {
if (selected) {
this.index = $.siblingIndex(selected);
} else {
Expand All @@ -278,14 +281,16 @@ _.prototype = {

var allowed = $.fire(this.input, "awesomplete-select", {
text: suggestion,
origin: origin || selected
origin: origin || selected,
originalEvent: originalEvent
});

if (allowed) {
this.replace(suggestion);
this.close({ reason: "select" });
$.fire(this.input, "awesomplete-selectcomplete", {
text: suggestion
text: suggestion,
originalEvent: originalEvent
});
}
}
Expand Down Expand Up @@ -369,8 +374,9 @@ _.ITEM = function (text, input, item_id) {
var html = input.trim() === "" ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>");
return $.create("li", {
innerHTML: html,
"role": "option",
"aria-selected": "false",
"id": "awesomplete_list_" + this.count + "_item_" + item_id
"id": "awesomplete_list_" + this.count + "_item_" + item_id
});
};

Expand Down
2 changes: 1 addition & 1 deletion awesomplete.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion awesomplete.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit b6bb273

Please sign in to comment.