Skip to content

Commit

Permalink
New Build
Browse files Browse the repository at this point in the history
  • Loading branch information
bseth99 committed Oct 27, 2013
1 parent 764354b commit 6954638
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-ui-multisearch",
"version": "0.0.2",
"version": "0.0.3",
"ignore": [
"bower_components",
"node_modules",
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h3>jQuery UI MultiSearch</h3>
</p>

<p class="text-center">
<a class="btn btn-primary" rel="nofollow" href="https://github.com/bseth99/jquery-ui-multisearch/archive/v0.0.2.zip" >
<a class="btn btn-primary" rel="nofollow" href="https://github.com/bseth99/jquery-ui-multisearch/archive/v0.0.3.zip" >
Download Latest Version
</a>
</p>
Expand Down
27 changes: 17 additions & 10 deletions jqueryui-multisearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

},
Expand Down Expand Up @@ -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 ) );
}
Expand Down Expand Up @@ -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, '&nbsp;') );
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, '&nbsp;') );
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();
}

});
Expand Down
4 changes: 2 additions & 2 deletions jqueryui-multisearch.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6954638

Please sign in to comment.