Tumortisch-Dist/resources/app/lib/3rdparty/virtual-keyboard/js/jquery.keyboard.extension-autocomplete.min.js

2 lines
3.0 KiB
JavaScript
Raw Normal View History

2021-06-15 16:00:08 +02:00
/*! jQuery UI Virtual Keyboard Autocomplete v1.11.3 */
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&"object"==typeof module.exports?module.exports=e(require("jquery")):e(jQuery)}(function(e){"use strict";e.fn.addAutocomplete=function(t){var o={position:{of:null,my:"right top",at:"left top",collision:"flip"},events:"autocomplete",data:""};return this.each(function(){var a,l,c=e(this).data("keyboard");c&&(l=c.namespace+"Autocomplete",c.autocomplete_namespace=l,c.extensionNamespace.push(l),c.autocomplete_init=function(){var u=(a=c.autocomplete_options=e.extend(!0,{},o,t)).events||a.data||"autocomplete";c.options.alwaysOpen&&c.isVisible()&&c.autocomplete_setup(),c.$el.unbind(l).bind(e.keyboard.events.kbVisible+l,function(){c.autocomplete_setup()}).bind(e.keyboard.events.kbHidden+l,function(){c.$el[a.data||"autocomplete"]("close")}).bind(e.keyboard.events.kbChange+l,function(){c.hasAutocomplete&&c.isVisible()&&c.$el.val(c.$preview.val())}).bind(u+"open"+l,function(){if(c.hasAutocomplete){var t=e.extend({},a.position);t.of=t.of||c.$keyboard,c.$autocomplete.menu.element.position(t)}}).bind(u+"select"+l,function(e,t){c.autocomplete_getVal(t.item)})},c.autocomplete_getVal=function(e){var t;switch(typeof e){case"string":t=e||"";break;case"object":t=e.label||e.value||"";break;default:t=c.preview&&c.preview.value||c.el.value}t=t.toString(),c.hasAutocomplete&&""!==t&&((c.$preview||c.$el).val(t).focus(),c.last.start=t.length,c.last.end=t.length,c.last.val=t)},c.autocomplete_update=function(e){clearTimeout(c.$autocomplete.searching),c.$autocomplete.searching=setTimeout(function(){c.$autocomplete.term!==c.$autocomplete.element.val()&&(c.$autocomplete.selectedItem=null,c.$autocomplete.search(null,e))},c.$autocomplete.options.delay)},c.autocomplete_navKeys={8:"backSpace",9:"tab",13:"enter",20:"capsLock",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete"},c.autocomplete_setup=function(){var e;if(c.$autocomplete=c.$el.data(c.autocomplete_options.data)||c.$el.data("uiAutocomplete")||c.$el.data("ui-autocomplete")||c.$el.data("autocomplete"),c.hasAutocomplete=void 0!==c.$autocomplete&&!c.$autocomplete.options.disabled,c.hasAutocomplete){c.$preview.bind("keydown"+l+" keypress"+l,function(t){c.$preview&&t.namespace!==c.$autocomplete.eventNamespace&&(t.namespace=c.$autocomplete.eventNamespace.slice(1),(e=c.autocomplete_navKeys[t.which])?c.el!==c.preview&&(c.$el.triggerHandler(t),"enter"===e&&setTimeout(function(){c.$preview.val(c.$autocomplete.selectedItem.value),c.$preview.focus()},100)):c.autocomplete_update(t))});var t="mouseup mousedown mouseleave touchstart touchend touchcancel ".split(" ").join(l+" ");c.$allKeys.bind(t,function(e){c.autocomplete_update(e)})}c.escCloseCallback.autocomplete||(c.escCloseCallback.autocomplete=c.checkAutocompleteMenu)},c.checkAutocompleteMenu=function(e){return c.hasAutocomplete&&e.closest("ul").hasClass("ui-autocomplete")},c.autocomplete_init())})}});