autosize-rails 1.16.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/autosize-rails.gemspec +24 -0
- data/lib/autosize/rails/engine.rb +8 -0
- data/lib/autosize/rails/version.rb +5 -0
- data/lib/autosize/rails.rb +7 -0
- data/vendor/assets/javascripts/jquery.autosize.js +192 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53cbda86330166837edb82f586ee6f6d1bbd034f
|
4
|
+
data.tar.gz: 3034dc0518e2197b3f91850c9cbc0e628c1056ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da84c85b1b8fe17ebf1f58ffe0561d3f25ddbe5490718ebeea92eb55a11fc27a08a89c9cedb8e667b882ca424d4cbc05f36ff9798ae20dbdf154f7ebf16897cb
|
7
|
+
data.tar.gz: 055151007c193da65c1a1c60c31e8f56771eb330fd82e62fc523fc9aea87d728155141ce3d98b6031c20e50f43b06eb590d8af08911283c6c873821a145c5913
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Caleb Thompson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Autosize::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'autosize-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install autosize-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'autosize/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "autosize-rails"
|
8
|
+
spec.version = Autosize::Rails::VERSION
|
9
|
+
spec.authors = ["Caleb Thompson"]
|
10
|
+
spec.email = ["cjaysson@gmail.com"]
|
11
|
+
spec.description = "Rails asset pipeline wrapper around jQuery Autosize"
|
12
|
+
spec.summary = "A plugin to enable automatic height for textarea elements."
|
13
|
+
spec.homepage = "http://www.jacklmoore.com/autosize/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rails', '>= 3.1'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/*!
|
2
|
+
jQuery Autosize v1.16.7
|
3
|
+
(c) 2013 Jack Moore - jacklmoore.com
|
4
|
+
updated: 2013-03-20
|
5
|
+
license: http://www.opensource.org/licenses/mit-license.php
|
6
|
+
*/
|
7
|
+
|
8
|
+
|
9
|
+
(function ($) {
|
10
|
+
var
|
11
|
+
defaults = {
|
12
|
+
className: 'autosizejs',
|
13
|
+
append: '',
|
14
|
+
callback: false
|
15
|
+
},
|
16
|
+
hidden = 'hidden',
|
17
|
+
borderBox = 'border-box',
|
18
|
+
lineHeight = 'lineHeight',
|
19
|
+
supportsScrollHeight,
|
20
|
+
|
21
|
+
// border:0 is unnecessary, but avoids a bug in FireFox on OSX (http://www.jacklmoore.com/autosize#comment-851)
|
22
|
+
copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border: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;"/>',
|
23
|
+
|
24
|
+
// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
|
25
|
+
copyStyle = [
|
26
|
+
'fontFamily',
|
27
|
+
'fontSize',
|
28
|
+
'fontWeight',
|
29
|
+
'fontStyle',
|
30
|
+
'letterSpacing',
|
31
|
+
'textTransform',
|
32
|
+
'wordSpacing',
|
33
|
+
'textIndent'
|
34
|
+
],
|
35
|
+
oninput = 'oninput',
|
36
|
+
onpropertychange = 'onpropertychange',
|
37
|
+
|
38
|
+
// to keep track which textarea is being mirrored when adjust() is called.
|
39
|
+
mirrored,
|
40
|
+
|
41
|
+
// the mirror element, which is used to calculate what size the mirrored element should be.
|
42
|
+
mirror = $(copy).data('autosize', true)[0];
|
43
|
+
|
44
|
+
// test that line-height can be accurately copied.
|
45
|
+
mirror.style.lineHeight = '99px';
|
46
|
+
if ($(mirror).css(lineHeight) === '99px') {
|
47
|
+
copyStyle.push(lineHeight);
|
48
|
+
}
|
49
|
+
mirror.style.lineHeight = '';
|
50
|
+
|
51
|
+
$.fn.autosize = function (options) {
|
52
|
+
options = $.extend({}, defaults, options || {});
|
53
|
+
|
54
|
+
if (mirror.parentNode !== document.body) {
|
55
|
+
$(document.body).append(mirror);
|
56
|
+
|
57
|
+
mirror.value = "\n\n\n";
|
58
|
+
mirror.scrollTop = 9e4;
|
59
|
+
supportsScrollHeight = mirror.scrollHeight === mirror.scrollTop + mirror.clientHeight;
|
60
|
+
}
|
61
|
+
|
62
|
+
return this.each(function () {
|
63
|
+
var
|
64
|
+
ta = this,
|
65
|
+
$ta = $(ta),
|
66
|
+
minHeight,
|
67
|
+
active,
|
68
|
+
resize,
|
69
|
+
boxOffset = 0,
|
70
|
+
callback = $.isFunction(options.callback);
|
71
|
+
|
72
|
+
if ($ta.data('autosize')) {
|
73
|
+
// exit if autosize has already been applied, or if the textarea is the mirror element.
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
if ($ta.css('box-sizing') === borderBox || $ta.css('-moz-box-sizing') === borderBox || $ta.css('-webkit-box-sizing') === borderBox){
|
78
|
+
boxOffset = $ta.outerHeight() - $ta.height();
|
79
|
+
}
|
80
|
+
|
81
|
+
minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset, $ta.height());
|
82
|
+
|
83
|
+
resize = ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal';
|
84
|
+
|
85
|
+
$ta.css({
|
86
|
+
overflow: hidden,
|
87
|
+
overflowY: hidden,
|
88
|
+
wordWrap: 'break-word',
|
89
|
+
resize: resize
|
90
|
+
}).data('autosize', true);
|
91
|
+
|
92
|
+
function initMirror() {
|
93
|
+
mirrored = ta;
|
94
|
+
mirror.className = options.className;
|
95
|
+
|
96
|
+
// mirror is a duplicate textarea located off-screen that
|
97
|
+
// is automatically updated to contain the same text as the
|
98
|
+
// original textarea. mirror always has a height of 0.
|
99
|
+
// This gives a cross-browser supported way getting the actual
|
100
|
+
// height of the text, through the scrollTop property.
|
101
|
+
$.each(copyStyle, function(i, val){
|
102
|
+
mirror.style[val] = $ta.css(val);
|
103
|
+
});
|
104
|
+
}
|
105
|
+
|
106
|
+
// Using mainly bare JS in this function because it is going
|
107
|
+
// to fire very often while typing, and needs to very efficient.
|
108
|
+
function adjust() {
|
109
|
+
var height, overflow, original;
|
110
|
+
|
111
|
+
if (mirrored !== ta) {
|
112
|
+
initMirror();
|
113
|
+
}
|
114
|
+
|
115
|
+
// the active flag keeps IE from tripping all over itself. Otherwise
|
116
|
+
// actions in the adjust function will cause IE to call adjust again.
|
117
|
+
if (!active) {
|
118
|
+
active = true;
|
119
|
+
mirror.value = ta.value + options.append;
|
120
|
+
mirror.style.overflowY = ta.style.overflowY;
|
121
|
+
original = parseInt(ta.style.height,10);
|
122
|
+
|
123
|
+
// Update the width in case the original textarea width has changed
|
124
|
+
// A floor of 0 is needed because IE8 returns a negative value for hidden textareas, raising an error.
|
125
|
+
mirror.style.width = Math.max($ta.width(), 0) + 'px';
|
126
|
+
|
127
|
+
if (supportsScrollHeight) {
|
128
|
+
height = mirror.scrollHeight;
|
129
|
+
} else { // IE6 & IE7
|
130
|
+
mirror.scrollTop = 0;
|
131
|
+
mirror.scrollTop = 9e4;
|
132
|
+
height = mirror.scrollTop;
|
133
|
+
}
|
134
|
+
|
135
|
+
var maxHeight = parseInt($ta.css('maxHeight'), 10);
|
136
|
+
// Opera returns '-1px' when max-height is set to 'none'.
|
137
|
+
maxHeight = maxHeight && maxHeight > 0 ? maxHeight : 9e4;
|
138
|
+
if (height > maxHeight) {
|
139
|
+
height = maxHeight;
|
140
|
+
overflow = 'scroll';
|
141
|
+
} else if (height < minHeight) {
|
142
|
+
height = minHeight;
|
143
|
+
}
|
144
|
+
height += boxOffset;
|
145
|
+
ta.style.overflowY = overflow || hidden;
|
146
|
+
|
147
|
+
if (original !== height) {
|
148
|
+
ta.style.height = height + 'px';
|
149
|
+
if (callback) {
|
150
|
+
options.callback.call(ta);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
// This small timeout gives IE a chance to draw it's scrollbar
|
155
|
+
// before adjust can be run again (prevents an infinite loop).
|
156
|
+
setTimeout(function () {
|
157
|
+
active = false;
|
158
|
+
}, 1);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
if (onpropertychange in ta) {
|
163
|
+
if (oninput in ta) {
|
164
|
+
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
|
165
|
+
// so binding to onkeyup to catch most of those occassions. There is no way that I
|
166
|
+
// know of to detect something like 'cut' in IE9.
|
167
|
+
ta[oninput] = ta.onkeyup = adjust;
|
168
|
+
} else {
|
169
|
+
// IE7 / IE8
|
170
|
+
ta[onpropertychange] = adjust;
|
171
|
+
}
|
172
|
+
} else {
|
173
|
+
// Modern Browsers
|
174
|
+
ta[oninput] = adjust;
|
175
|
+
}
|
176
|
+
|
177
|
+
$(window).on('resize', function(){
|
178
|
+
active = false;
|
179
|
+
adjust();
|
180
|
+
});
|
181
|
+
|
182
|
+
// Allow for manual triggering if needed.
|
183
|
+
$ta.on('autosize', function(){
|
184
|
+
active = false;
|
185
|
+
adjust();
|
186
|
+
});
|
187
|
+
|
188
|
+
// Call adjust in case the textarea already contains text.
|
189
|
+
adjust();
|
190
|
+
});
|
191
|
+
};
|
192
|
+
}(window.jQuery || window.Zepto));
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autosize-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.16.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Caleb Thompson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Rails asset pipeline wrapper around jQuery Autosize
|
56
|
+
email:
|
57
|
+
- cjaysson@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- autosize-rails.gemspec
|
68
|
+
- lib/autosize/rails.rb
|
69
|
+
- lib/autosize/rails/engine.rb
|
70
|
+
- lib/autosize/rails/version.rb
|
71
|
+
- vendor/assets/javascripts/jquery.autosize.js
|
72
|
+
homepage: http://www.jacklmoore.com/autosize/
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.0.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: A plugin to enable automatic height for textarea elements.
|
96
|
+
test_files: []
|