autosize 1.1.18.4 → 1.3.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98671965689ddc4534c46e5952269fe9c7285c00
4
- data.tar.gz: 1d41daa95bbdf19d2fb06f1d6d827388d60a53e2
3
+ metadata.gz: cc01d77ed65b15f67c17897daf682f51bff7346d
4
+ data.tar.gz: 164c9250165cfb11e94c6bf9db05dc73f915129c
5
5
  SHA512:
6
- metadata.gz: f0a7b9b0ec956baa3984e240834bc57a128d0afc9526b939b6e1d84139a6dce0e57c53bdd0b66b33ef969fdef692d80e2c94116935311597041a25d95c66a780
7
- data.tar.gz: a9ce722a0356fae797065689889819091e13faacade5982da693d299def4de81ab0e3cfda7f9795cba0bf869fed4a7fa9ff41b0dbcddccdaac6b0cdd1a59aee8
6
+ metadata.gz: b64c1957d3151e3eb5e28d164476952ab0f94c8769f86849133cc73c7927278a92b453c8babfcaadf90621e24186327d8ce555c8e77fdaece2499fdf78ddd877
7
+ data.tar.gz: 106dfcde53efef859426ba04c393a6a8104ff415a952d5a390494e6b1a560e1b15ded3dbd0719224e4b4ea2497688399ce381322d5ec701df85eb59974516396
data/README.md CHANGED
@@ -21,11 +21,3 @@ Contributing
21
21
  4. Push to the branch (`git push origin my_markup`)
22
22
  5. Open a [Pull Request][1]
23
23
  6. Enjoy a refreshing 'Insert Favorite Beverage' and wait
24
-
25
- License
26
- ------------
27
- The MIT License (MIT)
28
-
29
-
30
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/acrogenesis/autosize/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
31
-
@@ -1,5 +1,5 @@
1
1
  module Autosize
2
2
  module Rails
3
- VERSION = "1.1.18.4"
3
+ VERSION = "1.3.0.21"
4
4
  end
5
5
  end
@@ -0,0 +1,290 @@
1
+ /*!
2
+ Autosize 3.0.20
3
+ license: MIT
4
+ http://www.jacklmoore.com/autosize
5
+ */
6
+ (function (global, factory) {
7
+ if (typeof define === 'function' && define.amd) {
8
+ define(['exports', 'module'], factory);
9
+ } else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
10
+ factory(exports, module);
11
+ } else {
12
+ var mod = {
13
+ exports: {}
14
+ };
15
+ factory(mod.exports, mod);
16
+ global.autosize = mod.exports;
17
+ }
18
+ })(this, function (exports, module) {
19
+ 'use strict';
20
+
21
+ var map = typeof Map === "function" ? new Map() : (function () {
22
+ var keys = [];
23
+ var values = [];
24
+
25
+ return {
26
+ has: function has(key) {
27
+ return keys.indexOf(key) > -1;
28
+ },
29
+ get: function get(key) {
30
+ return values[keys.indexOf(key)];
31
+ },
32
+ set: function set(key, value) {
33
+ if (keys.indexOf(key) === -1) {
34
+ keys.push(key);
35
+ values.push(value);
36
+ }
37
+ },
38
+ 'delete': function _delete(key) {
39
+ var index = keys.indexOf(key);
40
+ if (index > -1) {
41
+ keys.splice(index, 1);
42
+ values.splice(index, 1);
43
+ }
44
+ }
45
+ };
46
+ })();
47
+
48
+ var createEvent = function createEvent(name) {
49
+ return new Event(name, { bubbles: true });
50
+ };
51
+ try {
52
+ new Event('test');
53
+ } catch (e) {
54
+ // IE does not support `new Event()`
55
+ createEvent = function (name) {
56
+ var evt = document.createEvent('Event');
57
+ evt.initEvent(name, true, false);
58
+ return evt;
59
+ };
60
+ }
61
+
62
+ function assign(ta) {
63
+ if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
64
+
65
+ var heightOffset = null;
66
+ var clientWidth = ta.clientWidth;
67
+ var cachedHeight = null;
68
+
69
+ function init() {
70
+ var style = window.getComputedStyle(ta, null);
71
+
72
+ if (style.resize === 'vertical') {
73
+ ta.style.resize = 'none';
74
+ } else if (style.resize === 'both') {
75
+ ta.style.resize = 'horizontal';
76
+ }
77
+
78
+ if (style.boxSizing === 'content-box') {
79
+ heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
80
+ } else {
81
+ heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
82
+ }
83
+ // Fix when a textarea is not on document body and heightOffset is Not a Number
84
+ if (isNaN(heightOffset)) {
85
+ heightOffset = 0;
86
+ }
87
+
88
+ update();
89
+ }
90
+
91
+ function changeOverflow(value) {
92
+ {
93
+ // Chrome/Safari-specific fix:
94
+ // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
95
+ // made available by removing the scrollbar. The following forces the necessary text reflow.
96
+ var width = ta.style.width;
97
+ ta.style.width = '0px';
98
+ // Force reflow:
99
+ /* jshint ignore:start */
100
+ ta.offsetWidth;
101
+ /* jshint ignore:end */
102
+ ta.style.width = width;
103
+ }
104
+
105
+ ta.style.overflowY = value;
106
+ }
107
+
108
+ function getParentOverflows(el) {
109
+ var arr = [];
110
+
111
+ while (el && el.parentNode && el.parentNode instanceof Element) {
112
+ if (el.parentNode.scrollTop) {
113
+ arr.push({
114
+ node: el.parentNode,
115
+ scrollTop: el.parentNode.scrollTop
116
+ });
117
+ }
118
+ el = el.parentNode;
119
+ }
120
+
121
+ return arr;
122
+ }
123
+
124
+ function resize() {
125
+ var originalHeight = ta.style.height;
126
+ var overflows = getParentOverflows(ta);
127
+ var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
128
+
129
+ ta.style.height = 'auto';
130
+
131
+ var endHeight = ta.scrollHeight + heightOffset;
132
+
133
+ if (ta.scrollHeight === 0) {
134
+ // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
135
+ ta.style.height = originalHeight;
136
+ return;
137
+ }
138
+
139
+ ta.style.height = endHeight + 'px';
140
+
141
+ // used to check if an update is actually necessary on window.resize
142
+ clientWidth = ta.clientWidth;
143
+
144
+ // prevents scroll-position jumping
145
+ overflows.forEach(function (el) {
146
+ el.node.scrollTop = el.scrollTop;
147
+ });
148
+
149
+ if (docTop) {
150
+ document.documentElement.scrollTop = docTop;
151
+ }
152
+ }
153
+
154
+ function update() {
155
+ resize();
156
+
157
+ var styleHeight = Math.round(parseFloat(ta.style.height));
158
+ var computed = window.getComputedStyle(ta, null);
159
+ var actualHeight = Math.round(parseFloat(computed.height));
160
+
161
+ // The actual height not matching the style height (set via the resize method) indicates that
162
+ // the max-height has been exceeded, in which case the overflow should be set to visible.
163
+ if (actualHeight !== styleHeight) {
164
+ if (computed.overflowY !== 'visible') {
165
+ changeOverflow('visible');
166
+ resize();
167
+ actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
168
+ }
169
+ } else {
170
+ // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
171
+ if (computed.overflowY !== 'hidden') {
172
+ changeOverflow('hidden');
173
+ resize();
174
+ actualHeight = Math.round(parseFloat(window.getComputedStyle(ta, null).height));
175
+ }
176
+ }
177
+
178
+ if (cachedHeight !== actualHeight) {
179
+ cachedHeight = actualHeight;
180
+ var evt = createEvent('autosize:resized');
181
+ try {
182
+ ta.dispatchEvent(evt);
183
+ } catch (err) {
184
+ // Firefox will throw an error on dispatchEvent for a detached element
185
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
186
+ }
187
+ }
188
+ }
189
+
190
+ var pageResize = function pageResize() {
191
+ if (ta.clientWidth !== clientWidth) {
192
+ update();
193
+ }
194
+ };
195
+
196
+ var destroy = (function (style) {
197
+ window.removeEventListener('resize', pageResize, false);
198
+ ta.removeEventListener('input', update, false);
199
+ ta.removeEventListener('keyup', update, false);
200
+ ta.removeEventListener('autosize:destroy', destroy, false);
201
+ ta.removeEventListener('autosize:update', update, false);
202
+
203
+ Object.keys(style).forEach(function (key) {
204
+ ta.style[key] = style[key];
205
+ });
206
+
207
+ map['delete'](ta);
208
+ }).bind(ta, {
209
+ height: ta.style.height,
210
+ resize: ta.style.resize,
211
+ overflowY: ta.style.overflowY,
212
+ overflowX: ta.style.overflowX,
213
+ wordWrap: ta.style.wordWrap
214
+ });
215
+
216
+ ta.addEventListener('autosize:destroy', destroy, false);
217
+
218
+ // IE9 does not fire onpropertychange or oninput for deletions,
219
+ // so binding to onkeyup to catch most of those events.
220
+ // There is no way that I know of to detect something like 'cut' in IE9.
221
+ if ('onpropertychange' in ta && 'oninput' in ta) {
222
+ ta.addEventListener('keyup', update, false);
223
+ }
224
+
225
+ window.addEventListener('resize', pageResize, false);
226
+ ta.addEventListener('input', update, false);
227
+ ta.addEventListener('autosize:update', update, false);
228
+ ta.style.overflowX = 'hidden';
229
+ ta.style.wordWrap = 'break-word';
230
+
231
+ map.set(ta, {
232
+ destroy: destroy,
233
+ update: update
234
+ });
235
+
236
+ init();
237
+ }
238
+
239
+ function destroy(ta) {
240
+ var methods = map.get(ta);
241
+ if (methods) {
242
+ methods.destroy();
243
+ }
244
+ }
245
+
246
+ function update(ta) {
247
+ var methods = map.get(ta);
248
+ if (methods) {
249
+ methods.update();
250
+ }
251
+ }
252
+
253
+ var autosize = null;
254
+
255
+ // Do nothing in Node.js environment and IE8 (or lower)
256
+ if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
257
+ autosize = function (el) {
258
+ return el;
259
+ };
260
+ autosize.destroy = function (el) {
261
+ return el;
262
+ };
263
+ autosize.update = function (el) {
264
+ return el;
265
+ };
266
+ } else {
267
+ autosize = function (el, options) {
268
+ if (el) {
269
+ Array.prototype.forEach.call(el.length ? el : [el], function (x) {
270
+ return assign(x, options);
271
+ });
272
+ }
273
+ return el;
274
+ };
275
+ autosize.destroy = function (el) {
276
+ if (el) {
277
+ Array.prototype.forEach.call(el.length ? el : [el], destroy);
278
+ }
279
+ return el;
280
+ };
281
+ autosize.update = function (el) {
282
+ if (el) {
283
+ Array.prototype.forEach.call(el.length ? el : [el], update);
284
+ }
285
+ return el;
286
+ };
287
+ }
288
+
289
+ module.exports = autosize;
290
+ });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autosize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.18.4
4
+ version: 1.3.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-10 00:00:00.000000000 Z
12
+ date: 2017-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jquery-rails
@@ -56,7 +56,7 @@ files:
56
56
  - autosize.gemspec
57
57
  - lib/autosize.rb
58
58
  - lib/autosize/version.rb
59
- - vendor/assets/javascripts/jquery.autosize.js
59
+ - vendor/assets/javascripts/autosize.js
60
60
  homepage: http://www.jacklmoore.com/autosize/
61
61
  licenses:
62
62
  - MIT
@@ -77,8 +77,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project: autosize
80
- rubygems_version: 2.2.1
80
+ rubygems_version: 2.5.2
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: This gem allows you to use Autosize jQuery plugin
84
84
  test_files: []
85
+ has_rdoc:
@@ -1,263 +0,0 @@
1
- /*!
2
- Autosize v1.18.4 - 2014-01-11
3
- Automatically adjust textarea height based on user input.
4
- (c) 2014 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
- placeholder: true
15
- },
16
-
17
- // border:0 is unnecessary, but avoids a bug in Firefox on OSX
18
- 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;"/>',
19
-
20
- // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
21
- typographyStyles = [
22
- 'fontFamily',
23
- 'fontSize',
24
- 'fontWeight',
25
- 'fontStyle',
26
- 'letterSpacing',
27
- 'textTransform',
28
- 'wordSpacing',
29
- 'textIndent'
30
- ],
31
-
32
- // to keep track which textarea is being mirrored when adjust() is called.
33
- mirrored,
34
-
35
- // the mirror element, which is used to calculate what size the mirrored element should be.
36
- mirror = $(copy).data('autosize', true)[0];
37
-
38
- // test that line-height can be accurately copied.
39
- mirror.style.lineHeight = '99px';
40
- if ($(mirror).css('lineHeight') === '99px') {
41
- typographyStyles.push('lineHeight');
42
- }
43
- mirror.style.lineHeight = '';
44
-
45
- $.fn.autosize = function (options) {
46
- if (!this.length) {
47
- return this;
48
- }
49
-
50
- options = $.extend({}, defaults, options || {});
51
-
52
- if (mirror.parentNode !== document.body) {
53
- $(document.body).append(mirror);
54
- }
55
-
56
- return this.each(function () {
57
- var
58
- ta = this,
59
- $ta = $(ta),
60
- maxHeight,
61
- minHeight,
62
- boxOffset = 0,
63
- callback = $.isFunction(options.callback),
64
- originalStyles = {
65
- height: ta.style.height,
66
- overflow: ta.style.overflow,
67
- overflowY: ta.style.overflowY,
68
- wordWrap: ta.style.wordWrap,
69
- resize: ta.style.resize
70
- },
71
- timeout,
72
- width = $ta.width();
73
-
74
- if ($ta.data('autosize')) {
75
- // exit if autosize has already been applied, or if the textarea is the mirror element.
76
- return;
77
- }
78
- $ta.data('autosize', true);
79
-
80
- if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
81
- boxOffset = $ta.outerHeight() - $ta.height();
82
- }
83
-
84
- // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
85
- minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
86
-
87
- $ta.css({
88
- overflow: 'hidden',
89
- overflowY: 'hidden',
90
- wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
91
- resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
92
- });
93
-
94
- // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
95
- // window.getComputedStyle, getBoundingClientRect returning a width are unsupported, but also unneeded in IE8 and lower.
96
- function setWidth() {
97
- var width;
98
- var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false;
99
-
100
- if (style) {
101
-
102
- width = ta.getBoundingClientRect().width;
103
-
104
- if (width === 0) {
105
- width = parseInt(style.width,10);
106
- }
107
-
108
- $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
109
- width -= parseInt(style[val],10);
110
- });
111
- } else {
112
- width = Math.max($ta.width(), 0);
113
- }
114
-
115
- mirror.style.width = width + 'px';
116
- }
117
-
118
- function initMirror() {
119
- var styles = {};
120
-
121
- mirrored = ta;
122
- mirror.className = options.className;
123
- maxHeight = parseInt($ta.css('maxHeight'), 10);
124
-
125
- // mirror is a duplicate textarea located off-screen that
126
- // is automatically updated to contain the same text as the
127
- // original textarea. mirror always has a height of 0.
128
- // This gives a cross-browser supported way getting the actual
129
- // height of the text, through the scrollTop property.
130
- $.each(typographyStyles, function(i,val){
131
- styles[val] = $ta.css(val);
132
- });
133
- $(mirror).css(styles);
134
-
135
- setWidth();
136
-
137
- // Chrome-specific fix:
138
- // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
139
- // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
140
- if (window.chrome) {
141
- var width = ta.style.width;
142
- ta.style.width = '0px';
143
- var ignore = ta.offsetWidth;
144
- ta.style.width = width;
145
- }
146
- }
147
-
148
- // Using mainly bare JS in this function because it is going
149
- // to fire very often while typing, and needs to very efficient.
150
- function adjust() {
151
- var height, original;
152
-
153
- if (mirrored !== ta) {
154
- initMirror();
155
- } else {
156
- setWidth();
157
- }
158
-
159
- if (!ta.value && options.placeholder) {
160
- // If the textarea is empty, copy the placeholder text into
161
- // the mirror control and use that for sizing so that we
162
- // don't end up with placeholder getting trimmed.
163
- mirror.value = ($(ta).attr("placeholder") || '') + options.append;
164
- } else {
165
- mirror.value = ta.value + options.append;
166
- }
167
-
168
- mirror.style.overflowY = ta.style.overflowY;
169
- original = parseInt(ta.style.height,10);
170
-
171
- // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
172
- mirror.scrollTop = 0;
173
-
174
- mirror.scrollTop = 9e4;
175
-
176
- // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
177
- height = mirror.scrollTop;
178
-
179
- if (maxHeight && height > maxHeight) {
180
- ta.style.overflowY = 'scroll';
181
- height = maxHeight;
182
- } else {
183
- ta.style.overflowY = 'hidden';
184
- if (height < minHeight) {
185
- height = minHeight;
186
- }
187
- }
188
-
189
- height += boxOffset;
190
-
191
- if (original !== height) {
192
- ta.style.height = height + 'px';
193
- if (callback) {
194
- options.callback.call(ta,ta);
195
- }
196
- }
197
- }
198
-
199
- function resize () {
200
- clearTimeout(timeout);
201
- timeout = setTimeout(function(){
202
- var newWidth = $ta.width();
203
-
204
- if (newWidth !== width) {
205
- width = newWidth;
206
- adjust();
207
- }
208
- }, parseInt(options.resizeDelay,10));
209
- }
210
-
211
- if ('onpropertychange' in ta) {
212
- if ('oninput' in ta) {
213
- // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
214
- // so binding to onkeyup to catch most of those occasions. There is no way that I
215
- // know of to detect something like 'cut' in IE9.
216
- $ta.on('input.autosize keyup.autosize', adjust);
217
- } else {
218
- // IE7 / IE8
219
- $ta.on('propertychange.autosize', function(){
220
- if(event.propertyName === 'value'){
221
- adjust();
222
- }
223
- });
224
- }
225
- } else {
226
- // Modern Browsers
227
- $ta.on('input.autosize', adjust);
228
- }
229
-
230
- // Set options.resizeDelay to false if using fixed-width textarea elements.
231
- // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
232
-
233
- if (options.resizeDelay !== false) {
234
- $(window).on('resize.autosize', resize);
235
- }
236
-
237
- // Event for manual triggering if needed.
238
- // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
239
- $ta.on('autosize.resize', adjust);
240
-
241
- // Event for manual triggering that also forces the styles to update as well.
242
- // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
243
- $ta.on('autosize.resizeIncludeStyle', function() {
244
- mirrored = null;
245
- adjust();
246
- });
247
-
248
- $ta.on('autosize.destroy', function(){
249
- mirrored = null;
250
- clearTimeout(timeout);
251
- $(window).off('resize', resize);
252
- $ta
253
- .off('autosize')
254
- .off('.autosize')
255
- .css(originalStyles)
256
- .removeData('autosize');
257
- });
258
-
259
- // Call adjust in case the textarea already contains text.
260
- adjust();
261
- });
262
- };
263
- }(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto