Sha256: fc929ecc7f7c5466c20d074f550e27839801f7dbaf6433e3c7da47c00b686323

Contents?: true

Size: 865 Bytes

Versions: 1

Compression:

Stored size: 865 Bytes

Contents

class TentStatus.Views.ReplyPostForm extends TentStatus.Views.NewPostForm
  initialize: (options = {}) ->
    super

    ## reply fields
    @replyToPostId = ($ '[name=mentions_post_id]', @$el).val()
    @replyToEntity = ($ '[name=mentions_post_entity]', @$el).val()

  submit: (e) =>
    e.preventDefault()
    data = @getData()
    return false unless @validate data

    post = new TentStatus.Models.Post data
    post.once 'sync', =>
      window.location.reload() unless @parentView.emptyPool
      @parentView.emptyPool()
      TentStatus.Collections.posts.unshift(post)
      @parentView.posts.unshift(post)
      @parentView.render()
    post.save()
    false

  buildMentions: (data) =>
    data = super
    if @replyToPostId and @replyToEntity
      data.mentions ||= []
      data.mentions.push { entity: @replyToEntity, post: @replyToPostId }
    data

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tent-status-0.0.1 assets/javascripts/views/reply_post_form.js.coffee