File "jquery.easy-autocomplete.min.js"

Full Path: /home/vantageo/public_html/cache/cache/.wp-cli/wp-content/plugins/woocommerce-products-filter/js/easy-autocomplete/jquery.easy-autocomplete.min.js
File size: 14.97 KB
MIME-type: text/plain
Charset: utf-8

"use strict";
(function(a){var b=function(b){return b.Configuration=function(c){function d(){if("xml"===c.dataType&&(!c.getValue&&(c.getValue=function(b){return a(b).text()}),!c.list&&(c.list={}),!c.list.sort&&(c.list.sort={}),c.list.sort.method=function(d,e){return d=c.getValue(d),e=c.getValue(e),d<e?-1:d>e?1:0},!c.list.match&&(c.list.match={}),c.list.match.method=function(a,b){return-1<a.search(b)}),void 0!==c.categories&&c.categories instanceof Array){for(var b,d=[],e=0,f=c.categories.length;e<f;e+=1){for(var g in b=c.categories[e],j.categories[0])void 0===b[g]&&(b[g]=j.categories[0][g]);d.push(b)}c.categories=d}}function e(){function a(b,c){var d=b||{};for(var e in b)void 0!==c[e]&&null!==c[e]&&("object"!=typeof c[e]||c[e]instanceof Array?d[e]=c[e]:a(b[e],c[e]));return void 0!==c.data&&null!==c.data&&"object"==typeof c.data&&(d.data=c.data),d}j=a(j,c)}function f(){if("list-required"!==j.url&&"function"!=typeof j.url){var b=j.url;j.url=function(){return b}}if(void 0!==j.ajaxSettings.url&&"function"!=typeof j.ajaxSettings.url){var b=j.ajaxSettings.url;j.ajaxSettings.url=function(){return b}}if("string"==typeof j.listLocation){var d=j.listLocation;j.listLocation="XML"===j.dataType.toUpperCase()?function(b){return a(b).find(d)}:function(a){return a[d]}}if("string"==typeof j.getValue){var e=j.getValue;j.getValue=function(a){return a[e]}}void 0!==c.categories&&(j.categoriesAssigned=!0)}function g(){j.ajaxSettings=void 0!==c.ajaxSettings&&"object"==typeof c.ajaxSettings?c.ajaxSettings:{}}function h(a){return void 0!==j[a]&&null!==j[a]}function i(b,c){function d(c,e){for(var f in e)void 0===c[f]&&b.log("Property '"+f+"' does not exist in EasyAutocomplete options API."),"object"==typeof c[f]&&-1===a.inArray(f,k)&&d(c[f],e[f])}d(j,c)}var j={data:"list-required",url:"list-required",dataType:"json",listLocation:function(a){return a},xmlElementName:"",getValue:function(a){return a},autocompleteOff:!0,placeholder:!1,ajaxCallback:function(){},matchResponseProperty:!1,list:{sort:{enabled:!1,method:function(c,d){return c=j.getValue(c),d=j.getValue(d),c<d?-1:c>d?1:0}},maxNumberOfElements:6,hideOnEmptyPhrase:!0,match:{enabled:!1,caseSensitive:!1,method:function(a,b){return-1<a.search(b)}},showAnimation:{type:"normal",time:400,callback:function(){}},hideAnimation:{type:"normal",time:400,callback:function(){}},onClickEvent:function(){},onSelectItemEvent:function(){},onLoadEvent:function(){},onChooseEvent:function(){},onKeyEnterEvent:function(){},onMouseOverEvent:function(){},onMouseOutEvent:function(){},onShowListEvent:function(){},onHideListEvent:function(){}},highlightPhrase:!0,theme:"",cssClasses:"",minCharNumber:0,requestDelay:0,adjustWidth:!0,ajaxSettings:{},preparePostData:function(a){return a},loggerEnabled:!0,template:"",categoriesAssigned:!1,categories:[{maxNumberOfElements:4}]},k=["ajaxSettings","template"];this.get=function(a){return j[a]},this.equals=function(a,b){return!!(h(a)&&j[a]===b)},this.checkDataUrlProperties=function(){return"list-required"!==j.url||"list-required"!==j.data},this.checkRequiredProperties=function(){for(var a in j)if("required"===j[a])return logger.error("Option "+a+" must be defined"),!1;return!0},this.printPropertiesThatDoesntExist=function(a,b){i(a,b)},d(),e(),!0===j.loggerEnabled&&i(console,c),g(),f()},b}(b||{}),b=function(a){return a.Logger=function(){this.error=function(a){console.log("ERROR: "+a)},this.warning=function(a){console.log("WARNING: "+a)}},a}(b||{}),b=function(a){return a.Constants=function(){var a={CONTAINER_CLASS:"easy-autocomplete-container",CONTAINER_ID:"eac-container-",WRAPPER_CSS_CLASS:"easy-autocomplete"};this.getValue=function(b){return a[b]}},a}(b||{}),b=function(b){return b.ListBuilderService=function(b,c){function d(c,d){function e(){var e,f={};return void 0!==c.xmlElementName&&(f.xmlElementName=c.xmlElementName),void 0===c.listLocation?void 0!==b.get("listLocation")&&(e=b.get("listLocation")):e=c.listLocation,void 0===e?f.data=d:"string"==typeof e?f.data=a(d).find(e):"function"==typeof e&&(f.data=e(d)),f}function f(){var a={};return void 0===c.listLocation?a.data=d:"string"==typeof c.listLocation?a.data=d[c.listLocation]:"function"==typeof c.listLocation&&(a.data=c.listLocation(d)),a}var g={};if(g="XML"===b.get("dataType").toUpperCase()?e():f(),void 0!==c.header&&(g.header=c.header),void 0!==c.maxNumberOfElements&&(g.maxNumberOfElements=c.maxNumberOfElements),void 0!==b.get("list").maxNumberOfElements&&(g.maxListSize=b.get("list").maxNumberOfElements),void 0===c.getValue)g.getValue=b.get("getValue");else if("string"==typeof c.getValue){var h=c.getValue;g.getValue=function(a){return a[h]}}else"function"==typeof c.getValue&&(g.getValue=c.getValue);return g}function e(c){var d=[];return void 0===c.xmlElementName&&(c.xmlElementName=b.get("xmlElementName")),a(c.data).find(c.xmlElementName).each(function(){d.push(this)}),d}this.init=function(a){var c=[],d={};return d.data=b.get("listLocation")(a),d.getValue=b.get("getValue"),d.maxListSize=b.get("list").maxNumberOfElements,c.push(d),c},this.updateCategories=function(a,c){if(b.get("categoriesAssigned")){a=[];for(var e,f=0;f<b.get("categories").length;f+=1)e=d(b.get("categories")[f],c),a.push(e)}return a},this.convertXml=function(a){if("XML"===b.get("dataType").toUpperCase())for(var c=0;c<a.length;c+=1)a[c].data=e(a[c]);return a},this.processData=function(a,d){for(var e=0,f=a.length;e<f;e+=1)a[e].data=c(b,a[e],d);return a},this.checkIfDataExists=function(a){for(var b=0,c=a.length;b<c;b+=1)if(void 0!==a[b].data&&a[b].data instanceof Array&&0<a[b].data.length)return!0;return!1}},b}(b||{}),b=function(a){return a.proccess=function(b,c,d){function e(a,c){var d=[],e="";if(b.get("list").match.enabled)for(var g=0,h=a.length;g<h;g+=1)e=b.get("getValue")(a[g]),f(e,c)&&d.push(a[g]);else d=a;return d}function f(a,c){return b.get("list").match.caseSensitive||("string"==typeof a&&(a=a.toLowerCase()),c=c.toLowerCase()),b.get("list").match.method(a,c)}function g(a){return void 0!==c.maxNumberOfElements&&a.length>c.maxNumberOfElements&&(a=a.slice(0,c.maxNumberOfElements)),a}function h(a){return b.get("list").sort.enabled&&a.sort(b.get("list").sort.method),a}a.proccess.match=f;var i=c.data;return i=e(i,d),i=g(i),i=h(i),i},a}(b||{}),b=function(a){return a.Template=function(a){var b={basic:{type:"basic",method:function(a){return a},cssClass:""},description:{type:"description",fields:{description:"description"},method:function(a){return a+" - description"},cssClass:"eac-description"},iconLeft:{type:"iconLeft",fields:{icon:""},method:function(a){return a},cssClass:"eac-icon-left"},iconRight:{type:"iconRight",fields:{iconSrc:""},method:function(a){return a},cssClass:"eac-icon-right"},links:{type:"links",fields:{link:""},method:function(a){return a},cssClass:""},custom:{type:"custom",method:function(){},cssClass:""}},c=function(a){var c,d=a.fields;return"description"===a.type?(c=b.description.method,"string"==typeof d.description?c=function(a,b){return a+" - <span>"+b[d.description]+"</span>"}:"function"==typeof d.description&&(c=function(a,b){return a+" - <span>"+d.description(b)+"</span>"}),c):"iconRight"===a.type?("string"==typeof d.iconSrc?c=function(a,b){return a+"<img class='eac-icon' src='"+b[d.iconSrc]+"' />"}:"function"==typeof d.iconSrc&&(c=function(a,b){return a+"<img class='eac-icon' src='"+d.iconSrc(b)+"' />"}),c):"iconLeft"===a.type?("string"==typeof d.iconSrc?c=function(a,b){return"<img class='eac-icon' src='"+b[d.iconSrc]+"' />"+a}:"function"==typeof d.iconSrc&&(c=function(a,b){return"<img class='eac-icon' src='"+d.iconSrc(b)+"' />"+a}),c):"links"===a.type?("string"==typeof d.link?c=function(a,b){return"<a href='"+b[d.link]+"' >"+a+"</a>"}:"function"==typeof d.link&&(c=function(a,b){return"<a href='"+d.link(b)+"' >"+a+"</a>"}),c):"custom"===a.type?a.method:b.basic.method};this.getTemplateClass=function(a){var c=function(){return""};return a&&a.type?a.type&&b[a.type]?function(){var c=b[a.type].cssClass;return function(){return c}}():c:c}(a),this.build=function(a){return a&&a.type?a.type&&b[a.type]?c(a):b.basic.method:b.basic.method}(a)},a}(b||{}),b=function(b){return b.main=function(c,d){function e(){return 0===u.length?void q.error("Input field doesn't exist."):p.checkDataUrlProperties()?p.checkRequiredProperties()?void(f(),h()):void q.error("Will not work without mentioned properties."):void q.error("One of options variables 'data' or 'url' must be defined.")}function f(){function b(){var a=u.outerWidth();u.parent().css("width",a)}function c(a,b){return p.get("highlightPhrase")&&""!==b?e(a,b):a}function d(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function e(a,b){var c=d(b);return(a+"").replace(new RegExp("("+c+")","gi"),"<b>$1</b>")}u.parent().hasClass(o.getValue("WRAPPER_CSS_CLASS"))&&(function(){u.next("."+o.getValue("CONTAINER_CLASS")).remove()}(),function(){u.unwrap()}()),function(){var c=a("<div>"),d=o.getValue("WRAPPER_CSS_CLASS");p.get("theme")&&""!==p.get("theme")&&(d+=" eac-"+p.get("theme")),p.get("cssClasses")&&""!==p.get("cssClasses")&&(d+=" "+p.get("cssClasses")),""!==r.getTemplateClass()&&(d+=" "+r.getTemplateClass()),c.addClass(d),u.wrap(c),!0===p.get("adjustWidth")&&b()}(),function(){var b=a("<div>").addClass(o.getValue("CONTAINER_CLASS"));b.attr("id",g()).prepend(a("<ul>")),function(){b.on("show.eac",function(){if(u.is(":focus")){switch(p.get("list").showAnimation.type){case"slide":var a=p.get("list").showAnimation.time,c=p.get("list").showAnimation.callback;b.find("ul").slideDown(a,c);break;case"fade":var a=p.get("list").showAnimation.time,c=p.get("list").showAnimation.callback;b.find("ul").fadeIn(a),c;break;default:b.find("ul").show();}p.get("list").onShowListEvent()}}).on("hide.eac",function(){switch(p.get("list").hideAnimation.type){case"slide":var a=p.get("list").hideAnimation.time,c=p.get("list").hideAnimation.callback;b.find("ul").slideUp(a,c);break;case"fade":var a=p.get("list").hideAnimation.time,c=p.get("list").hideAnimation.callback;b.find("ul").fadeOut(a,c);break;default:b.find("ul").hide();}p.get("list").onHideListEvent()}).on("selectElement.eac",function(){b.find("ul li").removeClass("selected"),b.find("ul li").eq(x).addClass("selected"),p.get("list").onSelectItemEvent()}).on("loadElements.eac",function(d,e,f){var g="",h=b.find("ul");h.empty().detach(),w=[];for(var l,m=0,n=0,o=e.length;n<o;n+=1)if(l=e[n].data,0!==l.length){void 0!==e[n].header&&0<e[n].header.length&&h.append("<div class='eac-category' >"+e[n].header+"</div>");for(var q=0,j=l.length;q<j&&m<e[n].maxListSize;q+=1)g=a("<li><div class='eac-item'></div></li>"),function(){var a=q,b=m,d=e[n].getValue(l[a]);g.find(" > div").on("click",function(){u.val(d).trigger("change"),x=b,k(b),p.get("list").onClickEvent(),p.get("list").onChooseEvent()}).mouseover(function(){x=b,k(b),p.get("list").onMouseOverEvent()}).mouseout(function(){p.get("list").onMouseOutEvent()}).html(r.build(c(d,f),l[a]))}(),h.append(g),w.push(l[q]),m+=1}b.append(h),p.get("list").onLoadEvent()})}(),u.after(b)}(),v=a("#"+g()),p.get("placeholder")&&u.attr("placeholder",p.get("placeholder"))}function g(){var a=u.attr("id");return a=o.getValue("CONTAINER_ID")+a,a}function h(){function b(){u.focusout(function(){var a,b=u.val();p.get("list").match.caseSensitive||(b=b.toLowerCase());for(var c=0,d=w.length;c<d;c+=1)if(a=p.get("getValue")(w[c]),p.get("list").match.caseSensitive||(a=a.toLowerCase()),a===b)return x=c,void k(x)})}function c(){u.off("keyup").keyup(function(b){function c(b){function c(){var a={},b=p.get("ajaxSettings")||{};for(var c in b)a[c]=b[c];return a}function d(a,b){return!1===p.get("matchResponseProperty")||("string"==typeof p.get("matchResponseProperty")?b[p.get("matchResponseProperty")]===a:"function"!=typeof p.get("matchResponseProperty")||p.get("matchResponseProperty")(b)===a)}if(!(b.length<p.get("minCharNumber"))){if("list-required"!==p.get("data")){var e=p.get("data"),f=s.init(e);f=s.updateCategories(f,e),f=s.processData(f,b),l(f,b),0<u.parent().find("li").length?i():j()}var g=c();(void 0===g.url||""===g.url)&&(g.url=p.get("url")),(void 0===g.dataType||""===g.dataType)&&(g.dataType=p.get("dataType")),void 0!==g.url&&"list-required"!==g.url&&(g.url=g.url(b),g.data=p.get("preparePostData")(g.data,b),a.ajax(g).done(function(a){var c=s.init(a);c=s.updateCategories(c,a),c=s.convertXml(c),d(b,a)&&(c=s.processData(c,b),l(c,b)),s.checkIfDataExists(c)&&0<u.parent().find("li").length?i():j(),p.get("ajaxCallback")()}).fail(function(){q.warning("Fail to load response data")}).always(function(){}))}}switch(b.keyCode){case 27:j(),m();break;case 38:b.preventDefault(),0<w.length&&0<x&&(x-=1,u.val(p.get("getValue")(w[x])),k(x));break;case 40:b.preventDefault(),0<w.length&&x<w.length-1&&(x+=1,u.val(p.get("getValue")(w[x])),k(x));break;default:if(40<b.keyCode||8===b.keyCode||0===b.keyCode){var d=u.val();!0===p.get("list").hideOnEmptyPhrase&&8===b.keyCode&&""===d?j():0<p.get("requestDelay")?(void 0!==n&&clearTimeout(n),n=setTimeout(function(){c(d)},p.get("requestDelay"))):c(d)}}})}function d(){u.on("keydown",function(a){a=a||window.event;var b=a.keyCode;if(38===b)return suppressKeypress=!0,!1}).keydown(function(a){13===a.keyCode&&-1<x&&(u.val(p.get("getValue")(w[x])),p.get("list").onKeyEnterEvent(),p.get("list").onChooseEvent(),x=-1,j(),a.preventDefault())})}function e(){u.off("keypress")}function f(){u.focus(function(){""!==u.val()&&0<w.length&&(x=-1,i())})}function g(){u.blur(function(){setTimeout(function(){x=-1,j()},250)})}function h(){u.attr("autocomplete","off")}(function(){t("autocompleteOff",!0)&&h(),b(),c(),d(),e(),f(),g()})()}function i(){v.trigger("show.eac")}function j(){v.trigger("hide.eac")}function k(a){v.trigger("selectElement.eac",a)}function l(a,b){v.trigger("loadElements.eac",[a,b])}function m(){u.trigger("blur")}var n,o=new b.Constants,p=new b.Configuration(d),q=new b.Logger,r=new b.Template(d.template),s=new b.ListBuilderService(p,b.proccess),t=p.equals,u=c,v="",w=[],x=-1;b.consts=o,this.getConstants=function(){return o},this.getConfiguration=function(){return p},this.getContainer=function(){return v},this.getSelectedItemIndex=function(){return x},this.getItems=function(){return w},this.getItemData=function(a){return w.length<a||void 0===w[a]?-1:w[a]},this.getSelectedItemData=function(){return this.getItemData(x)},this.build=function(){f()},this.init=function(){e()}},b.eacHandles=[],b.getHandle=function(a){return b.eacHandles[a]},b.inputHasId=function(b){return!!(void 0!==a(b).attr("id")&&0<a(b).attr("id").length)},b.assignRandomId=function(c){var d="";do d="eac-"+Math.floor(1e4*Math.random());while(0!==a("#"+d).length);elementId=b.consts.getValue("CONTAINER_ID")+d,a(c).attr("id",d)},b.setHandle=function(a,c){b.eacHandles[c]=a},b}(b||{});a.fn.easyAutocomplete=function(c){return this.each(function(){var d=a(this),e=new b.main(d,c);b.inputHasId(d)||b.assignRandomId(d),e.init(),b.setHandle(e,d.attr("id"))})},a.fn.getSelectedItemIndex=function(){var c=a(this).attr("id");return void 0===c?-1:b.getHandle(c).getSelectedItemIndex()},a.fn.getItems=function(){var c=a(this).attr("id");return void 0===c?-1:b.getHandle(c).getItems()},a.fn.getItemData=function(c){var d=a(this).attr("id");return void 0!==d&&-1<c?b.getHandle(d).getItemData(c):-1},a.fn.getSelectedItemData=function(){var c=a(this).attr("id");return void 0===c?-1:b.getHandle(c).getSelectedItemData()}})(jQuery);