maxchars 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/maxchars/version.rb +1 -1
- data/vendor/assets/javascripts/maxChars.js +35 -0
- metadata +4 -3
data/lib/maxchars/version.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
$.fn.extend({
|
4
|
+
maxChars: function(setMaxLen) {
|
5
|
+
return this.each(function() {
|
6
|
+
return $(this).tipsy({
|
7
|
+
gravity: 'w',
|
8
|
+
trigger: 'focus',
|
9
|
+
html: true
|
10
|
+
}).each(function() {
|
11
|
+
var el, hardLimit, maxLen, template;
|
12
|
+
el = $(this);
|
13
|
+
maxLen = setMaxLen != null ? setMaxLen : el.data('maxlen');
|
14
|
+
template = el.data('maxlen-text') || 'remaining chars: %x';
|
15
|
+
hardLimit = !el.data('maxlen-soft');
|
16
|
+
return el.data('doUpdateTitle', function() {
|
17
|
+
var len, remaining, remainingText;
|
18
|
+
len = el.val().length;
|
19
|
+
if (hardLimit && (len > maxLen)) {
|
20
|
+
el.val(el.val().substr(0, maxLen));
|
21
|
+
len = maxLen;
|
22
|
+
}
|
23
|
+
remaining = maxLen - len;
|
24
|
+
remainingText = template.replace(/%x/, remaining);
|
25
|
+
el.attr('title', remainingText).tipsy('hide').tipsy('show');
|
26
|
+
return len;
|
27
|
+
});
|
28
|
+
}).live('keyup', function() {
|
29
|
+
return $(this).data('doUpdateTitle')();
|
30
|
+
});
|
31
|
+
});
|
32
|
+
}
|
33
|
+
});
|
34
|
+
|
35
|
+
}).call(this);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maxchars
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-04 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70305490521580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70305490521580
|
25
25
|
description: jquery plugin to restrict characters that can be put into an input field
|
26
26
|
or text area. Displays remaining characters in a tipsy tooltip.
|
27
27
|
email:
|
@@ -36,6 +36,7 @@ files:
|
|
36
36
|
- lib/maxchars.rb
|
37
37
|
- lib/maxchars/version.rb
|
38
38
|
- maxchars.gemspec
|
39
|
+
- vendor/assets/javascripts/maxChars.js
|
39
40
|
- vendor/assets/javascripts/maxChars.js.coffee
|
40
41
|
homepage: ''
|
41
42
|
licenses: []
|