diff options
Diffstat (limited to 'widgets/comments/comments.coffee')
-rw-r--r-- | widgets/comments/comments.coffee | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/widgets/comments/comments.coffee b/widgets/comments/comments.coffee new file mode 100644 index 0000000..ff659ec --- /dev/null +++ b/widgets/comments/comments.coffee @@ -0,0 +1,24 @@ +class Dashing.Comments extends Dashing.Widget + + @accessor 'quote', -> + "“#{@get('current_comment')?.body}”" + + ready: -> + @currentIndex = 0 + @commentElem = $(@node).find('.comment-container') + @nextComment() + @startCarousel() + + onData: (data) -> + @currentIndex = 0 + + startCarousel: -> + setInterval(@nextComment, 8000) + + nextComment: => + comments = @get('comments') + if comments + @commentElem.fadeOut => + @currentIndex = (@currentIndex + 1) % comments.length + @set 'current_comment', comments[@currentIndex] + @commentElem.fadeIn() |