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

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

Version 1.0.0