From a837ed270b7d1480568aee551f454fb09e71b97b Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Fri, 19 Sep 2014 16:56:38 -0700 Subject: [PATCH] Sort by z-index on close --- client/css/style.css | 10 +++++----- client/js/shout.js | 29 +++++++++++++++++++++++------ package.json | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/client/css/style.css b/client/css/style.css index 6406c56e..c4e5456b 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -124,7 +124,7 @@ button { margin: 6px -12px 0 12px; } #sidebar { - bottom: 64px; + bottom: 52px; left: 0; overflow: hidden; overflow-y: auto; @@ -219,7 +219,7 @@ button { margin-top: 1px; padding: 3px 6px; position: absolute; - right: 10px; + right: 5px; transition: all .2s; } #sidebar .badge.highlight { @@ -236,7 +236,7 @@ button { border-radius: 3px; height: 18px; margin-top: 1px; - margin-right: 10px; + margin-right: 5px; opacity: 0; position: absolute; right: 0; @@ -255,9 +255,9 @@ button { background: rgba(0, 0, 0, .06); border-radius: 2px; bottom: 4px; - height: 60px; + height: 48px; left: 5px; - line-height: 60px; + line-height: 48px; position: absolute; text-align: center; width: 210px; diff --git a/client/js/shout.js b/client/js/shout.js index f354d25f..90333e8d 100644 --- a/client/js/shout.js +++ b/client/js/shout.js @@ -224,12 +224,29 @@ $(function() { socket.on("part", function(data) { var id = data.chan; - sidebar.find("[data-target=#chan-" + id + "]") - .remove() - .end() - .find(".chan") - .eq(0) - .trigger("click"); + console.log(id); + sidebar.find(".chan[data-id='" + id + "']").remove(); + $("#chan-" + id).remove(); + + var next = null; + var highest = -1; + chat.find(".chan").each(function() { + var self = $(this); + var z = parseInt(self.css("z-index")); + if (z > highest) { + highest = z; + next = self; + } + }); + + if (next !== null) { + var id = next.data("id"); + sidebar.find("[data-id=" + id + "]").click(); + } else { + sidebar.find(".chan") + .eq(0) + .click(); + } }); socket.on("quit", function(data) { diff --git a/package.json b/package.json index fd881ecd..9e90aef2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "shout", "description": "A web IRC client", - "version": "0.31.5", + "version": "0.31.6", "author": "Mattias Erming", "preferGlobal": true, "bin": {