<commit_before>class FollowButton extends KDToggleButton

  constructor:(options, data)->
    options.cssClass = @utils.curryCssClass "follow-btn", options.cssClass
    options.title        or= "Follow"
    options.dataPath     or= "followee"
    options.defaultState or= "Follow"
    options.bind           = "mouseenter mouseleave"
    options.loader       or=
      color                : "#333333"
      diameter             : 18
      top                  : 11
    options.states       or= [
      title    : "Follow"
      callback : @createStateCallback "follow"
    ,
      title    : "Following"
      callback : @createStateCallback "unfollow"
    ]
    super

  createStateCallback:(method)->
    (callback)=>
      unless @inProgress
        @inProgress = yes

        setTimeout =>
          @inProgress = no
        , 10000

        @getData()[method] (err, response)=>
          @inProgress = no
          unless err
            callback? null
            @redecorateState()

  decorateState:(name)->

  redecorateState:->
    @setTitle @state.title

    if @state.title is 'Follow'
      @unsetClass 'following-btn'
    else
      @setClass 'following-btn'

    @hideLoader()

  mouseEnter:->
    if @getTitle() is "Following"
      @setTitle "Unfollow"

  mouseLeave:->
    if @getTitle() is "Unfollow"
      @setTitle "Following"<commit_msg>Staging : added missing MemberFollowToggleButton class<commit_after>class FollowButton extends KDToggleButton

  constructor:(options, data)->
    options.cssClass = @utils.curryCssClass "follow-btn", options.cssClass
    options.title        or= "Follow"
    options.dataPath     or= "followee"
    options.defaultState or= "Follow"
    options.bind           = "mouseenter mouseleave"
    options.loader       or=
      color                : "#333333"
      diameter             : 18
      top                  : 11
    options.states       or= [
      title    : "Follow"
      callback : @createStateCallback "follow"
    ,
      title    : "Following"
      callback : @createStateCallback "unfollow"
    ]
    super

  createStateCallback:(method)->
    (callback)=>
      unless @inProgress
        @inProgress = yes

        setTimeout =>
          @inProgress = no
        , 10000

        @getData()[method] (err, response)=>
          @inProgress = no
          unless err
            callback? null
            @redecorateState()

  decorateState:(name)->

  redecorateState:->
    @setTitle @state.title

    if @state.title is 'Follow'
      @unsetClass 'following-btn'
    else
      @setClass 'following-btn'

    @hideLoader()

  mouseEnter:->
    if @getTitle() is "Following"
      @setTitle "Unfollow"

  mouseLeave:->
    if @getTitle() is "Unfollow"
      @setTitle "Following"

class MemberFollowToggleButton extends FollowButton

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

    options = $.extend

      errorMessages  :
        KodingError  : 'Something went wrong while follow'
        AccessDenied : 'You are not allowed to follow members'
      stateOptions   :
        unfollow     :
          cssClass   : 'following-btn'
      dataType       : 'JAccount'

    , options

    super options, data

  decorateState:(name)->
    KD.track "Members", name, @getData().profile.nickname
    super
{'fraction_non_alphanumeric': 0.1008249312557287, 'fraction_numerical': 0.00916590284142988, 'mean_word_length': 2.037105751391466, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7237717', 'n_tokens_mistral': 975, 'n_tokens_neox': 905, 'n_words': 224}