The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/packages/rocketchat-ui/client/lib/menu.js

56 lines
1.4 KiB

9 years ago
/* globals isRtl */
this.menu = new class {
constructor() {
this.updateUnreadBars = _.throttle(() => {
if (this.list == null) {
return;
}
const listOffset = this.list.offset();
const listHeight = this.list.height();
let showTop = false;
let showBottom = false;
$('li.has-alert').each(function() {
if ($(this).offset().top < listOffset.top - $(this).height()) {
showTop = true;
}
if ($(this).offset().top > listOffset.top + listHeight) {
return showBottom = true;
}
});
if (showTop === true) {
$('.top-unread-rooms').removeClass('hidden');
} else {
$('.top-unread-rooms').addClass('hidden');
}
if (showBottom === true) {
return $('.bottom-unread-rooms').removeClass('hidden');
} else {
return $('.bottom-unread-rooms').addClass('hidden');
}
}, 200);
}
init() {
this.mainContent = $('.main-content');
this.list = $('.rooms-list');
Session.set('isMenuOpen', false);
}
isOpen() {
return Session.get('isMenuOpen');
}
open() {
Session.set('isMenuOpen', true);
this.mainContent && this.mainContent.css('transform', `translateX(${ isRtl(localStorage.getItem('userLanguage'))?'-':'' }260px)`);
}
close() {
Session.set('isMenuOpen', false);
this.mainContent && this.mainContent .css('transform', 'translateX(0)');
}
toggle() {
return this.isOpen() ? this.close() : this.open();
}
};