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.2.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
lc_alchemy_cms-3.2.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
lc_alchemy_cms-3.2.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.2.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.2.0.rc1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.2.0.beta app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.rc3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.rc2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.rc1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.0.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.1.0.beta1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee