overleaf/services/web/public/coffee/main/announcements.coffee
2016-12-05 15:32:38 +00:00

23 lines
600 B
CoffeeScript

define [
"base"
], (App) ->
App.controller "AnnouncementsController", ($scope, $http, event_tracking, $window) ->
$scope.announcements = []
$scope.ui =
isOpen: false
hasNew: false
refreshAnnouncements = ->
$http.get("/announcements").success (announcements) ->
$scope.announcements = announcements
dismissCurrentAnnouncement = ->
event_tracking.sendMB "announcement-alert-dismissed", { blogPostId:announcement.id }
refreshAnnouncements()
$scope.openLink = ->
dismissCurrentAnnouncement()
.then(refreshAnnouncements)
$window.open = announcement.url