maxchars 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -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);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# needs jquery + tipsy
|
2
|
+
$.fn.extend
|
3
|
+
maxChars: (setMaxLen) ->
|
4
|
+
this.each ->
|
5
|
+
$(this).tipsy({gravity: 'w', trigger: 'focus', html: true})
|
6
|
+
.each ->
|
7
|
+
el = $(this)
|
8
|
+
maxLen = setMaxLen ? el.data('maxlen')
|
9
|
+
template = el.data('maxlen-text') || 'remaining chars: %x'
|
10
|
+
hardLimit =!el.data('maxlen-soft')
|
11
|
+
el.data 'doUpdateTitle', ->
|
12
|
+
len = el.val().length
|
13
|
+
if hardLimit && (len > maxLen)
|
14
|
+
el.val(el.val().substr(0, maxLen))
|
15
|
+
len = maxLen
|
16
|
+
remaining = maxLen - len
|
17
|
+
remainingText = template.replace(/%x/, remaining)
|
18
|
+
el.attr('title', remainingText).tipsy('hide').tipsy('show')
|
19
|
+
len
|
20
|
+
.live 'keyup', ->
|
21
|
+
$(this).data('doUpdateTitle')()
|
data/lib/maxchars/version.rb
CHANGED
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.3
|
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: &70217719998200 !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: *70217719998200
|
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:
|
@@ -33,6 +33,8 @@ files:
|
|
33
33
|
- .gitignore
|
34
34
|
- Gemfile
|
35
35
|
- Rakefile
|
36
|
+
- lib/assets/javascripts/maxChars.js
|
37
|
+
- lib/assets/javascripts/maxChars.js.coffee
|
36
38
|
- lib/maxchars.rb
|
37
39
|
- lib/maxchars/version.rb
|
38
40
|
- maxchars.gemspec
|