Created
October 5, 2015 10:03
-
-
Save robertolos/a60b81941066667d8cc8 to your computer and use it in GitHub Desktop.
Shopify dashing - Comments widget for twitter mentions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment