Added stickyscroll

This commit is contained in:
Mattias Erming 2014-07-05 02:31:20 +02:00
parent d38c5c77d4
commit 9491de4cb1
5 changed files with 73 additions and 7 deletions

View file

@ -0,0 +1,58 @@
/*!
* stickyscroll
* https://github.com/erming/stickyscroll
* v2.1.0
*/
(function($) {
$.fn.sticky = function() {
if (this.size() > 1) {
return self.each(function() {
$(this).sticky(options);
});
}
var isBottom = false;
var self = this;
this.on("beforeAppend", function() {
isBottom = isScrollBottom.call(self);
});
this.on("afterAppend", function() {
if (isBottom) {
self.scrollBottom();
}
});
var overflow = this.css("overflow-y");
if (overflow == "visible") {
overflow = "auto";
}
this.css({
"overflow-y": overflow
});
return this;
};
$.fn.scrollBottom = function() {
return this.each(function() {
$(this).animate({scrollTop: this.scrollHeight}, 0);
});
};
function isScrollBottom() {
if ((this.scrollTop() + this.outerHeight() + 1) >= this.prop("scrollHeight")) {
return true;
} else {
return false;
}
};
var append = $.fn.append;
$.fn.append = function() {
this.trigger("beforeAppend");
append.apply(this, arguments).trigger("afterAppend")
return this;
};
})(jQuery);

View file

@ -174,7 +174,6 @@ button {
bottom: 40px;
left: 0;
position: absolute;
overflow: auto;
right: 180px;
top: 0;
}
@ -230,6 +229,9 @@ button {
padding-left: 10px;
padding-right: 6px;
}
#messages .text a {
word-break: break-all;
}
#messages .type {
color: #ccc;
display: none;
@ -310,9 +312,10 @@ button {
#form input {
border: 0;
border-top: 1px solid #e9ecef;
font: 13px Consolas, monospace;
height: 100%;
outline: none;
padding: 0 10px;
padding: 0 12px;
width: 100%;
}
#submit {

View file

@ -49,6 +49,7 @@ $(function() {
});
socket.on("init", function(data) {
console.log("INIT");
networks.empty();
channels = $.map(data.networks, function(n) {
return n.channels;
@ -73,6 +74,9 @@ $(function() {
channels: [data.chan]
})
);
network.find(".chan")
.last()
.trigger("click");
});
socket.on("msg", function(data) {
@ -156,9 +160,10 @@ $(function() {
var chan = find(id);
if (typeof chan !== "undefined") {
activeChannel = chan;
chat.html(
render("chat", chan)
);
chat.html(render("chat", chan));
chat.find(".window")
.sticky()
.scrollBottom();
}
});

File diff suppressed because one or more lines are too long

View file

@ -9,7 +9,7 @@ module.exports = function(network, chan, cmd, args) {
var client = this;
var irc = network.irc;
if (args.length === 0) {
if (args.length === 0 || args[0] == "") {
return;
}