diff --git a/README.md b/README.md index f925e4ad..7e8b1737 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ There are multiple customizations and properties able to be instantiated within | `maxItems` | `data-maxitems` | Maximum number of suggestions to display. | Number | `10` | | `autoFirst` | `data-autofirst` | Should the first element be automatically | Boolean | `false` | | `listLabel` | `data-listlabel` | Denotes a label to be used as aria-label on the generated autocomplete list. | String | Results List | +| `listContainer` | `data-listcontainer` | Optional container where the list will be generated ; ex: `document.body`. | HMTL Element | created by the lib | ## License diff --git a/awesomplete.base.css b/awesomplete.base.css index 8e5ec125..f413abae 100644 --- a/awesomplete.base.css +++ b/awesomplete.base.css @@ -16,7 +16,8 @@ display: block; } -.awesomplete > ul { +.awesomplete > ul, +ul.awesomplete-suggestion-list { position: absolute; left: 0; z-index: 1; @@ -28,6 +29,7 @@ background: #fff; } -.awesomplete > ul:empty { +.awesomplete > ul:empty, +ul.awesomplete-suggestion-list:empty { display: none; } diff --git a/awesomplete.css b/awesomplete.css index 0b2ea34f..f9b9689b 100644 --- a/awesomplete.css +++ b/awesomplete.css @@ -16,7 +16,8 @@ display: block; } -.awesomplete > ul { +.awesomplete > ul, +ul.awesomplete-suggestion-list { position: absolute; left: 0; z-index: 1; @@ -28,11 +29,13 @@ background: #fff; } -.awesomplete > ul:empty { +.awesomplete > ul:empty, +ul.awesomplete-suggestion-list:empty { display: none; } -.awesomplete > ul { +.awesomplete > ul, +ul.awesomplete-suggestion-list { border-radius: .3em; margin: .2em 0 0; background: hsla(0,0%,100%,.9); @@ -43,13 +46,16 @@ } @supports (transform: scale(0)) { - .awesomplete > ul { + .awesomplete > ul, + ul.awesomplete-suggestion-list { transition: .3s cubic-bezier(.4,.2,.5,1.4); transform-origin: 1.43em -.43em; } .awesomplete > ul[hidden], - .awesomplete > ul:empty { + .awesomplete > ul:empty, + ul.awesomplete-suggestion-list[hidden], + ul.awesomplete-suggestion-list:empty { opacity: 0; transform: scale(0); display: block; @@ -58,7 +64,9 @@ } /* Pointer */ - .awesomplete > ul:before { + + .awesomplete > ul:before, + ul.awesomplete-suggestion-list:before { content: ""; position: absolute; top: -.43em; @@ -73,18 +81,21 @@ transform: rotate(45deg); } - .awesomplete > ul > li { + .awesomplete > ul > li, + ul.awesomplete-suggestion-list > li { position: relative; padding: .2em .5em; cursor: pointer; } - .awesomplete > ul > li:hover { + .awesomplete > ul > li:hover, + ul.awesomplete-suggestion-list > li:hover { background: hsl(200, 40%, 80%); color: black; } - .awesomplete > ul > li[aria-selected="true"] { + .awesomplete > ul >li [aria-selected="true"], + ul.awesomplete-suggestion-list > li[aria-selected="true"] { background: hsl(205, 40%, 40%); color: white; } diff --git a/awesomplete.css.map b/awesomplete.css.map index 3d578397..eb1b260c 100644 --- a/awesomplete.css.map +++ b/awesomplete.css.map @@ -1 +1 @@ -{"version":3,"sources":["awesomplete.base.css","awesomplete.theme.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"awesomplete.css","sourcesContent":[".awesomplete [hidden] {\n display: none;\n}\n\n.awesomplete .visually-hidden {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n}\n\n.awesomplete {\n display: inline-block;\n position: relative;\n}\n\n.awesomplete > input {\n display: block;\n}\n\n.awesomplete > ul {\n position: absolute;\n left: 0;\n z-index: 1;\n min-width: 100%;\n box-sizing: border-box;\n list-style: none;\n padding: 0;\n margin: 0;\n background: #fff;\n}\n\n.awesomplete > ul:empty {\n display: none;\n}\n",".awesomplete > ul {\n\tborder-radius: .3em;\n\tmargin: .2em 0 0;\n\tbackground: hsla(0,0%,100%,.9);\n\tbackground: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));\n\tborder: 1px solid rgba(0,0,0,.3);\n\tbox-shadow: .05em .2em .6em rgba(0,0,0,.2);\n\ttext-shadow: none;\n}\n\n@supports (transform: scale(0)) {\n\t.awesomplete > ul {\n\t\ttransition: .3s cubic-bezier(.4,.2,.5,1.4);\n\t\ttransform-origin: 1.43em -.43em;\n\t}\n\t\n\t.awesomplete > ul[hidden],\n\t.awesomplete > ul:empty {\n\t\topacity: 0;\n\t\ttransform: scale(0);\n\t\tdisplay: block;\n\t\ttransition-timing-function: ease;\n\t}\n}\n\n\t/* Pointer */\n\t.awesomplete > ul:before {\n\t\tcontent: \"\";\n\t\tposition: absolute;\n\t\ttop: -.43em;\n\t\tleft: 1em;\n\t\twidth: 0; height: 0;\n\t\tpadding: .4em;\n\t\tbackground: white;\n\t\tborder: inherit;\n\t\tborder-right: 0;\n\t\tborder-bottom: 0;\n\t\t-webkit-transform: rotate(45deg);\n\t\ttransform: rotate(45deg);\n\t}\n\n\t.awesomplete > ul > li {\n\t\tposition: relative;\n\t\tpadding: .2em .5em;\n\t\tcursor: pointer;\n\t}\n\t\n\t.awesomplete > ul > li:hover {\n\t\tbackground: hsl(200, 40%, 80%);\n\t\tcolor: black;\n\t}\n\t\n\t.awesomplete > ul > li[aria-selected=\"true\"] {\n\t\tbackground: hsl(205, 40%, 40%);\n\t\tcolor: white;\n\t}\n\t\n\t\t.awesomplete mark {\n\t\t\tbackground: hsl(65, 100%, 50%);\n\t\t}\n\t\t\n\t\t.awesomplete li:hover mark {\n\t\t\tbackground: hsl(68, 100%, 41%);\n\t\t}\n\t\t\n\t\t.awesomplete li[aria-selected=\"true\"] mark {\n\t\t\tbackground: hsl(86, 100%, 21%);\n\t\t\tcolor: inherit;\n\t\t}"]} \ No newline at end of file +{"version":3,"sources":["awesomplete.base.css","awesomplete.theme.css"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACnCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"awesomplete.css","sourcesContent":[".awesomplete [hidden] {\n display: none;\n}\n\n.awesomplete .visually-hidden {\n position: absolute;\n clip: rect(0, 0, 0, 0);\n}\n\n.awesomplete {\n display: inline-block;\n position: relative;\n}\n\n.awesomplete > input {\n display: block;\n}\n\n.awesomplete > ul,\nul.awesomplete-suggestion-list {\n position: absolute;\n left: 0;\n z-index: 1;\n min-width: 100%;\n box-sizing: border-box;\n list-style: none;\n padding: 0;\n margin: 0;\n background: #fff;\n}\n\n.awesomplete > ul:empty,\nul.awesomplete-suggestion-list:empty {\n display: none;\n}\n",".awesomplete > ul,\nul.awesomplete-suggestion-list {\n\tborder-radius: .3em;\n\tmargin: .2em 0 0;\n\tbackground: hsla(0,0%,100%,.9);\n\tbackground: linear-gradient(to bottom right, white, hsla(0,0%,100%,.8));\n\tborder: 1px solid rgba(0,0,0,.3);\n\tbox-shadow: .05em .2em .6em rgba(0,0,0,.2);\n\ttext-shadow: none;\n}\n\n@supports (transform: scale(0)) {\n\t.awesomplete > ul,\n\tul.awesomplete-suggestion-list {\n\t\ttransition: .3s cubic-bezier(.4,.2,.5,1.4);\n\t\ttransform-origin: 1.43em -.43em;\n\t}\n\t\n\t.awesomplete > ul[hidden],\n\t.awesomplete > ul:empty,\n\tul.awesomplete-suggestion-list[hidden],\n\tul.awesomplete-suggestion-list:empty {\n\t\topacity: 0;\n\t\ttransform: scale(0);\n\t\tdisplay: block;\n\t\ttransition-timing-function: ease;\n\t}\n}\n\n\t/* Pointer */\n\n\t.awesomplete > ul:before,\n\tul.awesomplete-suggestion-list:before {\n\t\tcontent: \"\";\n\t\tposition: absolute;\n\t\ttop: -.43em;\n\t\tleft: 1em;\n\t\twidth: 0; height: 0;\n\t\tpadding: .4em;\n\t\tbackground: white;\n\t\tborder: inherit;\n\t\tborder-right: 0;\n\t\tborder-bottom: 0;\n\t\t-webkit-transform: rotate(45deg);\n\t\ttransform: rotate(45deg);\n\t}\n\n\t.awesomplete > ul > li,\n\tul.awesomplete-suggestion-list > li {\n\t\tposition: relative;\n\t\tpadding: .2em .5em;\n\t\tcursor: pointer;\n\t}\n\t\n\t.awesomplete > ul > li:hover,\n\tul.awesomplete-suggestion-list > li:hover {\n\t\tbackground: hsl(200, 40%, 80%);\n\t\tcolor: black;\n\t}\n\t\n\t.awesomplete > ul >li [aria-selected=\"true\"],\n\tul.awesomplete-suggestion-list > li[aria-selected=\"true\"] {\n\t\tbackground: hsl(205, 40%, 40%);\n\t\tcolor: white;\n\t}\n\t\n\t\t.awesomplete mark {\n\t\t\tbackground: hsl(65, 100%, 50%);\n\t\t}\n\t\t\n\t\t.awesomplete li:hover mark {\n\t\t\tbackground: hsl(68, 100%, 41%);\n\t\t}\n\t\t\n\t\t.awesomplete li[aria-selected=\"true\"] mark {\n\t\t\tbackground: hsl(86, 100%, 21%);\n\t\t\tcolor: inherit;\n\t\t}"]} \ No newline at end of file diff --git a/awesomplete.js b/awesomplete.js index 95188f21..371a7b3e 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -38,6 +38,7 @@ var _ = function (input, o) { container: _.CONTAINER, item: _.ITEM, replace: _.REPLACE, + listContainer: _.CONTAINER, tabSelect: false, listLabel: "Results List" }, o); @@ -52,8 +53,9 @@ var _ = function (input, o) { hidden: "hidden", role: "listbox", id: "awesomplete_list_" + this.count, - inside: this.container, - "aria-label": this.listLabel + inside: + me.listContainer === _.CONTAINER ? me.container : me.listContainer, + "aria-label": this.listLabel, }); this.status = $.create("span", { @@ -69,14 +71,14 @@ var _ = function (input, o) { this._events = { input: { - "input": this.evaluate.bind(this), - "blur": this.close.bind(this, { reason: "blur" }), - "keydown": function(evt) { + input: this.evaluate.bind(this), + blur: this.close.bind(this, { reason: "blur" }), + keydown: function (evt) { var c = evt.keyCode; // If the dropdown `ul` is in view, then act on keydown for the following keys: // Enter / Esc / Up / Down - if(me.opened) { + if (me.opened) { if (c === 13 && me.selected) { // Enter evt.preventDefault(); me.select(undefined, undefined, evt); @@ -90,23 +92,23 @@ var _ = function (input, o) { } else if (c === 38 || c === 40) { // Down/Up arrow evt.preventDefault(); - me[c === 38? "previous" : "next"](); + me[c === 38 ? "previous" : "next"](); } } } }, form: { - "submit": this.close.bind(this, { reason: "submit" }) + submit: this.close.bind(this, { reason: "submit" }) }, ul: { // Prevent the default mousedowm, which ensures the input is not blurred. // The actual selection will happen on click. This also ensures dragging the // cursor away from the list item will cancel the selection - "mousedown": function(evt) { + mousedown: function (evt) { evt.preventDefault(); }, // The click event is fired even if the corresponding mousedown event has called preventDefault - "click": function(evt) { + click: function (evt) { var li = evt.target; if (li !== this) { @@ -121,12 +123,23 @@ var _ = function (input, o) { } } } - } + }, + window: { + scroll: function () { + var boundingRect = me.container.getBoundingClientRect(); + me.ul.style.top = boundingRect.top + boundingRect.height + "px"; + me.ul.style.left = boundingRect.left + "px"; + me.ul.style.minWidth = boundingRect.width + "px"; + }, + }, }; $.bind(this.input, this._events.input); $.bind(this.input.form, this._events.form); $.bind(this.ul, this._events.ul); + if (this.listContainer !== _.CONTAINER) { + $.bind(window, this._events.window); + } if (this.input.hasAttribute("list")) { this.list = "#" + this.input.getAttribute("list"); @@ -195,6 +208,17 @@ _.prototype = { }, open: function () { + if (this.listContainer !== _.CONTAINER) { + // In case the suggestion list is out of the container, + // get the bounding information of the container to set the position of the suggestion list below + var boundingRect = this.container.getBoundingClientRect(); + this.ul.style.top = boundingRect.top + boundingRect.height + "px"; + this.ul.style.left = boundingRect.left + "px"; + this.ul.style.position = "fixed"; + this.ul.style.transitionProperty = "height, width, transform"; + this.ul.style.minWidth = boundingRect.width + "px"; + this.ul.className = "awesomplete-suggestion-list"; + } this.input.setAttribute("aria-expanded", "true"); this.ul.removeAttribute("hidden"); this.isOpened = true; @@ -208,18 +232,25 @@ _.prototype = { $.fire(this.input, "awesomplete-open"); }, - destroy: function() { + destroy: function () { //remove events from the input and its form $.unbind(this.input, this._events.input); $.unbind(this.input.form, this._events.form); + if (this.listContainer !== _.CONTAINER) { + $.unbind(window, this._events.window); + } // cleanup container if it was created by Awesomplete but leave it alone otherwise if (!this.options.container) { //move the input out of the awesomplete container and remove the container and its children var parentNode = this.container.parentNode; - - parentNode.insertBefore(this.input, this.container); - parentNode.removeChild(this.container); + if (this.listContainer !== _.CONTAINER) { + var ulParentNode = this.ul.parentNode; + ulParentNode.removeChild(this.ul); + } else { + parentNode.insertBefore(this.input, this.container); + parentNode.removeChild(this.container); + } } //remove autocomplete and aria-autocomplete attributes @@ -299,7 +330,7 @@ _.prototype = { } }, - evaluate: function() { + evaluate: function () { var me = this; var value = this.input.value; @@ -309,10 +340,10 @@ _.prototype = { this.ul.innerHTML = ""; this.suggestions = this._list - .map(function(item) { + .map(function (item) { return new Suggestion(me.data(item, value)); }) - .filter(function(item) { + .filter(function (item) { return me.filter(item, value); }); @@ -322,7 +353,7 @@ _.prototype = { this.suggestions = this.suggestions.slice(0, this.maxItems); - this.suggestions.forEach(function(text, index) { + this.suggestions.forEach(function (text, index) { me.ul.appendChild(me.item(text, value, index)); }); @@ -363,7 +394,7 @@ _.SORT_BYLENGTH = function (a, b) { return a.length - b.length; } - return a < b? -1 : 1; + return a < b ? -1 : 1; }; _.CONTAINER = function (input) { @@ -371,15 +402,15 @@ _.CONTAINER = function (input) { className: "awesomplete", around: input }); -} +}; _.ITEM = function (text, input, item_id) { var html = input.trim() === "" ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "$&"); return $.create("li", { innerHTML: html, - "role": "option", + role: "option", "aria-selected": "false", - "id": "awesomplete_list_" + this.count + "_item_" + item_id + id: "awesomplete_list_" + this.count + "_item_" + item_id }); }; @@ -442,7 +473,7 @@ function $$(expr, con) { return slice.call((con || document).querySelectorAll(expr)); } -$.create = function(tag, o) { +$.create = function (tag, o) { var element = document.createElement(tag); for (var i in o) { @@ -471,7 +502,7 @@ $.create = function(tag, o) { return element; }; -$.bind = function(element, o) { +$.bind = function (element, o) { if (element) { for (var event in o) { var callback = o[event]; @@ -483,22 +514,22 @@ $.bind = function(element, o) { } }; -$.unbind = function(element, o) { +$.unbind = function (element, o) { if (element) { for (var event in o) { var callback = o[event]; - event.split(/\s+/).forEach(function(event) { + event.split(/\s+/).forEach(function (event) { element.removeEventListener(event, callback); }); } } }; -$.fire = function(target, type, properties) { +$.fire = function (target, type, properties) { var evt = document.createEvent("HTMLEvents"); - evt.initEvent(type, true, true ); + evt.initEvent(type, true, true); for (var j in properties) { evt[j] = properties[j]; @@ -513,7 +544,7 @@ $.regExpEscape = function (s) { $.siblingIndex = function (el) { /* eslint-disable no-cond-assign */ - for (var i = 0; el = el.previousElementSibling; i++); + for (var i = 0; (el = el.previousElementSibling); i++); return i; }; diff --git a/awesomplete.min.js b/awesomplete.min.js index aa019a24..7b70c8c0 100644 --- a/awesomplete.min.js +++ b/awesomplete.min.js @@ -1,3 +1,3 @@ // Awesomplete - Lea Verou - MIT license -!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):!1===s?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;r.count=(r.count||0)+1,this.count=r.count,this.isOpened=!1,this.input=i(t),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"),this.options=n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:!1!==n.sort&&r.SORT_BYLENGTH,container:r.CONTAINER,item:r.ITEM,replace:r.REPLACE,tabSelect:!1,listLabel:"Results List"},n),this.index=-1,this.container=this.container(t),this.ul=i.create("ul",{hidden:"hidden",role:"listbox",id:"awesomplete_list_"+this.count,inside:this.container,"aria-label":this.listLabel}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:0!=this.minChars?"Type "+this.minChars+" or more characters for results.":"Begin typing for results."}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select(void 0,void 0,t)):9===e&&s.selected&&s.tabSelect?s.select(void 0,void 0,t):27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){t.preventDefault()},click:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target,t))}}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.input.setAttribute("aria-expanded","false"),this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.input.setAttribute("aria-expanded","true"),this.ul.removeAttribute("hidden"),this.isOpened=!0,this.status.removeAttribute("hidden"),this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){if(i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form),!this.options.container){var t=this.container.parentNode;t.insertBefore(this.input,this.container),t.removeChild(this.container)}this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=r.all.indexOf(this);-1!==e&&r.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent+", list item "+(t+1)+" of "+e.length,this.input.setAttribute("aria-activedescendant",this.ul.id+"_item_"+this.index),this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e,n){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var s=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:s,origin:e||t,originalEvent:n})&&(this.replace(s),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:s,originalEvent:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.maxItems),this.suggestions.forEach(function(t,n){e.ul.appendChild(e.item(t,i,n))}),0===this.ul.children.length?(this.status.textContent="No results found",this.close({reason:"nomatches"})):(this.open(),this.status.textContent=this.ul.children.length+" results found")):(this.close({reason:"nomatches"}),this.status.textContent="No results found")}},r.all=[],r.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},r.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},r.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t$&"),role:"option","aria-selected":"false",id:"awesomplete_list_"+this.count+"_item_"+n})},r.REPLACE=function(t){this.input.value=t.value},r.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var o=Array.prototype.slice;i.create=function(t,e){var n=document.createElement(t);for(var s in e){var r=e[s];if("inside"===s)i(r).appendChild(n);else if("around"===s){var o=i(r);o.parentNode.insertBefore(n,o),n.appendChild(o),null!=o.getAttribute("autofocus")&&o.focus()}else s in n?n[s]=r:n.setAttribute(s,r)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.unbind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof self&&(self.Awesomplete=r),"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),r.$=i,r.$$=n,"object"==typeof module&&module.exports&&(module.exports=r)}(); +!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],o=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(o):!1===s?t[n]=null!==o:s instanceof Function?t[n]=null:t[n]=o,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return r.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new o(t)})}var o=function(t,n){var s=this;o.count=(o.count||0)+1,this.count=o.count,this.isOpened=!1,this.input=i(t),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"),this.options=n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:o.DATA,filter:o.FILTER_CONTAINS,sort:!1!==n.sort&&o.SORT_BYLENGTH,container:o.CONTAINER,item:o.ITEM,replace:o.REPLACE,listContainer:o.CONTAINER,tabSelect:!1,listLabel:"Results List"},n),this.index=-1,this.container=this.container(t),this.ul=i.create("ul",{hidden:"hidden",inside:s.listContainer===o.CONTAINER?s.container:s.listContainer,role:"listbox",id:"awesomplete_list_"+this.count,"aria-label":this.listLabel}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:0!=this.minChars?"Type "+this.minChars+" or more characters for results.":"Begin typing for results."}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select(void 0,void 0,t)):9===e&&s.selected&&s.tabSelect?(t.preventDefault(),s.select(void 0,void 0,t)):27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){t.preventDefault()},click:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target,t))}}},window:{scroll:function(){var t=s.container.getBoundingClientRect();s.ul.style.top=t.top+t.height+"px",s.ul.style.left=t.left+"px",s.ul.style.minWidth=t.width+"px"}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.listContainer!==o.CONTAINER&&i.bind(window,this._events.window),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],o.all.push(this)};o.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];r.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.input.setAttribute("aria-expanded","false"),this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),i.fire(this.input,"awesomplete-close",t||{}))},open:function(){if(this.listContainer!==o.CONTAINER){var t=this.container.getBoundingClientRect();this.ul.style.top=t.top+t.height+"px",this.ul.style.left=t.left+"px",this.ul.style.position="fixed",this.ul.style.transitionProperty="height, width, transform",this.ul.style.minWidth=t.width+"px",this.ul.className="awesomplete-suggestion-list"}this.input.setAttribute("aria-expanded","true"),this.ul.removeAttribute("hidden"),this.isOpened=!0,this.status.removeAttribute("hidden"),this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){if(i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form),this.listContainer!==o.CONTAINER&&i.unbind(window,this._events.window),!this.options.container){var t=this.container.parentNode;if(this.listContainer!==o.CONTAINER){this.ul.parentNode.removeChild(this.ul)}else t.insertBefore(this.input,this.container),t.removeChild(this.container)}this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=o.all.indexOf(this);-1!==e&&o.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent+", list item "+(t+1)+" of "+e.length,this.input.setAttribute("aria-activedescendant",this.ul.id+"_item_"+this.index),this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e,n){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var s=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:s,origin:e||t,originalEvent:n})&&(this.replace(s),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:s,originalEvent:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.maxItems),this.suggestions.forEach(function(t,n){e.ul.appendChild(e.item(t,i,n))}),0===this.ul.children.length?(this.status.textContent="No results found",this.close({reason:"nomatches"})):(this.open(),this.status.textContent=this.ul.children.length+" results found")):(this.close({reason:"nomatches"}),this.status.textContent="No results found")}},o.all=[],o.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},o.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},o.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t$&"),role:"option","aria-selected":"false",id:"awesomplete_list_"+this.count+"_item_"+n})},o.REPLACE=function(t){this.input.value=t.value},o.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var r=Array.prototype.slice;i.create=function(t,e){var n=document.createElement(t);for(var s in e){var o=e[s];if("inside"===s)i(o).appendChild(n);else if("around"===s){var r=i(o);r.parentNode.insertBefore(n,r),n.appendChild(r),null!=r.getAttribute("autofocus")&&r.focus()}else s in n?n[s]=o:n.setAttribute(s,o)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.unbind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof self&&(self.Awesomplete=o),"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),o.$=i,o.$$=n,"object"==typeof module&&module.exports&&(module.exports=o)}(); //# sourceMappingURL=awesomplete.min.js.map diff --git a/awesomplete.min.js.map b/awesomplete.min.js.map index 14802dbd..ebc720f7 100644 --- a/awesomplete.min.js.map +++ b/awesomplete.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["awesomplete.js"],"names":["Suggestion","data","o","Array","isArray","label","value","this","configure","instance","properties","i","initial","attrValue","input","getAttribute","toLowerCase","parseInt","Function","$","expr","con","document","querySelector","$$","slice","call","querySelectorAll","init","forEach","_","me","count","isOpened","setAttribute","options","minChars","maxItems","autoFirst","DATA","filter","FILTER_CONTAINS","sort","SORT_BYLENGTH","container","CONTAINER","item","ITEM","replace","REPLACE","tabSelect","listLabel","index","ul","create","hidden","role","id","inside","aria-label","status","className","aria-live","aria-atomic","textContent","_events","evaluate","bind","blur","close","reason","keydown","evt","c","keyCode","opened","selected","preventDefault","select","undefined","form","submit","mousedown","click","li","target","test","nodeName","parentNode","button","hasAttribute","list","removeAttribute","all","push","prototype","_list","indexOf","split","children","items","apply","el","disabled","text","trim","activeElement","fire","open","goto","destroy","unbind","insertBefore","removeChild","indexOfAwesomplete","splice","next","length","previous","pos","lis","scrollTop","offsetTop","clientHeight","suggestions","origin","originalEvent","siblingIndex","suggestion","innerHTML","map","appendChild","RegExp","regExpEscape","FILTER_STARTSWITH","a","b","around","item_id","aria-selected","Object","defineProperty","String","get","toString","valueOf","tag","element","createElement","val","ref","focus","event","callback","addEventListener","removeEventListener","type","createEvent","initEvent","j","dispatchEvent","s","previousElementSibling","self","Awesomplete","Document","readyState","module","exports"],"mappings":";CAOC,WAiYD,QAASA,GAAWC,GACnB,GAAIC,GAAIC,MAAMC,QAAQH,IAChBI,MAAOJ,EAAK,GAAIK,MAAOL,EAAK,IACd,gBAATA,IAAqB,SAAWA,IAAQ,SAAWA,GAAOA,GAASI,MAAOJ,EAAMK,MAAOL,EAElGM,MAAKF,MAAQH,EAAEG,OAASH,EAAEI,MAC1BC,KAAKD,MAAQJ,EAAEI,MAShB,QAASE,GAAUC,EAAUC,EAAYR,GACxC,IAAK,GAAIS,KAAKD,GAAY,CAC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F,GAAM,GAAM,EAE1B,KAAK,GAAIG,KAAKrJ,GACb8D,EAAIuF,GAAKrJ,EAAWqJ,EAGrB,OAAO1E,GAAO2E,cAAcxF,IAG7BrD,EAAEkH,aAAe,SAAU4B,GAC1B,MAAOA,GAAEjH,QAAQ,uBAAwB,SAG1C7B,EAAE4G,aAAe,SAAUzB,GAE1B,IAAK,GAAI3F,GAAI,EAAG2F,EAAKA,EAAG4D,uBAAwBvJ,KAChD,MAAOA,IAYY,mBAATwJ,QACVA,KAAKC,YAActI,GAII,mBAAbuI,YAEkB,YAAxB/I,SAASgJ,WACZ1I,IAIAN,SAASoI,iBAAiB,mBAAoB9H,IAIhDE,EAAEX,EAAIA,EACNW,EAAEN,GAAKA,EAGe,gBAAX+I,SAAuBA,OAAOC,UACxCD,OAAOC,QAAU1I","file":"awesomplete.min.js","sourcesContent":["/**\n * Simple, lightweight, usable local autocomplete library for modern browsers\n * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P\n * @author Lea Verou http://leaverou.github.io/awesomplete\n * MIT license\n */\n\n(function () {\n\nvar _ = function (input, o) {\n\tvar me = this;\n\n // Keep track of number of instances for unique IDs\n _.count = (_.count || 0) + 1;\n this.count = _.count;\n\n\t// Setup\n\n\tthis.isOpened = false;\n\n\tthis.input = $(input);\n\tthis.input.setAttribute(\"autocomplete\", \"off\");\n\tthis.input.setAttribute(\"aria-expanded\", \"false\");\n\tthis.input.setAttribute(\"aria-owns\", \"awesomplete_list_\" + this.count);\n\tthis.input.setAttribute(\"role\", \"combobox\");\n\n\t// store constructor options in case we need to distinguish\n\t// between default and customized behavior later on\n\tthis.options = o = o || {};\n\n\tconfigure(this, {\n\t\tminChars: 2,\n\t\tmaxItems: 10,\n\t\tautoFirst: false,\n\t\tdata: _.DATA,\n\t\tfilter: _.FILTER_CONTAINS,\n\t\tsort: o.sort === false ? false : _.SORT_BYLENGTH,\n\t\tcontainer: _.CONTAINER,\n\t\titem: _.ITEM,\n\t\treplace: _.REPLACE,\n\t\ttabSelect: false,\n\t\tlistLabel: \"Results List\"\n\t}, o);\n\n\tthis.index = -1;\n\n\t// Create necessary elements\n\n\tthis.container = this.container(input);\n\n\tthis.ul = $.create(\"ul\", {\n\t\thidden: \"hidden\",\n role: \"listbox\",\n id: \"awesomplete_list_\" + this.count,\n\t\tinside: this.container,\n\t\t\"aria-label\": this.listLabel\n\t});\n\n\tthis.status = $.create(\"span\", {\n\t\tclassName: \"visually-hidden\",\n\t\trole: \"status\",\n\t\t\"aria-live\": \"assertive\",\n \"aria-atomic\": true,\n inside: this.container,\n textContent: this.minChars != 0 ? (\"Type \" + this.minChars + \" or more characters for results.\") : \"Begin typing for results.\"\n\t});\n\n\t// Bind events\n\n\tthis._events = {\n\t\tinput: {\n\t\t\t\"input\": this.evaluate.bind(this),\n\t\t\t\"blur\": this.close.bind(this, { reason: \"blur\" }),\n\t\t\t\"keydown\": function(evt) {\n\t\t\t\tvar c = evt.keyCode;\n\n\t\t\t\t// If the dropdown `ul` is in view, then act on keydown for the following keys:\n\t\t\t\t// Enter / Esc / Up / Down\n\t\t\t\tif(me.opened) {\n\t\t\t\t\tif (c === 13 && me.selected) { // Enter\n\t\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\t\tme.select(undefined, undefined, evt);\n\t\t\t\t\t}\n\t\t\t\t\telse if (c === 9 && me.selected && me.tabSelect) {\n\t\t\t\t\t\tme.select(undefined, undefined, evt);\n\t\t\t\t\t}\n\t\t\t\t\telse if (c === 27) { // Esc\n\t\t\t\t\t\tme.close({ reason: \"esc\" });\n\t\t\t\t\t}\n\t\t\t\t\telse if (c === 38 || c === 40) { // Down/Up arrow\n\t\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\t\tme[c === 38? \"previous\" : \"next\"]();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tform: {\n\t\t\t\"submit\": this.close.bind(this, { reason: \"submit\" })\n\t\t},\n\t\tul: {\n\t\t\t// Prevent the default mousedowm, which ensures the input is not blurred.\n\t\t\t// The actual selection will happen on click. This also ensures dragging the\n\t\t\t// cursor away from the list item will cancel the selection\n\t\t\t\"mousedown\": function(evt) {\n\t\t\t\tevt.preventDefault();\n\t\t\t},\n\t\t\t// The click event is fired even if the corresponding mousedown event has called preventDefault\n\t\t\t\"click\": function(evt) {\n\t\t\t\tvar li = evt.target;\n\n\t\t\t\tif (li !== this) {\n\n\t\t\t\t\twhile (li && !/li/i.test(li.nodeName)) {\n\t\t\t\t\t\tli = li.parentNode;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (li && evt.button === 0) { // Only select on left click\n\t\t\t\t\t\tevt.preventDefault();\n\t\t\t\t\t\tme.select(li, evt.target, evt);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t$.bind(this.input, this._events.input);\n\t$.bind(this.input.form, this._events.form);\n\t$.bind(this.ul, this._events.ul);\n\n\tif (this.input.hasAttribute(\"list\")) {\n\t\tthis.list = \"#\" + this.input.getAttribute(\"list\");\n\t\tthis.input.removeAttribute(\"list\");\n\t}\n\telse {\n\t\tthis.list = this.input.getAttribute(\"data-list\") || o.list || [];\n\t}\n\n\t_.all.push(this);\n};\n\n_.prototype = {\n\tset list(list) {\n\t\tif (Array.isArray(list)) {\n\t\t\tthis._list = list;\n\t\t}\n\t\telse if (typeof list === \"string\" && list.indexOf(\",\") > -1) {\n\t\t\t\tthis._list = list.split(/\\s*,\\s*/);\n\t\t}\n\t\telse { // Element or CSS selector\n\t\t\tlist = $(list);\n\n\t\t\tif (list && list.children) {\n\t\t\t\tvar items = [];\n\t\t\t\tslice.apply(list.children).forEach(function (el) {\n\t\t\t\t\tif (!el.disabled) {\n\t\t\t\t\t\tvar text = el.textContent.trim();\n\t\t\t\t\t\tvar value = el.value || text;\n\t\t\t\t\t\tvar label = el.label || text;\n\t\t\t\t\t\tif (value !== \"\") {\n\t\t\t\t\t\t\titems.push({ label: label, value: value });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis._list = items;\n\t\t\t}\n\t\t}\n\n\t\tif (document.activeElement === this.input) {\n\t\t\tthis.evaluate();\n\t\t}\n\t},\n\n\tget selected() {\n\t\treturn this.index > -1;\n\t},\n\n\tget opened() {\n\t\treturn this.isOpened;\n\t},\n\n\tclose: function (o) {\n\t\tif (!this.opened) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.input.setAttribute(\"aria-expanded\", \"false\");\n\t\tthis.ul.setAttribute(\"hidden\", \"\");\n\t\tthis.isOpened = false;\n\t\tthis.index = -1;\n\n\t\tthis.status.setAttribute(\"hidden\", \"\");\n\n\t\t$.fire(this.input, \"awesomplete-close\", o || {});\n\t},\n\n\topen: function () {\n\t\tthis.input.setAttribute(\"aria-expanded\", \"true\");\n\t\tthis.ul.removeAttribute(\"hidden\");\n\t\tthis.isOpened = true;\n\n\t\tthis.status.removeAttribute(\"hidden\");\n\n\t\tif (this.autoFirst && this.index === -1) {\n\t\t\tthis.goto(0);\n\t\t}\n\n\t\t$.fire(this.input, \"awesomplete-open\");\n\t},\n\n\tdestroy: function() {\n\t\t//remove events from the input and its form\n\t\t$.unbind(this.input, this._events.input);\n\t\t$.unbind(this.input.form, this._events.form);\n\n\t\t// cleanup container if it was created by Awesomplete but leave it alone otherwise\n\t\tif (!this.options.container) {\n\t\t\t//move the input out of the awesomplete container and remove the container and its children\n\t\t\tvar parentNode = this.container.parentNode;\n\n\t\t\tparentNode.insertBefore(this.input, this.container);\n\t\t\tparentNode.removeChild(this.container);\n\t\t}\n\n\t\t//remove autocomplete and aria-autocomplete attributes\n\t\tthis.input.removeAttribute(\"autocomplete\");\n\t\tthis.input.removeAttribute(\"aria-autocomplete\");\n\n\t\t//remove this awesomeplete instance from the global array of instances\n\t\tvar indexOfAwesomplete = _.all.indexOf(this);\n\n\t\tif (indexOfAwesomplete !== -1) {\n\t\t\t_.all.splice(indexOfAwesomplete, 1);\n\t\t}\n\t},\n\n\tnext: function () {\n\t\tvar count = this.ul.children.length;\n\t\tthis.goto(this.index < count - 1 ? this.index + 1 : (count ? 0 : -1) );\n\t},\n\n\tprevious: function () {\n\t\tvar count = this.ul.children.length;\n\t\tvar pos = this.index - 1;\n\n\t\tthis.goto(this.selected && pos !== -1 ? pos : count - 1);\n\t},\n\n\t// Should not be used, highlights specific item without any checks!\n\tgoto: function (i) {\n\t\tvar lis = this.ul.children;\n\n\t\tif (this.selected) {\n\t\t\tlis[this.index].setAttribute(\"aria-selected\", \"false\");\n\t\t}\n\n\t\tthis.index = i;\n\n\t\tif (i > -1 && lis.length > 0) {\n\t\t\tlis[i].setAttribute(\"aria-selected\", \"true\");\n\n\t\t\tthis.status.textContent = lis[i].textContent + \", list item \" + (i + 1) + \" of \" + lis.length;\n\n this.input.setAttribute(\"aria-activedescendant\", this.ul.id + \"_item_\" + this.index);\n\n\t\t\t// scroll to highlighted element in case parent's height is fixed\n\t\t\tthis.ul.scrollTop = lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight;\n\n\t\t\t$.fire(this.input, \"awesomplete-highlight\", {\n\t\t\t\ttext: this.suggestions[this.index]\n\t\t\t});\n\t\t}\n\t},\n\n\tselect: function (selected, origin, originalEvent) {\n\t\tif (selected) {\n\t\t\tthis.index = $.siblingIndex(selected);\n\t\t} else {\n\t\t\tselected = this.ul.children[this.index];\n\t\t}\n\n\t\tif (selected) {\n\t\t\tvar suggestion = this.suggestions[this.index];\n\n\t\t\tvar allowed = $.fire(this.input, \"awesomplete-select\", {\n\t\t\t\ttext: suggestion,\n\t\t\t\torigin: origin || selected,\n\t\t\t\toriginalEvent: originalEvent\n\t\t\t});\n\n\t\t\tif (allowed) {\n\t\t\t\tthis.replace(suggestion);\n\t\t\t\tthis.close({ reason: \"select\" });\n\t\t\t\t$.fire(this.input, \"awesomplete-selectcomplete\", {\n\t\t\t\t\ttext: suggestion,\n\t\t\t\t\toriginalEvent: originalEvent\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n\n\tevaluate: function() {\n\t\tvar me = this;\n\t\tvar value = this.input.value;\n\n\t\tif (value.length >= this.minChars && this._list && this._list.length > 0) {\n\t\t\tthis.index = -1;\n\t\t\t// Populate list with options that match\n\t\t\tthis.ul.innerHTML = \"\";\n\n\t\t\tthis.suggestions = this._list\n\t\t\t\t.map(function(item) {\n\t\t\t\t\treturn new Suggestion(me.data(item, value));\n\t\t\t\t})\n\t\t\t\t.filter(function(item) {\n\t\t\t\t\treturn me.filter(item, value);\n\t\t\t\t});\n\n\t\t\tif (this.sort !== false) {\n\t\t\t\tthis.suggestions = this.suggestions.sort(this.sort);\n\t\t\t}\n\n\t\t\tthis.suggestions = this.suggestions.slice(0, this.maxItems);\n\n\t\t\tthis.suggestions.forEach(function(text, index) {\n\t\t\t\t\tme.ul.appendChild(me.item(text, value, index));\n\t\t\t\t});\n\n\t\t\tif (this.ul.children.length === 0) {\n\n this.status.textContent = \"No results found\";\n\n\t\t\t\tthis.close({ reason: \"nomatches\" });\n\n\t\t\t} else {\n\t\t\t\tthis.open();\n\n this.status.textContent = this.ul.children.length + \" results found\";\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.close({ reason: \"nomatches\" });\n\n this.status.textContent = \"No results found\";\n\t\t}\n\t}\n};\n\n// Static methods/properties\n\n_.all = [];\n\n_.FILTER_CONTAINS = function (text, input) {\n\treturn RegExp($.regExpEscape(input.trim()), \"i\").test(text);\n};\n\n_.FILTER_STARTSWITH = function (text, input) {\n\treturn RegExp(\"^\" + $.regExpEscape(input.trim()), \"i\").test(text);\n};\n\n_.SORT_BYLENGTH = function (a, b) {\n\tif (a.length !== b.length) {\n\t\treturn a.length - b.length;\n\t}\n\n\treturn a < b? -1 : 1;\n};\n\n_.CONTAINER = function (input) {\n\treturn $.create(\"div\", {\n\t\tclassName: \"awesomplete\",\n\t\taround: input\n\t});\n}\n\n_.ITEM = function (text, input, item_id) {\n\tvar html = input.trim() === \"\" ? text : text.replace(RegExp($.regExpEscape(input.trim()), \"gi\"), \"$&\");\n\treturn $.create(\"li\", {\n\t\tinnerHTML: html,\n\t\t\"role\": \"option\",\n\t\t\"aria-selected\": \"false\",\n\t\t\"id\": \"awesomplete_list_\" + this.count + \"_item_\" + item_id\n\t});\n};\n\n_.REPLACE = function (text) {\n\tthis.input.value = text.value;\n};\n\n_.DATA = function (item/*, input*/) { return item; };\n\n// Private functions\n\nfunction Suggestion(data) {\n\tvar o = Array.isArray(data)\n\t ? { label: data[0], value: data[1] }\n\t : typeof data === \"object\" && \"label\" in data && \"value\" in data ? data : { label: data, value: data };\n\n\tthis.label = o.label || o.value;\n\tthis.value = o.value;\n}\nObject.defineProperty(Suggestion.prototype = Object.create(String.prototype), \"length\", {\n\tget: function() { return this.label.length; }\n});\nSuggestion.prototype.toString = Suggestion.prototype.valueOf = function () {\n\treturn \"\" + this.label;\n};\n\nfunction configure(instance, properties, o) {\n\tfor (var i in properties) {\n\t\tvar initial = properties[i],\n\t\t attrValue = instance.input.getAttribute(\"data-\" + i.toLowerCase());\n\n\t\tif (typeof initial === \"number\") {\n\t\t\tinstance[i] = parseInt(attrValue);\n\t\t}\n\t\telse if (initial === false) { // Boolean options must be false by default anyway\n\t\t\tinstance[i] = attrValue !== null;\n\t\t}\n\t\telse if (initial instanceof Function) {\n\t\t\tinstance[i] = null;\n\t\t}\n\t\telse {\n\t\t\tinstance[i] = attrValue;\n\t\t}\n\n\t\tif (!instance[i] && instance[i] !== 0) {\n\t\t\tinstance[i] = (i in o)? o[i] : initial;\n\t\t}\n\t}\n}\n\n// Helpers\n\nvar slice = Array.prototype.slice;\n\nfunction $(expr, con) {\n\treturn typeof expr === \"string\"? (con || document).querySelector(expr) : expr || null;\n}\n\nfunction $$(expr, con) {\n\treturn slice.call((con || document).querySelectorAll(expr));\n}\n\n$.create = function(tag, o) {\n\tvar element = document.createElement(tag);\n\n\tfor (var i in o) {\n\t\tvar val = o[i];\n\n\t\tif (i === \"inside\") {\n\t\t\t$(val).appendChild(element);\n\t\t}\n\t\telse if (i === \"around\") {\n\t\t\tvar ref = $(val);\n\t\t\tref.parentNode.insertBefore(element, ref);\n\t\t\telement.appendChild(ref);\n\n\t\t\tif (ref.getAttribute(\"autofocus\") != null) {\n\t\t\t\tref.focus();\n\t\t\t}\n\t\t}\n\t\telse if (i in element) {\n\t\t\telement[i] = val;\n\t\t}\n\t\telse {\n\t\t\telement.setAttribute(i, val);\n\t\t}\n\t}\n\n\treturn element;\n};\n\n$.bind = function(element, o) {\n\tif (element) {\n\t\tfor (var event in o) {\n\t\t\tvar callback = o[event];\n\n\t\t\tevent.split(/\\s+/).forEach(function (event) {\n\t\t\t\telement.addEventListener(event, callback);\n\t\t\t});\n\t\t}\n\t}\n};\n\n$.unbind = function(element, o) {\n\tif (element) {\n\t\tfor (var event in o) {\n\t\t\tvar callback = o[event];\n\n\t\t\tevent.split(/\\s+/).forEach(function(event) {\n\t\t\t\telement.removeEventListener(event, callback);\n\t\t\t});\n\t\t}\n\t}\n};\n\n$.fire = function(target, type, properties) {\n\tvar evt = document.createEvent(\"HTMLEvents\");\n\n\tevt.initEvent(type, true, true );\n\n\tfor (var j in properties) {\n\t\tevt[j] = properties[j];\n\t}\n\n\treturn target.dispatchEvent(evt);\n};\n\n$.regExpEscape = function (s) {\n\treturn s.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n};\n\n$.siblingIndex = function (el) {\n\t/* eslint-disable no-cond-assign */\n\tfor (var i = 0; el = el.previousElementSibling; i++);\n\treturn i;\n};\n\n// Initialization\n\nfunction init() {\n\t$$(\"input.awesomplete\").forEach(function (input) {\n\t\tnew _(input);\n\t});\n}\n\n// Make sure to export Awesomplete on self when in a browser\nif (typeof self !== \"undefined\") {\n\tself.Awesomplete = _;\n}\n\n// Are we in a browser? Check for Document constructor\nif (typeof Document !== \"undefined\") {\n\t// DOM already loaded?\n\tif (document.readyState !== \"loading\") {\n\t\tinit();\n\t}\n\telse {\n\t\t// Wait for it\n\t\tdocument.addEventListener(\"DOMContentLoaded\", init);\n\t}\n}\n\n_.$ = $;\n_.$$ = $$;\n\n// Expose Awesomplete as a CJS module\nif (typeof module === \"object\" && module.exports) {\n\tmodule.exports = _;\n}\n\nreturn _;\n\n}());\n"]} \ No newline at end of file +{"version":3,"sources":["awesomplete.js"],"names":["Suggestion","data","o","Array","isArray","label","value","this","configure","instance","properties","i","initial","attrValue","input","getAttribute","toLowerCase","parseInt","Function","$","expr","con","document","querySelector","$$","slice","call","querySelectorAll","init","forEach","_","me","count","isOpened","setAttribute","options","minChars","maxItems","autoFirst","DATA","filter","FILTER_CONTAINS","sort","SORT_BYLENGTH","container","CONTAINER","item","ITEM","replace","REPLACE","listContainer","tabSelect","listLabel","index","ul","create","hidden","inside","role","id","aria-label","status","className","aria-live","aria-atomic","textContent","_events","evaluate","bind","blur","close","reason","keydown","evt","c","keyCode","opened","selected","preventDefault","select","undefined","form","submit","mousedown","click","li","target","test","nodeName","parentNode","button","window","scroll","boundingRect","getBoundingClientRect","style","top","height","left","minWidth","width","hasAttribute","list","removeAttribute","all","push","prototype","_list","indexOf","split","children","items","apply","el","disabled","text","trim","activeElement","fire","open","position","transitionProperty","goto","destroy","unbind","removeChild","insertBefore","indexOfAwesomplete","splice","next","length","previous","pos","lis","scrollTop","offsetTop","clientHeight","suggestions","origin","originalEvent","siblingIndex","suggestion","innerHTML","map","appendChild","RegExp","regExpEscape","FILTER_STARTSWITH","a","b","around","item_id","aria-selected","Object","defineProperty","String","get","toString","valueOf","tag","element","createElement","val","ref","focus","event","callback","addEventListener","removeEventListener","type","createEvent","initEvent","j","dispatchEvent","s","previousElementSibling","self","Awesomplete","Document","readyState","module","exports"],"mappings":";CAOA,WAmbE,QAASA,GAAWC,GAClB,GAAIC,GAAIC,MAAMC,QAAQH,IAChBI,MAAOJ,EAAK,GAAIK,MAAOL,EAAK,IACd,gBAATA,IAAqB,SAAWA,IAAQ,SAAWA,GAC1DA,GACEI,MAAOJ,EAAMK,MAAOL,EA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AAe,SAAU4B,GACzB,MAAOA,GAAE9H,QAAQ,uBAAwB,SAG3C7B,EAAEyH,aAAe,SAAU3B,GAEzB,IAAK,GAAItG,GAAI,EAAIsG,EAAKA,EAAG8D,uBAAyBpK,KAClD,MAAOA,IAYW,mBAATqK,QACTA,KAAKC,YAAcnJ,GAIG,mBAAboJ,YAEmB,YAAxB5J,SAAS6J,WACXvJ,IAGAN,SAASiJ,iBAAiB,mBAAoB3I,IAIlDE,EAAEX,EAAIA,EACNW,EAAEN,GAAKA,EAGe,gBAAX4J,SAAuBA,OAAOC,UACvCD,OAAOC,QAAUvJ","file":"awesomplete.min.js","sourcesContent":["/**\n * Simple, lightweight, usable local autocomplete library for modern browsers\n * Because there weren’t enough autocomplete scripts in the world? Because I’m completely insane and have NIH syndrome? Probably both. :P\n * @author Lea Verou http://leaverou.github.io/awesomplete\n * MIT license\n */\n\n(function () {\n var _ = function (input, o) {\n var me = this;\n\n // Keep track of number of instances for unique IDs\n _.count = (_.count || 0) + 1;\n this.count = _.count;\n\n // Setup\n\n this.isOpened = false;\n\n this.input = $(input);\n this.input.setAttribute(\"autocomplete\", \"off\");\n this.input.setAttribute(\"aria-expanded\", \"false\");\n this.input.setAttribute(\"aria-owns\", \"awesomplete_list_\" + this.count);\n this.input.setAttribute(\"role\", \"combobox\");\n\n // store constructor options in case we need to distinguish\n // between default and customized behavior later on\n this.options = o = o || {};\n\n configure(\n this,\n {\n minChars: 2,\n maxItems: 10,\n autoFirst: false,\n data: _.DATA,\n filter: _.FILTER_CONTAINS,\n sort: o.sort === false ? false : _.SORT_BYLENGTH,\n container: _.CONTAINER,\n item: _.ITEM,\n replace: _.REPLACE,\n listContainer: _.CONTAINER,\n tabSelect: false,\n listLabel: \"Results List\",\n },\n o\n );\n\n this.index = -1;\n\n // Create necessary elements\n\n this.container = this.container(input);\n\n this.ul = $.create(\"ul\", {\n hidden: \"hidden\",\n inside:\n me.listContainer === _.CONTAINER ? me.container : me.listContainer,\n role: \"listbox\",\n id: \"awesomplete_list_\" + this.count,\n \"aria-label\": this.listLabel,\n });\n\n this.status = $.create(\"span\", {\n className: \"visually-hidden\",\n role: \"status\",\n \"aria-live\": \"assertive\",\n \"aria-atomic\": true,\n inside: this.container,\n textContent:\n this.minChars != 0\n ? \"Type \" + this.minChars + \" or more characters for results.\"\n : \"Begin typing for results.\",\n });\n\n // Bind events\n\n this._events = {\n input: {\n input: this.evaluate.bind(this),\n blur: this.close.bind(this, { reason: \"blur\" }),\n keydown: function (evt) {\n var c = evt.keyCode;\n\n // If the dropdown `ul` is in view, then act on keydown for the following keys:\n // Enter / Esc / Up / Down\n if (me.opened) {\n if (c === 13 && me.selected) {\n // Enter\n evt.preventDefault();\n me.select(undefined, undefined, evt);\n } else if (c === 9 && me.selected && me.tabSelect) {\n evt.preventDefault();\n me.select(undefined, undefined, evt);\n } else if (c === 27) {\n // Esc\n me.close({ reason: \"esc\" });\n } else if (c === 38 || c === 40) {\n // Down/Up arrow\n evt.preventDefault();\n me[c === 38 ? \"previous\" : \"next\"]();\n }\n }\n },\n },\n form: {\n submit: this.close.bind(this, { reason: \"submit\" }),\n },\n ul: {\n // Prevent the default mousedowm, which ensures the input is not blurred.\n // The actual selection will happen on click. This also ensures dragging the\n // cursor away from the list item will cancel the selection\n mousedown: function (evt) {\n evt.preventDefault();\n },\n // The click event is fired even if the corresponding mousedown event has called preventDefault\n click: function (evt) {\n var li = evt.target;\n\n if (li !== this) {\n while (li && !/li/i.test(li.nodeName)) {\n li = li.parentNode;\n }\n\n if (li && evt.button === 0) {\n // Only select on left click\n evt.preventDefault();\n me.select(li, evt.target, evt);\n }\n }\n },\n },\n window: {\n scroll: function () {\n var boundingRect = me.container.getBoundingClientRect();\n me.ul.style.top = boundingRect.top + boundingRect.height + \"px\";\n me.ul.style.left = boundingRect.left + \"px\";\n me.ul.style.minWidth = boundingRect.width + \"px\";\n },\n },\n };\n\n $.bind(this.input, this._events.input);\n $.bind(this.input.form, this._events.form);\n $.bind(this.ul, this._events.ul);\n if (this.listContainer !== _.CONTAINER) {\n $.bind(window, this._events.window);\n }\n\n if (this.input.hasAttribute(\"list\")) {\n this.list = \"#\" + this.input.getAttribute(\"list\");\n this.input.removeAttribute(\"list\");\n } else {\n this.list = this.input.getAttribute(\"data-list\") || o.list || [];\n }\n\n _.all.push(this);\n };\n\n _.prototype = {\n set list(list) {\n if (Array.isArray(list)) {\n this._list = list;\n } else if (typeof list === \"string\" && list.indexOf(\",\") > -1) {\n this._list = list.split(/\\s*,\\s*/);\n } else {\n // Element or CSS selector\n list = $(list);\n\n if (list && list.children) {\n var items = [];\n slice.apply(list.children).forEach(function (el) {\n if (!el.disabled) {\n var text = el.textContent.trim();\n var value = el.value || text;\n var label = el.label || text;\n if (value !== \"\") {\n items.push({ label: label, value: value });\n }\n }\n });\n this._list = items;\n }\n }\n\n if (document.activeElement === this.input) {\n this.evaluate();\n }\n },\n\n get selected() {\n return this.index > -1;\n },\n\n get opened() {\n return this.isOpened;\n },\n\n close: function (o) {\n if (!this.opened) {\n return;\n }\n\n this.input.setAttribute(\"aria-expanded\", \"false\");\n this.ul.setAttribute(\"hidden\", \"\");\n this.isOpened = false;\n this.index = -1;\n\n this.status.setAttribute(\"hidden\", \"\");\n\n $.fire(this.input, \"awesomplete-close\", o || {});\n },\n\n open: function () {\n if (this.listContainer !== _.CONTAINER) {\n // In case the suggestion list is out of the container,\n // get the bounding information of the container to set the position of the suggestion list below\n var boundingRect = this.container.getBoundingClientRect();\n this.ul.style.top = boundingRect.top + boundingRect.height + \"px\";\n this.ul.style.left = boundingRect.left + \"px\";\n this.ul.style.position = \"fixed\";\n this.ul.style.transitionProperty = \"height, width, transform\";\n this.ul.style.minWidth = boundingRect.width + \"px\";\n this.ul.className = \"awesomplete-suggestion-list\";\n }\n this.input.setAttribute(\"aria-expanded\", \"true\");\n this.ul.removeAttribute(\"hidden\");\n this.isOpened = true;\n\n this.status.removeAttribute(\"hidden\");\n\n if (this.autoFirst && this.index === -1) {\n this.goto(0);\n }\n\n $.fire(this.input, \"awesomplete-open\");\n },\n\n destroy: function () {\n //remove events from the input and its form\n $.unbind(this.input, this._events.input);\n $.unbind(this.input.form, this._events.form);\n if (this.listContainer !== _.CONTAINER) {\n $.unbind(window, this._events.window);\n }\n\n // cleanup container if it was created by Awesomplete but leave it alone otherwise\n if (!this.options.container) {\n //move the input out of the awesomplete container and remove the container and its children\n var parentNode = this.container.parentNode;\n if (this.listContainer !== _.CONTAINER) {\n var ulParentNode = this.ul.parentNode;\n ulParentNode.removeChild(this.ul);\n } else {\n parentNode.insertBefore(this.input, this.container);\n parentNode.removeChild(this.container);\n }\n }\n\n //remove autocomplete and aria-autocomplete attributes\n this.input.removeAttribute(\"autocomplete\");\n this.input.removeAttribute(\"aria-autocomplete\");\n\n //remove this awesomeplete instance from the global array of instances\n var indexOfAwesomplete = _.all.indexOf(this);\n\n if (indexOfAwesomplete !== -1) {\n _.all.splice(indexOfAwesomplete, 1);\n }\n },\n\n next: function () {\n var count = this.ul.children.length;\n this.goto(this.index < count - 1 ? this.index + 1 : count ? 0 : -1);\n },\n\n previous: function () {\n var count = this.ul.children.length;\n var pos = this.index - 1;\n\n this.goto(this.selected && pos !== -1 ? pos : count - 1);\n },\n\n // Should not be used, highlights specific item without any checks!\n goto: function (i) {\n var lis = this.ul.children;\n\n if (this.selected) {\n lis[this.index].setAttribute(\"aria-selected\", \"false\");\n }\n\n this.index = i;\n\n if (i > -1 && lis.length > 0) {\n lis[i].setAttribute(\"aria-selected\", \"true\");\n\n this.status.textContent =\n lis[i].textContent + \", list item \" + (i + 1) + \" of \" + lis.length;\n\n this.input.setAttribute(\n \"aria-activedescendant\",\n this.ul.id + \"_item_\" + this.index\n );\n\n // scroll to highlighted element in case parent's height is fixed\n this.ul.scrollTop =\n lis[i].offsetTop - this.ul.clientHeight + lis[i].clientHeight;\n\n $.fire(this.input, \"awesomplete-highlight\", {\n text: this.suggestions[this.index],\n });\n }\n },\n\n select: function (selected, origin, originalEvent) {\n if (selected) {\n this.index = $.siblingIndex(selected);\n } else {\n selected = this.ul.children[this.index];\n }\n\n if (selected) {\n var suggestion = this.suggestions[this.index];\n\n var allowed = $.fire(this.input, \"awesomplete-select\", {\n text: suggestion,\n origin: origin || selected,\n originalEvent: originalEvent,\n });\n\n if (allowed) {\n this.replace(suggestion);\n this.close({ reason: \"select\" });\n $.fire(this.input, \"awesomplete-selectcomplete\", {\n text: suggestion,\n originalEvent: originalEvent,\n });\n }\n }\n },\n\n evaluate: function () {\n var me = this;\n var value = this.input.value;\n\n if (\n value.length >= this.minChars &&\n this._list &&\n this._list.length > 0\n ) {\n this.index = -1;\n // Populate list with options that match\n this.ul.innerHTML = \"\";\n\n this.suggestions = this._list\n .map(function (item) {\n return new Suggestion(me.data(item, value));\n })\n .filter(function (item) {\n return me.filter(item, value);\n });\n\n if (this.sort !== false) {\n this.suggestions = this.suggestions.sort(this.sort);\n }\n\n this.suggestions = this.suggestions.slice(0, this.maxItems);\n\n this.suggestions.forEach(function (text, index) {\n me.ul.appendChild(me.item(text, value, index));\n });\n\n if (this.ul.children.length === 0) {\n this.status.textContent = \"No results found\";\n\n this.close({ reason: \"nomatches\" });\n } else {\n this.open();\n\n this.status.textContent = this.ul.children.length + \" results found\";\n }\n } else {\n this.close({ reason: \"nomatches\" });\n\n this.status.textContent = \"No results found\";\n }\n },\n };\n\n // Static methods/properties\n\n _.all = [];\n\n _.FILTER_CONTAINS = function (text, input) {\n return RegExp($.regExpEscape(input.trim()), \"i\").test(text);\n };\n\n _.FILTER_STARTSWITH = function (text, input) {\n return RegExp(\"^\" + $.regExpEscape(input.trim()), \"i\").test(text);\n };\n\n _.SORT_BYLENGTH = function (a, b) {\n if (a.length !== b.length) {\n return a.length - b.length;\n }\n\n return a < b ? -1 : 1;\n };\n\n _.CONTAINER = function (input) {\n return $.create(\"div\", {\n className: \"awesomplete\",\n around: input,\n });\n };\n\n _.ITEM = function (text, input, item_id) {\n var html =\n input.trim() === \"\"\n ? text\n : text.replace(\n RegExp($.regExpEscape(input.trim()), \"gi\"),\n \"$&\"\n );\n return $.create(\"li\", {\n innerHTML: html,\n role: \"option\",\n \"aria-selected\": \"false\",\n id: \"awesomplete_list_\" + this.count + \"_item_\" + item_id,\n });\n };\n\n _.REPLACE = function (text) {\n this.input.value = text.value;\n };\n\n _.DATA = function (item /*, input*/) {\n return item;\n };\n\n // Private functions\n\n function Suggestion(data) {\n var o = Array.isArray(data)\n ? { label: data[0], value: data[1] }\n : typeof data === \"object\" && \"label\" in data && \"value\" in data\n ? data\n : { label: data, value: data };\n\n this.label = o.label || o.value;\n this.value = o.value;\n }\n Object.defineProperty(\n (Suggestion.prototype = Object.create(String.prototype)),\n \"length\",\n {\n get: function () {\n return this.label.length;\n },\n }\n );\n Suggestion.prototype.toString = Suggestion.prototype.valueOf = function () {\n return \"\" + this.label;\n };\n\n function configure(instance, properties, o) {\n for (var i in properties) {\n var initial = properties[i],\n attrValue = instance.input.getAttribute(\"data-\" + i.toLowerCase());\n\n if (typeof initial === \"number\") {\n instance[i] = parseInt(attrValue);\n } else if (initial === false) {\n // Boolean options must be false by default anyway\n instance[i] = attrValue !== null;\n } else if (initial instanceof Function) {\n instance[i] = null;\n } else {\n instance[i] = attrValue;\n }\n\n if (!instance[i] && instance[i] !== 0) {\n instance[i] = i in o ? o[i] : initial;\n }\n }\n }\n\n // Helpers\n\n var slice = Array.prototype.slice;\n\n function $(expr, con) {\n return typeof expr === \"string\"\n ? (con || document).querySelector(expr)\n : expr || null;\n }\n\n function $$(expr, con) {\n return slice.call((con || document).querySelectorAll(expr));\n }\n\n $.create = function (tag, o) {\n var element = document.createElement(tag);\n\n for (var i in o) {\n var val = o[i];\n\n if (i === \"inside\") {\n $(val).appendChild(element);\n } else if (i === \"around\") {\n var ref = $(val);\n ref.parentNode.insertBefore(element, ref);\n element.appendChild(ref);\n\n if (ref.getAttribute(\"autofocus\") != null) {\n ref.focus();\n }\n } else if (i in element) {\n element[i] = val;\n } else {\n element.setAttribute(i, val);\n }\n }\n\n return element;\n };\n\n $.bind = function (element, o) {\n if (element) {\n for (var event in o) {\n var callback = o[event];\n\n event.split(/\\s+/).forEach(function (event) {\n element.addEventListener(event, callback);\n });\n }\n }\n };\n\n $.unbind = function (element, o) {\n if (element) {\n for (var event in o) {\n var callback = o[event];\n\n event.split(/\\s+/).forEach(function (event) {\n element.removeEventListener(event, callback);\n });\n }\n }\n };\n\n $.fire = function (target, type, properties) {\n var evt = document.createEvent(\"HTMLEvents\");\n\n evt.initEvent(type, true, true);\n\n for (var j in properties) {\n evt[j] = properties[j];\n }\n\n return target.dispatchEvent(evt);\n };\n\n $.regExpEscape = function (s) {\n return s.replace(/[-\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n };\n\n $.siblingIndex = function (el) {\n /* eslint-disable no-cond-assign */\n for (var i = 0; (el = el.previousElementSibling); i++);\n return i;\n };\n\n // Initialization\n\n function init() {\n $$(\"input.awesomplete\").forEach(function (input) {\n new _(input);\n });\n }\n\n // Make sure to export Awesomplete on self when in a browser\n if (typeof self !== \"undefined\") {\n self.Awesomplete = _;\n }\n\n // Are we in a browser? Check for Document constructor\n if (typeof Document !== \"undefined\") {\n // DOM already loaded?\n if (document.readyState !== \"loading\") {\n init();\n } else {\n // Wait for it\n document.addEventListener(\"DOMContentLoaded\", init);\n }\n }\n\n _.$ = $;\n _.$$ = $$;\n\n // Expose Awesomplete as a CJS module\n if (typeof module === \"object\" && module.exports) {\n module.exports = _;\n }\n\n return _;\n})();\n"]} \ No newline at end of file diff --git a/awesomplete.theme.css b/awesomplete.theme.css index 8a964f11..78b63051 100644 --- a/awesomplete.theme.css +++ b/awesomplete.theme.css @@ -1,4 +1,5 @@ -.awesomplete > ul { +.awesomplete > ul, +ul.awesomplete-suggestion-list { border-radius: .3em; margin: .2em 0 0; background: hsla(0,0%,100%,.9); @@ -9,13 +10,16 @@ } @supports (transform: scale(0)) { - .awesomplete > ul { + .awesomplete > ul, + ul.awesomplete-suggestion-list { transition: .3s cubic-bezier(.4,.2,.5,1.4); transform-origin: 1.43em -.43em; } .awesomplete > ul[hidden], - .awesomplete > ul:empty { + .awesomplete > ul:empty, + ul.awesomplete-suggestion-list[hidden], + ul.awesomplete-suggestion-list:empty { opacity: 0; transform: scale(0); display: block; @@ -24,7 +28,9 @@ } /* Pointer */ - .awesomplete > ul:before { + + .awesomplete > ul:before, + ul.awesomplete-suggestion-list:before { content: ""; position: absolute; top: -.43em; @@ -39,18 +45,21 @@ transform: rotate(45deg); } - .awesomplete > ul > li { + .awesomplete > ul > li, + ul.awesomplete-suggestion-list > li { position: relative; padding: .2em .5em; cursor: pointer; } - .awesomplete > ul > li:hover { + .awesomplete > ul > li:hover, + ul.awesomplete-suggestion-list > li:hover { background: hsl(200, 40%, 80%); color: black; } - .awesomplete > ul > li[aria-selected="true"] { + .awesomplete > ul >li [aria-selected="true"], + ul.awesomplete-suggestion-list > li[aria-selected="true"] { background: hsl(205, 40%, 40%); color: white; } diff --git a/index.html b/index.html index 2ed5949c..4ca7c44f 100644 --- a/index.html +++ b/index.html @@ -420,6 +420,7 @@

E-mail autocomplete

data: function (text, input) { return input.slice(0, input.indexOf("@")) + "@" + text; }, + listContainer: document.body, filter: Awesomplete.FILTER_STARTSWITH }); @@ -445,19 +446,20 @@

Multiple values

-

Ajax example (restcountries.eu api)

+

Ajax example (restcountries.com api)

Custom list example (based on user input)

+
<input id="query" class="awesomplete"  />