diff --git a/client/lib/menu.coffee b/client/lib/menu.coffee index e91bf2db08cd..f2ad61eb7bdd 100644 --- a/client/lib/menu.coffee +++ b/client/lib/menu.coffee @@ -1,6 +1,7 @@ @menu = new class init: -> @container = $("#rocket-chat") + @list = $('.rooms-list') isOpen: -> return @container?.hasClass("menu-opened") is true @@ -17,4 +18,31 @@ if @isOpen() @close() else - @open() \ No newline at end of file + @open() + + updateUnreadBars: _.throttle -> + if not @list? + return + + listOffset = @list.offset() + listHeight = @list.height() + + showTop = false + showBottom = false + $('li.has-alert').each -> + if $(this).offset().top < listOffset.top - $(this).height() + showTop = true + + if $(this).offset().top > listOffset.top + listHeight + showBottom = true + + if showTop is true + $('.top-unread-rooms').removeClass('hidden') + else + $('.top-unread-rooms').addClass('hidden') + + if showBottom is true + $('.bottom-unread-rooms').removeClass('hidden') + else + $('.bottom-unread-rooms').addClass('hidden') + , 200 diff --git a/client/startup/unread.coffee b/client/startup/unread.coffee index 8326120a1734..3a0b0ea45efa 100644 --- a/client/startup/unread.coffee +++ b/client/startup/unread.coffee @@ -28,6 +28,8 @@ Meteor.startup -> readMessage.refreshUnreadMark(subscription.rid) + menu.updateUnreadBars() + if unreadCount > 0 if unreadCount > 999 Session.set 'unread', '999+' diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index bdde1e65520a..6c9912bd52c0 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -1521,6 +1521,35 @@ a.github-fork { font-size: 12px; } } + .unread-rooms { + background-color: #068FE4; + position: absolute; + z-index: 1000; + width: 100%; + text-align: center; + line-height: 24px; + color: white; + text-transform: uppercase; + font-weight: bold; + display: -webkit-flex; + display: flex; + align-items: center; + -webkit-align-items: center; + justify-content: center; + -webkit-justify-content: center; + + &.top-unread-rooms { + top: 60px; + } + &.bottom-unread-rooms { + bottom: 70px; + } + + i { + margin-left: 5px; + font-size: 12px; + } + } } .new-room-highlight a { diff --git a/client/views/app/sideNav/sideNav.coffee b/client/views/app/sideNav/sideNav.coffee index 8854c2b2a487..78633f2189e0 100644 --- a/client/views/app/sideNav/sideNav.coffee +++ b/client/views/app/sideNav/sideNav.coffee @@ -21,6 +21,12 @@ Template.sideNav.events 'mouseleave .header': -> SideNav.leaveArrow() + 'scroll .rooms-list': -> + menu.updateUnreadBars() + Template.sideNav.onRendered -> SideNav.init() menu.init() + + Meteor.defer -> + menu.updateUnreadBars() diff --git a/client/views/app/sideNav/sideNav.html b/client/views/app/sideNav/sideNav.html index 9cd6030a28f7..b0b5d8685672 100644 --- a/client/views/app/sideNav/sideNav.html +++ b/client/views/app/sideNav/sideNav.html @@ -4,6 +4,9 @@ {{> userStatus}} {{#if currentUser}} +
{{> starredRooms }} @@ -15,6 +18,9 @@

+