mirror of https://github.com/calzoneman/sync.git
Fix autoscrolling changes
This commit is contained in:
parent
59468ec77c
commit
b0d5e92350
|
@ -657,6 +657,7 @@ input#logout[type="submit"]:hover {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#newmessages-indicator .glyphicon {
|
#newmessages-indicator .glyphicon {
|
||||||
|
|
|
@ -46,6 +46,7 @@ var CHATHISTIDX = 0;
|
||||||
var CHATTHROTTLE = false;
|
var CHATTHROTTLE = false;
|
||||||
var CHATMAXSIZE = 100;
|
var CHATMAXSIZE = 100;
|
||||||
var SCROLLCHAT = true;
|
var SCROLLCHAT = true;
|
||||||
|
var IGNORE_SCROLL_EVENT = false;
|
||||||
var LASTCHAT = {
|
var LASTCHAT = {
|
||||||
name: ""
|
name: ""
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,7 +81,14 @@ $("#usercount").mouseleave(function () {
|
||||||
$("#usercount").find(".profile-box").remove();
|
$("#usercount").find(".profile-box").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#messagebuffer").scroll(function () {
|
$("#messagebuffer").scroll(function (ev) {
|
||||||
|
if (IGNORE_SCROLL_EVENT) {
|
||||||
|
// Skip event, this was triggered by scrollChat() and not by a user action.
|
||||||
|
// Reset for next event.
|
||||||
|
IGNORE_SCROLL_EVENT = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var m = $("#messagebuffer");
|
var m = $("#messagebuffer");
|
||||||
var isCaughtUp = m.height() + m.scrollTop() >= m.prop("scrollHeight");
|
var isCaughtUp = m.height() + m.scrollTop() >= m.prop("scrollHeight");
|
||||||
if (isCaughtUp) {
|
if (isCaughtUp) {
|
||||||
|
|
|
@ -820,10 +820,15 @@ function showPollMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollChat() {
|
function scrollChat() {
|
||||||
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
scrollAndIgnoreEvent($("#messagebuffer").prop("scrollHeight"));
|
||||||
$("#newmessages-indicator").remove();
|
$("#newmessages-indicator").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollAndIgnoreEvent(top) {
|
||||||
|
IGNORE_SCROLL_EVENT = true;
|
||||||
|
$("#messagebuffer").scrollTop(top);
|
||||||
|
}
|
||||||
|
|
||||||
function hasPermission(key) {
|
function hasPermission(key) {
|
||||||
if(key.indexOf("playlist") == 0 && CHANNEL.openqueue) {
|
if(key.indexOf("playlist") == 0 && CHANNEL.openqueue) {
|
||||||
var key2 = "o" + key;
|
var key2 = "o" + key;
|
||||||
|
@ -1455,12 +1460,6 @@ function formatChatMessage(data, last) {
|
||||||
if (data.meta.shadow) {
|
if (data.meta.shadow) {
|
||||||
div.addClass("chat-shadow");
|
div.addClass("chat-shadow");
|
||||||
}
|
}
|
||||||
|
|
||||||
div.find("img").load(function () {
|
|
||||||
if (SCROLLCHAT) {
|
|
||||||
scrollChat();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1472,17 +1471,19 @@ function addChatMessage(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var div = formatChatMessage(data, LASTCHAT);
|
var div = formatChatMessage(data, LASTCHAT);
|
||||||
|
var msgBuf = $("#messagebuffer");
|
||||||
// Incoming: a bunch of crap for the feature where if you hover over
|
// Incoming: a bunch of crap for the feature where if you hover over
|
||||||
// a message, it highlights messages from that user
|
// a message, it highlights messages from that user
|
||||||
var safeUsername = data.username.replace(/[^\w-]/g, '\\$');
|
var safeUsername = data.username.replace(/[^\w-]/g, '\\$');
|
||||||
div.addClass("chat-msg-" + safeUsername);
|
div.addClass("chat-msg-" + safeUsername);
|
||||||
div.appendTo($("#messagebuffer"));
|
div.appendTo(msgBuf);
|
||||||
div.mouseover(function() {
|
div.mouseover(function() {
|
||||||
$(".chat-msg-" + safeUsername).addClass("nick-hover");
|
$(".chat-msg-" + safeUsername).addClass("nick-hover");
|
||||||
});
|
});
|
||||||
div.mouseleave(function() {
|
div.mouseleave(function() {
|
||||||
$(".nick-hover").removeClass("nick-hover");
|
$(".nick-hover").removeClass("nick-hover");
|
||||||
});
|
});
|
||||||
|
var oldHeight = msgBuf.prop("scrollHeight");
|
||||||
var numRemoved = trimChatBuffer();
|
var numRemoved = trimChatBuffer();
|
||||||
if (SCROLLCHAT) {
|
if (SCROLLCHAT) {
|
||||||
scrollChat();
|
scrollChat();
|
||||||
|
@ -1499,14 +1500,27 @@ function addChatMessage(data) {
|
||||||
$("<span/>").text("New Messages Below").appendTo(bgHack);
|
$("<span/>").text("New Messages Below").appendTo(bgHack);
|
||||||
$("<span/>").addClass("glyphicon glyphicon-chevron-down")
|
$("<span/>").addClass("glyphicon glyphicon-chevron-down")
|
||||||
.appendTo(bgHack);
|
.appendTo(bgHack);
|
||||||
|
newMessageDiv.click(function () {
|
||||||
|
SCROLLCHAT = true;
|
||||||
|
scrollChat();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numRemoved > 0) {
|
if (numRemoved > 0) {
|
||||||
$("#messagebuffer").scrollTop(
|
IGNORE_SCROLL_EVENT = true;
|
||||||
$("#messagebuffer").scrollTop() - div.height());
|
var diff = oldHeight - msgBuf.prop("scrollHeight");
|
||||||
|
scrollAndIgnoreEvent(msgBuf.scrollTop() - diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.find("img").load(function () {
|
||||||
|
if (SCROLLCHAT) {
|
||||||
|
scrollChat();
|
||||||
|
} else if ($(this).position().top < 0) {
|
||||||
|
scrollAndIgnoreEvent(msgBuf.scrollTop() + $(this).height());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var isHighlight = false;
|
var isHighlight = false;
|
||||||
if (CLIENT.name && data.username != CLIENT.name) {
|
if (CLIENT.name && data.username != CLIENT.name) {
|
||||||
if (data.msg.toLowerCase().indexOf(CLIENT.name.toLowerCase()) != -1) {
|
if (data.msg.toLowerCase().indexOf(CLIENT.name.toLowerCase()) != -1) {
|
||||||
|
|
Loading…
Reference in New Issue