');
+ m.items = m.wrapper.find('li');
if(m.options.debug) console.log("Minimalect detected a DOM change for ", m.element);
}
});
diff --git a/jquery.minimalect.min.js b/jquery.minimalect.min.js
index c159af0..99600ab 100644
--- a/jquery.minimalect.min.js
+++ b/jquery.minimalect.min.js
@@ -3,4 +3,4 @@
A minimalistic select replacement
http://git.io/Xedg9w
************************************/
-!function(e,t,s){function i(t,s){this.element=e(t),this.options=e.extend({},a,s),this._defaults=a,this._name=l,this.label=e('[for="'+this.element.attr("id")+'"]').attr("for","minict_"+this.element.attr("id")),this._init()}var l="minimalect",a={theme:"",reset:!1,transition:"fade",transition_time:150,remove_empty_option:!0,searchable:!0,ajax:null,debug:!1,live:!0,placeholder:"Select a choice",empty:"No results match your keyword.",error_message:"There was a problem with the request.",class_container:"minict_wrapper",class_group:"minict_group",class_empty:"minict_empty",class_active:"active",class_disabled:"disabled",class_selected:"selected",class_hidden:"hidden",class_highlighted:"highlighted",class_first:"minict_first",class_last:"minict_last",class_reset:"minict_reset",beforeinit:function(){},afterinit:function(){},onchange:function(){},onopen:function(){},onclose:function(){},onfilter:function(){}};i.prototype={_init:function(){this.options.beforeinit();var i=this.options,l=this;if(this.wrapper=e(''),this.element.hide().after(this.wrapper),i.theme&&this.wrapper.addClass(i.theme),this.element.prop("disabled")&&this.wrapper.addClass(i.class_disabled),this.input=e(""+(this.element.find("option[selected]").html()||"")+"").appendTo(this.wrapper),i.reset&&(this.reset=e('×').appendTo(this.wrapper)),this.ul=e("
"),t.find("."+s.class_empty).show(),s.debug&&console.log("Minimalect didn't find any results for '"+i.input.text()+"' from ",i.element),i.options.onfilter(!1)}).error(function(e){t.find("."+s.class_empty).text(s.error_message),t.find("li").not("."+s.class_empty).addClass(s.class_hidden),t.find("."+s.class_empty).show(),s.debug&&console.error("Minimalect's AJAX query failed for ",i.element," - came back with ",e)});else{var l=this.input.text().replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");this.items.filter("."+s.class_highlighted).removeClass(s.class_highlighted),this.items.not(s.class_group).each(function(){e(this).text().search(new RegExp(l,"i"))<0||e(this).hasClass(s.class_disabled)?e(this).addClass(s.class_hidden):e(this).removeClass(s.class_hidden)}),this.items.filter("."+s.class_group).removeClass(s.class_hidden).each(function(){nextlis=e(this).nextAll("li").not("."+s.class_hidden+", ."+s.class_empty),(nextlis.first().hasClass(s.class_group)||!nextlis.length)&&e(this).addClass(s.class_hidden)}),t.find("."+s.class_empty).hide(),this.items.not("."+s.class_hidden+", ."+s.class_empty).length?this.options.onfilter(!0):(t.find("."+s.class_empty).show(),s.debug&&console.log("Minimalect didn't find any results for '"+this.input.text()+"' from ",this.element),this.options.onfilter(!1)),this._updateFirstLast(!0)}},_selectChoice:function(t){var s=this.element,i=this.options,l=[],a=[];return t.hasClass(this.options.class_disabled)?!1:(this.element.prop("multiple")||this.items.removeClass(i.class_selected),t.addClass(i.class_selected),this.items.filter("."+i.class_selected).each(function(){l.push(e(this).data("value")),a.push(e(this).text())}),this.input.text(a.join(", ")).attr("data-placeholder",a.join(", ")),(s.val()!=t.data("value")||s.val()!=l)&&(s.val(l),s.trigger("change")),this._showResetLink(),void this.options.onchange(t.data("value"),t.text()))},_resetChoice:function(){this.element.val("").trigger("change"),this._hideResetLink()},_showResetLink:function(){(this.input.text().length>0||this.ul.find("li."+this.options.class_selected).length>0)&&this.options.reset&&this.reset.show()},_hideResetLink:function(){this.options.reset&&this.reset.hide()},_updateFirstLast:function(e){var t=this.wrapper,s=this.options;t.find("."+s.class_first+", ."+s.class_last).removeClass(s.class_first+" "+s.class_last),e?(this.items.filter(":visible").first().addClass(s.class_first),this.items.filter(":visible").last().addClass(s.class_last)):(this.items.first().addClass(s.class_first),this.items.not("."+s.class_empty).last().addClass(s.class_last))},destroy:function(){this.wrapper.remove(),this.element.off("change focus blur").show(),t.MutationObserver&&this.observer.disconnect(),this.options.debug&&console.log("Minimalect destroyed for ",this.element)},update:function(){this.ul.html(this._parseSelect()+'
'+this.options.empty+"
")}},e.fn[l]=function(t,s){return this.each(function(){e.isFunction(i.prototype[t])&&"_"!=t.charAt(0)?1==arguments.length?e.data(this,"plugin_"+l)[t]():e.data(this,"plugin_"+l)[t](s):e.data(this,"plugin_"+l)||e.data(this,"plugin_"+l,new i(this,t))})}}(jQuery,window,document);
\ No newline at end of file
+!function(e,t,s){function i(t,s){this.element=e(t),this.options=e.extend({},a,s),this._defaults=a,this._name=l,this.label=e('[for="'+this.element.attr("id")+'"]').attr("for","minict_"+this.element.attr("id")),this._init()}var l="minimalect",a={theme:"",reset:!1,transition:"fade",transition_time:150,remove_empty_option:!0,searchable:!0,ajax:null,debug:!1,live:!0,placeholder:"Select a choice",empty:"No results match your keyword.",error_message:"There was a problem with the request.",class_container:"minict_wrapper",class_group:"minict_group",class_empty:"minict_empty",class_active:"active",class_disabled:"disabled",class_selected:"selected",class_hidden:"hidden",class_highlighted:"highlighted",class_first:"minict_first",class_last:"minict_last",class_reset:"minict_reset",beforeinit:function(){},afterinit:function(){},onchange:function(){},onopen:function(){},onclose:function(){},onfilter:function(){}};i.prototype={_init:function(){this.options.beforeinit();var i=this.options,l=this;if(this.wrapper=e(''),this.element.hide().after(this.wrapper),i.theme&&this.wrapper.addClass(i.theme),this.element.prop("disabled")&&this.wrapper.addClass(i.class_disabled),this.input=e(""+(this.element.find("option[selected]").html()||"")+"").appendTo(this.wrapper),i.reset&&(this.reset=e('×').appendTo(this.wrapper)),this.ul=e("
"),t.find("."+s.class_empty).show(),s.debug&&console.log("Minimalect didn't find any results for '"+i.input.text()+"' from ",i.element),i.options.onfilter(!1)}).error(function(e){t.find("."+s.class_empty).text(s.error_message),t.find("li").not("."+s.class_empty).addClass(s.class_hidden),t.find("."+s.class_empty).show(),s.debug&&console.error("Minimalect's AJAX query failed for ",i.element," - came back with ",e)});else{var l=this.input.text().replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&");this.items.filter("."+s.class_highlighted).removeClass(s.class_highlighted),this.items.not(s.class_group).each(function(){e(this).text().search(new RegExp(l,"i"))<0||e(this).hasClass(s.class_disabled)?e(this).addClass(s.class_hidden):e(this).removeClass(s.class_hidden)}),this.items.filter("."+s.class_group).removeClass(s.class_hidden).each(function(){nextlis=e(this).nextAll("li").not("."+s.class_hidden+", ."+s.class_empty),(nextlis.first().hasClass(s.class_group)||!nextlis.length)&&e(this).addClass(s.class_hidden)}),t.find("."+s.class_empty).hide(),this.items.not("."+s.class_hidden+", ."+s.class_empty).length?this.options.onfilter(!0):(t.find("."+s.class_empty).show(),s.debug&&console.log("Minimalect didn't find any results for '"+this.input.text()+"' from ",this.element),this.options.onfilter(!1)),this._updateFirstLast(!0)}},_selectChoice:function(t){var s=this.element,i=this.options,l=[],a=[];return t.hasClass(this.options.class_disabled)?!1:(this.element.prop("multiple")||this.items.removeClass(i.class_selected),t.addClass(i.class_selected),this.items.filter("."+i.class_selected).each(function(){l.push(e(this).data("value")),a.push(e(this).text())}),this.input.text(a.join(", ")).attr("data-placeholder",a.join(", ")),(s.val()!=t.data("value")||s.val()!=l)&&(s.val(l),s.trigger("change")),this._showResetLink(),void this.options.onchange(t.data("value"),t.text()))},_resetChoice:function(){this.element.val("").trigger("change"),this._hideResetLink()},_showResetLink:function(){(this.input.text().length>0||this.ul.find("li."+this.options.class_selected).length>0)&&this.options.reset&&this.reset.show()},_hideResetLink:function(){this.options.reset&&this.reset.hide()},_updateFirstLast:function(e){var t=this.wrapper,s=this.options;t.find("."+s.class_first+", ."+s.class_last).removeClass(s.class_first+" "+s.class_last),e?(this.items.filter(":visible").first().addClass(s.class_first),this.items.filter(":visible").last().addClass(s.class_last)):(this.items.first().addClass(s.class_first),this.items.not("."+s.class_empty).last().addClass(s.class_last))},destroy:function(){this.wrapper.remove(),this.element.off("change focus blur").show(),t.MutationObserver&&this.observer.disconnect(),this.options.debug&&console.log("Minimalect destroyed for ",this.element)},update:function(){this.ul.html(this._parseSelect()+'
'+this.options.empty+"
")}},e.fn[l]=function(t,s){return this.each(function(){e.isFunction(i.prototype[t])&&"_"!=t.charAt(0)?1==arguments.length?e.data(this,"plugin_"+l)[t]():e.data(this,"plugin_"+l)[t](s):e.data(this,"plugin_"+l)||e.data(this,"plugin_"+l,new i(this,t))})}}(jQuery,window,document);
\ No newline at end of file