From 5cb22714db8cdaa33bdff3c728126a9645e9eab3 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 21 Jan 2015 13:12:52 +0100 Subject: [PATCH] Improved way to set notification popover height. Added immediately set counter to 0 on client side after "mark all as read" click. --- .../widget/online_notification.js.coffee | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/widget/online_notification.js.coffee b/app/assets/javascripts/app/controllers/widget/online_notification.js.coffee index ac7c0348e..3e4daa2a3 100644 --- a/app/assets/javascripts/app/controllers/widget/online_notification.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/online_notification.js.coffee @@ -47,6 +47,7 @@ class App.OnlineNotificationWidget extends App.Controller @toggle.append('
' + count.toString() + '
') markAllAsRead: => + @counterUpdate(0) @ajax( id: 'markAllAsRead' type: 'POST' @@ -64,13 +65,19 @@ class App.OnlineNotificationWidget extends App.Controller @updateContent() # set heigth of notification popover - height = $('#app').height() - $('.js-notificationsContainer').css('height', "#{height-12}px") + heightApp = $('#navigation').height() + heightPopoverHeader = $('.js-notificationsContainer .popover-notificationsHeader').height() + heightPopoverContent = $('.js-notificationsContainer .popover-content').get(0).scrollHeight + height = heightPopoverHeader + heightPopoverContent + if height > heightApp + height = heightApp - heightPopoverHeader - 56 + $('.js-notificationsContainer .popover-content').css('height', "#{height}px") + + # set popover arrow $('.js-notificationsContainer .arrow').css('top', '20px') # close notification list on click $('.js-notificationsContainer').on('click', (e) => - #console.log('CL') @hidePopover() )