Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clicking with modifiers, page title updates #3282

Merged
merged 2 commits into from Feb 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion notebook/static/tree/js/notebooklist.js
Expand Up @@ -365,6 +365,10 @@ define([
breadcrumb.empty();
var list_item = $('<li/>');
var root = $('<li/>').append('<a href="/tree"><i class="fa fa-folder"></i></a>').click(function(e) {
// Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
if(e.altKey || e.metaKey || e.shiftKey) {
return true;
}
var path = '';
window.history.pushState({
path: path
Expand All @@ -383,6 +387,10 @@ define([
utils.encode_uri_components(path)
);
var crumb = $('<li/>').append('<a href="' + url + '">' + path_part + '</a>').click(function(e) {
// Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
if(e.altKey || e.metaKey || e.shiftKey) {
return true;
}
window.history.pushState({
path: path
}, path, url);
Expand All @@ -404,6 +412,10 @@ define([
$('body').attr('data-notebook-path', path);
// Update the file tree list without reloading the page
this.load_list();
// Update the page title so the browser tab reflects it
// Match how the title appears with a trailing slash or
// "Home" if the page loads from the server.
$('title').text(path ? path+'/' : i18n.msg._("Home"));
};

/**
Expand Down Expand Up @@ -810,8 +822,12 @@ define([
link.attr('target', IPython._target);
} else {
// Replace with a click handler that will use the History API to
// push a new route without reloading the page
// push a new route without reloading the page if the click is
// not modified (e.g., Ctrl-Click)
link.click(function (e) {
if(e.altKey || e.metaKey || e.shiftKey) {
return true;
}
window.history.pushState({
path: model.path
}, model.path, utils.url_path_join(
Expand Down