File: public/assets/autocomplete/autocomplete.min.js

Recommend this page to a friend!
  Classes of Aby Dahana  >  Aksara  >  public/assets/autocomplete/autocomplete.min.js  >  Download  
File: public/assets/autocomplete/autocomplete.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Aksara
A CodeIgniter based API and CRUD generator
Author: By
Last change: Initial commit
Initial commit
Date: 2 months ago
Size: 13,139 bytes
 

Contents

Class file image Download
/**
*  Ajax Autocomplete for jQuery, version 1.4.10
*  (c) 2017 Tomas Kirda
*
*  Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
*  For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
*/
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(h){"use strict";function i(e,t){var n=this;n.element=e,n.el=h(e),n.suggestions=[],n.badQueries=[],n.selectedIndex=-1,n.currentValue=n.element.value,n.timeoutId=null,n.cachedResponse={},n.onChangeTimeout=null,n.onChange=null,n.isLocal=!1,n.suggestionsContainer=null,n.noSuggestionsContainer=null,n.options=h.extend({},i.defaults,t),n.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},n.hint=null,n.hintValue="",n.selection=null,n.initialize(),n.setOptions(t)}var s={escapeRegExChars:function(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.position="absolute",t.style.display="none",t}},n=27,o=9,a=13,l=38,u=39,r=40,e=h.noop;i.utils=s,(h.Autocomplete=i).defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:400,deferRequestBy:0,params:{},formatResult:function(e,t){if(!t)return e.value;var n="("+s.escapeRegExChars(t)+")",o=e.label?e.label.replace(new RegExp(n,"gi"),"<strong>$1</strong>").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/&lt;(\/?strong)&gt;/g,"<$1>"):"";return'<div class="row'+(e.disabled?" disabled":"")+'">'+(e.image?'<div class="col-3 col-sm-2"><img src="'+e.image+'" class="img-fluid" alt="..." /></div>':"")+'<div class="'+(e.image?"col-9 col-sm-10":"col-12 col-sm-12")+'"><label class="m-0"'+(e.tooltip?' data-toggle="tooltip" title="'+e.tooltip+'"':"")+">"+(e.disabled?'<small class="text-danger">[Belum Disetujui]</small> ':"")+o+"</label>"+(e.description?'<p class="text-sm text-muted m-0"><i>'+e.description+"</i></p>":"")+"</div></div>"},formatGroup:function(e,t){return'<div class="autocomplete-group">'+t+"</div>"},delimiter:null,zIndex:1,type:"POST",noCache:!0,onSearchStart:e,onSearchComplete:e,onSearchError:e,preserveInput:!1,containerClass:"autocomplete-suggestions rounded",tabDisabled:!1,dataType:"json",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(e,t,n){return-1!==e.label.toLowerCase().indexOf(n)},paramName:"q",transformResult:function(e){return"string"==typeof e?h.parseJSON(e):e},showNoSuggestionNotice:!0,noSuggestionNotice:"No data found",orientation:"bottom",forceFixPosition:!1},i.prototype={initialize:function(){var e,t=this,n="."+t.classes.suggestion,o=t.classes.selected,s=t.options;t.element.setAttribute("autocomplete","off"),t.noSuggestionsContainer=h('<div class="autocomplete-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0),t.suggestionsContainer=i.utils.createNode(s.containerClass),(e=h(t.suggestionsContainer)).appendTo(s.appendTo||"body"),"auto"!==s.width&&e.css("width",s.width),e.on("mouseover.autocomplete",n,function(){t.activate(h(this).data("index"))}),e.on("mouseout.autocomplete",function(){t.selectedIndex=-1,e.children("."+o).removeClass(o)}),e.on("click.autocomplete",n,function(){t.select(h(this).data("index"))}),e.on("click.autocomplete",function(){clearTimeout(t.blurTimeoutId)}),t.fixPositionCapture=function(){t.visible&&t.fixPosition()},h(window).on("resize.autocomplete",t.fixPositionCapture),t.el.on("keydown.autocomplete",function(e){t.onKeyPress(e)}),t.el.on("keyup.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("blur.autocomplete",function(){t.onBlur()}),t.el.on("focus.autocomplete",function(){t.onFocus()}),t.el.on("change.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("input.autocomplete",function(e){t.onKeyUp(e)})},onFocus:function(){var e=this;e.fixPosition(),e.el.val().length>=e.options.minChars&&e.onValueChange()},onBlur:function(){var e=this;e.blurTimeoutId=setTimeout(function(){e.hide()},200)},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(e){var t=this,n=t.options;this.options=h.extend({},n,e),t.isLocal=h.isArray(n.lookup),t.isLocal&&(n.lookup=t.verifySuggestionsFormat(n.lookup)),n.orientation=t.validateOrientation(n.orientation,"bottom"),h(t.suggestionsContainer).css({"max-height":n.maxHeight+"px",width:n.width+"px","z-index":n.zIndex})},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var e=this;e.disabled=!0,clearTimeout(e.onChangeTimeout),e.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var e=this,t=h(e.suggestionsContainer),n=t.parent().get(0);if(n===document.body||e.options.forceFixPosition){var o=e.options.orientation,s=t.outerHeight(),i=e.el.outerHeight(),a=e.el.offset(),l={top:a.top,left:a.left};if("auto"===o){var u=h(window).height(),r=h(window).scrollTop(),c=-r+a.top-s,g=r+u-(a.top+i+s);o=Math.max(c,g)===c?"top":"bottom"}if(l.top+="top"===o?-s:i,n!==document.body){var d,p=t.css("opacity");e.visible||t.css("opacity",0).show(),d=t.offsetParent().offset(),l.top-=d.top,l.left-=d.left,e.visible||t.css("opacity",p).hide()}"auto"===e.options.width&&(l.width=e.el.outerWidth()+"px"),t.css(l)}},isCursorAtEnd:function(){var e,t=this.el.val().length,n=this.element.selectionStart;return"number"==typeof n?n===t:!document.selection||((e=document.selection.createRange()).moveStart("character",-t),t===e.text.length)},onKeyPress:function(e){var t=this;if(t.disabled||t.visible||e.which!==r||!t.currentValue){if(!t.disabled&&t.visible){switch(e.which){case n:t.el.val(t.currentValue),t.hide();break;case u:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case o:if(t.hint&&t.options.onHint)return void t.selectHint();if(-1===t.selectedIndex)return void t.hide();if(t.select(t.selectedIndex),!1===t.options.tabDisabled)return;break;case a:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case l:t.moveUp();break;case r:t.moveDown();break;default:return}e.stopImmediatePropagation(),e.preventDefault()}}else t.suggest()},onKeyUp:function(e){var t=this;if(!t.disabled){switch(e.which){case l:case r:return}clearTimeout(t.onChangeTimeout),t.currentValue!==t.el.val()&&(t.findBestHint(),0<t.options.deferRequestBy?t.onChangeTimeout=setTimeout(function(){t.onValueChange()},t.options.deferRequestBy):t.onValueChange())}},onValueChange:function(){var e=this,t=e.options,n=e.el.val(),o=e.getQuery(n);e.selection&&e.currentValue!==o&&(e.selection=null,(t.onInvalidateSelection||h.noop).call(e.element)),clearTimeout(e.onChangeTimeout),e.currentValue=n,e.selectedIndex=-1,t.triggerSelectOnValidInput&&e.isExactMatch(o)?e.select(0):o.length<t.minChars?e.hide():e.getSuggestions(o)},isExactMatch:function(e){var t=this.suggestions;return t&&1===t.length&&t[0].value.toLowerCase()===e.toLowerCase()},getQuery:function(e){var t,n=this.options.delimiter;return n?(t=e.split(n),h.trim(t[t.length-1])):e},getSuggestionsLocal:function(t){var e,n=this.options,o=t.toLowerCase(),s=n.lookupFilter,i=parseInt(n.lookupLimit,10);return e={suggestions:h.grep(n.lookup,function(e){return s(e,t,o)})},i&&e.suggestions.length>i&&(e.suggestions=e.suggestions.slice(0,i)),e},getSuggestions:function(o){var e,t,n,s,i=this,a=i.options,l=a.serviceUrl;a.params[a.paramName]=o,!1!==a.onSearchStart.call(i.element,a.params)&&(t=a.ignoreParams?null:a.params,h.isFunction(a.lookup)?a.lookup(o,function(e){i.suggestions=e.suggestions,i.suggest(),a.onSearchComplete.call(i.element,o,e.suggestions)}):(e=i.isLocal?i.getSuggestionsLocal(o):(h.isFunction(l)&&(l=l.call(i.element,o)),n=l+"?"+h.param(t||{}),i.cachedResponse[n]))&&h.isArray(e.suggestions)?(i.suggestions=e.suggestions,i.suggest(),a.onSearchComplete.call(i.element,o,e.suggestions)):i.isBadQuery(o)?a.onSearchComplete.call(i.element,o,[]):(i.abortAjax(),s={url:l,data:t,type:a.type,dataType:a.dataType},h.extend(s,a.ajaxSettings),i.currentRequest=h.ajax(s).done(function(e){var t;i.currentRequest=null,t=a.transformResult(e,o),i.processResponse(t,o,n),a.onSearchComplete.call(i.element,o,t.suggestions)}).fail(function(e,t,n){a.onSearchError.call(i.element,o,e,t,n)})))},isBadQuery:function(e){if(!this.options.preventBadQueries)return!1;for(var t=this.badQueries,n=t.length;n--;)if(0===e.indexOf(t[n]))return!0;return!1},hide:function(){var e=this,t=h(e.suggestionsContainer);h.isFunction(e.options.onHide)&&e.visible&&e.options.onHide.call(e.element,t),e.visible=!1,e.selectedIndex=-1,clearTimeout(e.onChangeTimeout),h(e.suggestionsContainer).hide(),e.signalHint(null)},suggest:function(){if(this.suggestions){var s,e=this,i=e.options,a=i.groupBy,l=i.formatResult,u=e.getQuery(e.currentValue),r=e.classes.suggestion,t=e.classes.selected,n=h(e.suggestionsContainer),o=h(e.noSuggestionsContainer),c=i.beforeRender,g="";i.triggerSelectOnValidInput&&e.isExactMatch(u)?e.select(0):(h.each(e.suggestions,function(e,t){var n,o;a&&(g+=(o=(n=t).value[a],s===o?"":(s=o,i.formatGroup(n,s)))),g+='<div class="'+r+'" data-index="'+e+'">'+l(t,u,e)+"</div>"}),this.adjustContainerWidth(),o.detach(),n.html(g),h.isFunction(c)&&c.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),i.autoSelectFirst&&(e.selectedIndex=0,n.scrollTop(0),n.children("."+r).first().addClass(t)),e.visible=!0,e.findBestHint())}else this.options.showNoSuggestionNotice?this.noSuggestions():this.hide()},noSuggestions:function(){var e=this,t=e.options.beforeRender,n=h(e.suggestionsContainer),o=h(e.noSuggestionsContainer);this.adjustContainerWidth(),o.detach(),n.empty(),n.append(o),h.isFunction(t)&&t.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),e.visible=!0},adjustContainerWidth:function(){var e,t=this.options,n=h(this.suggestionsContainer);"auto"===t.width?(e=this.el.outerWidth(),n.css("width",0<e?e:300)):"flex"===t.width&&n.css("width","")},findBestHint:function(){var o=this.el.val().toLowerCase(),s=null;o&&(h.each(this.suggestions,function(e,t){var n=0===(t.label?t.label.toLowerCase().indexOf(o):"");return n&&(s=t),!n}),this.signalHint(s))},signalHint:function(e){var t="",n=this;e&&(t=n.currentValue+e.label.substr(n.currentValue.length)),n.hintValue!==t&&(n.hintValue=t,n.hint=e,(this.options.onHint||h.noop)(t))},verifySuggestionsFormat:function(e){return e&&e.length&&"string"==typeof e[0]?h.map(e,function(e){return{value:e,data:null,description:null,image:null}}):e},validateOrientation:function(e,t){return e=h.trim(e||"").toLowerCase(),-1===h.inArray(e,["auto","bottom","top"])&&(e=t),e},processResponse:function(e,t,n){var o=this,s=o.options;e.suggestions=o.verifySuggestionsFormat(e.suggestions),s.noCache||(o.cachedResponse[n]=e,s.preventBadQueries&&!e.suggestions&&o.badQueries.push(t)),t===o.getQuery(o.currentValue)&&(o.suggestions=e.suggestions,o.suggest())},activate:function(e){var t,n=this,o=n.classes.selected,s=h(n.suggestionsContainer),i=s.find("."+n.classes.suggestion);return s.find("."+o).removeClass(o),n.selectedIndex=e,-1!==n.selectedIndex&&i.length>n.selectedIndex?(t=i.get(n.selectedIndex),h(t).addClass(o),t):null},selectHint:function(){var e=h.inArray(this.hint,this.suggestions);this.select(e)},select:function(e){this.hide(),this.onSelect(e)},moveUp:function(){var e=this;if(-1!==e.selectedIndex)return 0===e.selectedIndex?(h(e.suggestionsContainer).children().first().removeClass(e.classes.selected),e.selectedIndex=-1,e.el.val(e.currentValue),void e.findBestHint()):void e.adjustScroll(e.selectedIndex-1)},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(e){var t=this,n=t.activate(e);if(n){var o,s,i,a=h(n).outerHeight();o=n.offsetTop,i=(s=h(t.suggestionsContainer).scrollTop())+t.options.maxHeight-a,o<s?h(t.suggestionsContainer).scrollTop(o):i<o&&h(t.suggestionsContainer).scrollTop(o-t.options.maxHeight+a),t.options.preserveInput||t.el.val(t.getValue(t.suggestions[e].value)),t.signalHint(null)}},onSelect:function(e){var t=this,n=t.options.onSelect,o=t.suggestions[e];t.currentValue=t.getValue(o.label),t.currentValue===t.el.val()||t.options.preserveInput||t.el.val(t.currentValue),t.signalHint(null),t.suggestions=[],t.selection=o,h.isFunction(n)&&n.call(t.element,o)},getValue:function(e){var t,n,o=this.options.delimiter;return o?1===(n=(t=this.currentValue).split(o)).length?e:t.substr(0,t.length-n[n.length-1].length)+e:e},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete"),h(window).off("resize.autocomplete",this.fixPositionCapture),h(this.suggestionsContainer).remove()}},h.fn.devbridgeAutocomplete=function(n,o){return arguments.length?this.each(function(){var e=h(this),t=e.data("autocomplete");"string"==typeof n?t&&"function"==typeof t[n]&&t[n](o):(t&&t.dispose&&t.dispose(),t=new i(this,n),e.data("autocomplete",t))}):this.first().data("autocomplete")},h.fn.autocomplete||(h.fn.autocomplete=h.fn.devbridgeAutocomplete)});

For more information send a message to info at phpclasses dot org.