mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
Make the back button work for the settings and subscriptions pages
(imported from commit 650c884abc9514cdfc934ae01e0a490f5f681292)
This commit is contained in:
@@ -6,7 +6,18 @@ var expected_hash = false;
|
||||
|
||||
exports.changehash = function (newhash) {
|
||||
expected_hash = newhash;
|
||||
// Some browsers reset scrollTop when changing the hash to "",
|
||||
// so we save and restore it.
|
||||
// http://stackoverflow.com/questions/4715073/window-location-hash-prevent-scrolling-to-the-top
|
||||
var scrolltop;
|
||||
if (newhash === "") {
|
||||
scrolltop = viewport.scrollTop();
|
||||
}
|
||||
window.location.hash = newhash;
|
||||
util.reset_favicon();
|
||||
if (newhash === "") {
|
||||
viewport.scrollTop(scrolltop);
|
||||
}
|
||||
};
|
||||
|
||||
function hashchanged() {
|
||||
@@ -19,13 +30,24 @@ function hashchanged() {
|
||||
}
|
||||
|
||||
var hash = window.location.hash.split("/");
|
||||
if (hash[0] === "#narrow") {
|
||||
narrow.hashchanged(hash);
|
||||
ui.update_floating_recipient_bar();
|
||||
}
|
||||
else if (narrow.active()) {
|
||||
narrow.show_all_messages();
|
||||
ui.update_floating_recipient_bar();
|
||||
switch (hash[0]) {
|
||||
case "#narrow":
|
||||
ui.change_tab_to("#home");
|
||||
narrow.hashchanged(hash);
|
||||
ui.update_floating_recipient_bar();
|
||||
break;
|
||||
case "":
|
||||
case "#":
|
||||
ui.change_tab_to("#home");
|
||||
narrow.show_all_messages();
|
||||
ui.update_floating_recipient_bar();
|
||||
break;
|
||||
case "#subscriptions":
|
||||
ui.change_tab_to("#subscriptions");
|
||||
break;
|
||||
case "#settings":
|
||||
ui.change_tab_to("#settings");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user