Fixed not removable items. Automatically shown online notification popover on new messages. Defined missing @header element.

This commit is contained in:
Martin Edenhofer 2016-03-20 21:41:19 +01:00
parent cc2a8ce0c1
commit 6953ae52af
2 changed files with 19 additions and 10 deletions

View file

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