mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Merge pull request #3264 from takluyver/i3263
Change the path to create notebooks in when navigating directories
This commit is contained in:
commit
b96d75846d
@ -13,7 +13,6 @@ define([
|
|||||||
var NewNotebookWidget = function (selector, options) {
|
var NewNotebookWidget = function (selector, options) {
|
||||||
this.selector = selector;
|
this.selector = selector;
|
||||||
this.base_url = options.base_url;
|
this.base_url = options.base_url;
|
||||||
this.notebook_path = options.notebook_path;
|
|
||||||
this.contents = options.contents;
|
this.contents = options.contents;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.default_kernel = null;
|
this.default_kernel = null;
|
||||||
@ -74,12 +73,13 @@ define([
|
|||||||
this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
|
this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
|
||||||
};
|
};
|
||||||
|
|
||||||
NewNotebookWidget.prototype.new_notebook = function (kernel_name) {
|
NewNotebookWidget.prototype.new_notebook = function (kernel_name, evt) {
|
||||||
/** create and open a new notebook */
|
/** create and open a new notebook */
|
||||||
var that = this;
|
var that = this;
|
||||||
kernel_name = kernel_name || this.default_kernel;
|
kernel_name = kernel_name || this.default_kernel;
|
||||||
var w = window.open(undefined, IPython._target);
|
var w = window.open(undefined, IPython._target);
|
||||||
this.contents.new_untitled(that.notebook_path, {type: "notebook"}).then(
|
var dir_path = $('body').attr('data-notebook-path');
|
||||||
|
this.contents.new_untitled(dir_path, {type: "notebook"}).then(
|
||||||
function (data) {
|
function (data) {
|
||||||
var url = utils.url_path_join(
|
var url = utils.url_path_join(
|
||||||
that.base_url, 'notebooks',
|
that.base_url, 'notebooks',
|
||||||
@ -107,6 +107,9 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (evt !== undefined) {
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {'NewNotebookWidget': NewNotebookWidget};
|
return {'NewNotebookWidget': NewNotebookWidget};
|
||||||
|
@ -169,6 +169,7 @@ define([
|
|||||||
console.warn('Error during New file creation', e);
|
console.warn('Error during New file creation', e);
|
||||||
});
|
});
|
||||||
that.load_sessions();
|
that.load_sessions();
|
||||||
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('#new-folder').click(function(e) {
|
$('#new-folder').click(function(e) {
|
||||||
that.contents.new_untitled(that.notebook_path || '', {type: 'directory'})
|
that.contents.new_untitled(that.notebook_path || '', {type: 'directory'})
|
||||||
@ -189,6 +190,7 @@ define([
|
|||||||
console.warn('Error during New directory creation', e);
|
console.warn('Error during New directory creation', e);
|
||||||
});
|
});
|
||||||
that.load_sessions();
|
that.load_sessions();
|
||||||
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Bind events for action buttons.
|
// Bind events for action buttons.
|
||||||
@ -373,8 +375,8 @@ define([
|
|||||||
breadcrumb.append(root);
|
breadcrumb.append(root);
|
||||||
var path_parts = [];
|
var path_parts = [];
|
||||||
this.notebook_path.split('/').forEach(function(path_part) {
|
this.notebook_path.split('/').forEach(function(path_part) {
|
||||||
path_parts.push(path_part)
|
path_parts.push(path_part);
|
||||||
var path = path_parts.join('/')
|
var path = path_parts.join('/');
|
||||||
var url = utils.url_path_join(
|
var url = utils.url_path_join(
|
||||||
that.base_url,
|
that.base_url,
|
||||||
'/tree',
|
'/tree',
|
||||||
@ -399,6 +401,7 @@ define([
|
|||||||
|
|
||||||
NotebookList.prototype.update_location = function (path) {
|
NotebookList.prototype.update_location = function (path) {
|
||||||
this.notebook_path = path;
|
this.notebook_path = path;
|
||||||
|
$('body').attr('data-notebook-path', path);
|
||||||
// Update the file tree list without reloading the page
|
// Update the file tree list without reloading the page
|
||||||
this.load_list();
|
this.load_list();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user