Sha256: 68ff3055dd9275a881c1f8406e8392cc7497d5af54cf9ad3e115e8a5bf11a4e0
Contents?: true
Size: 864 Bytes
Versions: 8
Compression:
Stored size: 864 Bytes
Contents
class Storytime.Dashboard.CharacterCounter init: ()-> self = @ $(".character-limit").each () -> display = $(this).find(".character-limit-display") limit = display.data("limit") input = $(this).find(".character-limit-input") contenteditable = $(this).find(".character-limit-contenteditable") self.setText(display, limit, input) if contenteditable.length > 0 self.bind(contenteditable, input, display, limit) else self.bind(input, input, display, limit) setText: (display, limit, input) -> display.html limit - input.val().length bind: (field, input, display, limit) -> field.keypress((e) -> e.preventDefault() if (e.which is 32 or e.which > 0x20) and (input.val().length > limit - 1) return ).keyup(-> display.html limit - input.val().length return )
Version data entries
8 entries across 8 versions & 1 rubygems