mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-12 02:01:31 -04:00
chat: Move chat init to chat.js
This commit is contained in:
parent
8d3a6e5ef9
commit
a5c729af32
3 changed files with 43 additions and 41 deletions
|
@ -332,3 +332,43 @@ exports.handleClientMessage_CHAT_MESSAGES = (hookName, {msg}) => {
|
|||
$('#chatloadmessagesbutton').css('display', 'block');
|
||||
}
|
||||
};
|
||||
|
||||
exports.postAceInit = async (hookName, {clientVars, pad}) => {
|
||||
exports.chat.init(pad);
|
||||
|
||||
if (padcookie.getPref('chatAlwaysVisible')) {
|
||||
exports.chat.stickToScreen(true);
|
||||
$('#options-stickychat').prop('checked', true);
|
||||
}
|
||||
if (padcookie.getPref('chatAndUsers')) {
|
||||
exports.chat.chatAndUsers(true);
|
||||
$('#options-chatandusers').prop('checked', true);
|
||||
}
|
||||
|
||||
// Prevent sticky chat or chat and users to be checked for mobiles
|
||||
const checkChatAndUsersVisibility = (x) => {
|
||||
if (!x.matches) return;
|
||||
$('#options-chatandusers:checked').click();
|
||||
$('#options-stickychat:checked').click();
|
||||
};
|
||||
const mobileMatch = window.matchMedia('(max-width: 800px)');
|
||||
mobileMatch.addListener(checkChatAndUsersVisibility);
|
||||
setTimeout(() => { checkChatAndUsersVisibility(mobileMatch); }, 0);
|
||||
|
||||
if (clientVars.chatHead !== -1) {
|
||||
const chatHead = clientVars.chatHead;
|
||||
const start = Math.max(chatHead - 100, 0);
|
||||
pad.collabClient.sendMessage({type: 'GET_CHAT_MESSAGES', start, end: chatHead});
|
||||
} else {
|
||||
$('#chatloadmessagesbutton').css('display', 'none');
|
||||
}
|
||||
|
||||
if (clientVars.readonly) {
|
||||
exports.chat.hide();
|
||||
$('#chatinput').attr('disabled', true);
|
||||
$('#options-chatandusers').parent().hide();
|
||||
$('#options-stickychat').parent().hide();
|
||||
} else if (!pad.settings.hideChat) {
|
||||
$('#chaticon').show();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue