highlighting of the user with whom you are currently chatting with #1788

This commit is contained in:
Julian Lam
2014-07-07 13:09:09 -04:00
parent 07a82ec12c
commit a031bc2721
3 changed files with 32 additions and 21 deletions

View File

@@ -1,16 +1,21 @@
'use strict';
/* globals define, app*/
/* globals define, app, ajaxify, utils, socket */
define('forum/chats', ['string','sounds'], function(S, sounds) {
define('forum/chats', ['string', 'sounds'], function(S, sounds) {
var Chats = {};
Chats.init = function() {
var containerEl = $('.expanded-chat ul');
Chats.addEventListeners();
Chats.addSocketListeners();
Chats.scrollToBottom(containerEl);
Chats.setActive();
};
Chats.getRecipientUid = function() {
console.log($('.expanded-chat'));
return parseInt($('.expanded-chat').attr('data-uid'), 10);
};
@@ -93,5 +98,19 @@ define('forum/chats', ['string','sounds'], function(S, sounds) {
}
};
Chats.scrollToBottom = function(containerEl) {
if (containerEl.length) {
containerEl.scrollTop(
containerEl[0].scrollHeight - containerEl.height()
);
}
};
Chats.setActive = function() {
console.log(Chats.getRecipientUid());
$('.chats-list li').removeClass('bg-primary');
$('.chats-list li[data-uid="' + Chats.getRecipientUid() + '"]').addClass('bg-primary');
};
return Chats;
});