Frontend stuff

This commit is contained in:
Mattias Erming 2014-03-14 20:21:00 +01:00
parent ecc889373e
commit dd9dec5d1c
2 changed files with 19 additions and 16 deletions

View File

@ -31,12 +31,6 @@ h2 {
margin: 10px 0; margin: 10px 0;
padding: 0 10px; padding: 0 10px;
} }
#sidebar .list-group-item:hover {
color: #000;
}
#sidebar .list-group-item:first-child {
background: #f5f5f5;
}
#chat { #chat {
bottom: 0; bottom: 0;
left: 200px; left: 200px;

View File

@ -14,7 +14,7 @@ $(function() {
var chat = $("#chat"); var chat = $("#chat");
var sidebar = $("#sidebar"); var sidebar = $("#sidebar");
// Templates // Templates
var networks = $("#networks").html(); var networks = $("#networks").html();
var channels = $("#channels").html(); var channels = $("#channels").html();
@ -41,16 +41,16 @@ $(function() {
Mustache.render(networks, { Mustache.render(networks, {
networks: data networks: data
}) })
); ).find(".channel")
.last()
.addClass("active");
chat.find(".messages").sticky().scrollToBottom(); chat.find(".messages").sticky().scrollToBottom();
chat.find(".window") chat.find(".window")
// Sort windows by `data-id` value. // Sort windows by `data-id` value.
.sort(function(a, b) { return ($(a).data("id") - $(b).data("id")); }) .sort(function(a, b) { return ($(a).data("id") - $(b).data("id")); })
.last() .last()
.bringToTop() .bringToTop();
.find(".input")
.focus();
break; break;
case "users": case "users":
@ -78,19 +78,28 @@ $(function() {
}); });
sidebar.on("click", ".channel", function(e) { sidebar.on("click", ".channel", function(e) {
e.preventDefault(); sidebar.find(".active").removeClass("active");
$(this).addClass("active");
chat.find(".window[data-id='" + $(this).data("id") + "']") chat.find(".window[data-id='" + $(this).data("id") + "']")
.bringToTop(); .bringToTop();
// Prevent link from triggering
e.preventDefault();
}); });
}); });
(function($) { (function($) {
var highest = 1; var highest = 1;
$.fn.bringToTop = function() { $.fn.bringToTop = function() {
return this return this.css('z-index', highest++)
.css('z-index', highest++) .addClass("active")
.find("input") .find(".input")
.focus(); .focus()
.end()
.siblings()
.removeClass("active")
.end();
}; };
})(jQuery); })(jQuery);