<commit_before>class NavigationInviteLink extends KDCustomHTMLView

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

    options.tagName  = "a"
    options.cssClass = "title"

    super options, data

    @hide()
    @count = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "main-nav-icon #{__utils.slugify @getData().title}"
      pistachio : "{{#(quota)-#(usage)}}"

    @utils.wait 10000, =>
      KD.whoami().fetchLimit? 'invite', (err, limit)=>
        if limit?
          @show()
          @count.setData limit
          limit.on 'update', => @count.render()
          @count.render()

  sendInvite:(formData, modal)->

    KD.remote.api.JInvitation.create
      emails        : [formData.recipient]
      customMessage :
        # subject     : formData.subject
        body        : formData.body
    , (err)=>
      modal.modalTabs.forms["Invite Friends"].buttons.Send.hideLoader()
      if err
        message = 'This e-mail is already invited!' if err.code is 11000
        new KDNotificationView
          title: message or err.message or 'Sorry, something bad happened.'
          content: 'Please try again later!' unless message
      else
        new KDNotificationView title: 'Success!'
        modal.destroy()
        KD.track "Members", "InvitationSentToFriend"

  viewAppended:->

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

  pistachio:->
    "{{> @count}}#{@getData().title}"

  # take this somewhere else
  # was a beta quick solution
  click:(event)->
    event.stopPropagation()
    event.preventDefault()
    limit = @count.getData()
    if !limit? or limit.getAt('quota') - limit.getAt('usage') <= 0
      new KDNotificationView<commit_msg>invitation: Fixed sending invitation. Added koding group as default.<commit_after>class NavigationInviteLink extends KDCustomHTMLView

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

    options.tagName  = "a"
    options.cssClass = "title"

    super options, data

    @hide()
    @count = new KDCustomHTMLView
      tagName   : "span"
      cssClass  : "main-nav-icon #{__utils.slugify @getData().title}"
      pistachio : "{{#(quota)-#(usage)}}"

    @utils.wait 10000, =>
      KD.whoami().fetchLimit? 'invite', (err, limit)=>
        if limit?
          @show()
          @count.setData limit
          limit.on 'update', => @count.render()
          @count.render()

  sendInvite:(formData, modal)->

    KD.remote.api.JInvitation.create
      emails        : [formData.recipient]
      group         : "koding"
      customMessage :
        # subject     : formData.subject
        body        : formData.body
    , (err)=>
      modal.modalTabs.forms["Invite Friends"].buttons.Send.hideLoader()
      if err
        message = 'This e-mail is already invited!' if err.code is 11000
        new KDNotificationView
          title: message or err.message or 'Sorry, something bad happened.'
          content: 'Please try again later!' unless message
      else
        new KDNotificationView title: 'Success!'
        modal.destroy()
        KD.track "Members", "InvitationSentToFriend"

  viewAppended:->

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

  pistachio:->
    "{{> @count}}#{@getData().title}"

  # take this somewhere else
  # was a beta quick solution
  click:(event)->
    event.stopPropagation()
    event.preventDefault()
    limit = @count.getData()
    if !limit? or limit.getAt('quota') - limit.getAt('usage') <= 0
      new KDNotificationView
{'fraction_non_alphanumeric': 0.12985507246376812, 'fraction_numerical': 0.006376811594202898, 'mean_word_length': 2.5071138211382116, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '2562150', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1025, 'n_words': 249}