MajTextCounter for rails asset pipeline
MajTextCounter is a library for counting and limiting characters/words on text input, or textarea, elements (using .val()).
The maj-text-counter-rails
gem integrates the MajTextCounter
with the Rails asset pipeline.
Installation
Include maj-text-counter-rails
in Gemefile
gem 'maj-text-counter-rails'
Then run bundle install
Usage
Add to your app/assets/javascripts/application.js
if use with jQuery
//= require maj-text-counter
Add to your app/assets/stylesheets/application.css
*= require maj-text-counter
Basic usage:
$('input').majTextCounter();
Limit to a maximum words count:
$('input').majTextCounter({
wordLimit: 10,
});
Limit to a maximum caracters count:
$('input').majTextCounter({
carLimit: 10,
});
Speak french ?:
$('input').majTextCounter({
words: "mots",
letters: "lettres",
separator: " & ",
maximum: "MAX :",
});
Contributing
- Fork it ( http://github.com//majTextCounter-rails/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request