From 41b9ffb5e78f0e04b67dcbbe07384a817f89c5d2 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 5 Sep 2017 19:10:48 +0300 Subject: [PATCH] Move 'show more' to same event file --- client/js/lounge.js | 18 ------------------ client/js/socket-events/more.js | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 785949d7..170b4581 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -479,24 +479,6 @@ $(function() { container.html(templates.user_filtered({matches: result})).show(); }); - chat.on("click", ".show-more-button", function() { - var self = $(this); - var lastMessage = self.parent().next(".messages").children(".msg").first(); - if (lastMessage.is(".condensed")) { - lastMessage = lastMessage.children(".msg").first(); - } - var lastMessageId = parseInt(lastMessage[0].id.replace("msg-", ""), 10); - - self - .text("Loading older messages…") - .prop("disabled", true); - - socket.emit("more", { - target: self.data("id"), - lastId: lastMessageId - }); - }); - var forms = $("#sign-in, #connect, #change-password"); windows.on("show", "#sign-in", function() { diff --git a/client/js/socket-events/more.js b/client/js/socket-events/more.js index 20d5c12d..9183bfef 100644 --- a/client/js/socket-events/more.js +++ b/client/js/socket-events/more.js @@ -54,3 +54,21 @@ socket.on("more", function(data) { .text("Show older messages") .prop("disabled", false); }); + +chat.on("click", ".show-more-button", function() { + var self = $(this); + var lastMessage = self.parent().next(".messages").children(".msg").first(); + if (lastMessage.is(".condensed")) { + lastMessage = lastMessage.children(".msg").first(); + } + var lastMessageId = parseInt(lastMessage[0].id.replace("msg-", ""), 10); + + self + .text("Loading older messages…") + .prop("disabled", true); + + socket.emit("more", { + target: self.data("id"), + lastId: lastMessageId + }); +});