diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.coffee index 63ecb774a..500c95de3 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.coffee @@ -17,6 +17,7 @@ class App.OnlineNotificationWidget extends App.Controller '.js-mark': 'mark' '.js-item': 'item' '.js-content': 'content' + '.js-header': 'header' constructor: -> super @@ -50,7 +51,7 @@ class App.OnlineNotificationWidget extends App.Controller return if @access() - @subscribeId = App.OnlineNotification.subscribe(@show) + @subscribeId = App.OnlineNotification.subscribe(@updateContent) @bind('ui:reshow', => @show() @@ -59,6 +60,8 @@ class App.OnlineNotificationWidget extends App.Controller $(window).on 'click.notifications', @hide + @updateContent() + release: -> $(window).off 'click.notifications' App.OnlineNotification.unsubscribe(@subscribeId) @@ -131,6 +134,7 @@ class App.OnlineNotificationWidget extends App.Controller ) updateHeight: -> + # set height of notification popover heightApp = $('#app').height() heightPopoverSpacer = 22 @@ -150,7 +154,7 @@ class App.OnlineNotificationWidget extends App.Controller load = (data) => @fetchedData = true App.OnlineNotification.refresh(data.stream, clear: true) - @show() + @updateContent() App.OnlineNotification.fetchFull(load) toggle: => @@ -159,8 +163,7 @@ class App.OnlineNotificationWidget extends App.Controller else @show() - show: => - @shown = true + updateContent: => if !@Session.get() @content.html('') return @@ -197,19 +200,25 @@ class App.OnlineNotificationWidget extends App.Controller count: @count ) + return if !@shown + @show() + + show: => + @shown = true @el.show() + @updateHeight() hide: => @shown = false @el.hide() - onItemClick: (event) -> - @locationVerify(event) + onItemClick: (e) -> + @locationVerify(e) @hide() - removeItem: (event) -> - event.preventDefault() - event.stopPropagation() + removeItem: (e) => + e.preventDefault() + e.stopPropagation() row = $(e.target).closest('.js-item') id = row.data('id') App.OnlineNotification.destroy(id) diff --git a/app/assets/javascripts/app/views/widget/online_notification.jst.eco b/app/assets/javascripts/app/views/widget/online_notification.jst.eco index 540c5950f..da34fb6d3 100644 --- a/app/assets/javascripts/app/views/widget/online_notification.jst.eco +++ b/app/assets/javascripts/app/views/widget/online_notification.jst.eco @@ -1,6 +1,6 @@