Sha256: b86893a3d24be86f7e2d87a79b0f5c0d47e328e30a6372df852d531ab782a278

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

window.dorsaleComments =
  setup: ->
    dorsaleComments.setupCreateForm()
    dorsaleComments.setupEditForm()
    dorsaleComments.setupEditButtons()
    dorsaleComments.setupDeleteButtons()
    dorsaleComments.setupShowMoreLinks()

  setupCreateForm: ->
    $(document).on "ajax:success", "form#new-dorsale-comment", (e, data) ->
      if data.length
        $(this).find("#comment_title, #comment_text").val("")
        $(".dorsale-comments-list").prepend(data)

  setupEditForm: ->
    $(document).on "ajax:success", "form#edit-dorsale-comment", (e, data) ->
     $(this).replaceWith(data)

  setupEditButtons: ->
    $(document).on "click", "a.edit-dorsale-comment", ->
      container = $(this).parents(".comment")
      url       = this.href

      $.ajax
        url: url
        success: (data) ->
          container.replaceWith(data)
          setupDatepickers()

      return false

  setupDeleteButtons: ->
    $(document).on "ajax:success", ".delete-dorsale-comment", ->
      $(this).parents(".comment").fadeOut ->
        $(this).remove()

  setupShowMoreLinks: ->
    $(document).on "click", ".comment-show_more", ->
      $(this).parents(".comment-text-truncated").remove()
      return false

$(document).on "turbolinks:load", ->
  dorsaleComments.setup()

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dorsale-3.7.2 app/assets/javascripts/dorsale/common/comments.coffee
dorsale-3.7.1 app/assets/javascripts/dorsale/common/comments.coffee
dorsale-3.7.0 app/assets/javascripts/dorsale/common/comments.coffee
dorsale-3.6.1 app/assets/javascripts/dorsale/common/comments.coffee
dorsale-3.6.0 app/assets/javascripts/dorsale/common/comments.coffee