<commit_before>class AccountEditUsername extends KDView
  viewAppended:->
    # =================
    # ADDING EMAIL FORM
    # =================
    bongo.api.JUser.fetchUser (err,user)=>
      @putContents KD.whoami(), user

  putContents:(account, user)->
    @addSubView @emailForm = emailForm = new KDFormView
      callback     : (formData)->
        new KDNotificationView
          type  : "mini"
          title : "Currently disabled!"
    emailForm.addSubView emailLabel = new KDLabelView
      title        : "Your email"
      cssClass     : "main-label"

    emailInputs = new KDView cssClass : "hiddenval clearfix"
    emailInputs.addSubView emailInput = new KDInputView
      label        : emailLabel
      defaultValue : user.email
      placeholder  : "<EMAIL>..."
      name         : "email"
    emailInputs.addSubView inputActions = new KDView cssClass : "actions-wrapper"
    inputActions.addSubView emailSave = new KDButtonView
      title        : "Save"
      type         : 'submit'
    inputActions.addSubView emailCancel = new KDCustomHTMLView
      tagName      : "a"
      partial      : "cancel"
      cssClass     : "cancel-link"

    # EMAIL STATIC PART
    nonEmailInputs = new KDView cssClass : "initialval clearfix"

    nonEmailInputs.addSubView emailSpan = new KDCustomHTMLView
      tagName      : "span"
      partial      : user.email
      cssClass     : "static-text status-#{user.status}"
    nonEmailInputs.addSubView emailEdit = new KDCustomHTMLView
      tagName      : "a"
      partial      : "Edit"
      cssClass     : "action-link"

    # SET EMAIL SWAPPABLE
    emailForm.addSubView emailSwappable = new AccountsSwappable
      views    : [emailInputs,nonEmailInputs]
      cssClass : "clearfix"
    
    @listenTo KDEventTypes : "click", listenedToInstance : emailCancel, callback : emailSwappable.swapViews
    @listenTo KDEventTypes : "click", listenedToInstance : emailEdit,   callback : emailSwappable.swapViews

    # =================
    # ADDING USERNAME FORM
    # =================
    @addSubView usernameForm = usernameForm = new KDFormView
      callback     : (formData)->
        new KDNotificationView
          type  : "mini"
          title : "Currently disabled!"
    usernameForm.addSubView usernameLabel = new KDLabelView
      title        : "Your username"
      cssClass     : "main-label"

    usernameInputs = new KDView cssClass : "hiddenval clearfix"
    usernameInputs.addSubView usernameInput = new KDInputView
      label        : usernameLabel
      defaultValue : account.profile.nickname
      placeholder  : "username..."
      name         : "username"
    usernameInputs.addSubView inputActions = new KDView cssClass : "actions-wrapper"
    inputActions.addSubView usernameSave = new KDButtonView
      title        : "Save"
      type         : "submit"
    inputActions.addSubView usernameCancel = new KDCustomHTMLView
      tagName      : "a"
      partial      : "cancel"
      cssClass     : "cancel-link"

    # USERNAME STATIC PART
    usernameNonInputs = usernameNonInputs = new KDView cssClass : "initialval clearfix"
    usernameNonInputs.addSubView usernameSpan = new KDCustomHTMLView
      tagName      : "span"
      partial      : account.profile.nickname
      cssClass     : "static-text"
    usernameNonInputs.addSubView usernameEdit = new KDCustomHTMLView
      tagName      : "a"
      partial      : "Edit"
      cssClass     : "action-link"

    # SET USERNAME SWAPPABLE
    usernameForm.addSubView usernameSwappable = new AccountsSwappable
      views    : [usernameInputs,usernameNonInputs]
      cssClass : "clearfix"
    
    @listenTo KDEventTypes : "click", listenedToInstance : usernameCancel, callback : usernameSwappable.swapViews
    @listenTo KDEventTypes : "click", listenedToInstance : usernameEdit,   callback : usernameSwappable.swapViews
    
    @addSubView @emailOptOutView = new KDFormView
    @emailOptOutView.addSubView new KDLabelView
      title        : "Email notifications"
      cssClass     : "main-label"
    
    emailFrequency = user.getAt('emailFrequency.global')

    @emailOptOutView.addSubView new KDOnOffSwitch
      cssClass      : 'dark'
      defaultValue  : if emailFrequency is 'never' then off else on
      callback      : (state)-> 
        account.setEmailPreferences global: state, ->
          new KDNotificationView
            duration : 2000
            title    : if state then 'You will get email notifications.' \
                                else 'You will no longer get email notifications.'<commit_msg>Remove trailing whitespaces<commit_after>class AccountEditUsername extends KDView
  viewAppended:->
    # =================
    # ADDING EMAIL FORM
    # =================
    bongo.api.JUser.fetchUser (err,user)=>
      @putContents KD.whoami(), user

  putContents:(account, user)->
    @addSubView @emailForm = emailForm = new KDFormView
      callback     : (formData)->
        new KDNotificationView
          type  : "mini"
          title : "Currently disabled!"
    emailForm.addSubView emailLabel = new KDLabelView
      title        : "Your email"
      cssClass     : "main-label"

    emailInputs = new KDView cssClass : "hiddenval clearfix"
    emailInputs.addSubView emailInput = new KDInputView
      label        : emailLabel
      defaultValue : user.email
      placeholder  : "<EMAIL>..."
      name         : "email"
    emailInputs.addSubView inputActions = new KDView cssClass : "actions-wrapper"
    inputActions.addSubView emailSave = new KDButtonView
      title        : "Save"
      type         : 'submit'
    inputActions.addSubView emailCancel = new KDCustomHTMLView
      tagName      : "a"
      partial      : "cancel"
      cssClass     : "cancel-link"

    # EMAIL STATIC PART
    nonEmailInputs = new KDView cssClass : "initialval clearfix"

    nonEmailInputs.addSubView emailSpan = new KDCustomHTMLView
      tagName      : "span"
      partial      : user.email
      cssClass     : "static-text status-#{user.status}"
    nonEmailInputs.addSubView emailEdit = new KDCustomHTMLView
      tagName      : "a"
      partial      : "Edit"
      cssClass     : "action-link"

    # SET EMAIL SWAPPABLE
    emailForm.addSubView emailSwappable = new AccountsSwappable
      views    : [emailInputs,nonEmailInputs]
      cssClass : "clearfix"

    @listenTo KDEventTypes : "click", listenedToInstance : emailCancel, callback : emailSwappable.swapViews
    @listenTo KDEventTypes : "click", listenedToInstance : emailEdit,   callback : emailSwappable.swapViews

    # =================
    # ADDING USERNAME FORM
    # =================
    @addSubView usernameForm = usernameForm = new KDFormView
      callback     : (formData)->
        new KDNotificationView
          type  : "mini"
          title : "Currently disabled!"
    usernameForm.addSubView usernameLabel = new KDLabelView
      title        : "Your username"
      cssClass     : "main-label"

    usernameInputs = new KDView cssClass : "hiddenval clearfix"
    usernameInputs.addSubView usernameInput = new KDInputView
      label        : usernameLabel
      defaultValue : account.profile.nickname
      placeholder  : "username..."
      name         : "username"
    usernameInputs.addSubView inputActions = new KDView cssClass : "actions-wrapper"
    inputActions.addSubView usernameSave = new KDButtonView
      title        : "Save"
      type         : "submit"
    inputActions.addSubView usernameCancel = new KDCustomHTMLView
      tagName      : "a"
      partial      : "cancel"
      cssClass     : "cancel-link"

    # USERNAME STATIC PART
    usernameNonInputs = usernameNonInputs = new KDView cssClass : "initialval clearfix"
    usernameNonInputs.addSubView usernameSpan = new KDCustomHTMLView
      tagName      : "span"
      partial      : account.profile.nickname
      cssClass     : "static-text"
    usernameNonInputs.addSubView usernameEdit = new KDCustomHTMLView
      tagName      : "a"
      partial      : "Edit"
      cssClass     : "action-link"

    # SET USERNAME SWAPPABLE
    usernameForm.addSubView usernameSwappable = new AccountsSwappable
      views    : [usernameInputs,usernameNonInputs]
      cssClass : "clearfix"

    @listenTo KDEventTypes : "click", listenedToInstance : usernameCancel, callback : usernameSwappable.swapViews
    @listenTo KDEventTypes : "click", listenedToInstance : usernameEdit,   callback : usernameSwappable.swapViews

    @addSubView @emailOptOutView = new KDFormView
    @emailOptOutView.addSubView new KDLabelView
      title        : "Email notifications"
      cssClass     : "main-label"

    emailFrequency = user.getAt('emailFrequency.global')

    @emailOptOutView.addSubView new KDOnOffSwitch
      cssClass      : 'dark'
      defaultValue  : if emailFrequency is 'never' then off else on
      callback      : (state)->
        account.setEmailPreferences global: state, ->
          new KDNotificationView
            duration : 2000
            title    : if state then 'You will get email notifications.' \
                                else 'You will no longer get email notifications.'
{'fraction_non_alphanumeric': 0.08837361916220059, 'fraction_numerical': 0.0008749863283386198, 'mean_word_length': 2.525057825751735, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4159351', 'n_tokens_mistral': 2569, 'n_tokens_neox': 2507, 'n_words': 625}