template.js.base.autocomplete.min.js Maven / Gradle / Ivy
'use strict';(function(c){"function"===typeof define&&define.amd?define("jquery ./menu ../keycode ../position ../safe-active-element ../version ../widget".split(" "),c):c(jQuery)})(function(c){c.widget("ui.autocomplete",{version:"1.12.1",defaultElement:"\x3cinput\x3e",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,
_create:function(){var a,b,f,d=this.element[0].nodeName.toLowerCase(),h="textarea"===d,d="input"===d;this.isMultiLine=h||!d&&this._isContentEditable(this.element);this.valueMethod=this.element[h||d?"val":"text"];this.isNewMenu=!0;this._addClass("ui-autocomplete-input");this.element.attr("autocomplete","off");this._on(this.element,{keydown:function(e){if(this.element.prop("readOnly"))b=f=a=!0;else{b=f=a=!1;var g=c.ui.keyCode;switch(e.keyCode){case g.PAGE_UP:a=!0;this._move("previousPage",e);break;
case g.PAGE_DOWN:a=!0;this._move("nextPage",e);break;case g.UP:a=!0;this._keyEvent("previous",e);break;case g.DOWN:a=!0;this._keyEvent("next",e);break;case g.ENTER:this.menu.active&&(a=!0,e.preventDefault(),this.menu.select(e));break;case g.TAB:this.menu.active&&this.menu.select(e);break;case g.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(e),e.preventDefault());break;default:b=!0,this._searchTimeout(e)}}},keypress:function(e){if(a)a=!1,this.isMultiLine&&
!this.menu.element.is(":visible")||e.preventDefault();else if(!b){var g=c.ui.keyCode;switch(e.keyCode){case g.PAGE_UP:this._move("previousPage",e);break;case g.PAGE_DOWN:this._move("nextPage",e);break;case g.UP:this._keyEvent("previous",e);break;case g.DOWN:this._keyEvent("next",e)}}},input:function(a){f?(f=!1,a.preventDefault()):this._searchTimeout(a)},focus:function(){this.selectedItem=null;this.previous=this._value()},blur:function(a){this.cancelBlur?delete this.cancelBlur:(clearTimeout(this.searching),
this.close(a),this._change(a))}});this._initSource();this.menu=c("\x3cul\x3e").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance");this._addClass(this.menu.element,"ui-autocomplete","ui-front");this._on(this.menu.element,{mousedown:function(a){a.preventDefault();this.cancelBlur=!0;this._delay(function(){delete this.cancelBlur;this.element[0]!==c.ui.safeActiveElement(this.document[0])&&this.element.trigger("focus")})},menufocus:function(a,b){var d;if(this.isNewMenu&&(this.isNewMenu=
!1,a.originalEvent&&/^mouse/.test(a.originalEvent.type))){this.menu.blur();this.document.one("mousemove",function(){c(a.target).trigger(a.originalEvent)});return}d=b.item.data("ui-autocomplete-item");!1!==this._trigger("focus",a,{item:d})&&a.originalEvent&&/^key/.test(a.originalEvent.type)&&this._value(d.value);(d=b.item.attr("aria-label")||d.value)&&c.trim(d).length&&(this.liveRegion.children().hide(),c("\x3cdiv\x3e").text(d).appendTo(this.liveRegion))},menuselect:function(a,b){var d=b.item.data("ui-autocomplete-item"),
f=this.previous;this.element[0]!==c.ui.safeActiveElement(this.document[0])&&(this.element.trigger("focus"),this.previous=f,this._delay(function(){this.previous=f;this.selectedItem=d}));!1!==this._trigger("select",a,{item:d})&&this._value(d.value);this.term=this._value();this.close(a);this.selectedItem=d}});this.liveRegion=c("\x3cdiv\x3e",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).appendTo(this.document[0].body);this._addClass(this.liveRegion,null,"ui-helper-hidden-accessible");
this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching);this.element.removeAttr("autocomplete");this.menu.element.remove();this.liveRegion.remove()},_setOption:function(a,b){this._super(a,b);"source"===a&&this._initSource();"appendTo"===a&&this.menu.element.appendTo(this._appendTo());"disabled"===a&&b&&this.xhr&&this.xhr.abort()},_isEventTargetInWidget:function(a){var b=this.menu.element[0];return a.target===this.element[0]||
a.target===b||c.contains(b,a.target)},_closeOnClickOutside:function(a){this._isEventTargetInWidget(a)||this.close()},_appendTo:function(){var a=this.options.appendTo;a&&(a=a.jquery||a.nodeType?c(a):this.document.find(a).eq(0));a&&a[0]||(a=this.element.closest(".ui-front, dialog"));a.length||(a=this.document[0].body);return a},_initSource:function(){var a,b,f=this;c.isArray(this.options.source)?(a=this.options.source,this.source=function(b,f){f(c.ui.autocomplete.filter(a,b.term))}):"string"===typeof this.options.source?
(b=this.options.source,this.source=function(a,h){f.xhr&&f.xhr.abort();f.xhr=c.ajax({url:b,data:a,dataType:"json",success:function(a){h(a)},error:function(){h([])}})}):this.source=this.options.source},_searchTimeout:function(a){clearTimeout(this.searching);this.searching=this._delay(function(){var b=this.term===this._value(),c=this.menu.element.is(":visible"),d=a.altKey||a.ctrlKey||a.metaKey||a.shiftKey;if(!b||b&&!c&&!d)this.selectedItem=null,this.search(null,a)},this.options.delay)},search:function(a,
b){a=null!=a?a:this._value();this.term=this._value();if(a.length
© 2015 - 2024 Weber Informatics LLC | Privacy Policy