<commit_before>class CommentInputWidget extends ActivityInputWidget

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

    options.type         or= 'new-comment'
    options.cssClass       = KD.utils.curry 'comment-input-widget', options.cssClass
    options.showAvatar    ?= yes
    options.placeholder    = 'Type your comment and hit enter...'
    options.inputViewClass = CommentInputView

    options.showAvatar    ?= yes

    super options, data


  createSubViews: ->
    { inputViewClass, defaultValue, placeholder } = @getOptions()
    data = @getData()

    @input    = new inputViewClass { defaultValue, placeholder }
    @embedBox = new EmbedBoxWidget delegate: @input, data


  initEvents: ->
    @input.on 'Escape', @bound 'reset'
    @input.on 'Enter',  @bound 'submit'

    @input.on 'focus', @bound 'inputFocused'
    @input.on 'blur',  @bound 'inputBlured'

    @input.on 'keyup', =>
      @showPreview  if @preview


  lockSubmit: -> @locked = yes


  unlockSubmit: -> @locked = no


  setFocus: -> @input.focus()


  create: ({body, clientRequestId}, callback) ->

    { activity } = @getOptions()

    { appManager } = KD.singletons

    appManager.tell 'Activity', 'reply', {activity, body, clientRequestId}, (err, reply) =>

      return KD.showError err  if err

      callback err, reply


  inputFocused: ->

    @emit 'Focused'
    KD.mixpanel 'Comment activity, focus'


  inputBlured: ->

    return  unless @input.getValue() is ''
    @emit 'Blured'
<commit_msg>announcement: ugly fix for comment regression<commit_after>class CommentInputWidget extends ActivityInputWidget

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

    options.type         or= 'new-comment'
    options.cssClass       = KD.utils.curry 'comment-input-widget', options.cssClass
    options.showAvatar    ?= yes
    options.placeholder    = 'Type your comment and hit enter...'
    options.inputViewClass = CommentInputView

    options.showAvatar    ?= yes

    super options, data


  createSubViews: ->
    { inputViewClass, defaultValue, placeholder } = @getOptions()
    data = @getData()

    @input    = new inputViewClass { defaultValue, placeholder }
    @embedBox = new EmbedBoxWidget delegate: @input, data


  initEvents: ->
    @input.on 'Escape', @bound 'reset'
    @input.on 'Enter',  @bound 'submit'

    @input.on 'focus', @bound 'inputFocused'
    @input.on 'blur',  @bound 'inputBlured'

    @input.on 'keyup', =>
      @showPreview  if @preview


  lockSubmit: -> @locked = yes


  unlockSubmit: -> @locked = no


  setFocus: -> @input.focus()


  submit: (value) ->

    return  if @locked
    return @reset yes  unless body = value.trim()

    activity = @getData()
    {app}    = @getOptions()
    payload  = @getPayload()

    timestamp = Date.now()
    clientRequestId = KD.utils.generateFakeIdentifier timestamp

    @lockSubmit()

    obj = { body, payload, clientRequestId }

    fn = if activity
    then @bound 'update'
    else @bound 'create'

    fn(obj, @bound 'submissionCallback')

    @emit 'SubmitStarted', body, clientRequestId


  create: ({body, clientRequestId}, callback) ->

    { activity } = @getOptions()

    { appManager } = KD.singletons

    appManager.tell 'Activity', 'reply', {activity, body, clientRequestId}, (err, reply) =>

      return KD.showError err  if err

      callback err, reply


  inputFocused: ->

    @emit 'Focused'
    KD.mixpanel 'Comment activity, focus'


  inputBlured: ->

    return  unless @input.getValue() is ''
    @emit 'Blured'

{'fraction_non_alphanumeric': 0.12496425507577924, 'fraction_numerical': 0.0, 'mean_word_length': 2.9347581552305964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '2400061', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1031, 'n_words': 280}