Sha256: 833e445a70e55d4b90f1de8aa55552bee1ee2d8bb0c81e82bb604c2846c9a786

Contents?: true

Size: 573 Bytes

Versions: 168

Compression:

Stored size: 573 Bytes

Contents

class window.Alchemy.CharCounter

  constructor: (field) ->
    @$field = $(field)
    @max_chars = @$field.data('alchemy-char-counter')
    @text = Alchemy.t('allowed_chars', @max_chars)
    @$display = $('<small class="alchemy-char-counter"/>')
    @$field.after(@$display)
    countChars.call(this)
    @$field.keyup =>
      countChars.call(this)
      true

  countChars = ->
    char_length = @$field.val().length
    @$display.removeClass('too-long')
    @$display.text("#{char_length} #{@text}")
    if char_length > @max_chars
      @$display.addClass('too-long')

Version data entries

168 entries across 168 versions & 1 rubygems

Version Path
alchemy_cms-7.0.15 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.1.10 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.14 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.13 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.12 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.11 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.10 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.9 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.8 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.1.9 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.1.8 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.1.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-7.0.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee