gitlab-org--gitlab-foss/app/assets/javascripts/subscription.js.coffee

18 lines
677 B
CoffeeScript
Raw Normal View History

2015-03-15 16:17:12 +00:00
class @Subscription
constructor: (url) ->
2015-03-17 13:04:25 +00:00
$(".subscribe-button").unbind("click").click (event)=>
2015-03-15 16:17:12 +00:00
btn = $(event.currentTarget)
2015-03-17 13:04:25 +00:00
action = btn.find("span").text()
current_status = $(".subscription-status").attr("data-status")
btn.prop("disabled", true)
2015-03-15 16:17:12 +00:00
2015-03-16 15:20:17 +00:00
$.post url, =>
2015-03-17 13:04:25 +00:00
btn.prop("disabled", false)
2015-03-15 16:17:12 +00:00
status = if current_status == "subscribed" then "unsubscribed" else "subscribed"
2015-03-17 13:04:25 +00:00
$(".subscription-status").attr("data-status", status)
2015-03-15 16:17:12 +00:00
action = if status == "subscribed" then "Unsubscribe" else "Subscribe"
2015-03-17 13:04:25 +00:00
btn.find("span").text(action)
$(".subscription-status>div").toggleClass("hidden")
2015-03-15 16:17:12 +00:00