Sha256: 127c487a0404630d8a02141640d6feddeb0dcf020ca750901393ba9c67721129

Contents?: true

Size: 1.24 KB

Versions: 5

Compression:

Stored size: 1.24 KB

Contents

$ ->
  class @CommentsTreeInit
    # SELECTORS
    reply_links:      $('.comments_tree .comment .reply')
    skip_link:        $('.comments_tree .new_comment .skip')
    new_comment_form: $('.comments_tree form.new_comment')
    parent_input:     $(".comments_tree form.new_comment input[name='comment[parent_id]']")

    constructor: ->

      @reply_links.click (event) =>
        # GET DATA
        link         = $ event.target
        comment      = link.parents('.comment')
        title        = comment.find('.title .main')
        hidden_field = comment.find('input:hidden')
        parent_id    = hidden_field.val()

        form         = @new_comment_form
        for_block    = form.find('.for')
        name_field   = for_block.find('i')

        # SET DATA
        name_field.html   title.html()
        @parent_input.val parent_id 

        # SHOW and JUMP
        for_block.show()
        window.location.hash = '#new_comment'

        false

      @skip_link.click (event) =>
        link       = $ event.target
        form       = @new_comment_form
        for_block  = form.find('.for')
        name_field = for_block.find('i')

        name_field.html   ''
        @parent_input.val ''

        for_block.hide()

        false

  new @CommentsTreeInit

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
the_sortable_tree-1.9.4 app/assets/javascripts/comments/base.js.coffee
the_sortable_tree-1.9.3 app/assets/javascripts/comments/base.js.coffee
the_sortable_tree-1.9.2 app/assets/javascripts/comments/base.js.coffee
the_sortable_tree-1.9.1 app/assets/javascripts/comments/comments.js.coffee
the_sortable_tree-1.9.0 app/assets/javascripts/comments_tree.js.coffee