2 lines
95 KiB
JavaScript
2 lines
95 KiB
JavaScript
|
/*! For license information please see shaarli.min.js.LICENSE.txt */
|
||
|
(()=>{var r={219:r=>{!function(){var e=function(r,t){var a=this;e.count=(e.count||0)+1,this.count=e.count,this.isOpened=!1,this.input=o(r),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-autocomplete","list"),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("aria-controls","awesomplete_list_"+this.count),this.input.setAttribute("aria-owns","awesomplete_list_"+this.count),this.input.setAttribute("role","combobox"),this.options=t=t||{},function(r,e,t){for(var a in e){var o=e[a],n=r.input.getAttribute("data-"+a.toLowerCase());r[a]="number"==typeof o?parseInt(n):!1===o?null!==n:o instanceof Function?null:n,r[a]||0===r[a]||(r[a]=a in t?t[a]:o)}}(this,{minChars:2,maxItems:10,autoFirst:!1,data:e.DATA,filter:e.FILTER_CONTAINS,sort:!1!==t.sort&&e.SORT_BYLENGTH,container:e.CONTAINER,item:e.ITEM,replace:e.REPLACE,tabSelect:!1,listLabel:"Results List",statusNoResults:"No results found",statusXResults:"{0} results found",statusTypeXChar:"Type {0} or more characters for results"},t),this.index=-1,this.container=this.container(r),this.ul=o.create("ul",{hidden:"hidden",role:"listbox",id:"awesomplete_list_"+this.count,inside:this.container,"aria-label":this.listLabel}),this.status=o.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:""}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(r){var e=r.keyCode;a.opened&&(13===e&&a.selected||9===e&&a.selected&&a.tabSelect?(r.preventDefault(),a.select(void 0,void 0,r)):27===e?a.close({reason:"esc"}):38!==e&&40!==e||(r.preventDefault(),a[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(r){r.preventDefault()},click:function(r){var e=r.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===r.button&&(r.preventDefault(),a.select(e,r.target,r))}}}},o.bind(this.input,this._events.input),o.bind(this.input.form,this._events.form),o.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")||t.list||[],e.all.push(this)};function t(r){var e=Array.isArray(r)?{label:r[0],value:r[1]}:"object"==typeof r&&"label"in r&&"value"in r?r:{label:r,value:r};this.label=e.label||e.value,this.value=e.value}e.prototype={set list(r){if(Array.isArray(r))this._list=r;else if("string"==typeof r&&r.indexOf(",")>-1)this._list=r.split(/\s*,\s*/);else if((r=o(r))&&r.children){var e=[];a.apply(r.children).forEach((function(r){if(!r.disabled){var t=r.textContent.trim(),a=r.value||t,o=r.label||t;""!==a&&e.push({label:o,value:a})}})),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(r){this.opened&&(this.input.setAttribute("aria-expanded","false"),this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),this.input.setAttribute("aria-activedescendant",""),o.fire(this.input,"awesomplete-close",r||{}))},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),o.fire(this.input,"awesomplete-open")},destroy:function(){if(o.unbind(this.input,this._events.input),o.unbind(this.input.form,this._events.form),!this.options.container){var r=this.container.parentNode;r.insertBefore(this.input,this.container),r.removeChild(this.container)}this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete"),this.input.removeAttribute("aria-expanded"),this.input.removeAttribute("aria-controls"),this.input.removeAttribute("aria-owns"),this.input.removeAttribute("role");var t=e.all.indexOf(this);-1!==t&&e.all.splice(t,1)},next:function(){var r=this.ul.children.length;this.goto(this.index<r-1?this.index+1:r?0:-1)},previous:function(){var r=th
|