Files
zulip/zephyr/static/js/hashchange.js
Jeff Arnold f4ddf4412b Make it possible to paste a #narrow URL into a new tab
(imported from commit 0a2ac3e7100627fd02874b02c1b5abe6d4b58c77)
2012-12-20 14:45:11 -05:00

40 lines
942 B
JavaScript

var hashchange = (function () {
var exports = {};
var expected_hash = false;
exports.changehash = function (newhash) {
expected_hash = newhash;
window.location.hash = newhash;
};
function hashchanged() {
// If window.location.hash changed because our app explicitly
// changed it, then we don't need to do anything.
// (This function only neds to jump into action if it changed
// because e.g. the back button was pressed by the user)
if (window.location.hash === expected_hash) {
return;
}
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();
}
}
exports.initialize = function () {
window.onhashchange = hashchanged;
hashchanged();
};
return exports;
}());