<commit_before>class LoginView extends KDScrollView

  stop = (event)->
    event.preventDefault()
    event.stopPropagation()

  constructor:(options = {}, data)->

    {entryPoint} = KD.config
    options.cssClass = 'hidden'

    super options, data

    @hidden = yes

    @bindTransitionEnd()

    handler =(route, event)=>
      stop event
      KD.getSingleton('router').handleRoute route, {entryPoint}

    homeHandler       = handler.bind null, '/'
    loginHandler      = handler.bind null, '/Login'
    registerHandler   = handler.bind null, '/Register'
    recoverHandler    = handler.bind null, '/Recover'

    @logo = new KDCustomHTMLView
      tagName     : "div"
      cssClass    : "logo"
      partial     : "Koding"
      click       : homeHandler

    @backToLoginLink = new KDCustomHTMLView
      tagName   : "a"
      partial   : "Go ahead and login"
      click     : loginHandler

    @goToRecoverLink = new KDCustomHTMLView
      tagName     : "a"
      partial     : "Recover password"
      testPath    : "landing-recover-password"
      click       : recoverHandler

    @goToRegisterLink = new KDCustomHTMLView
      tagName     : "a"
      partial     : "Register an account"
      click       : registerHandler

    @loginOptions = new LoginOptions
      cssClass : "login-options-holder log"

    @registerOptions = new RegisterOptions
      cssClass : "login-options-holder reg"

    @loginForm = new LoginInlineForm
      cssClass : "login-form"
      testPath : "login-form"
      callback : (formData)=>
        formData.clientId = $.cookie('clientId')
        @doLogin formData
        KD.track "Login", "SignInButtonClicked"

    @registerForm = new RegisterInlineForm
      cssClass : "login-form"
      testPath : "register-form"
      callback : (formData)=>
        @doRegister formData
        KD.track "Login", "RegisterButtonClicked"

    @redeemForm = new RedeemInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        @doRedeem formData
        KD.track "Login", "RedeemButtonClicked"

    @recoverForm = new RecoverInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        @doRecover formData
        KD.track "Login", "RecoverButtonClicked"

    @resetForm = new ResetInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        formData.clientId = $.cookie('clientId')
        @doReset formData
        KD.track "Login", "ResetButtonClicked"

    @headBanner = new KDCustomHTMLView
      domId    : "invite-recovery-notification-bar"
      cssClass : "invite-recovery-notification-bar hidden"
      partial  : "..."

    KD.getSingleton("mainController").on "landingSidebarClicked", => @unsetClass 'landed'

    setValue = (field, value)=>
      @registerForm[field].input?.setValue value

    mainController = KD.getSingleton "mainController"
    mainController.on "ForeignAuthCompleted", (provider)=>
      isUserLoggedIn = KD.isLoggedIn()
      params = {isUserLoggedIn, provider}

      KD.remote.api.JUser.authenticateWithOauth params, (err, resp)=>
        if err
          showError err
        else
          {account, replacementToken, isNewUser, userInfo} = resp
          if isNewUser
            @animateToForm "register"
            for own field, value of userInfo
              setValue field, value
          else
            if isUserLoggedIn
              mainController.emit "ForeignAuthSuccess.#{provider}"
              new KDNotificationView
                title : "Thanks for linking your #{provider.capitalize()} account!"
            else
              @afterLoginCallback err, {account, replacementToken}

  viewAppended:->

    @setY -KD.getSingleton('windowController').winHeight
    @listenWindowResize()
    @setClass "login-screen login"

    @setTemplate @pistachio()
    @template.update()

  _windowDidResize:->
    if @hidden
      @setY -KD.getSingleton('windowController').winHeight

  pistachio:->
    """
    <div class="flex-wrapper">
      <div class="login-box-header">
        <a class="betatag">beta</a>
        {{> @logo}}
      </div>
      {{> @loginOptions}}
      {{> @registerOptions}}
      <div class="login-form-holder lf">
        {{> @loginForm}}
      </div>
      <div class="login-form-holder rf">
        {{> @registerForm}}<commit_msg>ForeignAuth: changed the auth success notification style<commit_after>class LoginView extends KDScrollView

  stop = (event)->
    event.preventDefault()
    event.stopPropagation()

  constructor:(options = {}, data)->

    {entryPoint} = KD.config
    options.cssClass = 'hidden'

    super options, data

    @hidden = yes

    @bindTransitionEnd()

    handler =(route, event)=>
      stop event
      KD.getSingleton('router').handleRoute route, {entryPoint}

    homeHandler       = handler.bind null, '/'
    loginHandler      = handler.bind null, '/Login'
    registerHandler   = handler.bind null, '/Register'
    recoverHandler    = handler.bind null, '/Recover'

    @logo = new KDCustomHTMLView
      tagName     : "div"
      cssClass    : "logo"
      partial     : "Koding"
      click       : homeHandler

    @backToLoginLink = new KDCustomHTMLView
      tagName   : "a"
      partial   : "Go ahead and login"
      click     : loginHandler

    @goToRecoverLink = new KDCustomHTMLView
      tagName     : "a"
      partial     : "Recover password"
      testPath    : "landing-recover-password"
      click       : recoverHandler

    @goToRegisterLink = new KDCustomHTMLView
      tagName     : "a"
      partial     : "Register an account"
      click       : registerHandler

    @loginOptions = new LoginOptions
      cssClass : "login-options-holder log"

    @registerOptions = new RegisterOptions
      cssClass : "login-options-holder reg"

    @loginForm = new LoginInlineForm
      cssClass : "login-form"
      testPath : "login-form"
      callback : (formData)=>
        formData.clientId = $.cookie('clientId')
        @doLogin formData
        KD.track "Login", "SignInButtonClicked"

    @registerForm = new RegisterInlineForm
      cssClass : "login-form"
      testPath : "register-form"
      callback : (formData)=>
        @doRegister formData
        KD.track "Login", "RegisterButtonClicked"

    @redeemForm = new RedeemInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        @doRedeem formData
        KD.track "Login", "RedeemButtonClicked"

    @recoverForm = new RecoverInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        @doRecover formData
        KD.track "Login", "RecoverButtonClicked"

    @resetForm = new ResetInlineForm
      cssClass : "login-form"
      callback : (formData)=>
        formData.clientId = $.cookie('clientId')
        @doReset formData
        KD.track "Login", "ResetButtonClicked"

    @headBanner = new KDCustomHTMLView
      domId    : "invite-recovery-notification-bar"
      cssClass : "invite-recovery-notification-bar hidden"
      partial  : "..."

    KD.getSingleton("mainController").on "landingSidebarClicked", => @unsetClass 'landed'

    setValue = (field, value)=>
      @registerForm[field].input?.setValue value

    mainController = KD.getSingleton "mainController"
    mainController.on "ForeignAuthCompleted", (provider)=>
      isUserLoggedIn = KD.isLoggedIn()
      params = {isUserLoggedIn, provider}

      KD.remote.api.JUser.authenticateWithOauth params, (err, resp)=>
        if err
          showError err
        else
          {account, replacementToken, isNewUser, userInfo} = resp
          if isNewUser
            @animateToForm "register"
            for own field, value of userInfo
              setValue field, value
          else
            if isUserLoggedIn
              mainController.emit "ForeignAuthSuccess.#{provider}"
              new KDNotificationView
                title : "Your #{provider.capitalize()} account has been linked."
                type  : "mini"

            else
              @afterLoginCallback err, {account, replacementToken}

  viewAppended:->

    @setY -KD.getSingleton('windowController').winHeight
    @listenWindowResize()
    @setClass "login-screen login"

    @setTemplate @pistachio()
    @template.update()

  _windowDidResize:->
    if @hidden
      @setY -KD.getSingleton('windowController').winHeight

  pistachio:->
    """
    <div class="flex-wrapper">
      <div class="login-box-header">
        <a class="betatag">beta</a>
        {{> @logo}}
      </div>
      {{> @loginOptions}}
      {{> @registerOptions}}
      <div class="login-form-holder lf">
        {{> @loginForm}}
      </div>
      <div class="login-form-holder rf">
        {{> @registerForm}}
{'fraction_non_alphanumeric': 0.10916628281897743, 'fraction_numerical': 0.0, 'mean_word_length': 2.3992172211350296, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399976', 'n_tokens_mistral': 2589, 'n_tokens_neox': 2512, 'n_words': 565}