<commit_before>@inviteUser = (email, message, onSuccess, onError) ->
  Meteor.call 'invite-user', email, (message or ''), (error, newPersonId) =>
    if (error)
      showNotification = if onError then onError error else true
      Notify.meteorError error, true if showNotification
      return

    showNotification = if onSuccess then onSuccess newPersonId else true
    Notify.success "User #{ email } invited.", "We have created an account and sent them an invitation email with a link to set their password." if showNotification

Template._loginButtonsLoggedInSingleLogoutButton.displayName = Template._loginButtonsLoggedInDropdown.displayName = ->
  Meteor.person(displayName: 1)?.displayName

changingPasswordInResetPassword = false
changingPasswordInEnrollAccount = false

# To close sign in buttons dialog box when clicking, focusing or pressing a key somewhere outside
$(document).on 'click focus keypress', (e) ->
  # originalEvent is defined only for native events, but we are triggering
  # click manually as well, so originalEvent is not always defined
  unless e.originalEvent?.accountsDialogBoxEvent
    Accounts._loginButtonsSession.closeDropdown()
    Accounts._loginButtonsSession.set 'resetPasswordToken', null
    Accounts._loginButtonsSession.set 'enrollAccountToken', null
    changingPasswordInResetPassword = false
    changingPasswordInEnrollAccount = false
  return # Make sure CoffeeScript does not return anything

# But if clicked inside, we mark the event so that dialog box is not closed
Template._loginButtons.events
  'click #login-buttons, focus #login-buttons, keypress #login-buttons': (e, template) ->
    e.accountsDialogBoxEvent = true
    return # Make sure CoffeeScript does not return anything

# Autofocus username when login form is rendered
Template._loginButtonsLoggedOutPasswordService.rendered = ->
  $('#login-username-or-email').focus()

# Autofocus e-mail when forgot password form is rendered
Template._forgotPasswordForm.rendered = ->
  $('#forgot-password-email').focus()

$(document).on 'keyup', (e) ->
  if e.keyCode is 27 # Escape key
    Accounts._loginButtonsSession.closeDropdown()
    Accounts._loginButtonsSession.set 'resetPasswordToken', null<commit_msg>Autofocused e-mail on enroll user form<commit_after>@inviteUser = (email, message, onSuccess, onError) ->
  Meteor.call 'invite-user', email, (message or ''), (error, newPersonId) =>
    if (error)
      showNotification = if onError then onError error else true
      Notify.meteorError error, true if showNotification
      return

    showNotification = if onSuccess then onSuccess newPersonId else true
    Notify.success "User #{ email } invited.", "We have created an account and sent them an invitation email with a link to set their password." if showNotification

Template._loginButtonsLoggedInSingleLogoutButton.displayName = Template._loginButtonsLoggedInDropdown.displayName = ->
  Meteor.person(displayName: 1)?.displayName

changingPasswordInResetPassword = false
changingPasswordInEnrollAccount = false

# To close sign in buttons dialog box when clicking, focusing or pressing a key somewhere outside
$(document).on 'click focus keypress', (e) ->
  # originalEvent is defined only for native events, but we are triggering
  # click manually as well, so originalEvent is not always defined
  unless e.originalEvent?.accountsDialogBoxEvent
    Accounts._loginButtonsSession.closeDropdown()
    Accounts._loginButtonsSession.set 'resetPasswordToken', null
    Accounts._loginButtonsSession.set 'enrollAccountToken', null
    changingPasswordInResetPassword = false
    changingPasswordInEnrollAccount = false
  return # Make sure CoffeeScript does not return anything

# But if clicked inside, we mark the event so that dialog box is not closed
Template._loginButtons.events
  'click #login-buttons, focus #login-buttons, keypress #login-buttons': (e, template) ->
    e.accountsDialogBoxEvent = true
    return # Make sure CoffeeScript does not return anything

# Autofocus username when login form is rendered
Template._loginButtonsLoggedOutPasswordService.rendered = ->
  $('#login-username-or-email').focus()

# Autofocus e-mail when forgot password form is rendered
Template._forgotPasswordForm.rendered = ->
  $('#forgot-password-email').focus()

# Autofocus password when enroll user form is rendered
Template._enrollAccountDialog.rendered = ->
  $('#enroll-account-password').focus()

$(document).on 'keyup', (e) ->
  if e.keyCode is 27 # Escape key
    Accounts._loginButtonsSession.closeDropdown()
    Accounts._loginButtonsSession.set 'resetPasswordToken', null
{'fraction_non_alphanumeric': 0.08165038002171553, 'fraction_numerical': 0.0013029315960912053, 'mean_word_length': 4.927927927927928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '316999', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1207, 'n_words': 408}