jquery-inputfit-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 443497deb8ddf96d52ab613215762d815e9ecc57
4
+ data.tar.gz: 03c90303006f90b2171bdbebc97458f5e57e0bc0
5
+ SHA512:
6
+ metadata.gz: e278c856d1ea48e8db17fe110e3836e59a8b838c763f20dcb27b5e502645ed7c84c70737cabc756adefcc0e928204ad28c3a7a998bb3b15df9f071400ce0a339
7
+ data.tar.gz: fd06d9bd589203654e820c34525725b380d2454079352560a07157ee023edad9915334005fb4a4fe59f549ec082dff79e7a30b53fa2dd3411e492ba92cf4d72b
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-inputfit-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 GoRefi
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,38 @@
1
+
2
+ # Jquery::Inputfit::Rails
3
+
4
+
5
+ TODO: Gemified version of [inputfit](https://github.com/vxsx/jquery.inputfit.js), which allows you to autoshrink input text in a given input field.
6
+
7
+ Plugin that makes value of the input fit into the input, see the [demo](http://vxsx.github.io/jquery.inputfit.js/)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'jquery-inputfit-rails'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Add the following to your `app/assets/javascripts/application.js`:
20
+
21
+ //= require jquery.inputfit
22
+
23
+
24
+ ## Plugin Documentation
25
+
26
+ https://github.com/vxsx/jquery.inputfit.js
27
+
28
+ ## Usage
29
+
30
+ TODO: Write usage instructions here
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/jquery-inputfit-rails/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jquery/inputfit/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jquery-inputfit-rails"
8
+ spec.version = Jquery::Inputfit::Rails::VERSION
9
+ spec.authors = ["Lenda"]
10
+ spec.email = ["elijah@lenda.com"]
11
+ spec.summary = %q{Autoshrink input text to fit into the field}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,64 @@
1
+ /*global define:true */
2
+ (function (factory) {
3
+ if (typeof define === 'function' && define.amd) {
4
+ // AMD. Register as an anonymous module.
5
+ define(['jquery'], factory);
6
+ } else {
7
+ // Browser globals
8
+ factory(jQuery);
9
+ }
10
+ }(function ($) {
11
+ $.fn.inputfit = function(options) {
12
+ var settings = $.extend({
13
+ minSize : 10,
14
+ maxSize : false
15
+ }, options);
16
+
17
+ this.each(function() {
18
+ var $input = $(this);
19
+
20
+ if ( !$input.is(':input') ) {
21
+ return;
22
+ }
23
+
24
+ $input.off('keyup.infputfit keydown.inputfit');
25
+
26
+ var maxSize = parseFloat(settings.maxSize || $input.css('font-size'), 10);
27
+ var width = $input.width();
28
+ var clone = $input.data('inputfit-clone');
29
+
30
+ if (!clone) {
31
+ clone = $('<div></div>', {
32
+ css : {
33
+ fontSize : $input.css('font-size'),
34
+ fontFamily : $input.css('font-family'),
35
+ position : 'absolute',
36
+ left : '-9999px',
37
+ visibility : 'hidden'
38
+ }
39
+ }).insertAfter($input);
40
+
41
+ $input.data('inputfit-clone', clone);
42
+ }
43
+
44
+ $input.on('keyup.inputfit keydown.inputfit', function() {
45
+ var $this = $(this);
46
+
47
+ clone.html($this.val().replace(/ /g, '&nbsp;'));
48
+
49
+ var ratio = width / (clone.width() || 1),
50
+ currentFontSize = parseInt( $this.css('font-size'), 10 ),
51
+ fontSize = Math.floor(currentFontSize * ratio);
52
+
53
+ if (fontSize > maxSize) { fontSize = maxSize; }
54
+ if (fontSize < settings.minSize) { fontSize = settings.minSize; }
55
+
56
+ $this.css('font-size', fontSize);
57
+ clone.css('font-size', fontSize);
58
+ });
59
+ });
60
+
61
+ return this;
62
+ };
63
+
64
+ }));
@@ -0,0 +1,6 @@
1
+ module Inputfit
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Jquery
2
+ module Inputfit
3
+ module Rails
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "jquery/inputfit/rails/version"
2
+
3
+ module Jquery
4
+ module Inputfit
5
+ module Rails
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,54 @@
1
+ #jquery.inputfit.js
2
+ Plugin that makes value of the input fit into the input, see the [demo](http://vxsx.github.io/jquery.inputfit.js/)
3
+ Plugin fits text by changing the font-size, so you should set min and
4
+ max font-size values. If you don't specify max font-size, plugin assumes current font-size
5
+ is maximum.
6
+
7
+
8
+ Requires
9
+
10
+ * jquery 1.6.2 or higher (why wouldn't you use latest anyway)
11
+
12
+ Default options
13
+
14
+ ``` javascript
15
+ minSize : 10
16
+ maxSize : false
17
+ ```
18
+
19
+ Using:
20
+
21
+ ``` html
22
+ <input type="text" name="younameit" id="input">
23
+ <script type="text/javascript">
24
+ $('input').inputfit();
25
+ </script>
26
+ ```
27
+
28
+ Note
29
+ -------
30
+ I just needed this functionality for our company's project, it works
31
+ alright with some potential tweaking in *all* browsers (IE6+, CHR, SAF,
32
+ FF3+, O10+ etc.). Please, file an issue if something is broken, I
33
+ promise I'll look in to it)
34
+
35
+
36
+
37
+ TODO:
38
+ -----
39
+
40
+ * fix jumps in some cases
41
+
42
+
43
+ License
44
+ -------
45
+
46
+ The MIT License
47
+
48
+ Copyright (c) 2013 Vadim Sikora
49
+
50
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,64 @@
1
+ /*global define:true */
2
+ (function (factory) {
3
+ if (typeof define === 'function' && define.amd) {
4
+ // AMD. Register as an anonymous module.
5
+ define(['jquery'], factory);
6
+ } else {
7
+ // Browser globals
8
+ factory(jQuery);
9
+ }
10
+ }(function ($) {
11
+ $.fn.inputfit = function(options) {
12
+ var settings = $.extend({
13
+ minSize : 10,
14
+ maxSize : false
15
+ }, options);
16
+
17
+ this.each(function() {
18
+ var $input = $(this);
19
+
20
+ if ( !$input.is(':input') ) {
21
+ return;
22
+ }
23
+
24
+ $input.off('keyup.infputfit keydown.inputfit');
25
+
26
+ var maxSize = parseFloat(settings.maxSize || $input.css('font-size'), 10);
27
+ var width = $input.width();
28
+ var clone = $input.data('inputfit-clone');
29
+
30
+ if (!clone) {
31
+ clone = $('<div></div>', {
32
+ css : {
33
+ fontSize : $input.css('font-size'),
34
+ fontFamily : $input.css('font-family'),
35
+ position : 'absolute',
36
+ left : '-9999px',
37
+ visibility : 'hidden'
38
+ }
39
+ }).insertAfter($input);
40
+
41
+ $input.data('inputfit-clone', clone);
42
+ }
43
+
44
+ $input.on('keyup.inputfit keydown.inputfit', function() {
45
+ var $this = $(this);
46
+
47
+ clone.html($this.val().replace(/ /g, '&nbsp;'));
48
+
49
+ var ratio = width / (clone.width() || 1),
50
+ currentFontSize = parseInt( $this.css('font-size'), 10 ),
51
+ fontSize = Math.floor(currentFontSize * ratio);
52
+
53
+ if (fontSize > maxSize) { fontSize = maxSize; }
54
+ if (fontSize < settings.minSize) { fontSize = settings.minSize; }
55
+
56
+ $this.css('font-size', fontSize);
57
+ clone.css('font-size', fontSize);
58
+ });
59
+ });
60
+
61
+ return this;
62
+ };
63
+
64
+ }));
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-inputfit-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lenda
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
42
+ email:
43
+ - elijah@lenda.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - jquery-inputfit-rails.gemspec
54
+ - jquery.inputfit.js
55
+ - lib/jquery/inputfit/rails.rb
56
+ - lib/jquery/inputfit/rails/engine.rb
57
+ - lib/jquery/inputfit/rails/version.rb
58
+ - vendor/assets/javascripts/README.markdown
59
+ - vendor/assets/javascripts/jquery.inputfit.js
60
+ homepage: ''
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:
80
+ rubygems_version: 2.0.14
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Autoshrink input text to fit into the field
84
+ test_files: []
85
+ has_rdoc: