/*! * Ajax Bootstrap Select * * Extends existing [Bootstrap Select] implementations by adding the ability to search via AJAX requests as you type. Originally for CROSCON. * * @version 1.4.5 * @author Adam Heim - https://github.com/truckingsim * @link https://github.com/truckingsim/Ajax-Bootstrap-Select * @copyright 2019 Adam Heim * @license Released under the MIT license. * * Contributors: * Mark Carver - https://github.com/markcarver * * Last build: 2019-04-23 12:18:55 PM EDT */ !function(t,e){var i=function(i,s){var o,l,n=this;s=s||{},this.$element=t(i),this.options=t.extend(!0,{},t.fn.ajaxSelectPicker.defaults,s),this.LOG_ERROR=1,this.LOG_WARNING=2,this.LOG_INFO=3,this.LOG_DEBUG=4,this.lastRequest=!1,this.previousQuery="",this.query="",this.request=!1;var a=[{from:"ajaxResultsPreHook",to:"preprocessData"},{from:"ajaxSearchUrl",to:{ajax:{url:"{{{value}}}"}}},{from:"ajaxOptions",to:"ajax"},{from:"debug",to:function(e){var i={};i.log=Boolean(n.options[e.from])?n.LOG_DEBUG:0,n.options=t.extend(!0,{},n.options,i),delete n.options[e.from],n.log(n.LOG_WARNING,'Deprecated option "'+e.from+'". Update code to use:',i)}},{from:"mixWithCurrents",to:"preserveSelected"},{from:"placeHolderOption",to:{locale:{emptyTitle:"{{{value}}}"}}}];a.length&&t.map(a,(function(e){if(n.options[e.from])if(t.isPlainObject(e.to))n.replaceValue(e.to,"{{{value}}}",n.options[e.from]),n.options=t.extend(!0,{},n.options,e.to),n.log(n.LOG_WARNING,'Deprecated option "'+e.from+'". Update code to use:',e.to),delete n.options[e.from];else if(t.isFunction(e.to))e.to.apply(n,[e]);else{var i={};i[e.to]=n.options[e.from],n.options=t.extend(!0,{},n.options,i),n.log(n.LOG_WARNING,'Deprecated option "'+e.from+'". Update code to use:',i),delete n.options[e.from]}}));var r=this.$element.data();r.searchUrl&&(n.log(n.LOG_WARNING,'Deprecated attribute name: "data-search-url". Update markup to use: \' data-abs-ajax-url="'+r.searchUrl+"\" '"),this.options.ajax.url=r.searchUrl);var p=function(t,e){return e.toLowerCase()},c=function(t,e,i){var s=[].concat(t),o=s.length,l=i||{};if(o){var n=s.shift();l[n]=c(s,e,l[n])}return o?l:e},h=Object.keys(r).filter(/./.test.bind(new RegExp("^abs[A-Z]")));if(h.length){var u={},g=["locale"];for(o=0,l=h.length;o1&&-1!==g.indexOf(f[0])){for(var v=[f.shift()],y="",O=0;O0)&&l.replaceValue(e[n],i,s,o):a===i&&(!1!==o.limit&&"number"==typeof o.limit&&o.limit--,e[n]=s)}))},i.prototype.t=function(t,e){return e=e||this.options.langCode,this.locale[e]&&this.locale[e].hasOwnProperty(t)?this.locale[e][t]:(this.log(this.LOG_WARNING,"Unknown translation key:",t),t)},e.AjaxBootstrapSelect=e.AjaxBootstrapSelect||i;var s=function(e){var i=this;this.$status=t(e.options.templates.status).hide().appendTo(e.selectpicker.$menu);var s=e.t("statusInitialized");s&&s.length&&this.setStatus(s),this.cache={},this.plugin=e,this.selected=[],this.title=null,this.selectedTextFormat=e.selectpicker.options.selectedTextFormat;var o=[];e.$element.find("option").each((function(){var i=t(this),s=i.attr("value");o.push({value:s,text:i.text(),class:i.attr("class")||"",data:i.data()||{},preserved:e.options.preserveSelected,selected:!!i.attr("selected")})})),this.cacheSet("",o),e.options.preserveSelected&&(i.selected=o,e.$element.on("change.abs.preserveSelected",(function(s){var o=e.$element.find(":selected");i.selected=[],e.selectpicker.multiple||(o=o.last()),o.each((function(){var e=t(this),s=e.attr("value");i.selected.push({value:s,text:e.text(),class:e.attr("class")||"",data:e.data()||{},preserved:!0,selected:!0})})),i.replaceOptions(i.cacheGet(i.plugin.query))})))};s.prototype.build=function(e){var i,s,o=e.length,l=t("