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-5.0.10 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.rc5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.6.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.rc4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.rc3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.9 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.9 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.6.6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.8 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.8 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.6.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.5.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.4.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.6.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.rc2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee