This repository has been archived on 2025-11-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
dashboard/widgets/comments/comments.coffee
2022-09-20 00:27:25 +01:00

25 lines
591 B
CoffeeScript

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()