Sha256: f1822cf22900b986e26debcc7f44cb0ce6e2ee819123378e66a2dca8470140a0

Contents?: true

Size: 840 Bytes

Versions: 2

Compression:

Stored size: 840 Bytes

Contents

$ ()->
  controller = $("body").data("controller")
  action = $("body").data("action")

  controllerObj = Storytime.Utilities.controllerFromString(controller)
  
  if controllerObj?
    instance = new controllerObj()
    instance["init"]() if typeof(instance["init"]) == "function"
    instance["init#{action}"]() if typeof(instance["init#{action}"]) == "function"
    Storytime.instance = instance

  $(".flash").delay(2000).fadeOut()

  $(document).on('ajax:beforeSend', '.btn-delete-resource', ()->
    $(@).attr("disabled", true)
  ).on('ajax:success', '.btn-delete-resource', ()->
    $("##{$(@).data('resource-type')}_#{$(@).data('resource-id')}").remove()
  ).on('ajax:error', '.btn-delete-resource', (e, data, d1, d2)->
    $(@).attr("disabled", false)
    alert("There was an error deleting your #{$(@).data('resource-type')}")
  )

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storytime-0.0.2 app/assets/javascripts/storytime/base.js.coffee
storytime-0.0.1 app/assets/javascripts/storytime/base.js.coffee