Sha256: 2019c023113254d43362cf763a4143ec72b988e2e61fd51afeadb671ee289f7c

Contents?: true

Size: 1.03 KB

Versions: 13

Compression:

Stored size: 1.03 KB

Contents

# Settings
$ ->
  show_update_btn = (el) ->
    $(el).closest('tr').find('.update_link').show()

  hide_update_btn = (el) ->
    $(el).closest('tr').find('.update_link').hide()

  $('#settings .form form input, textarea').change ->
    show_update_btn(this)

  $('#settings .form form input, textarea').keypress ->
    show_update_btn(this)

  $('#settings .form form').submit ->
    false

  show_saved_state = (el) ->
    saved_label = el.closest('tr').find('.saved-state')
    el.hide()
    saved_label.show()
    hide_label = (label, btn) -> label.fadeOut => btn.show()

    setTimeout ( -> hide_label(saved_label, el) ), 1000

  $('#settings .update_link').click (e) ->
    e.preventDefault()
    btn = $(this)
    tr  = $(btn.attr("data-id"))

    form = tr.find(".form form")
    form.ajaxSubmit
      success: (value) =>
        if form.parent().hasClass("file")
          form.find(".inline-hints").html(value)
          form.clearForm()
        if form.parent().hasClass("html")
          show_saved_state(btn)
        else
          btn.hide()

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
activeadmin-settings-0.4.4 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.4.3 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.4.2 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.4.1 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.4.0 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.5 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.4 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.3 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.2 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.1 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.3.0 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.2.9 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee
activeadmin-settings-0.2.8 vendor/assets/javascripts/activeadmin_settings/settings.js.coffee