Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ You can see a live example here: http://jsfiddle.net/mJMpw/617/
- Use css min/max-width to limit the size.
- Use css "transition: width 0.3s;" etc. if you want a nice animation when the width is changed.
- Have fun! :)

Options
-------

* min: Minimum size for field (default: 0)
* max: Maximum size for field (default: 9999999999)
19 changes: 15 additions & 4 deletions jquery.autosize.input.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
var Plugins;
(function (Plugins) {
var AutosizeInputOptions = (function () {
function AutosizeInputOptions(space) {
if (typeof space === "undefined") { space = 30; }
this.space = space;
function AutosizeInputOptions(opts) {
var defaults = {
space: 30,
min: 0,
max: 9999999999
}

if (typeof opts === "undefined") { opts = defaults; }

this.space = opts['space'];
this.max = opts['max'];
this.min = opts['min'];
}
return AutosizeInputOptions;
})();
Expand Down Expand Up @@ -58,7 +67,9 @@ var Plugins;
var newWidth = this._mirror.width() + this._options.space;

// Update the width
this._input.width(newWidth);
if (this._options.max > newWidth && this._options.min < newWidth) {
this._input.width(newWidth);
}
};

AutosizeInput.getDefaultOptions = function () {
Expand Down