<NME> jquery.flexdatalist.min.js
<BEF> jQuery.fn.flexdatalist=function(e,t){"use strict";var i,a=$(document),s=$(this),l=this;if(i=function(){var t,i,a=$(this),s={},r="",n=null;a.attr("name");a.hasClass("flexdatalist-set")&&l._destroy(a),l._options(a,$.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,searchByWord:!1,searchDisabled:!1,normalizeString:null,multiple:a.is("[multiple]"),maxShownResults:100,noResultsText:'No results found for "{keyword}"',toggleSelected:!1,allowDuplicateValues:!1,requestType:"get",limitOfValues:0,_values:[]},a.data(),"object"==typeof e?e:{})),a._options=function(e,t){return l._options(a,e,t)},t=a.clone(!1).attr({list:null,name:null,id:a.attr("id")?a.attr("id")+"-flexdatalist":null}).addClass("flexdatalist-alias").removeClass("flexdatalist"),a._options("multiple")?(i=$("<ul>").addClass("flexdatalist-multiple").css({"border-color":a.css("border-left-color"),"border-width":a.css("border-left-width"),"border-style":a.css("border-left-style"),"border-radius":a.css("border-top-left-radius"),"background-color":a.css("background-color")}).insertAfter(a).click(function(){$(this).find("input").focus()}),$('<li class="input-container">').addClass("flexdatalist-multiple-value").append(t).appendTo(i)):t.insertAfter(a),t.attr("autofocus")&&t.focus(),a._init=function(){var e=a._options();t.on("input keydown",function(i){var s=a._keyword();188!==l._keyNum(i)&&13!==l._keyNum(i)||e.selectionRequired||!e.multiple||a._resultSelected()?9===l._keyNum(i)?a._removeResults():0===s.length&&e.multiple&&8===l._keyNum(i)&&t.data("_remove",t.parents("li:eq(0)").prev()):(i.preventDefault(),a._value(s),a._removeResults())}).on("input keyup",function(i){if(a._changed()&&13!==l._keyNum(i)){var s=a._keyword();e.multiple||(e._values=[],e.selectionRequired?a._value(""):a._value(s)),s.length>=e.minLength?a._search(function(e){a._showResults(e)}):a._removeResults()}var n=t.data("_remove");n&&(n.find(".fdl-remove").click(),t.data("_remove",null)),r=a._keyword()}).on("focus",function(){var t=a._keyword();0===e.minLength?""===t&&a._tdata(function(e){a._showResults(e)}):t.length>=e.minLength&&!a._selected()&&a._search(function(e){a._showResults(e)})}).on("blur",function(){a._resultSelected()||!e.multiple||e.selectionRequired||a._value(a._keyword())}).attr("autocomplete","off"),window.onresize=function(){a._position()},a.addClass("flexdatalist flexdatalist-set").prop("type","hidden")},a._resultSelected=function(){return $("ul.flexdatalist-results").find("li.item.active").length>0},a._changed=function(){return r!==a._keyword()},a._chained=function(){var e=a._options();if(e.relatives&&e.chainedRelatives){var r=function(s){e.relatives.each(function(){var r=l._isEmpty($(this).val()),n=l._isEmpty(a.val());t.prop("disabled",r),s||!r&&n||(a._value(""),t.val(""),e.multiple&&i.find("li .fdl-remove").click()),i&&(r&&i?i.addClass("disabled"):i.removeClass("disabled"))})};e.relatives.on("change",function(){r(),s={}}),r(!0)}},a._initValue=function(){var e=a.attr("value");l._isEmpty(e)||(a._options("originalValue",a.val()),a._options("searchEqual",!0),a._parseValue(e,function(e){a.val("",!0),t.val(""),a._options("searchEqual",!1),l._isEmpty(e)||a._values(e,!0),r=a._keyword()}))},a._parseValue=function(e,t){var i=a._options();if(a._toJSON())try{t(JSON.parse(e))}catch(s){}else if(a._toCSV()||"string"==typeof i.valueProperty){var l=e.split(",");if("string"==typeof i.valueProperty){var r=i.searchIn;i.searchIn=i.valueProperty.split(","),i.searchEqual=!0,a._search(function(e){e.length>0&&t(e),i.searchIn=r,i.searchEqual=!1},l)}else t(l)}else t(e)},a._tdata=function(e){a.trigger("before:flexdatalist.data"),a._url(function(t){a._data(function(i){i=i.concat(t);for(var s=a._options("_values"),l=0;l<i.length;l++){var r=i[l];s&&s.indexOf(a._getText(r))>-1&&delete i[l]}a.trigger("after:flexdatalist.data",[i]),e(i)})})},a._data=function(e){var t=a._options();"string"==typeof t.data?a._remote({url:t.data,success:function(i){var s=a._getRemoteData(i);t.data=s,e(s)}}):e(t.data)},a._url=function(e){var t=a._options(),i=a._keyword(),s=a.val(),r=i;return l._isEmpty(t.url)?e([]):(clearTimeout(n),void(n=setTimeout(function(){t.cache&&2!==t.cache&&(r=i.substring(0,t.minLength>0?t.minLength:1));var l=a._cache(r);if(l&&t.cache)return void e(l);var n={};"post"==t.requestType&&($.each(t,function(e,t){0!=e.indexOf("_")&&(n[e]=t)}),delete n.relatives),a._remote({url:t.url,data:$.extend(a._relativesData(),t.params,{keyword:i,contain:t.searchContain,selected:s,options:n}),success:function(t){var s=a._getRemoteData(t),l=a._keyword();l.length>=i.length&&e(s),a._cache(r,s)}})},200)))},a._remote=function(e){a.hasClass("flexdatalist-loading")||(a.addClass("flexdatalist-loading"),e=$.extend({type:a._options("requestType"),dataType:"json",complete:function(){a.removeClass("flexdatalist-loading")}},e),$.ajax(e))},a._getRemoteData=function(e){var t=e.results?e.results:e;return"string"==typeof t&&0===t.indexOf("[{")&&(t=JSON.parse(t)),t.options&&l._options(a,t.options),l._isObject(t)?t:[]},a._relativesData=function(){var e=a._options("relatives"),t={};return e&&(t.relatives={},e.each(function(){var e=$(this),i=e.attr("name").split("][").join("-").split("]").join("-").split("[").join("-").replace(/^\|+|\-+$/g,"");t.relatives[i]=e.val()})),t},a._datalist=function(){var e=a._options(),t=a.attr("list");return l._isEmpty(t)||(e.data=[],$("#"+t).find("option").each(function(){var t=$(this),i=t.val(),a=t.text();e.data.push({label:a.length>0?a:i,value:i})})),a},a._cache=function(e,t){if(a._options("cache")){if(e=a._normalizeString(e),!l._isDefined(t))return l._isDefined(s,e)&&(t=s[e]),t;s[e]=t}return null},a._search=function(e,t){a._tdata(function(i){var s=[],r=a._options();if(r.searchDisabled)return e(i);l._isDefined(t)||(t=a._keyword()),a.trigger("before:flexdatalist.search",[t,i]),t=a._split(t);for(var n=0;n<i.length;n++){var o=a._matches(i[n],t);o&&s.push(o)}a.trigger("after:flexdatalist.search",[t,i,s]),e(s)})},a._matches=function(e,t){var i=$.extend({},e),s=a._options(),r=[],n=s.searchIn;if(t.length>0)for(var o=0;o<n.length;o++){var u=n[o];if(l._isDefined(e,u)&&e[u]){for(var f=e[u].toString(),d=f,c=a._split(f),_=0;_<t.length;_++){var p=t[_];a._find(p,c)&&(r.push(p),d=a._highlight(p,d))}d!==f&&(i[u+"_highlight"]=a._highlight(d))}}return 0===r.length||s.searchByWord&&r.length<t.length-1?!1:i},a._highlight=function(e,t){return t?t.replace(new RegExp(e,a._options("searchContain")?"ig":"i"),"|:|$&|::|"):(e=e.split("|:|").join('<span class="highlight">'),e.split("|::|").join("</span>"))},a._find=function(e,t){for(var i=a._options(),s=0;s<t.length;s++){var l=t[s];if(l=a._normalizeString(l),e=a._normalizeString(e),i.searchEqual)return l==e;if(i.searchContain?l.indexOf(e)>=0:0===l.indexOf(e))return!0}return!1},a._split=function(e){"string"==typeof e&&(e=[$.trim(e)]);var t=a._options();if(t.searchByWord)for(var i=0;i<e.length;i++){var s=$.trim(e[i]);if(s.indexOf(" ")>0){var l=s.split(" ");$.merge(e,l)}}return e},a._showResults=function(e){a._removeResults(!0);var t=a._options();if(0===e.length)return void a._noResults(t.noResultsText);var i=a._getResultsContainer();t.groupBy?(e=a._groupData(e),Object.keys(e).forEach(function(s){var l=e[s],r=t.groupBy,n=a._getHighlight(l[0],r,s);$("<li>").addClass("group").append($("<span>").addClass("group-name").html(n)).append($("<span>").addClass("group-item-count").text(" "+l.length)).appendTo(i);a._items(l,i)})):a._items(e,i);var s=i.find("li:not(.group)");s.on("click",function(){var e=$(this).data("item");e&&(a._selected(!0)._removeResults()._value(e),a.trigger("select:flexdatalist",[e,t]))}).hover(function(){s.removeClass("active"),$(this).addClass("active")},function(){$(this).removeClass("active")}),t.focusFirstResult&&s.filter(":first").addClass("active")},a._noResults=function(e){if(!l._isEmpty(e)){var t=a._getResultsContainer(),i=a._keyword();e=e.split("{keyword}").join(i),$("<li>").addClass("item no-results").append(e).appendTo(t)}},a._groupData=function(e){for(var t=[],i=a._options("groupBy"),s=0;s<e.length;s++){var r=e[s];if(l._isDefined(r,i)){var n=r[i];l._isDefined(t,n)||(t[n]=[]),t[n].push(r)}}return t},a._items=function(e,t){var i=a._options("maxShownResults");a.trigger("show:flexdatalist.results",[e]);for(var s=0;s<e.length&&!(i>0&&i===s);s++)a._item(e[s]).appendTo(t);a.trigger("shown:flexdatalist.results",[e])},a._item=function(e){for(var t=$("<li>").data("item",e).addClass("item"),i=a._options(),s=i.visibleProperties,r=0;r<s.length;r++){var n=s[r];if((!i.groupBy||i.groupBy!==n)&&l._isDefined(e,n)){var o={};if("thumb"===n)o=$("<img>").addClass("item item-"+n).attr("src",e[n]);else{var u=a._getHighlight(e,n);o=$("<span>").addClass("item item-"+n).html(u+" ")}o.appendTo(t)}}return t},a._getHighlight=function(e,t,i){return l._isDefined(e,t+"_highlight")?e[t+"_highlight"]:l._isDefined(e,t)?e[t]:i},a._getResultsContainer=function(){var e=a;a._options("multiple")&&(e=i);var s=$("ul.flexdatalist-results");return 0===s.length&&(s=$("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":e.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":e.css("border-bottom-left-radius"),"border-bottom-right-radius":e.css("border-bottom-right-radius")}).data("target",t),a._position()),s},a._removeResults=function(e){var t="ul.flexdatalist-results";return e&&(t="ul.flexdatalist-results li"),$(t).remove(),a},a._selected=function(e){var t="flexdatalist-selected";return l._isDefined(e)?(e?a.addClass(t):a.removeClass(t),a):a.hasClass(t)},a._values=function(e,t){return $.isArray(e)&&!l._isEmpty(e)?void $.each(e,function(e,i){a._value(i,t)}):void a._value(e,t)},a._value=function(e,s){var l=a._options(),n=a._getText(e),o=a._getValue(e);if(n.length>0&&!l.allowDuplicateValues&&l._values.push(n),l.multiple){if(""===e)return a;t.val("");var u=i.find("li.input-container"),f=$("<li>").addClass("value"+(l.toggleSelected?" toggle":"")).append('<span class="text">'+n+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(u);u.find("input").focus(),f.find("span.fdl-remove").click(function(){var e=$(this).parent(),t=e.index();if(!e.hasClass("disabled")&&(a._toJSON()||a._toCSV())){var i=a._normalizeValue();i.splice(t,1),l._values.splice(t,1),a._normalizeValue(i),a._allowValues()}e.remove()}),l.toggleSelected&&f.click(function(){var e=$(this),t=a._normalizeValue(),i=e.index();if(e.hasClass("disabled")){var s=e.data("_value");t.splice(i,0,s),l._values.splice(i,0,a._getText(s)),e.removeClass("disabled")}else{var s=t.splice(i,1);e.data("_value",s[0]),l._values.splice(i,1),e.addClass("disabled")}a._normalizeValue(t,n)})}else n&&n!==t.val()&&t.val(n);return a._normalizeValue(o,n,s),r=a._keyword(),a},a._normalizeValue=function(e,t,i){var s=a._toJSON(),r=(a._options(),a._toCSV());return l._isDefined(e)?(a._allowValues(),l._isObject(e)&&(s&&!l._isEmpty(e)?e=JSON.stringify(e):r&&(e=e.join(","))),e==a.val()?e:(""===e&&a._options("_values",[]),a.val(e,!0),!i&&a._changed()&&a.trigger("change:flexdatalist",[e,t,a._options()]).trigger("change"),e)):(e=a.val(),e?s?e=JSON.parse(e):r&&(e=e.split(",")):(s||r)&&(e=[]),e)},a._getText=function(e){var t=e,i=a._options();return l._isObject(e)&&(t=e[i.searchIn[0]],t=l._isDefined(e,i.textProperty)?e[i.textProperty]:a._replacePlaceholders(e,i.textProperty,t)),$("<div>").html(t).text()},a._getValue=function(e){var t=e,i=a._options();if(l._isObject(e))if(t=e[i.searchIn[0]],"*"===i.valueProperty)t=e;else if(l._isDefined(e,i.valueProperty))t=e[i.valueProperty];else if(a._toJSON()){var t={},s=i.valueProperty,r=i.textProperty;if(r){var n=r;"string"==typeof r&&(n=a._parsePlaceholders(r)),l._isObject(n)&&$.each(n,function(e,t){s.push(t)})}else l._isDefined(e,r)&&s.push(r);$.each(s,function(i,a){l._isDefined(e,a)&&(t[a]=e[a])})}if(i.multiple&&(a._toJSON()||a._toCSV())){var o=a._normalizeValue();!l._isEmpty(t)&&l._isObject(o)&&(o.push(t),t=o)}return t},a._replacePlaceholders=function(e,t,i){if(l._isObject(e)&&"string"==typeof t){var s=a._parsePlaceholders(t);if(!l._isEmpty(e)&&s)return $.each(s,function(i,a){l._isDefined(e,a)&&(t=t.replace(i,e[a]))}),t}return i},a._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},a._allowValues=function(){var e=a._options();if(e.limitOfValues>0&&e.multiple){var t=i.find(".flexdatalist-multiple-value");e._values.length>=e.limitOfValues?t.hide():t.show()}},a._normalizeString=function(e){if("string"==typeof e){var t=a._options("normalizeString");return"function"==typeof t&&(e=t(e)),e.toUpperCase()}return e},a._keyword=function(){return t.val().replace(/^\s+/,"")},a._toJSON=function(){var e=a._options("valueProperty");return l._isObject(e)||"*"===e},a._toCSV=function(){return!a._toJSON()&&a._options("multiple")},a._position=function(){var e=t;a._options("multiple")&&(e=i),$("ul.flexdatalist-results").css({width:e.outerWidth()+"px",top:e.offset().top+e.outerHeight()+"px",left:e.offset().left+"px"})},a._init(),a._datalist(),a._chained(),a._initValue()},this._destroy=function(e){e||(e=s),e.each(function(){var e=$(this).data("flexdatalist");$(this).removeClass("flexdatalist-set").attr("type","text").val(e&&e.originalValue?e.originalValue:"").removeData("flexdatalist").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove()})},this._reset=function(){this._destroy()},this._setValue=function(e){s.each(function(){var t=$(this),i=t.data("flexdatalist");if(l._isDefined(i)){if(i.originalValue=e,""==e)return t.val(e,!0),void(i.multiple&&t.next("ul.flexdatalist-multiple").find("li.value").remove());l._destroy()}})},this._keyNum=function(e){return e.which||e.keyCode},a.data("flexdatalist")||$(document).mouseup(function(e){var t=$(".flexdatalist-results"),i=t.data("target");i&&i.is(":focus")||t.is(e.target)||0!==t.has(e.target).length||t.remove()}).keydown(function(e){var t=$(".flexdatalist-results"),i=t.find("li"),a=i.filter(".active"),s=a.index(),r=i.length,n=l._keyNum(e);if(0!==r){if(27===l._keyNum(e))return t.remove();if(13===n)e.preventDefault(),a.click();else if(40===n||38===n){e.preventDefault(),40===n?a=r>s&&a.nextAll(".item").first().length>0?a.removeClass("active").nextAll(".item").first().addClass("active"):i.removeClass("active").filter(".item:first").addClass("active"):38===n&&(a=s>0&&a.prevAll(".item").first().length>0?a.removeClass("active").prevAll(".item").first().addClass("active"):i.removeClass("active").filter(".item:last").addClass("active"));var o=(0===a.prev().length?a:a.prev()).position().top;t.animate({scrollTop:o+t.scrollTop()},100)}}}).data("flexdatalist",!0),this._isEmpty=function(e){return l._isDefined(e)?null===e?!0:e===!0?!1:0===this._length(e)?!0:""===$.trim(e):!0},this._isObject=function(e){return e&&"object"==typeof e},this._csvToArray=function(e,t){return 0===e.length?t:"string"==typeof e?e.split(","):e},this._length=function(e){return this._isObject(e)?Object.keys(e).length:"number"==typeof e.length?e.length:0},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this._options=function(e,t,i){var a=e.data("flexdatalist");if(l._isDefined(t)){if(l._isDefined(i))a[t]=i;else{if(!l._isObject(t))return l._isDefined(a,t)?a[t]:null;a=t}a.searchIn=l._csvToArray(a.searchIn),a.relatives=a.relatives&&$(a.relatives).length>0?$(a.relatives):null,a.textProperty=null===a.textProperty?a.searchIn[0]:a.textProperty,a.visibleProperties=l._csvToArray(a.visibleProperties,a.searchIn),e.data("flexdatalist",a)}return a},"string"==typeof e)if("function"==typeof this["_"+e]){if(!this["_"+e]())return this}else{if("value"!==e)return t?(l._options(s,e,t),this):l._options(s,e);this._setValue(t)}return this.each(i)};var _defaultValFunc=jQuery.fn.val;jQuery.fn.val=function(e,t){return!t&&$(this).hasClass("flexdatalist-set")&&"undefined"!=typeof e&&$(this).flexdatalist("value",e),_defaultValFunc.apply(this,arguments)},$(function(){$("input.flexdatalist:not(.flexdatalist-set)").flexdatalist()});
//# sourceMappingURL=jquery.flexdatalist.min.js.map
<MSG> Minify

<DFF> @@ -1,1 +1,1 @@
-jQuery.fn.flexdatalist=function(e,t){"use strict";var i,a=$(document),s=$(this),l=this;if(i=function(){var t,i,a=$(this),s={},r="",n=null;a.attr("name");a.hasClass("flexdatalist-set")&&l._destroy(a),l._options(a,$.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,searchByWord:!1,searchDisabled:!1,normalizeString:null,multiple:a.is("[multiple]"),maxShownResults:100,noResultsText:'No results found for "{keyword}"',toggleSelected:!1,allowDuplicateValues:!1,requestType:"get",limitOfValues:0,_values:[]},a.data(),"object"==typeof e?e:{})),a._options=function(e,t){return l._options(a,e,t)},t=a.clone(!1).attr({list:null,name:null,id:a.attr("id")?a.attr("id")+"-flexdatalist":null}).addClass("flexdatalist-alias").removeClass("flexdatalist"),a._options("multiple")?(i=$("<ul>").addClass("flexdatalist-multiple").css({"border-color":a.css("border-left-color"),"border-width":a.css("border-left-width"),"border-style":a.css("border-left-style"),"border-radius":a.css("border-top-left-radius"),"background-color":a.css("background-color")}).insertAfter(a).click(function(){$(this).find("input").focus()}),$('<li class="input-container">').addClass("flexdatalist-multiple-value").append(t).appendTo(i)):t.insertAfter(a),t.attr("autofocus")&&t.focus(),a._init=function(){var e=a._options();t.on("input keydown",function(i){var s=a._keyword();188!==l._keyNum(i)&&13!==l._keyNum(i)||e.selectionRequired||!e.multiple||a._resultSelected()?9===l._keyNum(i)?a._removeResults():0===s.length&&e.multiple&&8===l._keyNum(i)&&t.data("_remove",t.parents("li:eq(0)").prev()):(i.preventDefault(),a._value(s),a._removeResults())}).on("input keyup",function(i){if(a._changed()&&13!==l._keyNum(i)){var s=a._keyword();e.multiple||(e._values=[],e.selectionRequired?a._value(""):a._value(s)),s.length>=e.minLength?a._search(function(e){a._showResults(e)}):a._removeResults()}var n=t.data("_remove");n&&(n.find(".fdl-remove").click(),t.data("_remove",null)),r=a._keyword()}).on("focus",function(){var t=a._keyword();0===e.minLength?""===t&&a._tdata(function(e){a._showResults(e)}):t.length>=e.minLength&&!a._selected()&&a._search(function(e){a._showResults(e)})}).on("blur",function(){a._resultSelected()||!e.multiple||e.selectionRequired||a._value(a._keyword())}).attr("autocomplete","off"),window.onresize=function(){a._position()},a.addClass("flexdatalist flexdatalist-set").prop("type","hidden")},a._resultSelected=function(){return $("ul.flexdatalist-results").find("li.item.active").length>0},a._changed=function(){return r!==a._keyword()},a._chained=function(){var e=a._options();if(e.relatives&&e.chainedRelatives){var r=function(s){e.relatives.each(function(){var r=l._isEmpty($(this).val()),n=l._isEmpty(a.val());t.prop("disabled",r),s||!r&&n||(a._value(""),t.val(""),e.multiple&&i.find("li .fdl-remove").click()),i&&(r&&i?i.addClass("disabled"):i.removeClass("disabled"))})};e.relatives.on("change",function(){r(),s={}}),r(!0)}},a._initValue=function(){var e=a.attr("value");l._isEmpty(e)||(a._options("originalValue",a.val()),a._options("searchEqual",!0),a._parseValue(e,function(e){a.val("",!0),t.val(""),a._options("searchEqual",!1),l._isEmpty(e)||a._values(e,!0),r=a._keyword()}))},a._parseValue=function(e,t){var i=a._options();if(a._toJSON())try{t(JSON.parse(e))}catch(s){}else if(a._toCSV()||"string"==typeof i.valueProperty){var l=e.split(",");if("string"==typeof i.valueProperty){var r=i.searchIn;i.searchIn=i.valueProperty.split(","),i.searchEqual=!0,a._search(function(e){e.length>0&&t(e),i.searchIn=r,i.searchEqual=!1},l)}else t(l)}else t(e)},a._tdata=function(e){a.trigger("before:flexdatalist.data"),a._url(function(t){a._data(function(i){i=i.concat(t);for(var s=a._options("_values"),l=0;l<i.length;l++){var r=i[l];s&&s.indexOf(a._getText(r))>-1&&delete i[l]}a.trigger("after:flexdatalist.data",[i]),e(i)})})},a._data=function(e){var t=a._options();"string"==typeof t.data?a._remote({url:t.data,success:function(i){var s=a._getRemoteData(i);t.data=s,e(s)}}):e(t.data)},a._url=function(e){var t=a._options(),i=a._keyword(),s=a.val(),r=i;return l._isEmpty(t.url)?e([]):(clearTimeout(n),void(n=setTimeout(function(){t.cache&&2!==t.cache&&(r=i.substring(0,t.minLength>0?t.minLength:1));var l=a._cache(r);if(l&&t.cache)return void e(l);var n={};"post"==t.requestType&&($.each(t,function(e,t){0!=e.indexOf("_")&&(n[e]=t)}),delete n.relatives),a._remote({url:t.url,data:$.extend(a._relativesData(),t.params,{keyword:i,contain:t.searchContain,selected:s,options:n}),success:function(t){var s=a._getRemoteData(t),l=a._keyword();l.length>=i.length&&e(s),a._cache(r,s)}})},200)))},a._remote=function(e){a.hasClass("flexdatalist-loading")||(a.addClass("flexdatalist-loading"),e=$.extend({type:a._options("requestType"),dataType:"json",complete:function(){a.removeClass("flexdatalist-loading")}},e),$.ajax(e))},a._getRemoteData=function(e){var t=e.results?e.results:e;return"string"==typeof t&&0===t.indexOf("[{")&&(t=JSON.parse(t)),t.options&&l._options(a,t.options),l._isObject(t)?t:[]},a._relativesData=function(){var e=a._options("relatives"),t={};return e&&(t.relatives={},e.each(function(){var e=$(this),i=e.attr("name").split("][").join("-").split("]").join("-").split("[").join("-").replace(/^\|+|\-+$/g,"");t.relatives[i]=e.val()})),t},a._datalist=function(){var e=a._options(),t=a.attr("list");return l._isEmpty(t)||(e.data=[],$("#"+t).find("option").each(function(){var t=$(this),i=t.val(),a=t.text();e.data.push({label:a.length>0?a:i,value:i})})),a},a._cache=function(e,t){if(a._options("cache")){if(e=a._normalizeString(e),!l._isDefined(t))return l._isDefined(s,e)&&(t=s[e]),t;s[e]=t}return null},a._search=function(e,t){a._tdata(function(i){var s=[],r=a._options();if(r.searchDisabled)return e(i);l._isDefined(t)||(t=a._keyword()),a.trigger("before:flexdatalist.search",[t,i]),t=a._split(t);for(var n=0;n<i.length;n++){var o=a._matches(i[n],t);o&&s.push(o)}a.trigger("after:flexdatalist.search",[t,i,s]),e(s)})},a._matches=function(e,t){var i=$.extend({},e),s=a._options(),r=[],n=s.searchIn;if(t.length>0)for(var o=0;o<n.length;o++){var u=n[o];if(l._isDefined(e,u)&&e[u]){for(var f=e[u].toString(),d=f,c=a._split(f),_=0;_<t.length;_++){var p=t[_];a._find(p,c)&&(r.push(p),d=a._highlight(p,d))}d!==f&&(i[u+"_highlight"]=a._highlight(d))}}return 0===r.length||s.searchByWord&&r.length<t.length-1?!1:i},a._highlight=function(e,t){return t?t.replace(new RegExp(e,a._options("searchContain")?"ig":"i"),"|:|$&|::|"):(e=e.split("|:|").join('<span class="highlight">'),e.split("|::|").join("</span>"))},a._find=function(e,t){for(var i=a._options(),s=0;s<t.length;s++){var l=t[s];if(l=a._normalizeString(l),e=a._normalizeString(e),i.searchEqual)return l==e;if(i.searchContain?l.indexOf(e)>=0:0===l.indexOf(e))return!0}return!1},a._split=function(e){"string"==typeof e&&(e=[$.trim(e)]);var t=a._options();if(t.searchByWord)for(var i=0;i<e.length;i++){var s=$.trim(e[i]);if(s.indexOf(" ")>0){var l=s.split(" ");$.merge(e,l)}}return e},a._showResults=function(e){a._removeResults(!0);var t=a._options();if(0===e.length)return void a._noResults(t.noResultsText);var i=a._getResultsContainer();t.groupBy?(e=a._groupData(e),Object.keys(e).forEach(function(s){var l=e[s],r=t.groupBy,n=a._getHighlight(l[0],r,s);$("<li>").addClass("group").append($("<span>").addClass("group-name").html(n)).append($("<span>").addClass("group-item-count").text(" "+l.length)).appendTo(i);a._items(l,i)})):a._items(e,i);var s=i.find("li:not(.group)");s.on("click",function(){var e=$(this).data("item");e&&(a._selected(!0)._removeResults()._value(e),a.trigger("select:flexdatalist",[e,t]))}).hover(function(){s.removeClass("active"),$(this).addClass("active")},function(){$(this).removeClass("active")}),t.focusFirstResult&&s.filter(":first").addClass("active")},a._noResults=function(e){if(!l._isEmpty(e)){var t=a._getResultsContainer(),i=a._keyword();e=e.split("{keyword}").join(i),$("<li>").addClass("item no-results").append(e).appendTo(t)}},a._groupData=function(e){for(var t=[],i=a._options("groupBy"),s=0;s<e.length;s++){var r=e[s];if(l._isDefined(r,i)){var n=r[i];l._isDefined(t,n)||(t[n]=[]),t[n].push(r)}}return t},a._items=function(e,t){var i=a._options("maxShownResults");a.trigger("show:flexdatalist.results",[e]);for(var s=0;s<e.length&&!(i>0&&i===s);s++)a._item(e[s]).appendTo(t);a.trigger("shown:flexdatalist.results",[e])},a._item=function(e){for(var t=$("<li>").data("item",e).addClass("item"),i=a._options(),s=i.visibleProperties,r=0;r<s.length;r++){var n=s[r];if((!i.groupBy||i.groupBy!==n)&&l._isDefined(e,n)){var o={};if("thumb"===n)o=$("<img>").addClass("item item-"+n).attr("src",e[n]);else{var u=a._getHighlight(e,n);o=$("<span>").addClass("item item-"+n).html(u+" ")}o.appendTo(t)}}return t},a._getHighlight=function(e,t,i){return l._isDefined(e,t+"_highlight")?e[t+"_highlight"]:l._isDefined(e,t)?e[t]:i},a._getResultsContainer=function(){var e=a;a._options("multiple")&&(e=i);var s=$("ul.flexdatalist-results");return 0===s.length&&(s=$("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":e.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":e.css("border-bottom-left-radius"),"border-bottom-right-radius":e.css("border-bottom-right-radius")}).data("target",t),a._position()),s},a._removeResults=function(e){var t="ul.flexdatalist-results";return e&&(t="ul.flexdatalist-results li"),$(t).remove(),a},a._selected=function(e){var t="flexdatalist-selected";return l._isDefined(e)?(e?a.addClass(t):a.removeClass(t),a):a.hasClass(t)},a._values=function(e,t){return $.isArray(e)&&!l._isEmpty(e)?void $.each(e,function(e,i){a._value(i,t)}):void a._value(e,t)},a._value=function(e,s){var l=a._options(),n=a._getText(e),o=a._getValue(e);if(n.length>0&&!l.allowDuplicateValues&&l._values.push(n),l.multiple){if(""===e)return a;t.val("");var u=i.find("li.input-container"),f=$("<li>").addClass("value"+(l.toggleSelected?" toggle":"")).append('<span class="text">'+n+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(u);u.find("input").focus(),f.find("span.fdl-remove").click(function(){var e=$(this).parent(),t=e.index();if(!e.hasClass("disabled")&&(a._toJSON()||a._toCSV())){var i=a._normalizeValue();i.splice(t,1),l._values.splice(t,1),a._normalizeValue(i),a._allowValues()}e.remove()}),l.toggleSelected&&f.click(function(){var e=$(this),t=a._normalizeValue(),i=e.index();if(e.hasClass("disabled")){var s=e.data("_value");t.splice(i,0,s),l._values.splice(i,0,a._getText(s)),e.removeClass("disabled")}else{var s=t.splice(i,1);e.data("_value",s[0]),l._values.splice(i,1),e.addClass("disabled")}a._normalizeValue(t,n)})}else n&&n!==t.val()&&t.val(n);return a._normalizeValue(o,n,s),r=a._keyword(),a},a._normalizeValue=function(e,t,i){var s=a._toJSON(),r=(a._options(),a._toCSV());return l._isDefined(e)?(a._allowValues(),l._isObject(e)&&(s&&!l._isEmpty(e)?e=JSON.stringify(e):r&&(e=e.join(","))),e==a.val()?e:(""===e&&a._options("_values",[]),a.val(e,!0),!i&&a._changed()&&a.trigger("change:flexdatalist",[e,t,a._options()]).trigger("change"),e)):(e=a.val(),e?s?e=JSON.parse(e):r&&(e=e.split(",")):(s||r)&&(e=[]),e)},a._getText=function(e){var t=e,i=a._options();return l._isObject(e)&&(t=e[i.searchIn[0]],t=l._isDefined(e,i.textProperty)?e[i.textProperty]:a._replacePlaceholders(e,i.textProperty,t)),$("<div>").html(t).text()},a._getValue=function(e){var t=e,i=a._options();if(l._isObject(e))if(t=e[i.searchIn[0]],"*"===i.valueProperty)t=e;else if(l._isDefined(e,i.valueProperty))t=e[i.valueProperty];else if(a._toJSON()){var t={},s=i.valueProperty,r=i.textProperty;if(r){var n=r;"string"==typeof r&&(n=a._parsePlaceholders(r)),l._isObject(n)&&$.each(n,function(e,t){s.push(t)})}else l._isDefined(e,r)&&s.push(r);$.each(s,function(i,a){l._isDefined(e,a)&&(t[a]=e[a])})}if(i.multiple&&(a._toJSON()||a._toCSV())){var o=a._normalizeValue();!l._isEmpty(t)&&l._isObject(o)&&(o.push(t),t=o)}return t},a._replacePlaceholders=function(e,t,i){if(l._isObject(e)&&"string"==typeof t){var s=a._parsePlaceholders(t);if(!l._isEmpty(e)&&s)return $.each(s,function(i,a){l._isDefined(e,a)&&(t=t.replace(i,e[a]))}),t}return i},a._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},a._allowValues=function(){var e=a._options();if(e.limitOfValues>0&&e.multiple){var t=i.find(".flexdatalist-multiple-value");e._values.length>=e.limitOfValues?t.hide():t.show()}},a._normalizeString=function(e){if("string"==typeof e){var t=a._options("normalizeString");return"function"==typeof t&&(e=t(e)),e.toUpperCase()}return e},a._keyword=function(){return t.val().replace(/^\s+/,"")},a._toJSON=function(){var e=a._options("valueProperty");return l._isObject(e)||"*"===e},a._toCSV=function(){return!a._toJSON()&&a._options("multiple")},a._position=function(){var e=t;a._options("multiple")&&(e=i),$("ul.flexdatalist-results").css({width:e.outerWidth()+"px",top:e.offset().top+e.outerHeight()+"px",left:e.offset().left+"px"})},a._init(),a._datalist(),a._chained(),a._initValue()},this._destroy=function(e){e||(e=s),e.each(function(){var e=$(this).data("flexdatalist");$(this).removeClass("flexdatalist-set").attr("type","text").val(e&&e.originalValue?e.originalValue:"").removeData("flexdatalist").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove()})},this._reset=function(){this._destroy()},this._setValue=function(e){s.each(function(){var t=$(this),i=t.data("flexdatalist");if(l._isDefined(i)){if(i.originalValue=e,""==e)return t.val(e,!0),void(i.multiple&&t.next("ul.flexdatalist-multiple").find("li.value").remove());l._destroy()}})},this._keyNum=function(e){return e.which||e.keyCode},a.data("flexdatalist")||$(document).mouseup(function(e){var t=$(".flexdatalist-results"),i=t.data("target");i&&i.is(":focus")||t.is(e.target)||0!==t.has(e.target).length||t.remove()}).keydown(function(e){var t=$(".flexdatalist-results"),i=t.find("li"),a=i.filter(".active"),s=a.index(),r=i.length,n=l._keyNum(e);if(0!==r){if(27===l._keyNum(e))return t.remove();if(13===n)e.preventDefault(),a.click();else if(40===n||38===n){e.preventDefault(),40===n?a=r>s&&a.nextAll(".item").first().length>0?a.removeClass("active").nextAll(".item").first().addClass("active"):i.removeClass("active").filter(".item:first").addClass("active"):38===n&&(a=s>0&&a.prevAll(".item").first().length>0?a.removeClass("active").prevAll(".item").first().addClass("active"):i.removeClass("active").filter(".item:last").addClass("active"));var o=(0===a.prev().length?a:a.prev()).position().top;t.animate({scrollTop:o+t.scrollTop()},100)}}}).data("flexdatalist",!0),this._isEmpty=function(e){return l._isDefined(e)?null===e?!0:e===!0?!1:0===this._length(e)?!0:""===$.trim(e):!0},this._isObject=function(e){return e&&"object"==typeof e},this._csvToArray=function(e,t){return 0===e.length?t:"string"==typeof e?e.split(","):e},this._length=function(e){return this._isObject(e)?Object.keys(e).length:"number"==typeof e.length?e.length:0},this._isDefined=function(e,t){var i="undefined"!=typeof e;return i&&"undefined"!=typeof t?"undefined"!=typeof e[t]:i},this._options=function(e,t,i){var a=e.data("flexdatalist");if(l._isDefined(t)){if(l._isDefined(i))a[t]=i;else{if(!l._isObject(t))return l._isDefined(a,t)?a[t]:null;a=t}a.searchIn=l._csvToArray(a.searchIn),a.relatives=a.relatives&&$(a.relatives).length>0?$(a.relatives):null,a.textProperty=null===a.textProperty?a.searchIn[0]:a.textProperty,a.visibleProperties=l._csvToArray(a.visibleProperties,a.searchIn),e.data("flexdatalist",a)}return a},"string"==typeof e)if("function"==typeof this["_"+e]){if(!this["_"+e]())return this}else{if("value"!==e)return t?(l._options(s,e,t),this):l._options(s,e);this._setValue(t)}return this.each(i)};var _defaultValFunc=jQuery.fn.val;jQuery.fn.val=function(e,t){return!t&&$(this).hasClass("flexdatalist-set")&&"undefined"!=typeof e&&$(this).flexdatalist("value",e),_defaultValFunc.apply(this,arguments)},$(function(){$("input.flexdatalist:not(.flexdatalist-set)").flexdatalist()});
\ No newline at end of file
+jQuery.fn.flexdatalist=function(b,c){var d=$(document),f=$(this),a,e=this;a=function(){var l=$(this),j,m,k={},i="",g=null,h=l.attr("name");if(l.hasClass("flexdatalist-set")){e._destroy(l)}e._options(l,$.extend({url:null,data:[],params:{},relatives:null,chainedRelatives:false,cache:true,minLength:2,groupBy:false,selectionRequired:false,focusFirstResult:false,textProperty:null,valueProperty:null,visibleProperties:[],searchIn:["label"],searchContain:false,searchEqual:false,searchByWord:false,searchDisabled:false,normalizeString:null,multiple:l.is("[multiple]"),maxShownResults:100,noResultsText:'No results found for "{keyword}"',toggleSelected:false,allowDuplicateValues:false,requestType:"get",limitOfValues:0,_values:[]},l.data(),(typeof b==="object"?b:{})));l._options=function(o,n){return e._options(l,o,n)};j=l.clone(false).attr({list:null,name:null,id:(l.attr("id")?l.attr("id")+"-flexdatalist":null)}).addClass("flexdatalist-alias").removeClass("flexdatalist");if(l._options("multiple")){m=$("<ul>").addClass("flexdatalist-multiple").css({"border-color":l.css("border-left-color"),"border-width":l.css("border-left-width"),"border-style":l.css("border-left-style"),"border-radius":l.css("border-top-left-radius"),"background-color":l.css("background-color")}).insertAfter(l).click(function(){$(this).find("input").focus()});$('<li class="input-container">').addClass("flexdatalist-multiple-value").append(j).appendTo(m)}else{j.insertAfter(l)}if(j.attr("autofocus")){j.focus()}l._init=function(){var n=l._options();j.on("input keydown",function(o){var p=l._keyword();if((e._keyNum(o)===188||e._keyNum(o)===13)&&!n.selectionRequired&&n.multiple&&!l._resultSelected()){o.preventDefault();l._value(p);l._removeResults()}else{if(e._keyNum(o)===9){l._removeResults()}else{if(p.length===0&&n.multiple&&e._keyNum(o)===8){j.data("_remove",j.parents("li:eq(0)").prev())}}}}).on("input keyup",function(q){if(l._changed()&&e._keyNum(q)!==13){var o=l._keyword();if(!n.multiple){n._values=[];if(!n.selectionRequired){l._value(o)}else{l._value("")}}if(o.length>=n.minLength){l._search(function(r){l._showResults(r)})}else{l._removeResults()}}var p=j.data("_remove");if(p){p.find(".fdl-remove").click();j.data("_remove",null)}i=l._keyword()}).on("focus",function(){var o=l._keyword();if(n.minLength===0){if(o===""){l._tdata(function(p){l._showResults(p)})}}else{if(o.length>=n.minLength&&!l._selected()){l._search(function(p){l._showResults(p)})}}}).on("focusin",function(){l.parent().find(".flexdatalist-multiple").addClass("focus")}).on("focusout",function(){l.parent().find(".flexdatalist-multiple").removeClass("focus")}).on("blur",function(){if(!l._resultSelected()&&n.multiple&&!n.selectionRequired){l._value(l._keyword())}}).attr("autocomplete","off");window.onresize=function(o){l._position()};l.addClass("flexdatalist flexdatalist-set").prop("type","hidden")};l._resultSelected=function(){return $("ul.flexdatalist-results").find("li.item.active").length>0};l._changed=function(){return i!==l._keyword()};l._chained=function(){var o=l._options();if(!o.relatives||!o.chainedRelatives){return}var n=function(p){o.relatives.each(function(){var q=e._isEmpty($(this).val()),r=e._isEmpty(l.val());j.prop("disabled",q);if(!p&&(q||!r)){l._value("");j.val("");if(o.multiple){m.find("li .fdl-remove").click()}}if(m){q&&m?m.addClass("disabled"):m.removeClass("disabled")}})};o.relatives.on("change",function(){n();k={}});n(true)};l._initValue=function(){var n=l.attr("value");if(e._isEmpty(n)){return}l._options("originalValue",l.val());l._options("searchEqual",true);l._parseValue(n,function(o){l.val("",true);j.val("");l._options("searchEqual",false);if(!e._isEmpty(o)){l._values(o,true)}i=l._keyword()})};l._parseValue=function(q,s){var o=l._options();if(l._toJSON()){try{s(JSON.parse(q))}catch(r){}}else{if(l._toCSV()||typeof o.valueProperty==="string"){var p=q.split(",");if(typeof o.valueProperty==="string"){var n=o.searchIn;o.searchIn=o.valueProperty.split(",");o.searchEqual=true;l._search(function(t){if(t.length>0){s(t)}o.searchIn=n;o.searchEqual=false},p)}else{s(p)}}else{s(q)}}};l._tdata=function(n){l.trigger("before:flexdatalist.data");l._url(function(o){l._data(function(s){s=s.concat(o);var p=l._options("_values");for(var q=0;q<s.length;q++){var r=s[q];if(p&&p.indexOf(l._getText(r))>-1){delete s[q]}}l.trigger("after:flexdatalist.data",[s]);n(s)})})};l._data=function(o){var n=l._options();if(typeof n.data==="string"){l._remote({url:n.data,success:function(q){var p=l._getRemoteData(q);n.data=p;o(p)}})}else{o(n.data)}};l._url=function(r){var n=l._options(),o=l._keyword(),p=l.val(),q=o;if(e._isEmpty(n.url)){return r([])}clearTimeout(g);g=setTimeout(function(){if(n.cache&&n.cache!==2){q=o.substring(0,(n.minLength>0?n.minLength:1))}var t=l._cache(q);if(t&&n.cache){r(t);return}var s={};if(n.requestType=="post"){$.each(n,function(u,v){if(u.indexOf("_")==0){return}s[u]=v});delete s.relatives}l._remote({url:n.url,data:$.extend(l._relativesData(),n.params,{keyword:o,contain:n.searchContain,selected:p,options:s}),success:function(v){var u=l._getRemoteData(v),w=l._keyword();if(w.length>=o.length){r(u)}l._cache(q,u)}})},200)};l._remote=function(n){if(l.hasClass("flexdatalist-loading")){return}l.addClass("flexdatalist-loading");n=$.extend({type:l._options("requestType"),dataType:"json",complete:function(){l.removeClass("flexdatalist-loading")}},n);$.ajax(n)};l._getRemoteData=function(o){var n=o.results?o.results:o;if(typeof n==="string"&&n.indexOf("[{")===0){n=JSON.parse(n)}if(n.options){e._options(l,n.options)}if(e._isObject(n)){return n}return[]};l._relativesData=function(){var n=l._options("relatives"),o={};if(n){o.relatives={};n.each(function(){var p=$(this),q=p.attr("name").split("][").join("-").split("]").join("-").split("[").join("-").replace(/^\|+|\-+$/g,"");o.relatives[q]=p.val()})}return o};l._datalist=function(){var n=l._options(),o=l.attr("list");if(!e._isEmpty(o)){n.data=[];$("#"+o).find("option").each(function(){var q=$(this),r=q.val(),p=q.text();n.data.push({label:(p.length>0?p:r),value:r})})}return l};l._cache=function(n,o){if(l._options("cache")){n=l._normalizeString(n);if(!e._isDefined(o)){if(e._isDefined(k,n)){o=k[n]}return o}k[n]=o}return null};l._search=function(o,n){l._tdata(function(t){var s=[],p=l._options();if(p.searchDisabled){return o(t)}if(!e._isDefined(n)){n=l._keyword()}l.trigger("before:flexdatalist.search",[n,t]);n=l._split(n);for(var q=0;q<t.length;q++){var r=l._matches(t[q],n);if(r){s.push(r)}}l.trigger("after:flexdatalist.search",[n,t,s]);o(s)})};l._matches=function(z,q){var o=false,u=$.extend({},z),x=l._options(),A=[],t=x.searchIn;if(q.length>0){for(var s=0;s<t.length;s++){var y=t[s];if(!e._isDefined(z,y)||!z[y]){continue}var w=z[y].toString(),p=w,v=l._split(w);for(var n=0;n<q.length;n++){var r=q[n];if(l._find(r,v)){A.push(r);p=l._highlight(r,p)}}if(p!==w){u[y+"_highlight"]=l._highlight(p)}}}if(A.length===0||(x.searchByWord&&A.length<(q.length-1))){return false}return u};l._highlight=function(n,o){if(o){return o.replace(new RegExp(n,(l._options("searchContain")?"ig":"i")),"|:|$&|::|")}n=n.split("|:|").join('<span class="highlight">');return n.split("|::|").join("</span>")};l._find=function(p,o){var n=l._options();for(var q=0;q<o.length;q++){var r=o[q];r=l._normalizeString(r),p=l._normalizeString(p);if(n.searchEqual){return r==p}if((n.searchContain?(r.indexOf(p)>=0):(r.indexOf(p)===0))){return true}}return false};l._split=function(q){if(typeof q==="string"){q=[$.trim(q)]}var n=l._options();if(n.searchByWord){for(var p=0;p<q.length;p++){var o=$.trim(q[p]);if(o.indexOf(" ")>0){var r=o.split(" ");$.merge(q,r)}}}return q};l._showResults=function(p){l._removeResults(true);var n=l._options();if(p.length===0){l._noResults(n.noResultsText);return}var o=l._getResultsContainer();if(!n.groupBy){l._items(p,o)}else{p=l._groupData(p);Object.keys(p).forEach(function(w,s){var r=p[w],u=n.groupBy,t=l._getHighlight(r[0],u,w);var v=$("<li>").addClass("group").append($("<span>").addClass("group-name").html(t)).append($("<span>").addClass("group-item-count").text(" "+r.length)).appendTo(o);l._items(r,o)})}var q=o.find("li:not(.group)");q.on("click",function(s){var r=$(this).data("item");if(r){l._selected(true)._removeResults()._value(r);l.trigger("select:flexdatalist",[r,n])}}).hover(function(){q.removeClass("active");$(this).addClass("active")},function(){$(this).removeClass("active")});if(n.focusFirstResult){q.filter(":first").addClass("active")}};l._noResults=function(p){if(e._isEmpty(p)){return}var o=l._getResultsContainer(),n=l._keyword();p=p.split("{keyword}").join(n);$("<li>").addClass("item no-results").append(p).appendTo(o)};l._groupData=function(o){var r=[],s=l._options("groupBy");for(var p=0;p<o.length;p++){var q=o[p];if(e._isDefined(q,s)){var n=q[s];if(!e._isDefined(r,n)){r[n]=[]}r[n].push(q)}}return r};l._items=function(o,q){var n=l._options("maxShownResults");l.trigger("show:flexdatalist.results",[o]);for(var p=0;p<o.length;p++){if(n>0&&n===p){break}l._item(o[p]).appendTo(q)}l.trigger("shown:flexdatalist.results",[o])};l._item=function(r){var u=$("<li>").data("item",r).addClass("item"),n=l._options(),o=n.visibleProperties;for(var q=0;q<o.length;q++){var t=o[q];if(n.groupBy&&n.groupBy===t||!e._isDefined(r,t)){continue}var p={};if(t==="thumb"){p=$("<img>").addClass("item item-"+t).attr("src",r[t])}else{var s=l._getHighlight(r,t);p=$("<span>").addClass("item item-"+t).html(s+" ")}p.appendTo(u)}return u};l._getHighlight=function(n,o,p){if(e._isDefined(n,o+"_highlight")){return n[o+"_highlight"]}return(e._isDefined(n,o)?n[o]:p)};l._getResultsContainer=function(){var n=l;if(l._options("multiple")){n=m}var o=$("ul.flexdatalist-results");if(o.length===0){o=$("<ul>").addClass("flexdatalist-results").appendTo("body").css({"border-color":n.css("border-left-color"),"border-width":"1px","border-bottom-left-radius":n.css("border-bottom-left-radius"),"border-bottom-right-radius":n.css("border-bottom-right-radius")}).data("target",j);l._position()}return o};l._removeResults=function(o){var n="ul.flexdatalist-results";if(o){n="ul.flexdatalist-results li"}$(n).remove();return l};l._selected=function(o){var n="flexdatalist-selected";if(!e._isDefined(o)){return l.hasClass(n)}o?l.addClass(n):l.removeClass(n);return l};l._values=function(n,o){if($.isArray(n)&&!e._isEmpty(n)){$.each(n,function(p,q){l._value(q,o)});return}l._value(n,o)};l._value=function(s,r){var n=l._options(),q=l._getText(s),p=l._getValue(s);if(q.length>0&&!n.allowDuplicateValues){n._values.push(q)}if(n.multiple){if(s===""){return l}j.val("");var o=m.find("li.input-container"),t=$("<li>").addClass("value"+(n.toggleSelected?" toggle":"")).append('<span class="text">'+q+"</span>").append('<span class="fdl-remove">&times;</span>').insertBefore(o);o.find("input").focus();t.find("span.fdl-remove").click(function(){var w=$(this).parent(),u=w.index();if(!w.hasClass("disabled")&&(l._toJSON()||l._toCSV())){var v=l._normalizeValue();v.splice(u,1);n._values.splice(u,1);l._normalizeValue(v);l._allowValues()}w.remove()});if(n.toggleSelected){t.click(function(){var u=$(this),w=l._normalizeValue(),v=u.index();if(u.hasClass("disabled")){var x=u.data("_value");w.splice(v,0,x);n._values.splice(v,0,l._getText(x));u.removeClass("disabled")}else{var x=w.splice(v,1);u.data("_value",x[0]);n._values.splice(v,1);u.addClass("disabled")}l._normalizeValue(w,q)})}}else{if(q&&q!==j.val()){j.val(q)}}l._normalizeValue(p,q,r);i=l._keyword();return l};l._normalizeValue=function(p,s,r){var o=l._toJSON(),n=l._options(),q=l._toCSV();if(!e._isDefined(p)){p=l.val();if(p){if(o){p=JSON.parse(p)}else{if(q){p=p.split(",")}}}else{if(o||q){p=[]}}return p}l._allowValues();if(e._isObject(p)){if(o&&!e._isEmpty(p)){p=JSON.stringify(p)}else{if(q){p=p.join(",")}}}if(p==l.val()){return p}if(p===""){l._options("_values",[])}l.val(p,true);if(!r&&l._changed()){l.trigger("change:flexdatalist",[p,s,l._options()]).trigger("change")}return p};l._getText=function(o){var p=o,n=l._options();if(e._isObject(o)){p=o[n.searchIn[0]];if(e._isDefined(o,n.textProperty)){p=o[n.textProperty]}else{p=l._replacePlaceholders(o,n.textProperty,p)}}return $("<div>").html(p).text()};l._getValue=function(s){var t=s,n=l._options();if(e._isObject(s)){t=s[n.searchIn[0]];if(n.valueProperty==="*"){t=s}else{if(e._isDefined(s,n.valueProperty)){t=s[n.valueProperty]}else{if(l._toJSON()){var t={},p=n.valueProperty,r=n.textProperty;if(r){var o=r;if(typeof r==="string"){o=l._parsePlaceholders(r)}if(e._isObject(o)){$.each(o,function(u,v){p.push(v)})}}else{if(e._isDefined(s,r)){p.push(r)}}$.each(p,function(u,v){if(e._isDefined(s,v)){t[v]=s[v]}})}}}}if(n.multiple&&(l._toJSON()||l._toCSV())){var q=l._normalizeValue();if(!e._isEmpty(t)&&e._isObject(q)){q.push(t);t=q}}return t};l._replacePlaceholders=function(o,q,p){if(e._isObject(o)&&typeof q==="string"){var n=l._parsePlaceholders(q);if(!e._isEmpty(o)&&n){$.each(n,function(r,s){if(e._isDefined(o,s)){q=q.replace(r,o[s])}});return q}}return p};l._parsePlaceholders=function(p){var o=p.match(/\{.+?\}/g);if(o){var n={};o.map(function(q){n[q]=q.slice(1,-1)});return n}return false};l._allowValues=function(){var n=l._options();if(n.limitOfValues>0&&n.multiple){var o=m.find(".flexdatalist-multiple-value");(n._values.length>=n.limitOfValues?o.hide():o.show())}};l._normalizeString=function(n){if(typeof n==="string"){var o=l._options("normalizeString");if(typeof o==="function"){n=o(n)}return n.toUpperCase()}return n};l._keyword=function(){return j.val().replace(/^\s+/,"")};l._toJSON=function(){var n=l._options("valueProperty");return e._isObject(n)||n==="*"};l._toCSV=function(){return(!l._toJSON()&&l._options("multiple"))};l._position=function(){var n=j;if(l._options("multiple")){n=m}$("ul.flexdatalist-results").css({width:n.outerWidth()+"px",top:((n.offset().top+n.outerHeight()))+"px",left:n.offset().left+"px"})};l._init();l._datalist();l._chained();l._initValue()};this._destroy=function(g){if(!g){g=f}g.each(function(){var h=$(this).data("flexdatalist");$(this).removeClass("flexdatalist-set").attr("type","text").val((h&&h.originalValue?h.originalValue:"")).removeData("flexdatalist").next(".flexdatalist-alias, ul.flexdatalist-multiple").remove()})};this._reset=function(){this._destroy()};this._setValue=function(g){f.each(function(){var h=$(this);var i=h.data("flexdatalist");if(e._isDefined(i)){i.originalValue=g;if(g==""){h.val(g,true);if(i.multiple){h.next("ul.flexdatalist-multiple").find("li.value").remove()}return}e._destroy()}})};this._keyNum=function(g){return g.which||g.keyCode};if(!d.data("flexdatalist")){$(document).mouseup(function(h){var i=$(".flexdatalist-results"),g=i.data("target");if((!g||!g.is(":focus"))&&!i.is(h.target)&&i.has(h.target).length===0){i.remove()}}).keydown(function(l){var j=$(".flexdatalist-results"),n=j.find("li"),h=n.filter(".active"),i=h.index(),k=n.length,m=e._keyNum(l);if(k===0){return}if(e._keyNum(l)===27){return j.remove()}if(m===13){l.preventDefault();h.click()}else{if(m===40||m===38){l.preventDefault();if(m===40){if(i<k&&h.nextAll(".item").first().length>0){h=h.removeClass("active").nextAll(".item").first().addClass("active")}else{h=n.removeClass("active").filter(".item:first").addClass("active")}}else{if(m===38){if(i>0&&h.prevAll(".item").first().length>0){h=h.removeClass("active").prevAll(".item").first().addClass("active")}else{h=n.removeClass("active").filter(".item:last").addClass("active")}}}var g=(h.prev().length===0?h:h.prev()).position().top;j.animate({scrollTop:g+j.scrollTop()},100)}}}).data("flexdatalist",true)}this._isEmpty=function(g){if(!e._isDefined(g)){return true}else{if(g===null){return true}else{if(g===true){return false}else{if(this._length(g)===0){return true}else{if($.trim(g)===""){return true}}}}}return false};this._isObject=function(g){return(g&&typeof g==="object")};this._csvToArray=function(h,g){if(h.length===0){return g}return typeof h==="string"?h.split(","):h};this._length=function(g){if(this._isObject(g)){return Object.keys(g).length}else{if(typeof g.length==="number"){return g.length}}return 0};this._isDefined=function(g,i){var h=(typeof g!=="undefined");if(h&&typeof i!=="undefined"){return(typeof g[i]!=="undefined")}return h};this._options=function(g,j,h){var i=g.data("flexdatalist");if(e._isDefined(j)){if(e._isDefined(h)){i[j]=h}else{if(!e._isObject(j)){return(e._isDefined(i,j)?i[j]:null)}else{i=j}}i.searchIn=e._csvToArray(i.searchIn);i.relatives=i.relatives&&$(i.relatives).length>0?$(i.relatives):null;i.textProperty=i.textProperty===null?i.searchIn[0]:i.textProperty;i.visibleProperties=e._csvToArray(i.visibleProperties,i.searchIn);g.data("flexdatalist",i)}return i};if(typeof b==="string"){if(typeof this["_"+b]==="function"){if(!this["_"+b]()){return this}}else{if(b==="value"){this._setValue(c)}else{if(!c){return e._options(f,b)}else{e._options(f,b,c);return this}}}}return this.each(a)};var _defaultValFunc=jQuery.fn.val;jQuery.fn.val=function(a,b){if(!b&&$(this).hasClass("flexdatalist-set")&&typeof a!=="undefined"){$(this).flexdatalist("value",a)}return _defaultValFunc.apply(this,arguments)};$(function(){$("input.flexdatalist:not(.flexdatalist-set)").flexdatalist()});
\ No newline at end of file

Minify