"),c=n.getValue("WRAPPER_CSS_CLASS");o.get("theme")&&""!==o.get("theme")&&(c+=" eac-"+o.get("theme")),o.get("cssClasses")&&""!==o.get("cssClasses")&&(c+=" "+o.get("cssClasses")),""!==q.getTemplateClass()&&(c+=" "+q.getTemplateClass()),a.addClass(c),t.wrap(a),o.get("adjustWidth")===!0&&b()}function b(){var a=t.outerWidth();t.parent().css("width",a)}function c(){t.unwrap()}function d(){var a=$("
").addClass(n.getValue("CONTAINER_CLASS"));a.attr("id",f()).prepend($("
")),function(){a.on("show.eac",function(){switch(o.get("list").showAnimation.type){case"slide":var b=o.get("list").showAnimation.time,c=o.get("list").showAnimation.callback;a.find("ul").slideDown(b,c);break;case"fade":var b=o.get("list").showAnimation.time,c=o.get("list").showAnimation.callback;a.find("ul").fadeIn(b),c;break;default:a.find("ul").show()}o.get("list").onShowListEvent()}).on("hide.eac",function(){switch(o.get("list").hideAnimation.type){case"slide":var b=o.get("list").hideAnimation.time,c=o.get("list").hideAnimation.callback;a.find("ul").slideUp(b,c);break;case"fade":var b=o.get("list").hideAnimation.time,c=o.get("list").hideAnimation.callback;a.find("ul").fadeOut(b,c);break;default:a.find("ul").hide()}o.get("list").onHideListEvent()}).on("selectElement.eac",function(){a.find("ul li").removeClass("selected"),a.find("ul li").eq(w).addClass("selected"),o.get("list").onSelectItemEvent()}).on("loadElements.eac",function(b,c,d){var e="",f=a.find("ul");f.empty().detach(),v=[];for(var h=0,i=0,k=c.length;k>i;i+=1){var l=c[i].data;if(0!==l.length){void 0!==c[i].header&&c[i].header.length>0&&f.append(""+c[i].header+"
");for(var m=0,n=l.length;n>m&&h"),function(){var a=m,b=h,f=c[i].getValue(l[a]);e.find(" > div").on("click",function(){t.val(f).trigger("change"),w=b,j(b),o.get("list").onClickEvent(),o.get("list").onChooseEvent()}).mouseover(function(){w=b,j(b),o.get("list").onMouseOverEvent()}).mouseout(function(){o.get("list").onMouseOutEvent()}).html(q.build(g(f,d),l[a]))}(),f.append(e),v.push(l[m]),h+=1}}a.append(f),o.get("list").onLoadEvent()})}(),t.after(a)}function e(){t.next("."+n.getValue("CONTAINER_CLASS")).remove()}function g(a,b){return o.get("highlightPhrase")&&""!==b?i(a,b):a}function h(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function i(a,b){var c=h(b);return(a+"").replace(new RegExp("("+c+")","gi"),"$1")}t.parent().hasClass(n.getValue("WRAPPER_CSS_CLASS"))&&(e(),c()),a(),d(),u=$("#"+f()),o.get("placeholder")&&t.attr("placeholder",o.get("placeholder"))}function f(){var a=t.attr("id");return a=n.getValue("CONTAINER_ID")+a}function g(){function a(){s("autocompleteOff",!0)&&g(),b(),c(),d(),e(),f()}function b(){t.off("keyup").keyup(function(a){function b(a){function b(){var a={},b=o.get("ajaxSettings")||{};for(var c in b)a[c]=b[c];return a}function c(a,b){return o.get("matchResponseProperty")!==!1?"string"==typeof o.get("matchResponseProperty")?b[o.get("matchResponseProperty")]===a:"function"==typeof o.get("matchResponseProperty")?o.get("matchResponseProperty")(b)===a:!0:!0}if(!(a.length0?h():i()}var f=b();(void 0===f.url||""===f.url)&&(f.url=o.get("url")),(void 0===f.dataType||""===f.dataType)&&(f.dataType=o.get("dataType")),void 0!==f.url&&"list-required"!==f.url&&(f.url=f.url(a),f.data=o.get("preparePostData")(f.data,a),$.ajax(f).done(function(b){var d=r.init(b);d=r.updateCategories(d,b),d=r.convertXml(d),c(a,b)&&(d=r.processData(d,a),k(d,a)),r.checkIfDataExists(d)&&t.parent().find("li").length>0?h():i(),o.get("ajaxCallback")()}).fail(function(){p.warning("Fail to load response data")}).always(function(){}))}}switch(a.keyCode){case 27:i(),l();break;case 38:a.preventDefault(),v.length>0&&w>0&&(w-=1,t.val(o.get("getValue")(v[w])),j(w));break;case 40:a.preventDefault(),v.length>0&&w40||8===a.keyCode){var c=t.val();o.get("list").hideOnEmptyPhrase!==!0||8!==a.keyCode||""!==c?o.get("requestDelay")>0?(void 0!==m&&clearTimeout(m),m=setTimeout(function(){b(c)},o.get("requestDelay"))):b(c):i()}}})}function c(){t.on("keydown",function(a){a=a||window.event;var b=a.keyCode;return 38===b?(suppressKeypress=!0,!1):void 0}).keydown(function(a){13===a.keyCode&&w>-1&&(t.val(o.get("getValue")(v[w])),o.get("list").onKeyEnterEvent(),o.get("list").onChooseEvent(),w=-1,i(),a.preventDefault())})}function d(){t.off("keypress")}function e(){t.focus(function(){""!==t.val()&&v.length>0&&(w=-1,h())})}function f(){t.blur(function(){setTimeout(function(){w=-1,i()},250)})}function g(){t.attr("autocomplete","off")}a()}function h(){u.trigger("show.eac")}function i(){u.trigger("hide.eac")}function j(a){u.trigger("selectElement.eac",a)}function k(a,b){u.trigger("loadElements.eac",[a,b])}function l(){t.trigger("blur")}var m,n=new a.Constans,o=new a.Configuration(c),p=new a.Logger,q=new a.Template(c.template),r=new a.ListBuilderService(o,a.proccess),s=o.equals,t=b,u="",v=[],w=-1;a.consts=n,this.getConstants=function(){return n},this.getConfiguration=function(){return o},this.getContainer=function(){return u},this.getSelectedItemIndex=function(){return w},this.getItemData=function(a){return v.length0?!0:!1},a.assignRandomId=function(b){var c="";do c="eac-"+Math.floor(1e4*Math.random());while(0!==$("#"+c).length);elementId=a.consts.getValue("CONTAINER_ID")+c,$(b).attr("id",c)},a}(EasyAutocomplete||{});$.fn.easyAutocomplete=function(a){return this.each(function(){var b=$(this),c=new EasyAutocomplete.main(b,a);EasyAutocomplete.inputHasId(b)||EasyAutocomplete.assignRandomId(b),c.init(),EasyAutocomplete.easyAutocompleteHandles[b.attr("id")]=c})},$.fn.getSelectedItemIndex=function(){var a=$(this).attr("id");return void 0!==a?EasyAutocomplete.easyAutocompleteHandles[a].getSelectedItemIndex():-1},$.fn.getItemData=function(a){var b=$(this).attr("id");return void 0!==b&&a>-1?EasyAutocomplete.easyAutocompleteHandles[b].getItemData(a):-1},$.fn.getSelectedItemData=function(){var a=$(this).attr("id");return void 0!==a?EasyAutocomplete.easyAutocompleteHandles[a].getSelectedItemData():-1};
\ No newline at end of file
diff --git a/src/logger.js b/src/logger.js
index ef9370a..b167ad3 100644
--- a/src/logger.js
+++ b/src/logger.js
@@ -4,15 +4,14 @@
var EasyAutocomplete = (function(scope){
scope.Logger = function Logger() {
- var logger = {};
this.error = function(message) {
console.log("ERROR: " + message);
- }
+ };
this.warning = function(message) {
console.log("WARNING: " + message);
- }
+ };
};
return scope;
diff --git a/src/template.js b/src/template.js
index 9789ddb..b22f5d4 100644
--- a/src/template.js
+++ b/src/template.js
@@ -68,11 +68,12 @@ var EasyAutocomplete = (function(scope){
convertTemplateToMethod = function(template) {
- var _fields = template.fields;
+ var _fields = template.fields,
+ buildMethod;
if (template.type === "description") {
- var buildMethod = genericTemplates.description.method;
+ buildMethod = genericTemplates.description.method;
if (typeof _fields.description === "string") {
buildMethod = function(elementValue, element) {
@@ -89,8 +90,6 @@ var EasyAutocomplete = (function(scope){
if (template.type === "iconRight") {
- var buildMethod = "";
-
if (typeof _fields.iconSrc === "string") {
buildMethod = function(elementValue, element) {
return elementValue + "" ;
@@ -107,8 +106,6 @@ var EasyAutocomplete = (function(scope){
if (template.type === "iconLeft") {
- var buildMethod = "";
-
if (typeof _fields.iconSrc === "string") {
buildMethod = function(elementValue, element) {
return "" + elementValue;
@@ -124,8 +121,6 @@ var EasyAutocomplete = (function(scope){
if(template.type === "links") {
- var buildMethod = "";
-
if (typeof _fields.link === "string") {
buildMethod = function(elementValue, element) {
return "" + elementValue + "";