autosize 0.1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5e634e4512fef5a3a56f1cedbcbd3018e2073b84
4
+ data.tar.gz: dc447b81bcc4460c6f166cce0430d1c6102aa442
5
+ SHA512:
6
+ metadata.gz: fbfffad7cff3a33ae93af7ef59d3c126d52f9f814653ca034e16665b166e17e6a4f8f52f8c65ee1f7deb35ef717f53582ae262b0becde541187c19bc59c9467b
7
+ data.tar.gz: c66d228379f52dcb7a3d7e5014f60640b26ce35da0a1a9263f7c1561cda85717cf39bc64bde48fc458228c38aba21c70216d6b4acaa701f9f494e4f7928c3468
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
6
+ .bin
7
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jquery-datatables-rails.gemspec
4
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Adrian Rangel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ Autosize
2
+ ============
3
+
4
+ This gem bundles the contents of the [JQuery Autosize Plugin](https://github.com/jackmoore/autosize) from Jack Moore
5
+
6
+ Small jQuery plugin to allow dynamic resizing of textarea height, so that it grows as based on visitor input. To use, just call the `.autosize()` method on any textarea element. Example `$('textarea').autosize();`. See the [project page](http://jacklmoore.com/autosize/) for documentation, caveats, and a demonstration.
7
+
8
+ ## Install
9
+
10
+ add `gem 'autosize'` to your `Gemfile` (and then run `bundle install`).
11
+
12
+ And in your application.js:
13
+ `//= require jquery.autosize`
14
+
15
+ Contributing
16
+ ------------
17
+
18
+ 1. Fork it.
19
+ 2. Create a branch (`git checkout -b my_markup`)
20
+ 3. Commit your changes (`git commit -am "Cool new feature"`)
21
+ 4. Push to the branch (`git push origin my_markup`)
22
+ 5. Open a [Pull Request][1]
23
+ 6. Enjoy a refreshing 'Insert Favorite Beverage' and wait
24
+
25
+ License
26
+ ------------
27
+ The MIT License (MIT)
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/autosize.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/autosize/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "autosize"
6
+ gem.version = Autosize::Rails::VERSION
7
+ gem.authors = ["Jack Moore", "Adrian Rangel"]
8
+ gem.email = ["adrian.rangel@gmail.com"]
9
+ gem.homepage = "https://github.com/acrogenesis/autosize-gem"
10
+ gem.summary = %q{This gem allows you to use Autosize jQuery plugin}
11
+ gem.description = %q{Small jQuery plugin to allow dynamic resizing of textarea height, so that it grows as based on visitor input. To use, just call the .autosize() method on any textarea element.}
12
+ gem.license = "MIT"
13
+
14
+ gem.rubyforge_project = "autosize"
15
+
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "jquery-rails"
22
+ gem.add_development_dependency "rake"
23
+
24
+ end
data/lib/autosize.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "autosize/version"
2
+
3
+ module Autosize
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Autosize
2
+ module Rails
3
+ VERSION = "0.1.18.1"
4
+ end
5
+ end
@@ -0,0 +1,250 @@
1
+ /*!
2
+ Autosize v1.18.1 - 2013-11-05
3
+ Automatically adjust textarea height based on user input.
4
+ (c) 2013 Jack Moore - http://www.jacklmoore.com/autosize
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+ (function ($) {
8
+ var
9
+ defaults = {
10
+ className: 'autosizejs',
11
+ append: '',
12
+ callback: false,
13
+ resizeDelay: 10
14
+ },
15
+
16
+ // border:0 is unnecessary, but avoids a bug in Firefox on OSX
17
+ copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
18
+
19
+ // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
20
+ typographyStyles = [
21
+ 'fontFamily',
22
+ 'fontSize',
23
+ 'fontWeight',
24
+ 'fontStyle',
25
+ 'letterSpacing',
26
+ 'textTransform',
27
+ 'wordSpacing',
28
+ 'textIndent'
29
+ ],
30
+
31
+ // to keep track which textarea is being mirrored when adjust() is called.
32
+ mirrored,
33
+
34
+ // the mirror element, which is used to calculate what size the mirrored element should be.
35
+ mirror = $(copy).data('autosize', true)[0];
36
+
37
+ // test that line-height can be accurately copied.
38
+ mirror.style.lineHeight = '99px';
39
+ if ($(mirror).css('lineHeight') === '99px') {
40
+ typographyStyles.push('lineHeight');
41
+ }
42
+ mirror.style.lineHeight = '';
43
+
44
+ $.fn.autosize = function (options) {
45
+ if (!this.length) {
46
+ return this;
47
+ }
48
+
49
+ options = $.extend({}, defaults, options || {});
50
+
51
+ if (mirror.parentNode !== document.body) {
52
+ $(document.body).append(mirror);
53
+ }
54
+
55
+ return this.each(function () {
56
+ var
57
+ ta = this,
58
+ $ta = $(ta),
59
+ maxHeight,
60
+ minHeight,
61
+ boxOffset = 0,
62
+ callback = $.isFunction(options.callback),
63
+ originalStyles = {
64
+ height: ta.style.height,
65
+ overflow: ta.style.overflow,
66
+ overflowY: ta.style.overflowY,
67
+ wordWrap: ta.style.wordWrap,
68
+ resize: ta.style.resize
69
+ },
70
+ timeout,
71
+ width = $ta.width();
72
+
73
+ if ($ta.data('autosize')) {
74
+ // exit if autosize has already been applied, or if the textarea is the mirror element.
75
+ return;
76
+ }
77
+ $ta.data('autosize', true);
78
+
79
+ if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
80
+ boxOffset = $ta.outerHeight() - $ta.height();
81
+ }
82
+
83
+ // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
84
+ minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
85
+
86
+ $ta.css({
87
+ overflow: 'hidden',
88
+ overflowY: 'hidden',
89
+ wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
90
+ resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
91
+ });
92
+
93
+ // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
94
+ function setWidth() {
95
+ var style, width;
96
+
97
+ if ('getComputedStyle' in window) {
98
+ style = window.getComputedStyle(ta, null);
99
+ width = ta.getBoundingClientRect().width;
100
+
101
+ $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
102
+ width -= parseInt(style[val],10);
103
+ });
104
+
105
+ mirror.style.width = width + 'px';
106
+ }
107
+ else {
108
+ // window.getComputedStyle, getBoundingClientRect returning a width are unsupported and unneeded in IE8 and lower.
109
+ mirror.style.width = Math.max($ta.width(), 0) + 'px';
110
+ }
111
+ }
112
+
113
+ function initMirror() {
114
+ var styles = {};
115
+
116
+ mirrored = ta;
117
+ mirror.className = options.className;
118
+ maxHeight = parseInt($ta.css('maxHeight'), 10);
119
+
120
+ // mirror is a duplicate textarea located off-screen that
121
+ // is automatically updated to contain the same text as the
122
+ // original textarea. mirror always has a height of 0.
123
+ // This gives a cross-browser supported way getting the actual
124
+ // height of the text, through the scrollTop property.
125
+ $.each(typographyStyles, function(i,val){
126
+ styles[val] = $ta.css(val);
127
+ });
128
+ $(mirror).css(styles);
129
+
130
+ setWidth();
131
+
132
+ // Chrome-specific fix:
133
+ // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
134
+ // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
135
+ if (window.chrome) {
136
+ var width = ta.style.width;
137
+ ta.style.width = '0px';
138
+ var ignore = ta.offsetWidth;
139
+ ta.style.width = width;
140
+ }
141
+ }
142
+
143
+ // Using mainly bare JS in this function because it is going
144
+ // to fire very often while typing, and needs to very efficient.
145
+ function adjust() {
146
+ var height, original;
147
+
148
+ if (mirrored !== ta) {
149
+ initMirror();
150
+ } else {
151
+ setWidth();
152
+ }
153
+
154
+ mirror.value = ta.value + options.append;
155
+ mirror.style.overflowY = ta.style.overflowY;
156
+ original = parseInt(ta.style.height,10);
157
+
158
+ // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
159
+ mirror.scrollTop = 0;
160
+
161
+ mirror.scrollTop = 9e4;
162
+
163
+ // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
164
+ height = mirror.scrollTop;
165
+
166
+ if (maxHeight && height > maxHeight) {
167
+ ta.style.overflowY = 'scroll';
168
+ height = maxHeight;
169
+ } else {
170
+ ta.style.overflowY = 'hidden';
171
+ if (height < minHeight) {
172
+ height = minHeight;
173
+ }
174
+ }
175
+
176
+ height += boxOffset;
177
+
178
+ if (original !== height) {
179
+ ta.style.height = height + 'px';
180
+ if (callback) {
181
+ options.callback.call(ta,ta);
182
+ }
183
+ }
184
+ }
185
+
186
+ function resize () {
187
+ clearTimeout(timeout);
188
+ timeout = setTimeout(function(){
189
+ var newWidth = $ta.width();
190
+
191
+ if (newWidth !== width) {
192
+ width = newWidth;
193
+ adjust();
194
+ }
195
+ }, parseInt(options.resizeDelay,10));
196
+ }
197
+
198
+ if ('onpropertychange' in ta) {
199
+ if ('oninput' in ta) {
200
+ // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
201
+ // so binding to onkeyup to catch most of those occasions. There is no way that I
202
+ // know of to detect something like 'cut' in IE9.
203
+ $ta.on('input.autosize keyup.autosize', adjust);
204
+ } else {
205
+ // IE7 / IE8
206
+ $ta.on('propertychange.autosize', function(){
207
+ if(event.propertyName === 'value'){
208
+ adjust();
209
+ }
210
+ });
211
+ }
212
+ } else {
213
+ // Modern Browsers
214
+ $ta.on('input.autosize', adjust);
215
+ }
216
+
217
+ // Set options.resizeDelay to false if using fixed-width textarea elements.
218
+ // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
219
+
220
+ if (options.resizeDelay !== false) {
221
+ $(window).on('resize.autosize', resize);
222
+ }
223
+
224
+ // Event for manual triggering if needed.
225
+ // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
226
+ $ta.on('autosize.resize', adjust);
227
+
228
+ // Event for manual triggering that also forces the styles to update as well.
229
+ // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
230
+ $ta.on('autosize.resizeIncludeStyle', function() {
231
+ mirrored = null;
232
+ adjust();
233
+ });
234
+
235
+ $ta.on('autosize.destroy', function(){
236
+ mirrored = null;
237
+ clearTimeout(timeout);
238
+ $(window).off('resize', resize);
239
+ $ta
240
+ .off('autosize')
241
+ .off('.autosize')
242
+ .css(originalStyles)
243
+ .removeData('autosize');
244
+ });
245
+
246
+ // Call adjust in case the textarea already contains text.
247
+ adjust();
248
+ });
249
+ };
250
+ }(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autosize
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.18.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack Moore
8
+ - Adrian Rangel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jquery-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Small jQuery plugin to allow dynamic resizing of textarea height, so
43
+ that it grows as based on visitor input. To use, just call the .autosize() method
44
+ on any textarea element.
45
+ email:
46
+ - adrian.rangel@gmail.com
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - MIT-LICENSE
54
+ - README.md
55
+ - Rakefile
56
+ - autosize.gemspec
57
+ - lib/autosize.rb
58
+ - lib/autosize/version.rb
59
+ - vendor/assets/javascripts/jquery.autosize.js
60
+ homepage: https://github.com/acrogenesis/autosize-gem
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project: autosize
80
+ rubygems_version: 2.2.0
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: This gem allows you to use Autosize jQuery plugin
84
+ test_files: []