adamoCellar/assets/autocomplete.min.js

1 line
15 KiB
JavaScript
Raw Permalink Normal View History

!function(s){var i={};function o(t){if(i[t])return i[t].exports;var e=i[t]={i:t,l:!1,exports:{}};return s[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=s,o.c=i,o.d=function(t,e,s){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(o.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(s,i,function(t){return e[t]}.bind(null,i));return s},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=0)}([function(t,e,s){"use strict";s.r(e),s.d(e,"AutoComplete",function(){return d});var i,o,n,r=(i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s])})(t,e)},function(t,e){function s(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(s.prototype=e.prototype,new s)}),l=(_.prototype.getDefaults=function(){return{}},_.prototype.getResults=function(t,e,s){return this.results},_.prototype.search=function(t,e){e(this.getResults())},r(p,o=_),p.prototype.getDefaults=function(){return{url:"",method:"get",queryKey:"q",extraData:{},timeout:void 0,requestThrottling:500}},p.prototype.search=function(t,e){var s=this;null!=this.jqXHR&&this.jqXHR.abort();var i={};i[this._settings.queryKey]=t,$.extend(i,this._settings.extraData),this.requestTID&&window.clearTimeout(this.requestTID),this.requestTID=window.setTimeout(function(){s.jqXHR=$.ajax(s._settings.url,{method:s._settings.method,data:i,timeout:s._settings.timeout}),s.jqXHR.done(function(t){e(t)}),s.jqXHR.fail(function(t){var e;null===(e=s._settings)||void 0===e||e.fail(t)}),s.jqXHR.always(function(){s.jqXHR=null})},this._settings.requestThrottling)},p),a=(f.prototype.init=function(){var s=this,t=$.extend({},this._$el.position(),{height:this._$el[0].offsetHeight});this._dd=$("<ul />"),this._dd.addClass("bootstrap-autocomplete dropdown-menu"),this._dd.insertAfter(this._$el),this._dd.css({top:t.top+this._$el.outerHeight(),left:t.left,width:this._$el.outerWidth()}),this._dd.on("click","li",function(t){var e=$(t.currentTarget).data("item");s.itemSelectedLaunchEvent(e)}),this._dd.on("keyup",function(t){if(s.shown){switch(t.which){case 27:s.hide(),s._$el.focus()}return!1}}),this._dd.on("mouseenter",function(t){s.ddMouseover=!0}),this._dd.on("mouseleave",function(t){s.ddMouseover=!1}),this._dd.on("mouseenter","li",function(t){s.haveResults&&($(t.currentTarget).closest("ul").find("li.active").removeClass("active"),$(t.currentTarget).addClass("active"),s.mouseover=!0)}),this._dd.on("mouseleave","li",function(t){s.mouseover=!1}),this.initialized=!0},f.prototype.checkInitialized=function(){this.initialized||this.init()},Object.defineProperty(f.prototype,"isMouseOver",{get:function(){return this.mouseover},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isDdMouseOver",{get:function(){return this.ddMouseover},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"haveResults",{get:function(){return 0<this.items.length},enumerable:!1,configurable:!0}),f.prototype.focusNextItem=function(t){var e,s;this.haveResults&&(e=this._dd.find("li.active"),0===(s=t?e.prev():e.next()).length&&(s=t?this._dd.find("li").last():this._dd.find("li").first()),e.removeClass("active"),s.addClass("active"))},f.prototype.focusPreviousItem=function(){this.focusNextItem(!0)},f.prototype.selectFocusItem=function(){this._dd.find("li.active").trigger("click")},Object.defineProperty(f.prototype,"isItemFocused",{get:function(){return!!(this.isShown()&&0<this._dd.find("li.active").length)},enumerable:!1,configurable:!0}),f.prototype.show=function(){this.shown||(this._dd.dropdow