mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
epic hax to make the chat message list resize #1788
This commit is contained in:
@@ -12,9 +12,11 @@ define('forum/chats', ['string', 'sounds'], function(S, sounds) {
|
|||||||
|
|
||||||
if (!Chats.initialised) {
|
if (!Chats.initialised) {
|
||||||
Chats.addSocketListeners();
|
Chats.addSocketListeners();
|
||||||
|
Chats.addGlobalEventListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Chats.addEventListeners();
|
Chats.addEventListeners();
|
||||||
|
Chats.resizeMainWindow();
|
||||||
Chats.scrollToBottom(containerEl);
|
Chats.scrollToBottom(containerEl);
|
||||||
Chats.setActive();
|
Chats.setActive();
|
||||||
|
|
||||||
@@ -62,6 +64,10 @@ define('forum/chats', ['string', 'sounds'], function(S, sounds) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Chats.addGlobalEventListeners = function() {
|
||||||
|
$(window).on('resize', Chats.resizeMainWindow);
|
||||||
|
};
|
||||||
|
|
||||||
Chats.addSocketListeners = function() {
|
Chats.addSocketListeners = function() {
|
||||||
socket.on('event:chats.receive', function(data) {
|
socket.on('event:chats.receive', function(data) {
|
||||||
var typingNotifEl = $('.user-typing'),
|
var typingNotifEl = $('.user-typing'),
|
||||||
@@ -102,6 +108,22 @@ define('forum/chats', ['string', 'sounds'], function(S, sounds) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Chats.resizeMainWindow = function() {
|
||||||
|
var messagesList = $('.expanded-chat ul');
|
||||||
|
|
||||||
|
if (messagesList.length) {
|
||||||
|
var inputEl = $('.chat-input'),
|
||||||
|
viewportHeight = $(window).height(),
|
||||||
|
margin = $('.expanded-chat ul').outerHeight() - $('.expanded-chat ul').height(),
|
||||||
|
inputHeight = inputEl.outerHeight(),
|
||||||
|
fromTop = messagesList.offset().top;
|
||||||
|
|
||||||
|
messagesList.height(viewportHeight-(fromTop+inputHeight+(margin*4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
Chats.notifyTyping = function(toUid, typing) {
|
Chats.notifyTyping = function(toUid, typing) {
|
||||||
socket.emit('modules.chats.user' + (typing ? 'Start' : 'Stop') + 'Typing', {
|
socket.emit('modules.chats.user' + (typing ? 'Start' : 'Stop') + 'Typing', {
|
||||||
touid: toUid,
|
touid: toUid,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var posts = require('../posts'),
|
|||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
_ = require('underscore'),
|
_ = require('underscore'),
|
||||||
server = require('./'),
|
server = require('./'),
|
||||||
|
nconf = require('nconf'),
|
||||||
|
|
||||||
SocketModules = {
|
SocketModules = {
|
||||||
composer: {
|
composer: {
|
||||||
|
|||||||
Reference in New Issue
Block a user