From dd9dec5d1cbc83a37a1f9913eee9ecf10ef29401 Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 14 Mar 2014 20:21:00 +0100 Subject: [PATCH] Frontend stuff --- client/css/style.css | 6 ------ client/js/chat.js | 29 +++++++++++++++++++---------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 3a7d5c74..4e9789ce 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -31,12 +31,6 @@ h2 { margin: 10px 0; padding: 0 10px; } -#sidebar .list-group-item:hover { - color: #000; -} -#sidebar .list-group-item:first-child { - background: #f5f5f5; -} #chat { bottom: 0; left: 200px; diff --git a/client/js/chat.js b/client/js/chat.js index dc1043a4..7c5e2513 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -14,7 +14,7 @@ $(function() { var chat = $("#chat"); var sidebar = $("#sidebar"); - + // Templates var networks = $("#networks").html(); var channels = $("#channels").html(); @@ -41,16 +41,16 @@ $(function() { Mustache.render(networks, { networks: data }) - ); + ).find(".channel") + .last() + .addClass("active"); chat.find(".messages").sticky().scrollToBottom(); chat.find(".window") // Sort windows by `data-id` value. .sort(function(a, b) { return ($(a).data("id") - $(b).data("id")); }) .last() - .bringToTop() - .find(".input") - .focus(); + .bringToTop(); break; case "users": @@ -78,19 +78,28 @@ $(function() { }); sidebar.on("click", ".channel", function(e) { - e.preventDefault(); + sidebar.find(".active").removeClass("active"); + $(this).addClass("active"); + chat.find(".window[data-id='" + $(this).data("id") + "']") .bringToTop(); + + // Prevent link from triggering + e.preventDefault(); }); }); (function($) { var highest = 1; $.fn.bringToTop = function() { - return this - .css('z-index', highest++) - .find("input") - .focus(); + return this.css('z-index', highest++) + .addClass("active") + .find(".input") + .focus() + .end() + .siblings() + .removeClass("active") + .end(); }; })(jQuery);