<NME> jquery.flexdatalist.min.js
<BEF> !function(e){"use strict";e.fn.flexdatalist=function(t){var i=e(document),a=this;return i.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),r=i.find("li"),s=r.filter(".active"),n=s.index(),l=r.length,o=t.keyCode||t.which;0!==l&&(13===o?(t.preventDefault(),s.click()):40!==o&&38!==o||(t.preventDefault(),40===o?s=l>n&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=n>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:last").addClass("active")),a._scrollTo(i,s)))}).data("flexdatalist",!0),this._scrollTo=function(e,t){var i=(0===t.prev().length?t:t.prev()).position().top;e.animate({scrollTop:i+e.scrollTop()},100)},this._keyNum=function(e){return e.which||e.keyCode},this._ignoreKey=function(e){var t=a._keyNum(e);return 0===t||13===t||38===t||40===t},this._isEmpty=function(e){return a._isDefined(e)?null===e?!0:this._isObject(e)&&0===Object.keys(e).length?!0:""===e:!0},this._isObject=function(e){return e&&"object"==typeof e},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),r={};i.attr("name");if(i.destroy=function(){i.removeClass("flexdatalist-set").off().attr("type","text").next(".flexdatalist-alias").remove()},i.reset=function(){i.destroy()},("string"!=typeof t||(i[t](),"destroy"!==t))&&!i.hasClass("flexdatalist-set")){var s=e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:0,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,maxShownResults:100},t,i.data());s.searchIn="string"==typeof s.searchIn?s.searchIn.split(","):s.searchIn,s.visibleProperties=0===s.visibleProperties.length?s.searchIn:s.visibleProperties,s.textProperty=null===s.textProperty?s.searchIn[0]:s.textProperty,s.multiple=i.attr("multiple"),s.relatives=s.relatives&&e(s.relatives).length>0?e(s.relatives):null;var n=i.clone(!0).attr("name",null).addClass("flexdatalist-alias").removeClass("flexdatalist");if(s.multiple){var l=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(n).appendTo(l)}else n.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){i._chained(),i._datalist(),n.on("input keyup",function(e){var t=i._keyword();a._ignoreKey(e)||(t.length>=s.minLength?i._search(t,function(e){i._showResults(e)}):i._removeResults(),s.multiple||(s.selectionRequired?0!==t.length&&i._selected()||i._value(""):i._value(t)))}).on("input keydown",function(e){188===a._keyNum(e)&&!s.selectionRequired&&s.multiple&&(e.preventDefault(),i._value(i._keyword()))}).focus(function(){0===s.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):n.trigger("keyup"))}).blur(function(){s.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._chained=function(){if(s.relatives&&s.chainedRelatives){var t=function(){s.relatives.each(function(){var t=""===e.trim(e(this).val());n.prop("disabled",t),t&&(i._value(""),n.val(""))})};s.relatives.on("change",function(){t()}),t()}},i._initValue=function(){var e=i.attr("value");a._isEmpty(e)||i._parseValue(e,function(e){a._isEmpty(e)||(i.val(""),i._values(e))})},i._parseValue=function(e,t){if(i._toJSON())try{t(JSON.parse(e))}catch(a){}else if(i._toCSV()||"string"==typeof s.valueProperty){var r=e.split(",");if("string"==typeof s.valueProperty){var n=s.searchIn;s.searchIn=s.valueProperty.split(","),s.searchEqual=!0,i._search(r,function(e,i){i.length>0&&t(i),s.searchIn=n,s.searchEqual=!1})}else t(r)}else t(e)},i._data=function(t){if(a._isObject(s.data)&&Object.keys(s.data).length>0)return void t(s.data);if("string"==typeof s.data)s.url=s.data;else if(!s.url&&!s.data)return;var r=i._keyword(),n=r.substring(0,s.minLength),l=i._cache(n);return l?void t(l):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:s.url,data:e.extend(i._relativesData(),s.params,{keyword:n,contain:s.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var r=e.results?e.results:e;"string"==typeof r&&0===r.indexOf("[{")&&(r=JSON.parse(r)),a._isObject(r)&&(t(r),"string"==typeof s.data?s.data=e:s.url&&i._cache(n,r))}})))},i._relativesData=function(){var t={};return s.relatives&&(t.relatives={},s.relatives.each(function(){var i=e(this);t.relatives[i.attr("name")]=i.val()})),t},i._datalist=function(){var t=i.attr("list");return a._isEmpty(t)||(n.attr("list",null),s.data=[],e("#"+t).find("option").each(function(){var t=e(this).val();s.data.push({label:t,value:t})})),i},i._cache=function(e,t){if(s.cache){if(e=i._normalizeString(e),!a._isDefined(t))return a._isDefined(r,e)&&(t=r[e]),t;r[e]=t}return null},i._search=function(e,t){"string"==typeof e&&(e=[e]),i._data(function(r){for(var n=[],l=[],o=s.groupBy,u=0;u<e.length;u++)for(var c=e[u],d=0;d<r.length;d++){var f=i._matches(r[d],c);if(f)if(l.push(f),o){if(a._isDefined(f,o)){var p=f[o];a._isDefined(n,p)||(n[p]=[]),n[p].push(f)}}else n.push(f)}t(n,l)})},i._matches=function(e,t){for(var r=!1,n=0;n<s.searchIn.length;n++){var l=s.searchIn[n];if(a._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),r=!0)}}return r?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,s.searchContain?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){return t=i._normalizeString(t),e=i._normalizeString(e),s.searchEqual?t==e:s.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer();i._selected()&&i._selected(!1)._value(""),s.groupBy?Object.keys(t).forEach(function(r){var n=t[r],l=s.groupBy,o=i._getHighlight(n[0],l,r);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+n.length)).appendTo(a);i._items(n,a)}):i._items(t,a);var r=a.find("li:not(.group)");r.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,s]))}).hover(function(){r.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),s.focusFirstResult&&r.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;s.multiple&&(t=l);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",n)),a},i._items=function(e,t){for(var a=s.maxShownResults,r=0;r<e.length&&!(a>0&&a===r);r++)i._item(e[r]).appendTo(t)},i._item=function(t){for(var r=e("<li>").data("item",t).addClass("item"),n=0;n<s.visibleProperties.length;n++){var l=s.visibleProperties[n];if((!s.groupBy||s.groupBy!==l)&&a._isDefined(t,l)){var o={};if("thumb"===l)o=e("<img>").addClass("item item-"+l).attr("src",t[l]);else{var u=i._getHighlight(t,l);o=e("<span>").addClass("item item-"+l).html(u+" ")}o.appendTo(r)}}return r},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return a._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return a._isObject(t)&&a._isDefined(t)&&t.length>0?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),r=i._getValue(t);if(s.multiple){if(""===t)return i;n.val("");var o=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="remove">&times;</span>').insertBefore(l.find("li.input-container"));o.find("span.remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&n.val(a);return i._inputValue(r,a),i},i._inputValue=function(e,t){var r=i._toJSON(),n=i._toCSV();return a._isDefined(e)?(a._isObject(e)&&(r&&!a._isEmpty(e)?e=JSON.stringify(e):n&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,s]).trigger("change"),e):(e=i.val(),e?r?e=JSON.parse(e):n&&(e=e.split(",")):(r||n)&&(e=[]),e)},i._getText=function(e){var t=e;return a._isObject(e)&&(t=e[s.searchIn[0]],t=a._isDefined(e,s.textProperty)?e[s.textProperty]:i._replacePlaceholders(e,s.textProperty,t)),t},i._getValue=function(t){var r=t;if(a._isObject(t))if(r=t[s.searchIn[0]],"*"===s.valueProperty)r=t;else if(a._isDefined(t,s.valueProperty))r=t[s.valueProperty];else if(i._toJSON()){var r={},n=s.valueProperty,l=s.textProperty;if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),a._isObject(o)&&e.each(o,function(e,t){n.push(t)})}else a._isDefined(t,l)&&n.push(l);e.each(n,function(e,i){a._isDefined(t,i)&&(r[i]=t[i])})}if(s.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!a._isEmpty(r)&&a._isObject(u)&&(u.push(r),r=u)}return r},i._replacePlaceholders=function(t,r,s){if(a._isObject(t)&&"string"==typeof r){var n=i._parsePlaceholders(r);if(!a._isEmpty(t)&&n)return e.each(n,function(e,i){a._isDefined(t,i)&&(r=r.replace(e,t[i]))}),r}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){return"string"==typeof e?("function"==typeof s.normalizeString&&(e=s.normalizeString(e)),e.toUpperCase()):e},i._keyword=function(){return n.val().replace(/^\s+/,"")},i._toJSON=function(){return a._isObject(s.valueProperty)||"*"===s.valueProperty},i._toCSV=function(){return!i._toJSON()&&s.multiple},i._getHighlight=function(e,t,i){return a._isDefined(e,t+"_highlight")?e[t+"_highlight"]:a._isDefined(e,t)?e[t]:i},i._position=function(){var t=n;s.multiple&&(t=l),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._init(),i._initValue()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
//# sourceMappingURL=jquery.flexdatalist.min.js.map
<MSG> minor fix

<DFF> @@ -1,1 +1,1 @@
-!function(e){"use strict";e.fn.flexdatalist=function(t){var i=e(document),a=this;return i.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),r=i.find("li"),s=r.filter(".active"),n=s.index(),l=r.length,o=t.keyCode||t.which;0!==l&&(13===o?(t.preventDefault(),s.click()):40!==o&&38!==o||(t.preventDefault(),40===o?s=l>n&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=n>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:last").addClass("active")),a._scrollTo(i,s)))}).data("flexdatalist",!0),this._scrollTo=function(e,t){var i=(0===t.prev().length?t:t.prev()).position().top;e.animate({scrollTop:i+e.scrollTop()},100)},this._keyNum=function(e){return e.which||e.keyCode},this._ignoreKey=function(e){var t=a._keyNum(e);return 0===t||13===t||38===t||40===t},this._isEmpty=function(e){return a._isDefined(e)?null===e?!0:this._isObject(e)&&0===Object.keys(e).length?!0:""===e:!0},this._isObject=function(e){return e&&"object"==typeof e},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),r={};i.attr("name");if(i.destroy=function(){i.removeClass("flexdatalist-set").off().attr("type","text").next(".flexdatalist-alias").remove()},i.reset=function(){i.destroy()},("string"!=typeof t||(i[t](),"destroy"!==t))&&!i.hasClass("flexdatalist-set")){var s=e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:0,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,maxShownResults:100},t,i.data());s.searchIn="string"==typeof s.searchIn?s.searchIn.split(","):s.searchIn,s.visibleProperties=0===s.visibleProperties.length?s.searchIn:s.visibleProperties,s.textProperty=null===s.textProperty?s.searchIn[0]:s.textProperty,s.multiple=i.attr("multiple"),s.relatives=s.relatives&&e(s.relatives).length>0?e(s.relatives):null;var n=i.clone(!0).attr("name",null).addClass("flexdatalist-alias").removeClass("flexdatalist");if(s.multiple){var l=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(n).appendTo(l)}else n.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){i._chained(),i._datalist(),n.on("input keyup",function(e){var t=i._keyword();a._ignoreKey(e)||(t.length>=s.minLength?i._search(t,function(e){i._showResults(e)}):i._removeResults(),s.multiple||(s.selectionRequired?0!==t.length&&i._selected()||i._value(""):i._value(t)))}).on("input keydown",function(e){188===a._keyNum(e)&&!s.selectionRequired&&s.multiple&&(e.preventDefault(),i._value(i._keyword()))}).focus(function(){0===s.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):n.trigger("keyup"))}).blur(function(){s.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._chained=function(){if(s.relatives&&s.chainedRelatives){var t=function(){s.relatives.each(function(){var t=""===e.trim(e(this).val());n.prop("disabled",t),t&&(i._value(""),n.val(""))})};s.relatives.on("change",function(){t()}),t()}},i._initValue=function(){var e=i.attr("value");a._isEmpty(e)||i._parseValue(e,function(e){a._isEmpty(e)||(i.val(""),i._values(e))})},i._parseValue=function(e,t){if(i._toJSON())try{t(JSON.parse(e))}catch(a){}else if(i._toCSV()||"string"==typeof s.valueProperty){var r=e.split(",");if("string"==typeof s.valueProperty){var n=s.searchIn;s.searchIn=s.valueProperty.split(","),s.searchEqual=!0,i._search(r,function(e,i){i.length>0&&t(i),s.searchIn=n,s.searchEqual=!1})}else t(r)}else t(e)},i._data=function(t){if(a._isObject(s.data)&&Object.keys(s.data).length>0)return void t(s.data);if("string"==typeof s.data)s.url=s.data;else if(!s.url&&!s.data)return;var r=i._keyword(),n=r.substring(0,s.minLength),l=i._cache(n);return l?void t(l):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:s.url,data:e.extend(i._relativesData(),s.params,{keyword:n,contain:s.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var r=e.results?e.results:e;"string"==typeof r&&0===r.indexOf("[{")&&(r=JSON.parse(r)),a._isObject(r)&&(t(r),"string"==typeof s.data?s.data=e:s.url&&i._cache(n,r))}})))},i._relativesData=function(){var t={};return s.relatives&&(t.relatives={},s.relatives.each(function(){var i=e(this);t.relatives[i.attr("name")]=i.val()})),t},i._datalist=function(){var t=i.attr("list");return a._isEmpty(t)||(n.attr("list",null),s.data=[],e("#"+t).find("option").each(function(){var t=e(this).val();s.data.push({label:t,value:t})})),i},i._cache=function(e,t){if(s.cache){if(e=i._normalizeString(e),!a._isDefined(t))return a._isDefined(r,e)&&(t=r[e]),t;r[e]=t}return null},i._search=function(e,t){"string"==typeof e&&(e=[e]),i._data(function(r){for(var n=[],l=[],o=s.groupBy,u=0;u<e.length;u++)for(var c=e[u],d=0;d<r.length;d++){var f=i._matches(r[d],c);if(f)if(l.push(f),o){if(a._isDefined(f,o)){var p=f[o];a._isDefined(n,p)||(n[p]=[]),n[p].push(f)}}else n.push(f)}t(n,l)})},i._matches=function(e,t){for(var r=!1,n=0;n<s.searchIn.length;n++){var l=s.searchIn[n];if(a._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),r=!0)}}return r?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,s.searchContain?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){return t=i._normalizeString(t),e=i._normalizeString(e),s.searchEqual?t==e:s.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer();i._selected()&&i._selected(!1)._value(""),s.groupBy?Object.keys(t).forEach(function(r){var n=t[r],l=s.groupBy,o=i._getHighlight(n[0],l,r);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+n.length)).appendTo(a);i._items(n,a)}):i._items(t,a);var r=a.find("li:not(.group)");r.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,s]))}).hover(function(){r.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),s.focusFirstResult&&r.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;s.multiple&&(t=l);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",n)),a},i._items=function(e,t){for(var a=s.maxShownResults,r=0;r<e.length&&!(a>0&&a===r);r++)i._item(e[r]).appendTo(t)},i._item=function(t){for(var r=e("<li>").data("item",t).addClass("item"),n=0;n<s.visibleProperties.length;n++){var l=s.visibleProperties[n];if((!s.groupBy||s.groupBy!==l)&&a._isDefined(t,l)){var o={};if("thumb"===l)o=e("<img>").addClass("item item-"+l).attr("src",t[l]);else{var u=i._getHighlight(t,l);o=e("<span>").addClass("item item-"+l).html(u+" ")}o.appendTo(r)}}return r},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return a._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return a._isObject(t)&&a._isDefined(t)&&t.length>0?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),r=i._getValue(t);if(s.multiple){if(""===t)return i;n.val("");var o=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="remove">&times;</span>').insertBefore(l.find("li.input-container"));o.find("span.remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&n.val(a);return i._inputValue(r,a),i},i._inputValue=function(e,t){var r=i._toJSON(),n=i._toCSV();return a._isDefined(e)?(a._isObject(e)&&(r&&!a._isEmpty(e)?e=JSON.stringify(e):n&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,s]).trigger("change"),e):(e=i.val(),e?r?e=JSON.parse(e):n&&(e=e.split(",")):(r||n)&&(e=[]),e)},i._getText=function(e){var t=e;return a._isObject(e)&&(t=e[s.searchIn[0]],t=a._isDefined(e,s.textProperty)?e[s.textProperty]:i._replacePlaceholders(e,s.textProperty,t)),t},i._getValue=function(t){var r=t;if(a._isObject(t))if(r=t[s.searchIn[0]],"*"===s.valueProperty)r=t;else if(a._isDefined(t,s.valueProperty))r=t[s.valueProperty];else if(i._toJSON()){var r={},n=s.valueProperty,l=s.textProperty;if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),a._isObject(o)&&e.each(o,function(e,t){n.push(t)})}else a._isDefined(t,l)&&n.push(l);e.each(n,function(e,i){a._isDefined(t,i)&&(r[i]=t[i])})}if(s.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!a._isEmpty(r)&&a._isObject(u)&&(u.push(r),r=u)}return r},i._replacePlaceholders=function(t,r,s){if(a._isObject(t)&&"string"==typeof r){var n=i._parsePlaceholders(r);if(!a._isEmpty(t)&&n)return e.each(n,function(e,i){a._isDefined(t,i)&&(r=r.replace(e,t[i]))}),r}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){return"string"==typeof e?("function"==typeof s.normalizeString&&(e=s.normalizeString(e)),e.toUpperCase()):e},i._keyword=function(){return n.val().replace(/^\s+/,"")},i._toJSON=function(){return a._isObject(s.valueProperty)||"*"===s.valueProperty},i._toCSV=function(){return!i._toJSON()&&s.multiple},i._getHighlight=function(e,t,i){return a._isDefined(e,t+"_highlight")?e[t+"_highlight"]:a._isDefined(e,t)?e[t]:i},i._position=function(){var t=n;s.multiple&&(t=l),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._init(),i._initValue()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
\ No newline at end of file
+!function(e){"use strict";e.fn.flexdatalist=function(t){var i=e(document),a=this;return i.data("flexdatalist")||e(document).mouseup(function(t){var i=e(".flexdatalist-results"),a=i.data("target");a&&a.is(":focus")||i.is(t.target)||0!==i.has(t.target).length||i.remove()}).keydown(function(t){var i=e(".flexdatalist-results"),r=i.find("li"),s=r.filter(".active"),n=s.index(),l=r.length,o=t.keyCode||t.which;0!==l&&(13===o?(t.preventDefault(),s.click()):40!==o&&38!==o||(t.preventDefault(),40===o?s=l>n&&s.nextAll(".item").first().length>0?s.removeClass("active").nextAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:first").addClass("active"):38===o&&(s=n>0&&s.prevAll(".item").first().length>0?s.removeClass("active").prevAll(".item").first().addClass("active"):r.removeClass("active").filter(".item:last").addClass("active")),a._scrollTo(i,s)))}).data("flexdatalist",!0),this._scrollTo=function(e,t){var i=(0===t.prev().length?t:t.prev()).position().top;e.animate({scrollTop:i+e.scrollTop()},100)},this._keyNum=function(e){return e.which||e.keyCode},this._ignoreKey=function(e){var t=a._keyNum(e);return 0===t||13===t||38===t||40===t},this._isEmpty=function(e){return a._isDefined(e)?null===e?!0:this._isObject(e)&&0===Object.keys(e).length?!0:""===e:!0},this._isObject=function(e){return e&&"object"==typeof e},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this.each(function(){var i=e(this),r={};i.attr("name");if(i.destroy=function(){i.removeClass("flexdatalist-set").off().attr("type","text").next(".flexdatalist-alias").remove()},i.reset=function(){i.destroy()},("string"!=typeof t||(i[t](),"destroy"!==t))&&!i.hasClass("flexdatalist-set")){var s=e.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:!1,cache:!0,minLength:2,groupBy:!1,selectionRequired:!1,focusFirstResult:!1,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:!1,searchEqual:!1,normalizeString:null,maxShownResults:100},t,i.data());s.searchIn="string"==typeof s.searchIn?s.searchIn.split(","):s.searchIn,s.visibleProperties=0===s.visibleProperties.length?s.searchIn:s.visibleProperties,s.textProperty=null===s.textProperty?s.searchIn[0]:s.textProperty,s.multiple=i.attr("multiple"),s.relatives=s.relatives&&e(s.relatives).length>0?e(s.relatives):null;var n=i.clone(!0).attr("name",null).addClass("flexdatalist-alias").removeClass("flexdatalist");if(s.multiple){var l=e("<ul>").addClass("flexdatalist-multiple").css({"background-color":i.css("background-color"),"border-color":i.css("border-left-color"),"border-width":i.css("border-left-width"),"border-style":i.css("border-left-style"),"border-radius":i.css("border-top-left-radius")}).insertAfter(i);e('<li class="input-container">').addClass("flexdatalist-multiple-value").append(n).appendTo(l)}else n.insertAfter(i);i.addClass("flexdatalist").attr("type","hidden"),i._init=function(){i._chained(),i._datalist(),n.on("input keyup",function(e){var t=i._keyword();a._ignoreKey(e)||(t.length>=s.minLength?i._search(t,function(e){i._showResults(e)}):i._removeResults(),s.multiple||(s.selectionRequired?0!==t.length&&i._selected()||i._value(""):i._value(t)))}).on("input keydown",function(e){188===a._keyNum(e)&&!s.selectionRequired&&s.multiple&&(e.preventDefault(),i._value(i._keyword()))}).focus(function(){0===s.minLength&&(""===i._keyword()?i._data(function(e){i._showResults(e)}):n.trigger("keyup"))}).blur(function(){s.selectionRequired&&!i._selected()&&i._value("")}).attr("autocomplete","off"),i.addClass("flexdatalist-set"),window.onresize=function(){i._position()}},i._chained=function(){if(s.relatives&&s.chainedRelatives){var t=function(){s.relatives.each(function(){var t=""===e.trim(e(this).val());n.prop("disabled",t),t&&(i._value(""),n.val(""))})};s.relatives.on("change",function(){t()}),t()}},i._initValue=function(){var e=i.attr("value");a._isEmpty(e)||i._parseValue(e,function(e){a._isEmpty(e)||(i.val(""),i._values(e))})},i._parseValue=function(e,t){if(i._toJSON())try{t(JSON.parse(e))}catch(a){}else if(i._toCSV()||"string"==typeof s.valueProperty){var r=e.split(",");if("string"==typeof s.valueProperty){var n=s.searchIn;s.searchIn=s.valueProperty.split(","),s.searchEqual=!0,i._search(r,function(e,i){i.length>0&&t(i),s.searchIn=n,s.searchEqual=!1})}else t(r)}else t(e)},i._data=function(t){if(a._isObject(s.data)&&Object.keys(s.data).length>0)return void t(s.data);if("string"==typeof s.data)s.url=s.data;else if(!s.url&&!s.data)return;var r=i._keyword(),n=r.substring(0,s.minLength),l=i._cache(n);return l?void t(l):void(i.hasClass("flexdatalist-loading")||(i.addClass("flexdatalist-loading"),e.ajax({url:s.url,data:e.extend(i._relativesData(),s.params,{keyword:n,contain:s.searchContain,selected:i.val()}),type:"post",dataType:"json",success:function(e){i.removeClass("flexdatalist-loading");var r=e.results?e.results:e;"string"==typeof r&&0===r.indexOf("[{")&&(r=JSON.parse(r)),a._isObject(r)&&(t(r),"string"==typeof s.data?s.data=e:s.url&&i._cache(n,r))}})))},i._relativesData=function(){var t={};return s.relatives&&(t.relatives={},s.relatives.each(function(){var i=e(this);t.relatives[i.attr("name")]=i.val()})),t},i._datalist=function(){var t=i.attr("list");return a._isEmpty(t)||(n.attr("list",null),s.data=[],e("#"+t).find("option").each(function(){var t=e(this).val();s.data.push({label:t,value:t})})),i},i._cache=function(e,t){if(s.cache){if(e=i._normalizeString(e),!a._isDefined(t))return a._isDefined(r,e)&&(t=r[e]),t;r[e]=t}return null},i._search=function(e,t){"string"==typeof e&&(e=[e]),i._data(function(r){for(var n=[],l=[],o=s.groupBy,u=0;u<e.length;u++)for(var c=e[u],d=0;d<r.length;d++){var f=i._matches(r[d],c);if(f)if(l.push(f),o){if(a._isDefined(f,o)){var p=f[o];a._isDefined(n,p)||(n[p]=[]),n[p].push(f)}}else n.push(f)}t(n,l)})},i._matches=function(e,t){for(var r=!1,n=0;n<s.searchIn.length;n++){var l=s.searchIn[n];if(a._isDefined(e,l)){var o=e[l];i._find(t,o,e)&&(e[l+"_highlight"]=i._highlight(t,o),r=!0)}}return r?e:null},i._highlight=function(e,t){return t.replace(new RegExp(e,s.searchContain?"ig":"i"),'<span class="highlight">$&</span>')},i._find=function(e,t){return t=i._normalizeString(t),e=i._normalizeString(e),s.searchEqual?t==e:s.searchContain?t.indexOf(e)>=0:0===t.indexOf(e)},i._showResults=function(t){i._removeResults();var a=i._getResultsContainer();i._selected()&&i._selected(!1)._value(""),s.groupBy?Object.keys(t).forEach(function(r){var n=t[r],l=s.groupBy,o=i._getHighlight(n[0],l,r);e("<li>").addClass("group").append(e("<span>").addClass("group-name").html(o)).append(e("<span>").addClass("group-item-count").text(" "+n.length)).appendTo(a);i._items(n,a)}):i._items(t,a);var r=a.find("li:not(.group)");r.on("click",function(){var t=e(this).data("item");t&&(i._selected(!0)._removeResults()._value(t),i.trigger("select:flexdatalist",[t,s]))}).hover(function(){r.removeClass("active"),e(this).addClass("active")},function(){e(this).removeClass("active")}),s.focusFirstResult&&r.filter(":first").addClass("active"),i._position()},i._getResultsContainer=function(){var t=i;s.multiple&&(t=l);var a=e("ul.flexdatalist-results");return 0===a.length&&(a=e("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":t.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":t.css("border-bottom-left-radius"),"border-bottom-right-radius":t.css("border-bottom-right-radius")}).data("target",n)),a},i._items=function(e,t){for(var a=s.maxShownResults,r=0;r<e.length&&!(a>0&&a===r);r++)i._item(e[r]).appendTo(t)},i._item=function(t){for(var r=e("<li>").data("item",t).addClass("item"),n=0;n<s.visibleProperties.length;n++){var l=s.visibleProperties[n];if((!s.groupBy||s.groupBy!==l)&&a._isDefined(t,l)){var o={};if("thumb"===l)o=e("<img>").addClass("item item-"+l).attr("src",t[l]);else{var u=i._getHighlight(t,l);o=e("<span>").addClass("item item-"+l).html(u+" ")}o.appendTo(r)}}return r},i._removeResults=function(){return e("ul.flexdatalist-results").remove(),i},i._selected=function(e){var t="flexdatalist-selected";return a._isDefined(e)?(e?i.addClass(t):i.removeClass(t),i):i.hasClass(t)},i._values=function(t){return a._isObject(t)&&a._isDefined(t)&&t.length>0?void e.each(t,function(e,t){i._value(t)}):void i._value(t)},i._value=function(t){var a=i._getText(t),r=i._getValue(t);if(s.multiple){if(""===t)return i;n.val("");var o=e("<li>").addClass("value").append('<span class="text">'+a+"</span>").append('<span class="remove">&times;</span>').insertBefore(l.find("li.input-container"));o.find("span.remove").click(function(){var t=e(this).parent();if(i._toJSON()||i._toCSV()){var a=i._inputValue();a.splice(t.index(),1),i._inputValue(a)}t.remove()})}else a&&n.val(a);return i._inputValue(r,a),i},i._inputValue=function(e,t){var r=i._toJSON(),n=i._toCSV();return a._isDefined(e)?(a._isObject(e)&&(r&&!a._isEmpty(e)?e=JSON.stringify(e):n&&(e=e.join(","))),i.val(e),i.trigger("change:flexdatalist",[e,t,s]).trigger("change"),e):(e=i.val(),e?r?e=JSON.parse(e):n&&(e=e.split(",")):(r||n)&&(e=[]),e)},i._getText=function(e){var t=e;return a._isObject(e)&&(t=e[s.searchIn[0]],t=a._isDefined(e,s.textProperty)?e[s.textProperty]:i._replacePlaceholders(e,s.textProperty,t)),t},i._getValue=function(t){var r=t;if(a._isObject(t))if(r=t[s.searchIn[0]],"*"===s.valueProperty)r=t;else if(a._isDefined(t,s.valueProperty))r=t[s.valueProperty];else if(i._toJSON()){var r={},n=s.valueProperty,l=s.textProperty;if(l){var o=l;"string"==typeof l&&(o=i._parsePlaceholders(l)),a._isObject(o)&&e.each(o,function(e,t){n.push(t)})}else a._isDefined(t,l)&&n.push(l);e.each(n,function(e,i){a._isDefined(t,i)&&(r[i]=t[i])})}if(s.multiple&&(i._toJSON()||i._toCSV())){var u=i._inputValue();!a._isEmpty(r)&&a._isObject(u)&&(u.push(r),r=u)}return r},i._replacePlaceholders=function(t,r,s){if(a._isObject(t)&&"string"==typeof r){var n=i._parsePlaceholders(r);if(!a._isEmpty(t)&&n)return e.each(n,function(e,i){a._isDefined(t,i)&&(r=r.replace(e,t[i]))}),r}return s},i._parsePlaceholders=function(e){var t=e.match(/\{.+?\}/g);if(t){var i={};return t.map(function(e){i[e]=e.slice(1,-1)}),i}return!1},i._normalizeString=function(e){return"string"==typeof e?("function"==typeof s.normalizeString&&(e=s.normalizeString(e)),e.toUpperCase()):e},i._keyword=function(){return n.val().replace(/^\s+/,"")},i._toJSON=function(){return a._isObject(s.valueProperty)||"*"===s.valueProperty},i._toCSV=function(){return!i._toJSON()&&s.multiple},i._getHighlight=function(e,t,i){return a._isDefined(e,t+"_highlight")?e[t+"_highlight"]:a._isDefined(e,t)?e[t]:i},i._position=function(){var t=n;s.multiple&&(t=l),e("ul.flexdatalist-results").css({width:t.outerWidth()+"px",top:t.offset().top+t.outerHeight()+"px",left:t.offset().left+"px","z-index":t.css("z-index")+1})},i._init(),i._initValue()}})},e("input.flexdatalist").flexdatalist()}(jQuery);
\ No newline at end of file

minor fix