mirror of https://github.com/freeCodeCamp/devdocs
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
678 B
35 lines
678 B
11 years ago
|
#= require views/misc/notif
|
||
|
|
||
|
class app.views.News extends app.views.Notif
|
||
|
@className += ' _notif-news'
|
||
|
|
||
|
@defautOptions:
|
||
9 years ago
|
autoHide: 30000
|
||
11 years ago
|
|
||
|
init: ->
|
||
|
@unreadNews = @getUnreadNews()
|
||
|
@show() if @unreadNews.length
|
||
|
@markAllAsRead()
|
||
|
return
|
||
|
|
||
|
render: ->
|
||
|
@html app.templates.notifNews(@unreadNews)
|
||
|
return
|
||
|
|
||
|
getUnreadNews: ->
|
||
|
return [] unless time = @getLastReadTime()
|
||
|
|
||
|
for news in app.news
|
||
10 years ago
|
break if new Date(news[0]).getTime() <= time
|
||
11 years ago
|
news
|
||
|
|
||
|
getLastNewsTime: ->
|
||
10 years ago
|
new Date(app.news[0][0]).getTime()
|
||
11 years ago
|
|
||
|
getLastReadTime: ->
|
||
10 years ago
|
app.settings.get 'news'
|
||
11 years ago
|
|
||
|
markAllAsRead: ->
|
||
10 years ago
|
app.settings.set 'news', @getLastNewsTime()
|
||
11 years ago
|
return
|