mirror of https://github.com/zulip/zulip.git
Make the back button work for the settings and subscriptions pages
(imported from commit 650c884abc9514cdfc934ae01e0a490f5f681292)
This commit is contained in:
parent
f4ddf4412b
commit
4feae6b202
|
@ -73,7 +73,7 @@ exports.start = function (msg_type, opts) {
|
|||
compose.message_content(opts.message);
|
||||
}
|
||||
|
||||
$('#sidebar a[href="#home"]').tab('show');
|
||||
ui.change_tab_to("#home");
|
||||
|
||||
var focus_area;
|
||||
if (opts.stream && ! opts.subject) {
|
||||
|
|
|
@ -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") {
|
||||
switch (hash[0]) {
|
||||
case "#narrow":
|
||||
ui.change_tab_to("#home");
|
||||
narrow.hashchanged(hash);
|
||||
ui.update_floating_recipient_bar();
|
||||
}
|
||||
else if (narrow.active()) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ exports.home_tab_obscured = function () {
|
|||
var scroll_positions = {};
|
||||
var gravatar_stamp = 1;
|
||||
|
||||
exports.change_tab_to = function (tabname) {
|
||||
$('#sidebar a[href="' + tabname + '"]').tab('show');
|
||||
};
|
||||
|
||||
exports.focus_on = function (field_id) {
|
||||
// Call after autocompleting on a field, to advance the focus to
|
||||
// the next input field.
|
||||
|
@ -505,9 +509,9 @@ $(function () {
|
|||
// Set the URL bar title to show the sub-page you're currently on.
|
||||
var browser_url = target_tab;
|
||||
if (browser_url === "#home") {
|
||||
browser_url = "#";
|
||||
browser_url = "";
|
||||
}
|
||||
window.history.pushState("object or string", "Title", browser_url);
|
||||
hashchange.changehash(browser_url);
|
||||
});
|
||||
|
||||
$('#sidebar a[href="#subscriptions"]').click(subs.fetch);
|
||||
|
|
Loading…
Reference in New Issue