jquery-inputfit-rails 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/jquery-inputfit-rails.gemspec +1 -1
- data/lib/jquery-inputfit-rails.rb +9 -0
- data/lib/{jquery/inputfit/rails → jquery-inputfit-rails}/engine.rb +0 -0
- data/lib/{jquery/inputfit/rails → jquery-inputfit-rails}/version.rb +1 -1
- metadata +4 -5
- data/jquery.inputfit.js +0 -64
- data/lib/jquery/inputfit/rails.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e148ae9c078f14210d61eb5f3028687083d508
|
4
|
+
data.tar.gz: ae931e937bf374b7ccd76594b7db50744498bcda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36db5512ae14fb604bb08bff8a6c2b3d5c5e24a0b759d1a5024be8a3b67082ba4f21a6dffc82800e998d3bc40d4cb227fa1e534f5766308a3a2150315fa317e8
|
7
|
+
data.tar.gz: 335f6ac413e818b93be755a58c91c3d9b26a0314aafdc1a9cbedbf42a0eaef9f9482ee0036d4cc490e23ab19984f811a43dc48eb5efe097deec1b84e7f383c95
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require "jquery-inputfit-rails/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "jquery-inputfit-rails"
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-inputfit-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lenda
|
@@ -51,10 +51,9 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- jquery-inputfit-rails.gemspec
|
54
|
-
- jquery
|
55
|
-
- lib/jquery
|
56
|
-
- lib/jquery
|
57
|
-
- lib/jquery/inputfit/rails/version.rb
|
54
|
+
- lib/jquery-inputfit-rails.rb
|
55
|
+
- lib/jquery-inputfit-rails/engine.rb
|
56
|
+
- lib/jquery-inputfit-rails/version.rb
|
58
57
|
- vendor/assets/javascripts/README.markdown
|
59
58
|
- vendor/assets/javascripts/jquery.inputfit.js
|
60
59
|
homepage: ''
|
data/jquery.inputfit.js
DELETED
@@ -1,64 +0,0 @@
|
|
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, ' '));
|
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
|
-
}));
|