maj-text-counter-rails 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzZlNTM3OGU0NzIyZDNkNzQwYzM4YjE5MjNkOTFhZmM1NGI0ZmYxMw==
5
+ data.tar.gz: !binary |-
6
+ OTVmYmQ4ZmUxNDkzZTRjYWMwODUzYzFjNTRjN2NmZDU0NDg0ZTlkYw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDNjM2FiODdiZjUyMGRkNjFjZjcwNGFhNWU0ZTQ0YWYwOWRmNWI3ZThiNGI1
10
+ ZTY1YzNkNzkwNDg0YzA1MzViNGY5ZTA1YTBiOTAzZTkyY2UyYTM3NGU5YTA1
11
+ MmI1NWFmMzk4OTk1ZDIwNTU2ZTFmZGI4ZGRkMTA3YmY1YTU0ZWM=
12
+ data.tar.gz: !binary |-
13
+ YTczMTUwZTljMTI3OGI1YTllYTNkOGFiMzRlZGU2ZmM1M2UxZmI5MmYwMjE0
14
+ YjJjMDk3YTJkNGU3YzFhOThiOWQ5ZjQ5MWQyYmY5M2RkMTgzZTUwOTAzNjgx
15
+ MDBmM2U2ZWQwMzU5NjU4NzI4N2RjMzMwY2RmOWUzODVmNzRhYWI=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in majTextCounter-rails.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ maj-text-counter-rails (0.0.9)
5
+ coffee-rails (>= 3.2)
6
+ compass-rails (>= 1.1.2)
7
+ railties (>= 3.0)
8
+ sass-rails (>= 3.2)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionmailer (4.1.0)
14
+ actionpack (= 4.1.0)
15
+ actionview (= 4.1.0)
16
+ mail (~> 2.5.4)
17
+ actionpack (4.1.0)
18
+ actionview (= 4.1.0)
19
+ activesupport (= 4.1.0)
20
+ rack (~> 1.5.2)
21
+ rack-test (~> 0.6.2)
22
+ actionview (4.1.0)
23
+ activesupport (= 4.1.0)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ activemodel (4.1.0)
27
+ activesupport (= 4.1.0)
28
+ builder (~> 3.1)
29
+ activerecord (4.1.0)
30
+ activemodel (= 4.1.0)
31
+ activesupport (= 4.1.0)
32
+ arel (~> 5.0.0)
33
+ activesupport (4.1.0)
34
+ i18n (~> 0.6, >= 0.6.9)
35
+ json (~> 1.7, >= 1.7.7)
36
+ minitest (~> 5.1)
37
+ thread_safe (~> 0.1)
38
+ tzinfo (~> 1.1)
39
+ arel (5.0.1.20140414130214)
40
+ builder (3.2.2)
41
+ chunky_png (1.3.2)
42
+ coffee-rails (4.0.1)
43
+ coffee-script (>= 2.2.0)
44
+ railties (>= 4.0.0, < 5.0)
45
+ coffee-script (2.3.0)
46
+ coffee-script-source
47
+ execjs
48
+ coffee-script-source (1.8.0)
49
+ compass (0.12.7)
50
+ chunky_png (~> 1.2)
51
+ fssm (>= 0.2.7)
52
+ sass (~> 3.2.19)
53
+ compass-rails (2.0.0)
54
+ compass (>= 0.12.2)
55
+ erubis (2.7.0)
56
+ execjs (2.2.2)
57
+ fssm (0.2.10)
58
+ hike (1.2.3)
59
+ i18n (0.6.11)
60
+ json (1.8.1)
61
+ mail (2.5.4)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.25.1)
65
+ minitest (5.4.2)
66
+ multi_json (1.10.1)
67
+ polyglot (0.3.5)
68
+ rack (1.5.2)
69
+ rack-test (0.6.2)
70
+ rack (>= 1.0)
71
+ rails (4.1.0)
72
+ actionmailer (= 4.1.0)
73
+ actionpack (= 4.1.0)
74
+ actionview (= 4.1.0)
75
+ activemodel (= 4.1.0)
76
+ activerecord (= 4.1.0)
77
+ activesupport (= 4.1.0)
78
+ bundler (>= 1.3.0, < 2.0)
79
+ railties (= 4.1.0)
80
+ sprockets-rails (~> 2.0)
81
+ railties (4.1.0)
82
+ actionpack (= 4.1.0)
83
+ activesupport (= 4.1.0)
84
+ rake (>= 0.8.7)
85
+ thor (>= 0.18.1, < 2.0)
86
+ rake (10.3.2)
87
+ sass (3.2.19)
88
+ sass-rails (4.0.3)
89
+ railties (>= 4.0.0, < 5.0)
90
+ sass (~> 3.2.0)
91
+ sprockets (~> 2.8, <= 2.11.0)
92
+ sprockets-rails (~> 2.0)
93
+ sprockets (2.11.0)
94
+ hike (~> 1.2)
95
+ multi_json (~> 1.0)
96
+ rack (~> 1.0)
97
+ tilt (~> 1.1, != 1.3.0)
98
+ sprockets-rails (2.2.0)
99
+ actionpack (>= 3.0)
100
+ activesupport (>= 3.0)
101
+ sprockets (>= 2.8, < 4.0)
102
+ thor (0.19.1)
103
+ thread_safe (0.3.4)
104
+ tilt (1.4.1)
105
+ treetop (1.4.15)
106
+ polyglot
107
+ polyglot (>= 0.3.1)
108
+ tzinfo (1.2.2)
109
+ thread_safe (~> 0.1)
110
+
111
+ PLATFORMS
112
+ ruby
113
+
114
+ DEPENDENCIES
115
+ bundler (>= 1.0)
116
+ maj-text-counter-rails!
117
+ rails (>= 3.0)
118
+ thor (>= 0.14)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Administrator
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
+ # MajTextCounter::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'majTextCounter-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install majTextCounter-rails
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/majTextCounter-rails/fork )
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,9 @@
1
+ module MajTextCounter
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer 'MajTextCounter precompile hook', :group => :all do |app|
5
+ app.config.assets.precompile += ['maj-text-counter.js']
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module MajTextCounter
2
+ module Rails
3
+ VERSION = "0.0.9"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module MajTextCounter
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
Binary file
@@ -0,0 +1,17 @@
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
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ # lib = File.expand_path('../lib', __FILE__)
3
+ # $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require File.expand_path('../lib/maj-text-counter-rails/version', __FILE__)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "maj-text-counter-rails"
8
+ spec.version = MajTextCounter::Rails::VERSION
9
+ spec.authors = ["Supernini"]
10
+ spec.email = ["denis@miseajour.net"]
11
+ spec.summary = %q{The gem integrate majTextCounter with Rails asset pipelin for easy of use}
12
+ spec.description = %q{Integrate majTextCounter with Rails asset pipelin for easy of use}
13
+ spec.homepage = "https://github.com/Miseajour/majTextCounter-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'railties', '>= 3.0'
23
+ spec.add_dependency 'coffee-rails', '>= 3.2'
24
+ spec.add_dependency 'sass-rails', '>= 3.2'
25
+ spec.add_dependency 'compass-rails', '>= 1.1.2'
26
+
27
+ spec.add_development_dependency 'bundler', '>= 1.0'
28
+ spec.add_development_dependency 'rails', '>= 3.0'
29
+ spec.add_development_dependency 'thor', '>= 0.14'
30
+ end
@@ -0,0 +1,71 @@
1
+ /*!
2
+ * jQuery Maj Text Counter Plugin v0.1
3
+ * https://github.com/supernini/majTextCounter
4
+ *
5
+ * Copyright 2014 miseajour.net
6
+ * Released under the MIT license
7
+ */
8
+
9
+ $.fn.extend
10
+ majTextCounter: (options) ->
11
+ # Default settings
12
+ settings =
13
+ wordLimit: 255
14
+ carLimit: 255
15
+ words: "words"
16
+ letters: "letters"
17
+ separator: " | "
18
+ class_counter: "maj-text-counter"
19
+ maximum: "MAX :"
20
+
21
+ settings = $.extend settings, options
22
+
23
+ wordCount = (ch) ->
24
+ return ch.replace(/[ ,;\.!\?:\n\r]/gi, ' ').trim().replace(/\s+/gi, ' ').split(" ").length
25
+
26
+ displayContent = (obj) ->
27
+ ch = $(obj).val()
28
+ max_span = "<span class=\"maximum\">" + settings.maximum + settings.wordLimit + "</span>"
29
+ message = wordCount(ch) + " " + settings.words
30
+ message += " (" + max_span + ") " if checkWordLimit(obj)
31
+ message += settings.separator
32
+
33
+ max_span = "<span class=\"maximum\">" + settings.maximum + settings.carLimit + "</span>"
34
+ message += ch .length + " " + settings.letters
35
+ message += " (" + max_span + ")" if checkCarLimit(obj)
36
+
37
+ $(obj).parent().find("." + settings.class_counter).html message
38
+ return
39
+
40
+ checkCarLimit = (obj)->
41
+ ch = $(obj).val()
42
+ return ch.length >= settings.carLimit
43
+
44
+ checkWordLimit = (obj, event)->
45
+ ch = $(obj).val()
46
+ if !event
47
+ return wordCount(ch) >= settings.wordLimit
48
+ code = event.which
49
+ return wordCount(ch) >= settings.wordLimit && [32,188, 190, 191,186].indexOf(code)!=-1
50
+
51
+ checkLimit = (obj, event) ->
52
+ return false if checkCarLimit(obj)
53
+ return false if checkWordLimit(obj, event)
54
+ return true
55
+
56
+
57
+ generateContent = (obj) ->
58
+ new_span = $("<span>", {class: settings.class_counter})
59
+ $( obj ).after( new_span );
60
+ $( obj ).keydown (event) ->
61
+ return checkLimit(this, event)
62
+ $( obj ).keyup ->
63
+ displayContent(this)
64
+ displayContent(obj)
65
+ return
66
+
67
+ return @each ()->
68
+ generateContent this
69
+
70
+ $ ->
71
+ $(".text-counter").majTextCounter { wordLimit: 3}
@@ -0,0 +1 @@
1
+ alert('bbb');
@@ -0,0 +1,15 @@
1
+ .form-inputs {
2
+ .maj-text-counter {
3
+ display: block;
4
+ text-align: right;
5
+ float: right;
6
+ margin-top: 4px;
7
+ margin-bottom: 4px;
8
+ color: white;
9
+ padding: 0 5px;
10
+ background-color: grey;
11
+ }
12
+ .maximum {
13
+ color: #990000;
14
+ }
15
+ }
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maj-text-counter-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Supernini
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: compass-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0.14'
111
+ description: Integrate majTextCounter with Rails asset pipelin for easy of use
112
+ email:
113
+ - denis@miseajour.net
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - Gemfile
119
+ - Gemfile.lock
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/maj-text-counter-rails/engine.rb
124
+ - lib/maj-text-counter-rails/version.rb
125
+ - lib/maj-text-counter.rb
126
+ - maj-text-counter-rails-0.0.2.gem
127
+ - majTextCounter-rails.gemspec
128
+ - majTextCounter-rails/.gitignore
129
+ - vendor/assets/javascripts/maj-text-counter.coffee
130
+ - vendor/assets/javascripts/test.js
131
+ - vendor/assets/stylesheets/maj-text-counter.css.scss
132
+ homepage: https://github.com/Miseajour/majTextCounter-rails
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.2.2
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: The gem integrate majTextCounter with Rails asset pipelin for easy of use
156
+ test_files: []