Show More
@@ -8119,7 +8119,7 b' input.engine_num_input {' | |||||
8119 | .file_icon:before.pull-right { |
|
8119 | .file_icon:before.pull-right { | |
8120 | margin-left: .3em; |
|
8120 | margin-left: .3em; | |
8121 | } |
|
8121 | } | |
8122 |
ul#new- |
|
8122 | ul#new-menu { | |
8123 | left: auto; |
|
8123 | left: auto; | |
8124 | right: 0; |
|
8124 | right: 0; | |
8125 | } |
|
8125 | } |
@@ -71,7 +71,7 b' require([' | |||||
71 |
|
71 | |||
72 | var login_widget = new loginwidget.LoginWidget('#login_widget', common_options); |
|
72 | var login_widget = new loginwidget.LoginWidget('#login_widget', common_options); | |
73 |
|
73 | |||
74 |
var n |
|
74 | var new_buttons = new newnotebook.NewNotebookWidget("#new-buttons", | |
75 | $.extend( |
|
75 | $.extend( | |
76 | {contents: contents}, |
|
76 | {contents: contents}, | |
77 | common_options |
|
77 | common_options | |
@@ -130,7 +130,7 b' require([' | |||||
130 | IPython.session_list = session_list; |
|
130 | IPython.session_list = session_list; | |
131 | IPython.kernel_list = kernel_list; |
|
131 | IPython.kernel_list = kernel_list; | |
132 | IPython.login_widget = login_widget; |
|
132 | IPython.login_widget = login_widget; | |
133 |
IPython.new_notebook_widget = n |
|
133 | IPython.new_notebook_widget = new_buttons; | |
134 |
|
134 | |||
135 | events.trigger('app_initialized.DashboardApp'); |
|
135 | events.trigger('app_initialized.DashboardApp'); | |
136 |
|
136 |
@@ -15,7 +15,6 b' define([' | |||||
15 | this.notebook_path = options.notebook_path; |
|
15 | this.notebook_path = options.notebook_path; | |
16 | this.contents = options.contents; |
|
16 | this.contents = options.contents; | |
17 | this.default_kernel = null; |
|
17 | this.default_kernel = null; | |
18 | this.config = options.config; |
|
|||
19 | this.kernelspecs = {}; |
|
18 | this.kernelspecs = {}; | |
20 | if (this.selector !== undefined) { |
|
19 | if (this.selector !== undefined) { | |
21 | this.element = $(selector); |
|
20 | this.element = $(selector); | |
@@ -41,7 +40,7 b' define([' | |||||
41 | /** load kernelspec list */ |
|
40 | /** load kernelspec list */ | |
42 | var that = this; |
|
41 | var that = this; | |
43 | this.kernelspecs = data.kernelspecs; |
|
42 | this.kernelspecs = data.kernelspecs; | |
44 |
var menu = this.element.find("#n |
|
43 | var menu = this.element.find("#notebook-kernels"); | |
45 | var keys = Object.keys(data.kernelspecs).sort(function (a, b) { |
|
44 | var keys = Object.keys(data.kernelspecs).sort(function (a, b) { | |
46 | var da = data.kernelspecs[a].display_name; |
|
45 | var da = data.kernelspecs[a].display_name; | |
47 | var db = data.kernelspecs[b].display_name; |
|
46 | var db = data.kernelspecs[b].display_name; | |
@@ -64,45 +63,8 b' define([' | |||||
64 | .text(ks.display_name) |
|
63 | .text(ks.display_name) | |
65 | .attr('title', 'Create a new notebook with ' + ks.display_name) |
|
64 | .attr('title', 'Create a new notebook with ' + ks.display_name) | |
66 | ); |
|
65 | ); | |
67 |
menu.a |
|
66 | menu.after(li); | |
68 | } |
|
67 | } | |
69 | this.config.loaded.then(function () { |
|
|||
70 | that._load_default_kernelspec(data['default']); |
|
|||
71 | }); |
|
|||
72 | }; |
|
|||
73 |
|
||||
74 | NewNotebookWidget.prototype._load_default_kernelspec = function (default_name) { |
|
|||
75 | /** load default kernelspec name from config, if defined */ |
|
|||
76 | if (this.config.data.NewNotebookWidget && |
|
|||
77 | this.config.data.NewNotebookWidget.default_kernel && |
|
|||
78 | this.kernelspecs[this.config.data.NewNotebookWidget.default_kernel] !== undefined |
|
|||
79 | ) { |
|
|||
80 | default_name = this.config.data.NewNotebookWidget.default_kernel; |
|
|||
81 | } |
|
|||
82 | this.set_default_kernel(default_name); |
|
|||
83 | }; |
|
|||
84 |
|
||||
85 | NewNotebookWidget.prototype.set_default_kernel = function (kernel_name) { |
|
|||
86 | /** select the current default kernel */ |
|
|||
87 | this.default_kernel = kernel_name; |
|
|||
88 | this.config.update({ |
|
|||
89 | NewNotebookWidget: { |
|
|||
90 | default_kernel: kernel_name |
|
|||
91 | } |
|
|||
92 | }); |
|
|||
93 | var spec = this.kernelspecs[kernel_name]; |
|
|||
94 | var display_name; |
|
|||
95 | if (spec) { |
|
|||
96 | display_name = spec.display_name; |
|
|||
97 | this.element.find("#current-kernel") |
|
|||
98 | .text(display_name) |
|
|||
99 | .attr('title', display_name + " is the default kernel for new notebooks"); |
|
|||
100 | } else { |
|
|||
101 | display_name = 'default kernel'; |
|
|||
102 | } |
|
|||
103 | this.element.find("#new_notebook").attr('title', |
|
|||
104 | 'Create a new notebook with ' + display_name |
|
|||
105 | ); |
|
|||
106 | }; |
|
68 | }; | |
107 |
|
69 | |||
108 | NewNotebookWidget.prototype.new_notebook = function (kernel_name) { |
|
70 | NewNotebookWidget.prototype.new_notebook = function (kernel_name) { |
@@ -7,7 +7,8 b' define([' | |||||
7 | 'base/js/utils', |
|
7 | 'base/js/utils', | |
8 | 'base/js/dialog', |
|
8 | 'base/js/dialog', | |
9 | 'base/js/events', |
|
9 | 'base/js/events', | |
10 | ], function(IPython, $, utils, dialog, events) { |
|
10 | 'base/js/keyboard', | |
|
11 | ], function(IPython, $, utils, dialog, events, keyboard) { | |||
11 | "use strict"; |
|
12 | "use strict"; | |
12 |
|
13 | |||
13 | var NotebookList = function (selector, options) { |
|
14 | var NotebookList = function (selector, options) { | |
@@ -54,7 +55,6 b' define([' | |||||
54 | this.element.addClass("list_container"); |
|
55 | this.element.addClass("list_container"); | |
55 | }; |
|
56 | }; | |
56 |
|
57 | |||
57 |
|
||||
58 | NotebookList.prototype.bind_events = function () { |
|
58 | NotebookList.prototype.bind_events = function () { | |
59 | var that = this; |
|
59 | var that = this; | |
60 | $('#refresh_' + this.element_name + '_list').click(function () { |
|
60 | $('#refresh_' + this.element_name + '_list').click(function () { | |
@@ -67,6 +67,25 b' define([' | |||||
67 | that.handleFilesUpload(event,'drop'); |
|
67 | that.handleFilesUpload(event,'drop'); | |
68 | return false; |
|
68 | return false; | |
69 | }); |
|
69 | }); | |
|
70 | ||||
|
71 | // Bind events for singleton controls. | |||
|
72 | if (!NotebookList._bound_singletons) { | |||
|
73 | NotebookList._bound_singletons = true; | |||
|
74 | $('#new-file').click(function(e) { | |||
|
75 | var w = window.open(); | |||
|
76 | that.contents.new_untitled(that.notebook_path || '', {type: 'file', ext: '.txt'}).then(function(data) { | |||
|
77 | var url = utils.url_join_encode( | |||
|
78 | that.base_url, 'edit', data.path | |||
|
79 | ); | |||
|
80 | w.location = url; | |||
|
81 | }); | |||
|
82 | that.load_sessions(); | |||
|
83 | }); | |||
|
84 | $('#new-folder').click(function(e) { | |||
|
85 | that.contents.new_untitled(that.notebook_path || '', {type: 'directory'}); | |||
|
86 | that.load_sessions(); | |||
|
87 | }); | |||
|
88 | } | |||
70 | }; |
|
89 | }; | |
71 |
|
90 | |||
72 | NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) { |
|
91 | NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) { |
@@ -156,7 +156,7 b' input.engine_num_input {' | |||||
156 | .icon(@fa-var-file-o) |
|
156 | .icon(@fa-var-file-o) | |
157 | } |
|
157 | } | |
158 |
|
158 | |||
159 |
ul#new- |
|
159 | ul#new-menu { | |
160 | // align right instead of left |
|
160 | // align right instead of left | |
161 | left: auto; |
|
161 | left: auto; | |
162 | right: 0; |
|
162 | right: 0; |
@@ -42,16 +42,22 b' data-terminals-available="{{terminals_available}}"' | |||||
42 | </span> |
|
42 | </span> | |
43 | </span> |
|
43 | </span> | |
44 | </form> |
|
44 | </form> | |
45 |
<div |
|
45 | <div class="pull-right"> | |
46 |
<div id="new- |
|
46 | <div id="new-buttons" class="btn-group"> | |
47 | <button id="new_notebook" class="btn btn-default btn-xs"> |
|
|||
48 | New Notebook |
|
|||
49 | </button> |
|
|||
50 | <button class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown"> |
|
47 | <button class="dropdown-toggle btn btn-default btn-xs" data-toggle="dropdown"> | |
51 |
<span |
|
48 | <span>New</span> | |
52 | <span class="caret"></span> |
|
49 | <span class="caret"></span> | |
53 | </button> |
|
50 | </button> | |
54 |
<ul id="new- |
|
51 | <ul id="new-menu" class="dropdown-menu"> | |
|
52 | <li role="presentation" id="new-file"> | |||
|
53 | <a role="menuitem" tabindex="-1" href="#">File</a> | |||
|
54 | </li> | |||
|
55 | <li role="presentation" id="new-folder"> | |||
|
56 | <a role="menuitem" tabindex="-1" href="#">Folder</a> | |||
|
57 | </li> | |||
|
58 | <li role="presentation" class="divider"></li> | |||
|
59 | <li role="presentation" class="dropdown-header" id="notebook-kernels">Notebooks</li> | |||
|
60 | </ul> | |||
55 | </div> |
|
61 | </div> | |
56 | <div class="btn-group"> |
|
62 | <div class="btn-group"> | |
57 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
|
63 | <button id="refresh_notebook_list" title="Refresh notebook list" class="btn btn-default btn-xs"><i class="fa fa-refresh"></i></button> |
@@ -13,7 +13,8 b' casper.open_new_notebook = function () {' | |||||
13 | var baseUrl = this.get_notebook_server(); |
|
13 | var baseUrl = this.get_notebook_server(); | |
14 | this.start(baseUrl); |
|
14 | this.start(baseUrl); | |
15 | this.waitFor(this.page_loaded); |
|
15 | this.waitFor(this.page_loaded); | |
16 | this.thenClick('button#new_notebook'); |
|
16 | this.thenClick('#kernel-python2 a, #kernel-python3 a'); | |
|
17 | ||||
17 | this.waitForPopup(''); |
|
18 | this.waitForPopup(''); | |
18 |
|
19 | |||
19 | this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');}); |
|
20 | this.withPopup('', function () {this.waitForSelector('.CodeMirror-code');}); |
General Comments 0
You need to be logged in to leave comments.
Login now