input-autogrow
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "input-autogrow", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Autogrow plugin for inputs", | ||
@@ -5,0 +5,0 @@ "main": "dist/input-autogrow.min.js", |
/* | ||
* input-autogrow - Autogrow plugin for inputs | ||
* @version v1.0.1 | ||
* @version v1.0.2 | ||
* @link http://github.com/westonganger/input-autogrow | ||
* @license MIT | ||
*/ | ||
!function(t){var a="oninput"in document.createElement("input")?"input":"keydown";t.fn.inputAutogrow=function(i){if(i&&("destroy"===i||t(this).data("autogrow-span"))&&(this.each(function(){var i=t(this);i.off(a+".autogrow autogrow change");var n=i.data("autogrow-span");n.remove(),i.data("autogrow-span","")}),"destroy"===i))return input.data("original-width",""),this;if(t(this).data("original-width"))var n=t(this).data("original-width");else{var n=t(this).width();t(this).data("original-width",n)}var o=t.extend({maxWidth:t(this).parent().width(),minWidth:n,trailingSpace:0},i);return this.each(function(){var n=t(this),e=" ",r=i&&"trailingSpace"in i?o.trailingSpace:parseInt(n.css("fontSize")),s=t("<span/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:n.css("fontSize"),fontFamily:n.css("fontFamily"),fontWeight:n.css("fontWeight"),letterSpacing:n.css("letterSpacing"),textTransform:n.css("textTransform"),whiteSpace:"nowrap",ariaHidden:!0}).appendTo("body"),h=function(t){if(e!==(e=n.val())||"autogrow"===t.type){e||(e=n.attr("placeholder")||""),s.html(e.replace(/&/g,"&").replace(/\s/g," ").replace(/</g,"<").replace(/>/g,">"));var a=s.width()+r,i="function"==typeof o.maxWidth?o.maxWidth():o.maxWidth;a>i?a=i:a<o.minWidth&&(a=o.minWidth),a!=n.width()&&n.width(a)}};n.data("autogrow-span",s),n.off(a+".autogrow autogrow change").on(a+".autogrow autogrow change",h),h()}),this}}(window.jQuery||window.Zepto||window.$); | ||
!function(t){var i=("oninput"in document.createElement("input")?"input":"keydown")+".autogrow change.autogrow autogrow";t.fn.inputAutogrow=function(a){if(a&&("destroy"===a||t(this).data("autogrow-span"))&&(this.each(function(){var a=t(this);a.off(i);var n=a.data("autogrow-span");n.remove(),a.data("autogrow-span","")}),"destroy"===a))return input.data("original-width",""),this;if(t(this).data("original-width"))var n=t(this).data("original-width");else{var n=t(this).width();t(this).data("original-width",n)}var o=t.extend({maxWidth:t(this).parent().width(),minWidth:n,trailingSpace:0},a);return this.each(function(){var n=t(this),e=" ",r=a&&"trailingSpace"in a?o.trailingSpace:parseInt(n.css("fontSize")),s=t("<span/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:n.css("fontSize"),fontFamily:n.css("fontFamily"),fontWeight:n.css("fontWeight"),letterSpacing:n.css("letterSpacing"),textTransform:n.css("textTransform"),whiteSpace:"nowrap",ariaHidden:!0}).appendTo("body"),d=function(t){if(e!==(e=n.val())||"autogrow"===t.type){e||(e=n.attr("placeholder")||""),s.html(e.replace(/&/g,"&").replace(/\s/g," ").replace(/</g,"<").replace(/>/g,">"));var i=s.width()+r,a="function"==typeof o.maxWidth?o.maxWidth():o.maxWidth;i>a?i=a:i<o.minWidth&&(i=o.minWidth),i!=n.width()&&n.width(i)}};n.data("autogrow-span",s),n.off(i).on(i,d),d()}),this}}(window.jQuery||window.Zepto||window.$); |
{ | ||
"name": "input-autogrow", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Autogrow plugin for inputs", | ||
@@ -5,0 +5,0 @@ "main": "dist/input-autogrow.min.js", |
@@ -6,3 +6,3 @@ # input-autogrow | ||
Requires a DOM library such as jQuery, Zepto, or any that support $.fn extending. | ||
Requires a DOM library such as jQuery, Zepto, or any that supports $.fn plugins. | ||
@@ -9,0 +9,0 @@ # Install |
/* | ||
* input-autogrow - Autogrow plugin for inputs | ||
* @version v1.0.1 | ||
* @version v1.0.2 | ||
* @link http://github.com/westonganger/input-autogrow | ||
@@ -9,3 +9,3 @@ * @license MIT | ||
(function($){ | ||
var event = ('oninput' in document.createElement('input')) ? 'input' : 'keydown'; | ||
var events = (('oninput' in document.createElement('input')) ? 'input' : 'keydown') + '.autogrow change.autogrow autogrow'; | ||
@@ -16,3 +16,3 @@ $.fn.inputAutogrow = function(options){ | ||
var input = $(this); | ||
input.off(event + '.autogrow autogrow change'); | ||
input.off(events); | ||
var span = input.data("autogrow-span"); | ||
@@ -83,3 +83,3 @@ span.remove(); | ||
input.data("autogrow-span", span); | ||
input.off(event + '.autogrow autogrow change').on(event+'.autogrow autogrow change', check); | ||
input.off(events).on(events, check); | ||
@@ -86,0 +86,0 @@ check(); //init on page load |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11231