Use location.hash to remember active window

This commit is contained in:
Mattias Erming 2014-05-07 16:01:46 +02:00
parent 53257ee2b2
commit c7de3a897d
1 changed files with 23 additions and 8 deletions

View File

@ -79,14 +79,24 @@ $(function() {
.prev(".show-more")
.show();
chat.find(".messages")
.scrollGlue({speed: 400});
.scrollGlue({speed: 400})
.end();
$("#networks")
.html(render("networks", {networks: data.networks}))
.parent()
.find("button")
.first()
.trigger("click");
var networks = $("#networks")
.html(render("networks", {networks: data.networks}));
var target = null;
if (location.hash) {
var id = location.hash;
target = sidebar
.find("button[data-target='" + id + "']");
} else {
target = sidebar
.find("button")
.first()
}
target.trigger("click");
break;
case "part":
@ -107,12 +117,17 @@ $(function() {
sidebar.on("click", "button", function() {
var button = $(this);
var target = button.data("target");
location.hash = target;
sidebar.find(".active").removeClass("active");
button.addClass("active")
.find(".badge")
.removeClass("highlight")
.empty();
$(target).css("z-index", z++)
var window = $(target)
.css("z-index", z++)
.find("input")
.focus();
});