Xmpp.Views.Popup ||= {}

class Xmpp.Views.Popup.NewAccountView extends Xmpp.Views.Popup.PopupView
  template: JST["backbone/templates/popup/add_account"]

  events:
    'submit form': 'addAccount'

  render: ->
    super(@template())
    $(@el).css(width: '20%')

  addAccount: (e) ->
    e.preventDefault()
    jid = $(@el).find('input[name=jid]').val()
    pass = $(@el).find('input[name=password]').val()
    $.ajax(
      url: '/sessions'
      type: 'POST'
      data:
        jid: jid,
        password: pass,
        override: 1
      success: (msg) ->
        App.debug msg
    )