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.1.6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.rc1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.b6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.b5 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.pre.b4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.b3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.b2 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-6.0.0.b1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.0.6 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.1 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-4.6.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.0.4 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.1.3 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-5.2.0 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee
alchemy_cms-3.6.7 app/assets/javascripts/alchemy/alchemy.char_counter.js.coffee