Skip to content

Commit

Permalink
Merge pull request #761 from RocketChat/menu-more-unreads
Browse files Browse the repository at this point in the history
Add bars to indicate unread rooms hidden by scroll
  • Loading branch information
engelgabriel committed Sep 11, 2015
2 parents 47721ed + 9ccf8e1 commit 895bd84
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
30 changes: 29 additions & 1 deletion client/lib/menu.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@menu = new class
init: ->
@container = $("#rocket-chat")
@list = $('.rooms-list')

isOpen: ->
return @container?.hasClass("menu-opened") is true
Expand All @@ -17,4 +18,31 @@
if @isOpen()
@close()
else
@open()
@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
2 changes: 2 additions & 0 deletions client/startup/unread.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Meteor.startup ->

readMessage.refreshUnreadMark(subscription.rid)

menu.updateUnreadBars()

if unreadCount > 0
if unreadCount > 999
Session.set 'unread', '999+'
Expand Down
29 changes: 29 additions & 0 deletions client/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions client/views/app/sideNav/sideNav.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 6 additions & 0 deletions client/views/app/sideNav/sideNav.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{{> userStatus}}
</header>
{{#if currentUser}}
<div class="unread-rooms top-unread-rooms hidden">
{{_ "More_unreads"}} <i class="icon-up-big"></i>
</div>
<div class="rooms-list">
<div class="wrapper">
{{> starredRooms }}
Expand All @@ -15,6 +18,9 @@ <h3>
</h3>
</div>
</div>
<div class="unread-rooms bottom-unread-rooms hidden">
{{_ "More_unreads"}} <i class="icon-down-big"></i>
</div>
<div class="flex-nav hidden">
<section>
{{> UI.dynamic template=flexTemplate data=flexData}}
Expand Down
1 change: 1 addition & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
"Meta_robots" : "Robots",
"minutes" : "minutes",
"More_channels" : "More channels",
"More_unreads" : "More unreads",
"Msgs" : "Msgs",
"multi" : "multi",
"My_Account" : "My Account",
Expand Down

0 comments on commit 895bd84

Please sign in to comment.