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