Sha256: 1e5e14d3ddc7af548f96e89484d2adae177630b555f729502aaf82bd5a54af74

Contents?: true

Size: 928 Bytes

Versions: 6

Compression:

Stored size: 928 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 = '<img src="/assets/alchemy/ajax_loader.gif" style="width: 16px; height: 16px">'
    $button.data('label', $button.text())
    $button.attr('disabled', true)
    $button.addClass('disabled')
    $button.css
      width: $button.outerWidth()
    $button.html(spinner)
    return true

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alchemy_cms-2.5.3.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-2.5.3 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-2.5.2.2 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-2.5.2.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-2.5.2 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee
alchemy_cms-2.5.1 app/assets/javascripts/alchemy/alchemy.buttons.js.coffee