mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-01 11:27:14 -05:00
36 lines
1 KiB
CoffeeScript
36 lines
1 KiB
CoffeeScript
|
RootView = require 'views/kinds/RootView'
|
||
|
template = require 'templates/account/unsubscribe'
|
||
|
{me} = require 'lib/auth'
|
||
|
|
||
|
module.exports = class UnsubscribeView extends RootView
|
||
|
id: "unsubscribe-view"
|
||
|
template: template
|
||
|
|
||
|
events:
|
||
|
'click #unsubscribe-button': 'onUnsubscribeButtonClicked'
|
||
|
|
||
|
getRenderData: ->
|
||
|
context = super()
|
||
|
context.email = @getQueryVariable 'email'
|
||
|
context
|
||
|
|
||
|
onUnsubscribeButtonClicked: ->
|
||
|
@$el.find('#unsubscribe-button').addClass 'hide'
|
||
|
@$el.find('.progress').removeClass 'hide'
|
||
|
@$el.find('.alert').addClass 'hide'
|
||
|
|
||
|
email = @getQueryVariable 'email'
|
||
|
url = "/auth/unsubscribe?email=#{encodeURIComponent(email)}"
|
||
|
|
||
|
success = =>
|
||
|
@$el.find('.progress').addClass 'hide'
|
||
|
@$el.find('#success-alert').removeClass 'hide'
|
||
|
me.fetch()
|
||
|
|
||
|
error = =>
|
||
|
@$el.find('.progress').addClass 'hide'
|
||
|
@$el.find('#fail-alert').removeClass 'hide'
|
||
|
@$el.find('#unsubscribe-button').removeClass 'hide'
|
||
|
|
||
|
$.ajax { url: url, success: success, error: error }
|