aboutsummaryrefslogtreecommitdiffstats
path: root/app/assets/javascripts/tweets.coffee
blob: 62e79a78ec79490d1caed3246b48ce21ce8135b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Application.Views.tweets =
  _: ->
    formatTweet = (d) ->
      Application.Helpers.localize_time(d)
      Application.Helpers.rescue_profile_image(d)
    formatTweet $(".statuses")

    if $("link[rel=next]") isnt null
      $.autopager
        content: $(".statuses")
        link: $("link[rel=next]")
        onStart: -> $(".loading").show()
        onReceived: (obj) -> formatTweet(obj)
        onComplete: -> $(".loading").hide()

      $(".statuses").on "click", ".expand-responses-button", ->
        id = $(this).data("id")
        type = $(this).data("type")
        Application.Helpers.call_api "tweets/responses", { id: id, type: type }, (json) ->
          obj = $(".status[data-id=\"" + id + "\"] .status-responses-" + type).html(json.html)
          Application.Helpers.rescue_profile_image obj
        return false