Sha256: 289778f7dc6019fd82844746eca4a9058e0a381dd12f152a59ccd29b382b90b9
Contents?: true
Size: 1.35 KB
Versions: 43
Compression:
Stored size: 1.35 KB
Contents
I"W(function() { var CharacterCounter, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; CharacterCounter = (function() { function CharacterCounter(el) { this.el = el; this.inject_counter = bind(this.inject_counter, this); this.adjust_count = bind(this.adjust_count, this); this.bind_events = bind(this.bind_events, this); this.inject_counter(); this.bind_events(); this.adjust_count(); } CharacterCounter.prototype.bind_events = function() { return this.el.keyup(this.adjust_count); }; CharacterCounter.prototype.adjust_count = function() { var count, title; count = this.el.val().length; title = count === 1 ? 'character' : 'characters'; return this.counter_el.html(count + " " + title); }; CharacterCounter.prototype.inject_counter = function() { var group; group = this.el.parents(".form-group"); this.counter_wrap = $("<div class='character-count-wrap'> <span class='count'></span> </div>"); group.prepend(this.counter_wrap); return this.counter_el = this.counter_wrap.find('.count'); }; return CharacterCounter; })(); $(function() { return $("[data-toggle='character-counter']").each(function() { return new CharacterCounter($(this)); }); }); }).call(this); :ET
Version data entries
43 entries across 36 versions & 1 rubygems