Move 'show more' to same event file

This commit is contained in:
Pavel Djundik 2017-09-05 19:10:48 +03:00
parent 17af195994
commit 41b9ffb5e7
2 changed files with 18 additions and 18 deletions

View file

@ -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() {

View file

@ -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
});
});