diff --git a/bower.json b/bower.json
index da5b113..30aa071 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "jquery-ui-multisearch",
- "version": "0.0.2",
+ "version": "0.0.3",
"ignore": [
"bower_components",
"node_modules",
diff --git a/index.html b/index.html
index 603756e..e89ac89 100644
--- a/index.html
+++ b/index.html
@@ -92,7 +92,7 @@
jQuery UI MultiSearch
-
+
Download Latest Version
diff --git a/jqueryui-multisearch.js b/jqueryui-multisearch.js
index 1cbe9e9..040d07a 100644
--- a/jqueryui-multisearch.js
+++ b/jqueryui-multisearch.js
@@ -543,13 +543,10 @@
whiteSpace: 'nowrap'
}).insertAfter( this.$input );
- this.maxInputWidth = this.$sizer.width();
- this.$sizer.css( 'width', 'auto' );
-
+ // The first call will initialize the rest since we need to be sure
+ // the elements are in the DOM.
this.$input.on( 'keyup', $.proxy( this, '_autoSizeInput' ) );
- this._autoSizeInput();
- this.minInputWidth = this.$input.width();
}
},
@@ -1005,7 +1002,7 @@
this._showPicker();
- if ( this.options.preventNotFound ) {
+ if ( this.options.preventNotFound || this.optionData.length == 1 ) {
this.optionIndex = 0;
this._overPickerItem( this._getPickerChildren().eq( 0 ) );
}
@@ -1128,11 +1125,21 @@
_autoSizeInput: function() {
- var text = this.$input.val(),
- max = this.maxInputWidth;
+ var text = this.$input.val(),
+ max = this.maxInputWidth;
+
+ // First time through, make some min/max calcs
+ // TODO: What if the element resizes, how to reset?
+ if ( !this.maxInputWidth ) {
+ this.maxInputWidth = this.$sizer.width();
+ this.$sizer.css( 'width', 'auto' );
+ }
- this.$sizer.html( (regexp_escape( text ) || regexp_escape( this.$input.attr( 'placeholder' ) ) || 'MMMMMMMMMMMMMMMM').replace(/ /g, ' ') );
- this.$input.css({ width: Math.min( 100, Math.ceil( ( Math.max( this.minInputWidth, this.$sizer.outerWidth( true ) + 25 ) ) / max * 100 ) )+'%' });
+ this.$sizer.html( (regexp_escape( text ) || regexp_escape( this.$input.attr( 'placeholder' ) ) || 'MMMMMMMMMMMMMMMM').replace(/ /g, ' ') );
+ this.$input.css({ width: Math.min( 100, Math.ceil( ( Math.max( this.minInputWidth, this.$sizer.outerWidth( true ) + 25 ) ) / max * 100 ) )+'%' });
+
+ if ( !this.minInputWidth )
+ this.minInputWidth = this.$input.width();
}
});
diff --git a/jqueryui-multisearch.min.js b/jqueryui-multisearch.min.js
index 72822c6..6e96cbb 100644
--- a/jqueryui-multisearch.min.js
+++ b/jqueryui-multisearch.min.js
@@ -1,5 +1,5 @@
-/*! jquery-ui-multisearch: jQuery UI MultiSearch (v0.0.2 built 2013-10-09)
+/*! jquery-ui-multisearch: jQuery UI MultiSearch (v0.0.3 built 2013-10-27)
* https://github.com/bseth99/jquery-ui-multisearch
* Copyright 2013 Ben Olson; Licensed MIT
*/
-(function(e,t){"function"==typeof define&&define.amd?define(["jquery","underscore"],t):e.$=t(e.$,e._)})(this,function(e,t){"use strict";function i(e){return e.replace(s,"\\$&")}var s=RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g");return e.widget("osb.multisearch",{optionData:null,optionIndex:-1,itemData:null,itemIndex:-1,localCache:null,options:{source:null,ajaxOptions:null,keyAttrs:null,searchAttrs:null,formatPickerItem:function(e){return''+e.name+""},formatSelectedItem:function(e){return''+e.name+""},buildNewItem:function(e){return{id:null,name:e}},minSearchChars:2,searchThrottle:200,maxShowOptions:5,minLocalCache:50,preventNotFound:!1,preventDuplicates:!0,useAutoWidth:!0,pickerPosition:{my:"left top",at:"left bottom"},inputPosition:"end",localMatcher:function(e,t){return t.toLowerCase().indexOf(e.toLowerCase())>-1}},value:function(e){var i=this;return e?(this.remove(),t.each(e,function(e){i.add(e)}),void 0):t.map(this.itemData,function(e){return t.clone(e)})},add:function(e,t){var i,s={silent:!0};t!==void 0&&(s.at=t),(i=this._findByKeys(e))>-1&&(this._removeItem(i),(s.at===void 0||null===s.at)&&(s.at=i)),this._addItem(e,s)},remove:function(e){var i;0===arguments.length?(this._getSelectedChildren().remove(),this.itemData=[],this.itemIndex=-1):t.isObject(e)?(i=this._findByKeys(e))>-1&&this._removeItem(i,{silent:!0}):this._removeItem(e,{silent:!0})},_findByKeys:function(e){var i,s,n=this.options.keyAttrs,r=-1;return i=t.values(t.pick(e,n)),i.length==n.length&&(s=t.findWhere(this.itemData,t.object(n,i)),s&&(r=t.indexOf(this.itemData,s))),r},_create:function(){var t=this.options;t.keyAttrs=t.keyAttrs||["id"],t.searchAttrs=t.searchAttrs||["name"],this.localCache={},this.optionData=[],this.itemData=[],this.search_text="",this.element.addClass("osb-multisearch"),this.$input=this.element.find('[data-role="input"]').attr({autocomplete:"off",autocapitalize:"off",spellcheck:"false"}),this.$picker=this.element.find('[data-role="picker"]').css("position","absolute").hide(),this.$pickerList=this.element.find('[data-role="picker-list"]'),this.$itemList=this.element.find('[data-role="selected-list"]'),this.$input.on("keydown.multisearch",e.proxy(this,"_processInput")),this.$picker.on("click.multisearch mouseenter.multisearch mouseleave.multisearch",'[data-role="picker-item"]',e.proxy(this,"_processPicker")),this.$itemList.on("click.multisearch mouseenter.multisearch mouseleave keydown.multisearch",'[data-role="selected-item"]',e.proxy(this,"_processSelected")),this._initAutoWidth(),this._initRemote();var i=this;e(document).on("click.multisearch",function(e){0===i.element.has(e.target).length&&i._hidePicker()})},_initRemote:function(){var i=this,s=this.options,n=function(e,t){i._trigger("searched",null,{term:e,picker:i.$picker,list:t}),i.localCache[e]=t,i.optionData=t.slice(0,s.maxShowOptions),i._renderPickerItems()};"string"==typeof s.source?(s.ajaxOptions=s.ajaxOptions||{searchTerm:"term",dataType:"json",method:"GET"},this._remoteSearch=t.throttle(function(){i.localCache[i.search_text]?n(i.search_text,i.localCache[i.search_text]):(i._xhr&&i._xhr.abort(),i._xhr=e.ajax({url:s.source,data:s.ajaxOptions.searchTerm+"="+i.search_text,dataType:s.ajaxOptions.dataType,method:s.ajaxOptions.method}).done(t.partial(n,i.search_text)))},s.searchThrottle,{leading:!1})):this._remoteSearch=e.isFunction(s.source)?t.throttle(function(){i.localCache[i.search_text]?n(i.search_text,i.localCache[i.search_text]):s.source.call(i,i.search_text,t.partial(n,i.search_text))},s.searchThrottle,{leading:!1}):function(){var e=t.filter(s.source,function(e){return i._matcher.call(i,e)});i.optionData=e.slice(0,s.maxShowOptions),i._renderPickerItems()}},_initAutoWidth:function(){this.options.useAutoWidth&&(this.$sizer=e("").css({position:"absolute",top:-9999,left:-9999,width:"100%",fontSize:this.$input.css("font-size"),fontFamily:this.$input.css("font-family"),fontWeight:this.$input.css("font-weight"),letterSpacing:this.$input.css("letter-spacing"),paddingLeft:this.$input.css("padding-left"),paddingRight:this.$input.css("padding-right"),marginLeft:this.$input.css("margin-left"),marginRight:this.$input.css("margin-right"),whiteSpace:"nowrap"}).insertAfter(this.$input),this.maxInputWidth=this.$sizer.width(),this.$sizer.css("width","auto"),this.$input.on("keyup",e.proxy(this,"_autoSizeInput")),this._autoSizeInput(),this.minInputWidth=this.$input.width())},_destroy:function(){this.element.removeClass("osb-multisearch"),e(document).off(".multisearch"),this.$input.off(".multisearch"),this.$picker.off(".multisearch"),this.$itemList.off(".multisearch"),this.$sizer.remove(),this.$pickerList.html(""),this._getSelectedChildren().remove(),this.$picker.show(),this._remoteSearch=null,this.localCache=null,this.optionData=null,this.itemData=null},_processInput:function(i){switch(i.keyCode){case jQuery.ui.keyCode.UP:case jQuery.ui.keyCode.DOWN:case jQuery.ui.keyCode.LEFT:case jQuery.ui.keyCode.RIGHT:return this.$input.val().length?(i.keyCode===jQuery.ui.keyCode.DOWN||i.keyCode===jQuery.ui.keyCode.RIGHT?this.optionIndex0&&this._offPickerItem(this._getPickerChildren().eq(--this.optionIndex)),!1):(i.keyCode===jQuery.ui.keyCode.DOWN||i.keyCode===jQuery.ui.keyCode.RIGHT?this._gotoPrevItem():this._gotoNextItem(),!1);case jQuery.ui.keyCode.SPACE:if(!this.$input.val().length)return this.itemIndex>-1&&this.itemIndex-1&&this.itemIndex0&&(this.itemIndex>-1&&this.itemIndex0)return this.optionIndex>-1?this._addSelectedItem():this.options.preventNotFound||this._addItem(this.options.buildNewItem(this.search_text)),this._clearSelectedItem(),i.stopPropagation(),i.preventDefault(),!1;break;case jQuery.ui.keyCode.ESCAPE:return this._hidePicker(),!0;default:String.fromCharCode(i.which)&&(this._clearSelectedItem(),t.defer(e.proxy(this,"_search")))}},_processPicker:function(t){var i=e(t.currentTarget);switch(t.type){case"click":this.optionIndex=this._getPickerChildren().index(i),this._addSelectedItem(),this.$input.focus();break;case"mouseenter":this._overPickerItem(i);break;case"mouseleave":this._offPickerItem(i)}},_processSelected:function(t){var i,s=e(t.target),n=e(t.currentTarget);switch(t.type){case"click":if(this.itemIndex=this._getSelectedChildren().index(n),this._activeSelectedItem(n),s.is("[data-action]")||(s=s.parents("[data-action]").first()),s.length&&n.has(s).length){if(i=s.attr("data-action"),this._trigger("itemaction",null,{action:i,data:this.itemData[this.itemIndex],element:n}))switch(i){case"remove":var r=jQuery.Event("keydown");return r.keyCode=jQuery.ui.keyCode.DELETE,n.trigger(r),t.stopPropagation(),t.preventDefault(),!1}}else this._trigger("itemselect",null,{data:this.itemData[this.itemIndex],element:n});break;case"mouseenter":this._overSelectedItem(n);break;case"mouseleave":this._offSelectedItem(n);break;case"keydown":switch(t.keyCode){case jQuery.ui.keyCode.UP:case jQuery.ui.keyCode.DOWN:case jQuery.ui.keyCode.LEFT:case jQuery.ui.keyCode.RIGHT:return t.keyCode===jQuery.ui.keyCode.DOWN||t.keyCode===jQuery.ui.keyCode.RIGHT?this._gotoPrevItem():this._gotoNextItem(),!1;case jQuery.ui.keyCode.SPACE:return this.itemIndex>-1&&this.itemIndex-1&&this.itemIndex0?"start"==a?r.insertAfter(this.$input):r.insertBefore(this.$input):this.$itemList.append(r),this.itemData.push(i)):(r.insertBefore(this._getSelectedChildren().eq(d)),this.itemData.splice(d,0,i)),this.$input.val(""),this.search_text="",this._hidePicker(),-1==this.itemIndex||this.itemIndex==this.itemData.length-1?this._gotoFirstItem():this.itemIndex>=d&&this.itemIndex++,l||this._trigger("added",null,{data:i,element:r,notfound:c})))},_removeSelectedItem:function(){this._removeItem(this.itemIndex)},_removeItem:function(e,t){var i=t||{},s=i.silent||!1,n=this.itemData[e];n&&(s||this._trigger("removing",null,{data:n}))&&(this._getSelectedChildren().eq(e).remove(),this.itemData.splice(e,1),this.itemData.length>0&&(this.itemIndex>e&&this.itemIndex--,this.itemIndex>-1&&this.itemIndex-1&&this._overSelectedItem(this._getSelectedChildren().eq(this.itemIndex)))},_gotoPrevItem:function(){this.itemIndex0?this.$itemList.children().not(this.$input).eq(--this.itemIndex).trigger("mouseenter"):0===this.itemIndex&&(this.itemIndex--,this.$itemList.children().removeClass("hover"))},_gotoFirstItem:function(){this.itemIndex="start"==this.options.inputPosition?-1:this.itemData.length},_renderPickerItems:function(){var i=this;this.$pickerList.html(""),this.optionIndex=-1,this.optionData.length>0?(t.each(this.optionData,function(t){i.$pickerList.append(e(i.options.formatPickerItem(i._formatter(t))).attr("data-role","picker-item"))}),this._showPicker(),this.options.preventNotFound&&(this.optionIndex=0,this._overPickerItem(this._getPickerChildren().eq(0)))):this._hidePicker()},_showPicker:function(){this.$picker.show(),this.$picker.position({my:this.options.pickerPosition.my,at:this.options.pickerPosition.at,of:this.$input})},_hidePicker:function(){this.$picker.hide()},_getPickerChildren:function(){return this.$pickerList.children('[data-role="picker-item"]')},_overPickerItem:function(e){this._trigger("pickerhoverin",null,{target:e,siblings:e.siblings('[data-role="picker-item"]')})&&e.addClass("hover").siblings('[data-role="picker-item"]').removeClass("hover")},_offPickerItem:function(e){this._trigger("pickerhoverout",null,{target:e,siblings:e.siblings('[data-role="picker-item"]')})&&(e.removeClass("hover"),this.optionIndex>-1&&this._overPickerItem(this._getPickerChildren().eq(this.optionIndex)))},_formatter:function(e){var s=this,n=this.search_text,r=t.clone(e);return n.length>0&&t.each(this.options.searchAttrs,function(e){r[e]&&s.options.localMatcher(n,r[e])&&(r[e]=r[e].replace(RegExp("(?![^&;]+;)(?!<[^<>]*)("+i(n)+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1"))}),r},_matcher:function(e){var i=this;return 0===this.search_text.length||this.search_text.length>0&&t.any(t.values(t.pick(e,i.options.searchAttrs)),function(e){return i.options.localMatcher(i.search_text,e)})},_search:function(){var e,i,s=this;i=this.search_text=this.$input.val(),this.search_text.length1?i.slice(0,i.length-1):null,i&&this.localCache[i]&&this.localCache[i].length<=this.options.minLocalCache?(e=t.filter(this.localCache[i],function(e){return s._matcher.call(s,e)}),this.localCache[this.search_text]=e,this.optionData=e.slice(0,this.options.maxShowOptions),this._renderPickerItems()):(this._showPicker(),this._trigger("searching",null,{term:this.search_text,picker:this.$picker}),this._remoteSearch()))},_autoSizeInput:function(){var e=this.$input.val(),t=this.maxInputWidth;this.$sizer.html((i(e)||i(this.$input.attr("placeholder"))||"MMMMMMMMMMMMMMMM").replace(/ /g," ")),this.$input.css({width:Math.min(100,Math.ceil(100*(Math.max(this.minInputWidth,this.$sizer.outerWidth(!0)+25)/t)))+"%"})}}),e});
\ No newline at end of file
+(function(e,t){"function"==typeof define&&define.amd?define(["jquery","underscore"],t):e.$=t(e.$,e._)})(this,function(e,t){"use strict";function i(e){return e.replace(s,"\\$&")}var s=RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g");return e.widget("osb.multisearch",{optionData:null,optionIndex:-1,itemData:null,itemIndex:-1,localCache:null,options:{source:null,ajaxOptions:null,keyAttrs:null,searchAttrs:null,formatPickerItem:function(e){return''+e.name+""},formatSelectedItem:function(e){return''+e.name+""},buildNewItem:function(e){return{id:null,name:e}},minSearchChars:2,searchThrottle:200,maxShowOptions:5,minLocalCache:50,preventNotFound:!1,preventDuplicates:!0,useAutoWidth:!0,pickerPosition:{my:"left top",at:"left bottom"},inputPosition:"end",localMatcher:function(e,t){return t.toLowerCase().indexOf(e.toLowerCase())>-1}},value:function(e){var i=this;return e?(this.remove(),t.each(e,function(e){i.add(e)}),void 0):t.map(this.itemData,function(e){return t.clone(e)})},add:function(e,t){var i,s={silent:!0};t!==void 0&&(s.at=t),(i=this._findByKeys(e))>-1&&(this._removeItem(i),(s.at===void 0||null===s.at)&&(s.at=i)),this._addItem(e,s)},remove:function(e){var i;0===arguments.length?(this._getSelectedChildren().remove(),this.itemData=[],this.itemIndex=-1):t.isObject(e)?(i=this._findByKeys(e))>-1&&this._removeItem(i,{silent:!0}):this._removeItem(e,{silent:!0})},_findByKeys:function(e){var i,s,n=this.options.keyAttrs,r=-1;return i=t.values(t.pick(e,n)),i.length==n.length&&(s=t.findWhere(this.itemData,t.object(n,i)),s&&(r=t.indexOf(this.itemData,s))),r},_create:function(){var t=this.options;t.keyAttrs=t.keyAttrs||["id"],t.searchAttrs=t.searchAttrs||["name"],this.localCache={},this.optionData=[],this.itemData=[],this.search_text="",this.element.addClass("osb-multisearch"),this.$input=this.element.find('[data-role="input"]').attr({autocomplete:"off",autocapitalize:"off",spellcheck:"false"}),this.$picker=this.element.find('[data-role="picker"]').css("position","absolute").hide(),this.$pickerList=this.element.find('[data-role="picker-list"]'),this.$itemList=this.element.find('[data-role="selected-list"]'),this.$input.on("keydown.multisearch",e.proxy(this,"_processInput")),this.$picker.on("click.multisearch mouseenter.multisearch mouseleave.multisearch",'[data-role="picker-item"]',e.proxy(this,"_processPicker")),this.$itemList.on("click.multisearch mouseenter.multisearch mouseleave keydown.multisearch",'[data-role="selected-item"]',e.proxy(this,"_processSelected")),this._initAutoWidth(),this._initRemote();var i=this;e(document).on("click.multisearch",function(e){0===i.element.has(e.target).length&&i._hidePicker()})},_initRemote:function(){var i=this,s=this.options,n=function(e,t){i._trigger("searched",null,{term:e,picker:i.$picker,list:t}),i.localCache[e]=t,i.optionData=t.slice(0,s.maxShowOptions),i._renderPickerItems()};"string"==typeof s.source?(s.ajaxOptions=s.ajaxOptions||{searchTerm:"term",dataType:"json",method:"GET"},this._remoteSearch=t.throttle(function(){i.localCache[i.search_text]?n(i.search_text,i.localCache[i.search_text]):(i._xhr&&i._xhr.abort(),i._xhr=e.ajax({url:s.source,data:s.ajaxOptions.searchTerm+"="+i.search_text,dataType:s.ajaxOptions.dataType,method:s.ajaxOptions.method}).done(t.partial(n,i.search_text)))},s.searchThrottle,{leading:!1})):this._remoteSearch=e.isFunction(s.source)?t.throttle(function(){i.localCache[i.search_text]?n(i.search_text,i.localCache[i.search_text]):s.source.call(i,i.search_text,t.partial(n,i.search_text))},s.searchThrottle,{leading:!1}):function(){var e=t.filter(s.source,function(e){return i._matcher.call(i,e)});i.optionData=e.slice(0,s.maxShowOptions),i._renderPickerItems()}},_initAutoWidth:function(){this.options.useAutoWidth&&(this.$sizer=e("").css({position:"absolute",top:-9999,left:-9999,width:"100%",fontSize:this.$input.css("font-size"),fontFamily:this.$input.css("font-family"),fontWeight:this.$input.css("font-weight"),letterSpacing:this.$input.css("letter-spacing"),paddingLeft:this.$input.css("padding-left"),paddingRight:this.$input.css("padding-right"),marginLeft:this.$input.css("margin-left"),marginRight:this.$input.css("margin-right"),whiteSpace:"nowrap"}).insertAfter(this.$input),this.$input.on("keyup",e.proxy(this,"_autoSizeInput")))},_destroy:function(){this.element.removeClass("osb-multisearch"),e(document).off(".multisearch"),this.$input.off(".multisearch"),this.$picker.off(".multisearch"),this.$itemList.off(".multisearch"),this.$sizer.remove(),this.$pickerList.html(""),this._getSelectedChildren().remove(),this.$picker.show(),this._remoteSearch=null,this.localCache=null,this.optionData=null,this.itemData=null},_processInput:function(i){switch(i.keyCode){case jQuery.ui.keyCode.UP:case jQuery.ui.keyCode.DOWN:case jQuery.ui.keyCode.LEFT:case jQuery.ui.keyCode.RIGHT:return this.$input.val().length?(i.keyCode===jQuery.ui.keyCode.DOWN||i.keyCode===jQuery.ui.keyCode.RIGHT?this.optionIndex0&&this._offPickerItem(this._getPickerChildren().eq(--this.optionIndex)),!1):(i.keyCode===jQuery.ui.keyCode.DOWN||i.keyCode===jQuery.ui.keyCode.RIGHT?this._gotoPrevItem():this._gotoNextItem(),!1);case jQuery.ui.keyCode.SPACE:if(!this.$input.val().length)return this.itemIndex>-1&&this.itemIndex-1&&this.itemIndex0&&(this.itemIndex>-1&&this.itemIndex0)return this.optionIndex>-1?this._addSelectedItem():this.options.preventNotFound||this._addItem(this.options.buildNewItem(this.search_text)),this._clearSelectedItem(),i.stopPropagation(),i.preventDefault(),!1;break;case jQuery.ui.keyCode.ESCAPE:return this._hidePicker(),!0;default:String.fromCharCode(i.which)&&(this._clearSelectedItem(),t.defer(e.proxy(this,"_search")))}},_processPicker:function(t){var i=e(t.currentTarget);switch(t.type){case"click":this.optionIndex=this._getPickerChildren().index(i),this._addSelectedItem(),this.$input.focus();break;case"mouseenter":this._overPickerItem(i);break;case"mouseleave":this._offPickerItem(i)}},_processSelected:function(t){var i,s=e(t.target),n=e(t.currentTarget);switch(t.type){case"click":if(this.itemIndex=this._getSelectedChildren().index(n),this._activeSelectedItem(n),s.is("[data-action]")||(s=s.parents("[data-action]").first()),s.length&&n.has(s).length){if(i=s.attr("data-action"),this._trigger("itemaction",null,{action:i,data:this.itemData[this.itemIndex],element:n}))switch(i){case"remove":var r=jQuery.Event("keydown");return r.keyCode=jQuery.ui.keyCode.DELETE,n.trigger(r),t.stopPropagation(),t.preventDefault(),!1}}else this._trigger("itemselect",null,{data:this.itemData[this.itemIndex],element:n});break;case"mouseenter":this._overSelectedItem(n);break;case"mouseleave":this._offSelectedItem(n);break;case"keydown":switch(t.keyCode){case jQuery.ui.keyCode.UP:case jQuery.ui.keyCode.DOWN:case jQuery.ui.keyCode.LEFT:case jQuery.ui.keyCode.RIGHT:return t.keyCode===jQuery.ui.keyCode.DOWN||t.keyCode===jQuery.ui.keyCode.RIGHT?this._gotoPrevItem():this._gotoNextItem(),!1;case jQuery.ui.keyCode.SPACE:return this.itemIndex>-1&&this.itemIndex-1&&this.itemIndex0?"start"==a?r.insertAfter(this.$input):r.insertBefore(this.$input):this.$itemList.append(r),this.itemData.push(i)):(r.insertBefore(this._getSelectedChildren().eq(d)),this.itemData.splice(d,0,i)),this.$input.val(""),this.search_text="",this._hidePicker(),-1==this.itemIndex||this.itemIndex==this.itemData.length-1?this._gotoFirstItem():this.itemIndex>=d&&this.itemIndex++,l||this._trigger("added",null,{data:i,element:r,notfound:c})))},_removeSelectedItem:function(){this._removeItem(this.itemIndex)},_removeItem:function(e,t){var i=t||{},s=i.silent||!1,n=this.itemData[e];n&&(s||this._trigger("removing",null,{data:n}))&&(this._getSelectedChildren().eq(e).remove(),this.itemData.splice(e,1),this.itemData.length>0&&(this.itemIndex>e&&this.itemIndex--,this.itemIndex>-1&&this.itemIndex-1&&this._overSelectedItem(this._getSelectedChildren().eq(this.itemIndex)))},_gotoPrevItem:function(){this.itemIndex0?this.$itemList.children().not(this.$input).eq(--this.itemIndex).trigger("mouseenter"):0===this.itemIndex&&(this.itemIndex--,this.$itemList.children().removeClass("hover"))},_gotoFirstItem:function(){this.itemIndex="start"==this.options.inputPosition?-1:this.itemData.length},_renderPickerItems:function(){var i=this;this.$pickerList.html(""),this.optionIndex=-1,this.optionData.length>0?(t.each(this.optionData,function(t){i.$pickerList.append(e(i.options.formatPickerItem(i._formatter(t))).attr("data-role","picker-item"))}),this._showPicker(),(this.options.preventNotFound||1==this.optionData.length)&&(this.optionIndex=0,this._overPickerItem(this._getPickerChildren().eq(0)))):this._hidePicker()},_showPicker:function(){this.$picker.show(),this.$picker.position({my:this.options.pickerPosition.my,at:this.options.pickerPosition.at,of:this.$input})},_hidePicker:function(){this.$picker.hide()},_getPickerChildren:function(){return this.$pickerList.children('[data-role="picker-item"]')},_overPickerItem:function(e){this._trigger("pickerhoverin",null,{target:e,siblings:e.siblings('[data-role="picker-item"]')})&&e.addClass("hover").siblings('[data-role="picker-item"]').removeClass("hover")},_offPickerItem:function(e){this._trigger("pickerhoverout",null,{target:e,siblings:e.siblings('[data-role="picker-item"]')})&&(e.removeClass("hover"),this.optionIndex>-1&&this._overPickerItem(this._getPickerChildren().eq(this.optionIndex)))},_formatter:function(e){var s=this,n=this.search_text,r=t.clone(e);return n.length>0&&t.each(this.options.searchAttrs,function(e){r[e]&&s.options.localMatcher(n,r[e])&&(r[e]=r[e].replace(RegExp("(?![^&;]+;)(?!<[^<>]*)("+i(n)+")(?![^<>]*>)(?![^&;]+;)","gi"),"$1"))}),r},_matcher:function(e){var i=this;return 0===this.search_text.length||this.search_text.length>0&&t.any(t.values(t.pick(e,i.options.searchAttrs)),function(e){return i.options.localMatcher(i.search_text,e)})},_search:function(){var e,i,s=this;i=this.search_text=this.$input.val(),this.search_text.length1?i.slice(0,i.length-1):null,i&&this.localCache[i]&&this.localCache[i].length<=this.options.minLocalCache?(e=t.filter(this.localCache[i],function(e){return s._matcher.call(s,e)}),this.localCache[this.search_text]=e,this.optionData=e.slice(0,this.options.maxShowOptions),this._renderPickerItems()):(this._showPicker(),this._trigger("searching",null,{term:this.search_text,picker:this.$picker}),this._remoteSearch()))},_autoSizeInput:function(){var e=this.$input.val(),t=this.maxInputWidth;this.maxInputWidth||(this.maxInputWidth=this.$sizer.width(),this.$sizer.css("width","auto")),this.$sizer.html((i(e)||i(this.$input.attr("placeholder"))||"MMMMMMMMMMMMMMMM").replace(/ /g," ")),this.$input.css({width:Math.min(100,Math.ceil(100*(Math.max(this.minInputWidth,this.$sizer.outerWidth(!0)+25)/t)))+"%"}),this.minInputWidth||(this.minInputWidth=this.$input.width())}}),e});
\ No newline at end of file
diff --git a/package.json b/package.json
index 030d7c3..fa40a01 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jquery-ui-multisearch",
"title": "jQuery UI MultiSearch",
"description": "A jQuery UI widget that enables building a list of multiple items using an autocomplete entry box without imposing specific HTML structure or CSS style rules.",
- "version": "0.0.2",
+ "version": "0.0.3",
"author": {
"name": "Ben Olson",
"url": "http://bseth99.github.com/jquery-ui-multisearch"