{I" class:EFI"ProcessedAsset; FI"logical_path; FI"outpost/field_counter.js; TI" pathname; FI"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/field_counter.js.coffee; TI"content_type; FI"application/javascript; FI" mtime; Fl+d}RI"length; FiQI"digest; F"%1dde4163ba65419725e1cba366086137I"source; FI"Q(function() { $(function() { var el, field, fuzziness, target, _i, _len, _ref, _results; _ref = $("form .field-counter"); _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { field = _ref[_i]; el = $(field); target = el.attr("data-target"); fuzziness = el.attr("data-fuzziness"); _results.push(new outpost.FieldCounter(el, { target: target, fuzziness: fuzziness })); } return _results; }); outpost.FieldCounter = (function() { FieldCounter.prototype.DefaultOptions = { target: 145, fuzziness: 20, inRangeClass: "alert alert-success", outOfRangeClass: "alert alert-warning", counterClass: "counter-notify", counterWrapper: ".controls", counterStyle: "padding: 3px; margin: 0 0 2px 0;" }; function FieldCounter(el, options) { var _this = this; this.el = el; if (options == null) { options = {}; } this.options = _.defaults(options, this.DefaultOptions); this.field = $("input, textarea", this.el); this.counterEl = $("
", { "class": this.options.counterClass, style: this.options.counterStyle }); $(this.options.counterWrapper, this.el).prepend(this.counterEl); this.count = 0; this.target = parseInt(this.options.target); this.fuzziness = parseInt(this.options.fuzziness); this.rangeLow = this.target - this.fuzziness; this.rangeHigh = this.target + this.fuzziness; this.inRangeClass = this.options.inRangeClass; this.outOfRangeClass = this.options.outOfRangeClass; this.field.on({ keyup: function(event) { return _this.updateCount($(event.target).val().length); } }); this.el.on({ updateCounter: function(event, count) { _this.updateText(count); return _this.updateColor(count); } }); this.updateCount(this.field.val().length); } FieldCounter.prototype.inRange = function() { return this.rangeLow <= this.count && this.count <= this.rangeHigh; }; FieldCounter.prototype.updateCount = function(length) { this.count = length; return this.el.trigger("updateCounter", this.count); }; FieldCounter.prototype.updateText = function(count) { return this.counterEl.html("Optimal Length: " + count + " of " + this.target + " (+/- " + this.fuzziness + ")"); }; FieldCounter.prototype.updateColor = function(count) { if (this.inRange()) { this.counterEl.removeClass(this.outOfRangeClass); return this.counterEl.addClass(this.inRangeClass); } else { this.counterEl.removeClass(this.inRangeClass); return this.counterEl.addClass(this.outOfRangeClass); } }; return FieldCounter; })(); }).call(this); ; TI"dependency_digest; F"%397a5d520fb72bb434a9946e34167ec0I"required_paths; F[I"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/field_counter.js.coffee; TI"dependency_paths; F[{I" path; FI"`/Users/bricker/websites/kpcc/outpost/app/assets/javascripts/outpost/field_counter.js.coffee; TI" mtime; FI"2013-11-08T18:26:44-08:00; FI"digest; F"%ec9c654b28dac13dd74596a180aea687I" _version; F"%ac1cd7cf9811f9938e2b8937c60a24e6