Sha256: b299b2244f4181be80f7c8b5a9c44f8b7a4d0a3626bf98567802b989addb3941

Contents?: true

Size: 899 Bytes

Versions: 26

Compression:

Stored size: 899 Bytes

Contents

window.Alchemy = {} if typeof(window.Alchemy) is 'undefined'

Alchemy.Buttons =

  observe: (scope) ->
    $('form', scope).not('.button_with_label form').on 'submit', (event) ->
      $btn = $(this).find(':submit')
      if $btn.attr('disabled') == 'disabled'
        event.preventDefault()
        event.stopPropagation()
        false
      else
        Alchemy.Buttons.disable($btn)

  disable: (button) ->
    $button = $(button)
    spinner = Alchemy.Spinner.small()
    $button.data('content', $button.html())
    $button.attr('disabled', true)
    $button.addClass('disabled')
    $button.css
      width: $button.outerWidth()
    $button.empty()
    spinner.spin($button[0])
    return true

  enable: (scope) ->
    $button = $('form :submit:disabled', scope)
    $button.removeClass('disabled')
    $button.removeAttr('disabled')
    $button.html($button.data('content'))
    return true

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.3 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
lc_alchemy_cms-3.2.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
lc_alchemy_cms-3.2.0 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.2.0 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.2.0.rc1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.2.0.beta app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.0.4 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.rc3 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.rc2 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.rc1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta6 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta5 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta4 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.0.3 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta3 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta2 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-3.1.0.beta1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee