Sha256: ce5b94e7e3c8a58f948337ad8d1d61d174308a72fabb3cd27b8b1b0afd0f38bc

Contents?: true

Size: 574 Bytes

Versions: 26

Compression:

Stored size: 574 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

26 entries across 26 versions & 2 rubygems

Version Path
alchemy_cms-3.0.2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.0.rc8 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.0.rc7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.0.rc6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee