##// END OF EJS Templates
add choice of kernel for new notebook
Mathieu -
Show More
@@ -1,156 +1,220 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'base/js/utils',
7 'base/js/utils',
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var KernelSelector = function(selector, notebook) {
11 var KernelSelector = function(selector, notebook) {
12 this.selector = selector;
12 this.selector = selector;
13 this.notebook = notebook;
13 this.notebook = notebook;
14 this.notebook.set_kernelselector(this);
14 this.notebook.set_kernelselector(this);
15 this.events = notebook.events;
15 this.events = notebook.events;
16 this.current_selection = null;
16 this.current_selection = null;
17 this.kernelspecs = {};
17 this.kernelspecs = {};
18 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
19 this.element = $(selector);
19 this.element = $(selector);
20 this.request_kernelspecs();
20 this.request_kernelspecs();
21 }
21 }
22 this.bind_events();
22 this.bind_events();
23 // Make the object globally available for user convenience & inspection
23 // Make the object globally available for user convenience & inspection
24 IPython.kernelselector = this;
24 IPython.kernelselector = this;
25 Object.seal(this);
25 Object.seal(this);
26 };
26 };
27
27
28 KernelSelector.prototype.request_kernelspecs = function() {
28 KernelSelector.prototype.request_kernelspecs = function() {
29 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
29 var url = utils.url_join_encode(this.notebook.base_url, 'api/kernelspecs');
30 utils.promising_ajax(url).then($.proxy(this._got_kernelspecs, this));
30 utils.promising_ajax(url).then($.proxy(this._got_kernelspecs, this));
31 };
31 };
32
32
33 KernelSelector.prototype._got_kernelspecs = function(data) {
33 KernelSelector.prototype._got_kernelspecs = function(data) {
34 this.kernelspecs = data.kernelspecs;
34 this.kernelspecs = data.kernelspecs;
35 var change_kernel_submenu = $("#menu-change-kernel-submenu");
35 var change_kernel_submenu = $("#menu-change-kernel-submenu");
36 var new_notebook_submenu = $("#menu-new-notebook-submenu");
37
38 // Create the change kernel submenu
36 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
39 var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
37 // sort by display_name
40 // sort by display_name
38 var da = data.kernelspecs[a].spec.display_name;
41 var da = data.kernelspecs[a].spec.display_name;
39 var db = data.kernelspecs[b].spec.display_name;
42 var db = data.kernelspecs[b].spec.display_name;
40 if (da === db) {
43 if (da === db) {
41 return 0;
44 return 0;
42 } else if (da > db) {
45 } else if (da > db) {
43 return 1;
46 return 1;
44 } else {
47 } else {
45 return -1;
48 return -1;
46 }
49 }
47 });
50 });
48 for (var i = 0; i < keys.length; i++) {
51 for (var i = 0; i < keys.length; i++) {
49 var ks = this.kernelspecs[keys[i]];
52 var ks = this.kernelspecs[keys[i]];
50 var ks_submenu_entry = $("<li>").attr("id", "kernel-submenu-"+ks.name).append($('<a>')
53 var ks_submenu_entry = $("<li>").attr("id", "kernel-submenu-"+ks.name).append($('<a>')
51 .attr('href', '#')
54 .attr('href', '#')
52 .click($.proxy(this.change_kernel, this, ks.name))
55 .click($.proxy(this.change_kernel, this, ks.name))
53 .text(ks.spec.display_name));
56 .text(ks.spec.display_name));
54 change_kernel_submenu.append(ks_submenu_entry);
57 change_kernel_submenu.append(ks_submenu_entry);
55 }
58 }
59
60 // Create the new notebook submenu
61 /** This code is supposed to put the current kernel at the top of the submenu
62 * but at the time _got_kernelspecs gets called, this.notebook.kernel is null
63 *
64 * var current_kernel_name = this.notebook.kernel.name
65 * var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
66 * // sort by display_name, putting the current kernel on top
67 * var da = data.kernelspecs[a].spec.display_name;
68 * var db = data.kernelspecs[b].spec.display_name;
69 * if (da === db) {
70 * return 0;
71 * } else if (db == current_kernel_name || da > db) {
72 * return 1;
73 * } else {
74 * return -1;
75 * }
76 * });
77 */
78
79 /** Uncomment to add header the the new notebook submenu
80 *
81 * new_notebook_submenu.append($("<li>").attr("id","notebook-kernels")
82 * .attr("class","dropdown-header")
83 * .attr("role","presentation")
84 * .text("Notebook"))
85 */
86 for (var i = 0; i < keys.length; i++) {
87 var ks = this.kernelspecs[keys[i]];
88 var ks_submenu_entry = $("<li>").attr("id", "new-notebook-submenu-"+ks.name).append($('<a>')
89 .attr('href', '#')
90 .click($.proxy(this.new_notebook, this, ks.name))
91 .text(ks.spec.display_name));
92 new_notebook_submenu.append(ks_submenu_entry);
93 }
56 };
94 };
57
95
58 KernelSelector.prototype._spec_changed = function (event, ks) {
96 KernelSelector.prototype._spec_changed = function (event, ks) {
59 /** event handler for spec_changed */
97 /** event handler for spec_changed */
60
98
61 // update selection
99 // update selection
62 this.current_selection = ks.name;
100 this.current_selection = ks.name;
63
101
64 // load logo
102 // load logo
65 var logo_img = this.element.find("img.current_kernel_logo");
103 var logo_img = this.element.find("img.current_kernel_logo");
66 $("#kernel_indicator").find('.kernel_indicator_name').text(ks.spec.display_name);
104 $("#kernel_indicator").find('.kernel_indicator_name').text(ks.spec.display_name);
67 if (ks.resources['logo-64x64']) {
105 if (ks.resources['logo-64x64']) {
68 logo_img.attr("src", ks.resources['logo-64x64']);
106 logo_img.attr("src", ks.resources['logo-64x64']);
69 logo_img.show();
107 logo_img.show();
70 } else {
108 } else {
71 logo_img.hide();
109 logo_img.hide();
72 }
110 }
73
111
74 // load kernel css
112 // load kernel css
75 var css_url = ks.resources['kernel.css'];
113 var css_url = ks.resources['kernel.css'];
76 if (css_url) {
114 if (css_url) {
77 $('#kernel-css').attr('href', css_url);
115 $('#kernel-css').attr('href', css_url);
78 } else {
116 } else {
79 $('#kernel-css').attr('href', '');
117 $('#kernel-css').attr('href', '');
80 }
118 }
81
119
82 // load kernel js
120 // load kernel js
83 if (ks.resources['kernel.js']) {
121 if (ks.resources['kernel.js']) {
84 require([ks.resources['kernel.js']],
122 require([ks.resources['kernel.js']],
85 function (kernel_mod) {
123 function (kernel_mod) {
86 if (kernel_mod && kernel_mod.onload) {
124 if (kernel_mod && kernel_mod.onload) {
87 kernel_mod.onload();
125 kernel_mod.onload();
88 } else {
126 } else {
89 console.warn("Kernel " + ks.name + " has a kernel.js file that does not contain "+
127 console.warn("Kernel " + ks.name + " has a kernel.js file that does not contain "+
90 "any asynchronous module definition. This is undefined behavior "+
128 "any asynchronous module definition. This is undefined behavior "+
91 "and not recommended.");
129 "and not recommended.");
92 }
130 }
93 }, function (err) {
131 }, function (err) {
94 console.warn("Failed to load kernel.js from ", ks.resources['kernel.js'], err);
132 console.warn("Failed to load kernel.js from ", ks.resources['kernel.js'], err);
95 }
133 }
96 );
134 );
97 }
135 }
98 };
136 };
99
137
100 KernelSelector.prototype.change_kernel = function (kernel_name) {
138 KernelSelector.prototype.change_kernel = function (kernel_name) {
101 /**
139 /**
102 * TODO, have a methods to set kernel spec directly ?
140 * TODO, have a methods to set kernel spec directly ?
103 **/
141 **/
104 if (kernel_name === this.current_selection) {
142 if (kernel_name === this.current_selection) {
105 return;
143 return;
106 }
144 }
107 var ks = this.kernelspecs[kernel_name];
145 var ks = this.kernelspecs[kernel_name];
108
146
109 try {
147 try {
110 this.notebook.start_session(kernel_name);
148 this.notebook.start_session(kernel_name);
111 } catch (e) {
149 } catch (e) {
112 if (e.name === 'SessionAlreadyStarting') {
150 if (e.name === 'SessionAlreadyStarting') {
113 console.log("Cannot change kernel while waiting for pending session start.");
151 console.log("Cannot change kernel while waiting for pending session start.");
114 } else {
152 } else {
115 // unhandled error
153 // unhandled error
116 throw e;
154 throw e;
117 }
155 }
118 // only trigger spec_changed if change was successful
156 // only trigger spec_changed if change was successful
119 return;
157 return;
120 }
158 }
121 console.log('spec', kernel_name, ks);
159 console.log('spec', kernel_name, ks);
122 this.events.trigger('spec_changed.Kernel', ks);
160 this.events.trigger('spec_changed.Kernel', ks);
123 };
161 };
124
162
163 KernelSelector.prototype.new_notebook = function (kernel_name) {
164
165 var w = window.open();
166 // Create a new notebook in the same path as the current
167 // notebook's path.
168 var that = this;
169 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
170 that.notebook.contents.new_untitled(parent, {type: "notebook"}).then(
171 function (data) {
172 var url = utils.url_join_encode(
173 that.notebook.base_url, 'notebooks', data.path
174 );
175 url += "?kernel_name=" + kernel_name;
176 w.location = url;
177 },
178 function(error) {
179 w.close();
180 dialog.modal({
181 title : 'Creating Notebook Failed',
182 body : "The error was: " + error.message,
183 buttons : {'OK' : {'class' : 'btn-primary'}}
184 });
185 }
186 );
187 };
188
125 KernelSelector.prototype.lock_switch = function() {
189 KernelSelector.prototype.lock_switch = function() {
126 // should set a flag and display warning+reload if user want to
190 // should set a flag and display warning+reload if user want to
127 // re-change kernel. As UI discussion never finish
191 // re-change kernel. As UI discussion never finish
128 // making that a separate PR.
192 // making that a separate PR.
129 console.warn('switching kernel is not guaranteed to work !');
193 console.warn('switching kernel is not guaranteed to work !');
130 };
194 };
131
195
132 KernelSelector.prototype.bind_events = function() {
196 KernelSelector.prototype.bind_events = function() {
133 var that = this;
197 var that = this;
134 this.events.on('spec_changed.Kernel', $.proxy(this._spec_changed, this));
198 this.events.on('spec_changed.Kernel', $.proxy(this._spec_changed, this));
135
199
136 this.events.on('kernel_created.Session', function (event, data) {
200 this.events.on('kernel_created.Session', function (event, data) {
137 if (data.kernel.name !== that.current_selection) {
201 if (data.kernel.name !== that.current_selection) {
138 // If we created a 'python' session, we only know if it's Python
202 // If we created a 'python' session, we only know if it's Python
139 // 3 or 2 on the server's reply, so we fire the event again to
203 // 3 or 2 on the server's reply, so we fire the event again to
140 // set things up.
204 // set things up.
141 var ks = that.kernelspecs[data.kernel.name];
205 var ks = that.kernelspecs[data.kernel.name];
142 that.events.trigger('spec_changed.Kernel', ks);
206 that.events.trigger('spec_changed.Kernel', ks);
143 }
207 }
144 });
208 });
145
209
146 var logo_img = this.element.find("img.current_kernel_logo");
210 var logo_img = this.element.find("img.current_kernel_logo");
147 logo_img.on("load", function() {
211 logo_img.on("load", function() {
148 logo_img.show();
212 logo_img.show();
149 });
213 });
150 logo_img.on("error", function() {
214 logo_img.on("error", function() {
151 logo_img.hide();
215 logo_img.hide();
152 });
216 });
153 };
217 };
154
218
155 return {'KernelSelector': KernelSelector};
219 return {'KernelSelector': KernelSelector};
156 });
220 });
@@ -1,426 +1,432 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'jquery',
5 'jquery',
6 'base/js/namespace',
6 'base/js/namespace',
7 'base/js/dialog',
7 'base/js/dialog',
8 'base/js/utils',
8 'base/js/utils',
9 'notebook/js/tour',
9 'notebook/js/tour',
10 'bootstrap',
10 'bootstrap',
11 'moment',
11 'moment',
12 ], function($, IPython, dialog, utils, tour, bootstrap, moment) {
12 ], function($, IPython, dialog, utils, tour, bootstrap, moment) {
13 "use strict";
13 "use strict";
14
14
15 var MenuBar = function (selector, options) {
15 var MenuBar = function (selector, options) {
16 /**
16 /**
17 * Constructor
17 * Constructor
18 *
18 *
19 * A MenuBar Class to generate the menubar of IPython notebook
19 * A MenuBar Class to generate the menubar of IPython notebook
20 *
20 *
21 * Parameters:
21 * Parameters:
22 * selector: string
22 * selector: string
23 * options: dictionary
23 * options: dictionary
24 * Dictionary of keyword arguments.
24 * Dictionary of keyword arguments.
25 * notebook: Notebook instance
25 * notebook: Notebook instance
26 * contents: ContentManager instance
26 * contents: ContentManager instance
27 * events: $(Events) instance
27 * events: $(Events) instance
28 * save_widget: SaveWidget instance
28 * save_widget: SaveWidget instance
29 * quick_help: QuickHelp instance
29 * quick_help: QuickHelp instance
30 * base_url : string
30 * base_url : string
31 * notebook_path : string
31 * notebook_path : string
32 * notebook_name : string
32 * notebook_name : string
33 */
33 */
34 options = options || {};
34 options = options || {};
35 this.base_url = options.base_url || utils.get_body_data("baseUrl");
35 this.base_url = options.base_url || utils.get_body_data("baseUrl");
36 this.selector = selector;
36 this.selector = selector;
37 this.notebook = options.notebook;
37 this.notebook = options.notebook;
38 this.contents = options.contents;
38 this.contents = options.contents;
39 this.events = options.events;
39 this.events = options.events;
40 this.save_widget = options.save_widget;
40 this.save_widget = options.save_widget;
41 this.quick_help = options.quick_help;
41 this.quick_help = options.quick_help;
42
42
43 try {
43 try {
44 this.tour = new tour.Tour(this.notebook, this.events);
44 this.tour = new tour.Tour(this.notebook, this.events);
45 } catch (e) {
45 } catch (e) {
46 this.tour = undefined;
46 this.tour = undefined;
47 console.log("Failed to instantiate Notebook Tour", e);
47 console.log("Failed to instantiate Notebook Tour", e);
48 }
48 }
49
49
50 if (this.selector !== undefined) {
50 if (this.selector !== undefined) {
51 this.element = $(selector);
51 this.element = $(selector);
52 this.style();
52 this.style();
53 this.bind_events();
53 this.bind_events();
54 }
54 }
55 };
55 };
56
56
57 // TODO: This has definitively nothing to do with style ...
57 // TODO: This has definitively nothing to do with style ...
58 MenuBar.prototype.style = function () {
58 MenuBar.prototype.style = function () {
59 var that = this;
59 var that = this;
60 this.element.find("li").click(function (event, ui) {
60 this.element.find("li").click(function (event, ui) {
61 // The selected cell loses focus when the menu is entered, so we
61 // The selected cell loses focus when the menu is entered, so we
62 // re-select it upon selection.
62 // re-select it upon selection.
63 var i = that.notebook.get_selected_index();
63 var i = that.notebook.get_selected_index();
64 that.notebook.select(i);
64 that.notebook.select(i);
65 }
65 }
66 );
66 );
67 };
67 };
68
68
69 MenuBar.prototype._nbconvert = function (format, download) {
69 MenuBar.prototype._nbconvert = function (format, download) {
70 download = download || false;
70 download = download || false;
71 var notebook_path = this.notebook.notebook_path;
71 var notebook_path = this.notebook.notebook_path;
72 var url = utils.url_join_encode(
72 var url = utils.url_join_encode(
73 this.base_url,
73 this.base_url,
74 'nbconvert',
74 'nbconvert',
75 format,
75 format,
76 notebook_path
76 notebook_path
77 ) + "?download=" + download.toString();
77 ) + "?download=" + download.toString();
78
78
79 var w = window.open();
79 var w = window.open();
80 if (this.notebook.dirty) {
80 if (this.notebook.dirty) {
81 this.notebook.save_notebook().then(function() {
81 this.notebook.save_notebook().then(function() {
82 w.location = url;
82 w.location = url;
83 });
83 });
84 } else {
84 } else {
85 w.location = url;
85 w.location = url;
86 }
86 }
87 };
87 };
88
88
89 MenuBar.prototype._size_header = function() {
89 MenuBar.prototype._size_header = function() {
90 /**
90 /**
91 * Update header spacer size.
91 * Update header spacer size.
92 */
92 */
93 this.events.trigger('resize-header.Page');
93 this.events.trigger('resize-header.Page');
94 };
94 };
95
95
96 MenuBar.prototype.bind_events = function () {
96 MenuBar.prototype.bind_events = function () {
97 /**
97 /**
98 * File
98 * File
99 */
99 */
100 var that = this;
100 var that = this;
101 this.element.find('#new_notebook').click(function () {
101 /*var new_buttons = new newnotebook.NewNotebookWidget("#new-buttons",
102 $.extend(
103 {contents: contents},
104 common_options
105 )
106 );*/
107 /*this.element.find('#new_notebook').click(function () {
102 var w = window.open();
108 var w = window.open();
103 // Create a new notebook in the same path as the current
109 // Create a new notebook in the same path as the current
104 // notebook's path.
110 // notebook's path.
105 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
111 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
106 that.contents.new_untitled(parent, {type: "notebook"}).then(
112 that.contents.new_untitled(parent, {type: "notebook"}).then(
107 function (data) {
113 function (data) {
108 var url = utils.url_join_encode(
114 var url = utils.url_join_encode(
109 that.base_url, 'notebooks', data.path
115 that.base_url, 'notebooks', data.path
110 );
116 );
111 url += "?kernel_name=" + that.notebook.kernel.name;
117 url += "?kernel_name=" + that.notebook.kernel.name;
112 w.location = url;
118 w.location = url;
113 },
119 },
114 function(error) {
120 function(error) {
115 w.close();
121 w.close();
116 dialog.modal({
122 dialog.modal({
117 title : 'Creating Notebook Failed',
123 title : 'Creating Notebook Failed',
118 body : "The error was: " + error.message,
124 body : "The error was: " + error.message,
119 buttons : {'OK' : {'class' : 'btn-primary'}}
125 buttons : {'OK' : {'class' : 'btn-primary'}}
120 });
126 });
121 }
127 }
122 );
128 );
123 });
129 });*/
124 this.element.find('#open_notebook').click(function () {
130 this.element.find('#open_notebook').click(function () {
125 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
131 var parent = utils.url_path_split(that.notebook.notebook_path)[0];
126 window.open(utils.url_join_encode(that.base_url, 'tree', parent));
132 window.open(utils.url_join_encode(that.base_url, 'tree', parent));
127 });
133 });
128 this.element.find('#copy_notebook').click(function () {
134 this.element.find('#copy_notebook').click(function () {
129 that.notebook.copy_notebook();
135 that.notebook.copy_notebook();
130 return false;
136 return false;
131 });
137 });
132 this.element.find('#download_ipynb').click(function () {
138 this.element.find('#download_ipynb').click(function () {
133 var base_url = that.notebook.base_url;
139 var base_url = that.notebook.base_url;
134 var notebook_path = that.notebook.notebook_path;
140 var notebook_path = that.notebook.notebook_path;
135 if (that.notebook.dirty) {
141 if (that.notebook.dirty) {
136 that.notebook.save_notebook({async : false});
142 that.notebook.save_notebook({async : false});
137 }
143 }
138
144
139 var url = utils.url_join_encode(base_url, 'files', notebook_path);
145 var url = utils.url_join_encode(base_url, 'files', notebook_path);
140 window.open(url + '?download=1');
146 window.open(url + '?download=1');
141 });
147 });
142
148
143 this.element.find('#print_preview').click(function () {
149 this.element.find('#print_preview').click(function () {
144 that._nbconvert('html', false);
150 that._nbconvert('html', false);
145 });
151 });
146
152
147 this.element.find('#download_html').click(function () {
153 this.element.find('#download_html').click(function () {
148 that._nbconvert('html', true);
154 that._nbconvert('html', true);
149 });
155 });
150
156
151 this.element.find('#download_rst').click(function () {
157 this.element.find('#download_rst').click(function () {
152 that._nbconvert('rst', true);
158 that._nbconvert('rst', true);
153 });
159 });
154
160
155 this.element.find('#download_pdf').click(function () {
161 this.element.find('#download_pdf').click(function () {
156 that._nbconvert('pdf', true);
162 that._nbconvert('pdf', true);
157 });
163 });
158
164
159 this.element.find('#download_script').click(function () {
165 this.element.find('#download_script').click(function () {
160 that._nbconvert('script', true);
166 that._nbconvert('script', true);
161 });
167 });
162
168
163 this.element.find('#rename_notebook').click(function () {
169 this.element.find('#rename_notebook').click(function () {
164 that.save_widget.rename_notebook({notebook: that.notebook});
170 that.save_widget.rename_notebook({notebook: that.notebook});
165 });
171 });
166 this.element.find('#save_checkpoint').click(function () {
172 this.element.find('#save_checkpoint').click(function () {
167 that.notebook.save_checkpoint();
173 that.notebook.save_checkpoint();
168 });
174 });
169 this.element.find('#restore_checkpoint').click(function () {
175 this.element.find('#restore_checkpoint').click(function () {
170 });
176 });
171 this.element.find('#trust_notebook').click(function () {
177 this.element.find('#trust_notebook').click(function () {
172 that.notebook.trust_notebook();
178 that.notebook.trust_notebook();
173 });
179 });
174 this.events.on('trust_changed.Notebook', function (event, trusted) {
180 this.events.on('trust_changed.Notebook', function (event, trusted) {
175 if (trusted) {
181 if (trusted) {
176 that.element.find('#trust_notebook')
182 that.element.find('#trust_notebook')
177 .addClass("disabled")
183 .addClass("disabled")
178 .find("a").text("Trusted Notebook");
184 .find("a").text("Trusted Notebook");
179 } else {
185 } else {
180 that.element.find('#trust_notebook')
186 that.element.find('#trust_notebook')
181 .removeClass("disabled")
187 .removeClass("disabled")
182 .find("a").text("Trust Notebook");
188 .find("a").text("Trust Notebook");
183 }
189 }
184 });
190 });
185 this.element.find('#kill_and_exit').click(function () {
191 this.element.find('#kill_and_exit').click(function () {
186 var close_window = function () {
192 var close_window = function () {
187 /**
193 /**
188 * allow closing of new tabs in Chromium, impossible in FF
194 * allow closing of new tabs in Chromium, impossible in FF
189 */
195 */
190 window.open('', '_self', '');
196 window.open('', '_self', '');
191 window.close();
197 window.close();
192 };
198 };
193 // finish with close on success or failure
199 // finish with close on success or failure
194 that.notebook.session.delete(close_window, close_window);
200 that.notebook.session.delete(close_window, close_window);
195 });
201 });
196 // Edit
202 // Edit
197 this.element.find('#cut_cell').click(function () {
203 this.element.find('#cut_cell').click(function () {
198 that.notebook.cut_cell();
204 that.notebook.cut_cell();
199 });
205 });
200 this.element.find('#copy_cell').click(function () {
206 this.element.find('#copy_cell').click(function () {
201 that.notebook.copy_cell();
207 that.notebook.copy_cell();
202 });
208 });
203 this.element.find('#delete_cell').click(function () {
209 this.element.find('#delete_cell').click(function () {
204 that.notebook.delete_cell();
210 that.notebook.delete_cell();
205 });
211 });
206 this.element.find('#undelete_cell').click(function () {
212 this.element.find('#undelete_cell').click(function () {
207 that.notebook.undelete_cell();
213 that.notebook.undelete_cell();
208 });
214 });
209 this.element.find('#split_cell').click(function () {
215 this.element.find('#split_cell').click(function () {
210 that.notebook.split_cell();
216 that.notebook.split_cell();
211 });
217 });
212 this.element.find('#merge_cell_above').click(function () {
218 this.element.find('#merge_cell_above').click(function () {
213 that.notebook.merge_cell_above();
219 that.notebook.merge_cell_above();
214 });
220 });
215 this.element.find('#merge_cell_below').click(function () {
221 this.element.find('#merge_cell_below').click(function () {
216 that.notebook.merge_cell_below();
222 that.notebook.merge_cell_below();
217 });
223 });
218 this.element.find('#move_cell_up').click(function () {
224 this.element.find('#move_cell_up').click(function () {
219 that.notebook.move_cell_up();
225 that.notebook.move_cell_up();
220 });
226 });
221 this.element.find('#move_cell_down').click(function () {
227 this.element.find('#move_cell_down').click(function () {
222 that.notebook.move_cell_down();
228 that.notebook.move_cell_down();
223 });
229 });
224 this.element.find('#edit_nb_metadata').click(function () {
230 this.element.find('#edit_nb_metadata').click(function () {
225 that.notebook.edit_metadata({
231 that.notebook.edit_metadata({
226 notebook: that.notebook,
232 notebook: that.notebook,
227 keyboard_manager: that.notebook.keyboard_manager});
233 keyboard_manager: that.notebook.keyboard_manager});
228 });
234 });
229
235
230 // View
236 // View
231 this.element.find('#toggle_header').click(function () {
237 this.element.find('#toggle_header').click(function () {
232 $('div#header-container').toggle();
238 $('div#header-container').toggle();
233 that._size_header();
239 that._size_header();
234 });
240 });
235 this.element.find('#toggle_toolbar').click(function () {
241 this.element.find('#toggle_toolbar').click(function () {
236 $('div#maintoolbar').toggle();
242 $('div#maintoolbar').toggle();
237 that._size_header();
243 that._size_header();
238 });
244 });
239 // Insert
245 // Insert
240 this.element.find('#insert_cell_above').click(function () {
246 this.element.find('#insert_cell_above').click(function () {
241 that.notebook.insert_cell_above('code');
247 that.notebook.insert_cell_above('code');
242 that.notebook.select_prev();
248 that.notebook.select_prev();
243 });
249 });
244 this.element.find('#insert_cell_below').click(function () {
250 this.element.find('#insert_cell_below').click(function () {
245 that.notebook.insert_cell_below('code');
251 that.notebook.insert_cell_below('code');
246 that.notebook.select_next();
252 that.notebook.select_next();
247 });
253 });
248 // Cell
254 // Cell
249 this.element.find('#run_cell').click(function () {
255 this.element.find('#run_cell').click(function () {
250 that.notebook.execute_cell();
256 that.notebook.execute_cell();
251 });
257 });
252 this.element.find('#run_cell_select_below').click(function () {
258 this.element.find('#run_cell_select_below').click(function () {
253 that.notebook.execute_cell_and_select_below();
259 that.notebook.execute_cell_and_select_below();
254 });
260 });
255 this.element.find('#run_cell_insert_below').click(function () {
261 this.element.find('#run_cell_insert_below').click(function () {
256 that.notebook.execute_cell_and_insert_below();
262 that.notebook.execute_cell_and_insert_below();
257 });
263 });
258 this.element.find('#run_all_cells').click(function () {
264 this.element.find('#run_all_cells').click(function () {
259 that.notebook.execute_all_cells();
265 that.notebook.execute_all_cells();
260 });
266 });
261 this.element.find('#run_all_cells_above').click(function () {
267 this.element.find('#run_all_cells_above').click(function () {
262 that.notebook.execute_cells_above();
268 that.notebook.execute_cells_above();
263 });
269 });
264 this.element.find('#run_all_cells_below').click(function () {
270 this.element.find('#run_all_cells_below').click(function () {
265 that.notebook.execute_cells_below();
271 that.notebook.execute_cells_below();
266 });
272 });
267 this.element.find('#to_code').click(function () {
273 this.element.find('#to_code').click(function () {
268 that.notebook.to_code();
274 that.notebook.to_code();
269 });
275 });
270 this.element.find('#to_markdown').click(function () {
276 this.element.find('#to_markdown').click(function () {
271 that.notebook.to_markdown();
277 that.notebook.to_markdown();
272 });
278 });
273 this.element.find('#to_raw').click(function () {
279 this.element.find('#to_raw').click(function () {
274 that.notebook.to_raw();
280 that.notebook.to_raw();
275 });
281 });
276
282
277 this.element.find('#toggle_current_output').click(function () {
283 this.element.find('#toggle_current_output').click(function () {
278 that.notebook.toggle_output();
284 that.notebook.toggle_output();
279 });
285 });
280 this.element.find('#toggle_current_output_scroll').click(function () {
286 this.element.find('#toggle_current_output_scroll').click(function () {
281 that.notebook.toggle_output_scroll();
287 that.notebook.toggle_output_scroll();
282 });
288 });
283 this.element.find('#clear_current_output').click(function () {
289 this.element.find('#clear_current_output').click(function () {
284 that.notebook.clear_output();
290 that.notebook.clear_output();
285 });
291 });
286
292
287 this.element.find('#toggle_all_output').click(function () {
293 this.element.find('#toggle_all_output').click(function () {
288 that.notebook.toggle_all_output();
294 that.notebook.toggle_all_output();
289 });
295 });
290 this.element.find('#toggle_all_output_scroll').click(function () {
296 this.element.find('#toggle_all_output_scroll').click(function () {
291 that.notebook.toggle_all_output_scroll();
297 that.notebook.toggle_all_output_scroll();
292 });
298 });
293 this.element.find('#clear_all_output').click(function () {
299 this.element.find('#clear_all_output').click(function () {
294 that.notebook.clear_all_output();
300 that.notebook.clear_all_output();
295 });
301 });
296
302
297 // Kernel
303 // Kernel
298 this.element.find('#int_kernel').click(function () {
304 this.element.find('#int_kernel').click(function () {
299 that.notebook.kernel.interrupt();
305 that.notebook.kernel.interrupt();
300 });
306 });
301 this.element.find('#restart_kernel').click(function () {
307 this.element.find('#restart_kernel').click(function () {
302 that.notebook.restart_kernel();
308 that.notebook.restart_kernel();
303 });
309 });
304 this.element.find('#reconnect_kernel').click(function () {
310 this.element.find('#reconnect_kernel').click(function () {
305 that.notebook.kernel.reconnect();
311 that.notebook.kernel.reconnect();
306 });
312 });
307 // Help
313 // Help
308 if (this.tour) {
314 if (this.tour) {
309 this.element.find('#notebook_tour').click(function () {
315 this.element.find('#notebook_tour').click(function () {
310 that.tour.start();
316 that.tour.start();
311 });
317 });
312 } else {
318 } else {
313 this.element.find('#notebook_tour').addClass("disabled");
319 this.element.find('#notebook_tour').addClass("disabled");
314 }
320 }
315 this.element.find('#keyboard_shortcuts').click(function () {
321 this.element.find('#keyboard_shortcuts').click(function () {
316 that.quick_help.show_keyboard_shortcuts();
322 that.quick_help.show_keyboard_shortcuts();
317 });
323 });
318
324
319 this.update_restore_checkpoint(null);
325 this.update_restore_checkpoint(null);
320
326
321 this.events.on('checkpoints_listed.Notebook', function (event, data) {
327 this.events.on('checkpoints_listed.Notebook', function (event, data) {
322 that.update_restore_checkpoint(that.notebook.checkpoints);
328 that.update_restore_checkpoint(that.notebook.checkpoints);
323 });
329 });
324
330
325 this.events.on('checkpoint_created.Notebook', function (event, data) {
331 this.events.on('checkpoint_created.Notebook', function (event, data) {
326 that.update_restore_checkpoint(that.notebook.checkpoints);
332 that.update_restore_checkpoint(that.notebook.checkpoints);
327 });
333 });
328
334
329 this.events.on('notebook_loaded.Notebook', function() {
335 this.events.on('notebook_loaded.Notebook', function() {
330 var langinfo = that.notebook.metadata.language_info || {};
336 var langinfo = that.notebook.metadata.language_info || {};
331 that.update_nbconvert_script(langinfo);
337 that.update_nbconvert_script(langinfo);
332 });
338 });
333
339
334 this.events.on('kernel_ready.Kernel', function(event, data) {
340 this.events.on('kernel_ready.Kernel', function(event, data) {
335 var langinfo = data.kernel.info_reply.language_info || {};
341 var langinfo = data.kernel.info_reply.language_info || {};
336 that.update_nbconvert_script(langinfo);
342 that.update_nbconvert_script(langinfo);
337 that.add_kernel_help_links(data.kernel.info_reply.help_links || []);
343 that.add_kernel_help_links(data.kernel.info_reply.help_links || []);
338 });
344 });
339 };
345 };
340
346
341 MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
347 MenuBar.prototype.update_restore_checkpoint = function(checkpoints) {
342 var ul = this.element.find("#restore_checkpoint").find("ul");
348 var ul = this.element.find("#restore_checkpoint").find("ul");
343 ul.empty();
349 ul.empty();
344 if (!checkpoints || checkpoints.length === 0) {
350 if (!checkpoints || checkpoints.length === 0) {
345 ul.append(
351 ul.append(
346 $("<li/>")
352 $("<li/>")
347 .addClass("disabled")
353 .addClass("disabled")
348 .append(
354 .append(
349 $("<a/>")
355 $("<a/>")
350 .text("No checkpoints")
356 .text("No checkpoints")
351 )
357 )
352 );
358 );
353 return;
359 return;
354 }
360 }
355
361
356 var that = this;
362 var that = this;
357 checkpoints.map(function (checkpoint) {
363 checkpoints.map(function (checkpoint) {
358 var d = new Date(checkpoint.last_modified);
364 var d = new Date(checkpoint.last_modified);
359 ul.append(
365 ul.append(
360 $("<li/>").append(
366 $("<li/>").append(
361 $("<a/>")
367 $("<a/>")
362 .attr("href", "#")
368 .attr("href", "#")
363 .text(moment(d).format("LLLL"))
369 .text(moment(d).format("LLLL"))
364 .click(function () {
370 .click(function () {
365 that.notebook.restore_checkpoint_dialog(checkpoint);
371 that.notebook.restore_checkpoint_dialog(checkpoint);
366 })
372 })
367 )
373 )
368 );
374 );
369 });
375 });
370 };
376 };
371
377
372 MenuBar.prototype.update_nbconvert_script = function(langinfo) {
378 MenuBar.prototype.update_nbconvert_script = function(langinfo) {
373 /**
379 /**
374 * Set the 'Download as foo' menu option for the relevant language.
380 * Set the 'Download as foo' menu option for the relevant language.
375 */
381 */
376 var el = this.element.find('#download_script');
382 var el = this.element.find('#download_script');
377
383
378 // Set menu entry text to e.g. "Python (.py)"
384 // Set menu entry text to e.g. "Python (.py)"
379 var langname = (langinfo.name || 'Script');
385 var langname = (langinfo.name || 'Script');
380 langname = langname.charAt(0).toUpperCase()+langname.substr(1); // Capitalise
386 langname = langname.charAt(0).toUpperCase()+langname.substr(1); // Capitalise
381 el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')');
387 el.find('a').text(langname + ' ('+(langinfo.file_extension || 'txt')+')');
382 };
388 };
383
389
384 MenuBar.prototype.add_kernel_help_links = function(help_links) {
390 MenuBar.prototype.add_kernel_help_links = function(help_links) {
385 /** add links from kernel_info to the help menu */
391 /** add links from kernel_info to the help menu */
386 var divider = $("#kernel-help-links");
392 var divider = $("#kernel-help-links");
387 if (divider.length === 0) {
393 if (divider.length === 0) {
388 // insert kernel help section above about link
394 // insert kernel help section above about link
389 var about = $("#notebook_about").parent();
395 var about = $("#notebook_about").parent();
390 divider = $("<li>")
396 divider = $("<li>")
391 .attr('id', "kernel-help-links")
397 .attr('id', "kernel-help-links")
392 .addClass('divider');
398 .addClass('divider');
393 about.prev().before(divider);
399 about.prev().before(divider);
394 }
400 }
395 // remove previous entries
401 // remove previous entries
396 while (!divider.next().hasClass('divider')) {
402 while (!divider.next().hasClass('divider')) {
397 divider.next().remove();
403 divider.next().remove();
398 }
404 }
399 if (help_links.length === 0) {
405 if (help_links.length === 0) {
400 // no help links, remove the divider
406 // no help links, remove the divider
401 divider.remove();
407 divider.remove();
402 return;
408 return;
403 }
409 }
404 var cursor = divider;
410 var cursor = divider;
405 help_links.map(function (link) {
411 help_links.map(function (link) {
406 cursor.after($("<li>")
412 cursor.after($("<li>")
407 .append($("<a>")
413 .append($("<a>")
408 .attr('target', '_blank')
414 .attr('target', '_blank')
409 .attr('title', 'Opens in a new window')
415 .attr('title', 'Opens in a new window')
410 .attr('href', link.url)
416 .attr('href', link.url)
411 .text(link.text)
417 .text(link.text)
412 .append($("<i>")
418 .append($("<i>")
413 .addClass("fa fa-external-link menu-icon pull-right")
419 .addClass("fa fa-external-link menu-icon pull-right")
414 )
420 )
415 )
421 )
416 );
422 );
417 cursor = cursor.next();
423 cursor = cursor.next();
418 });
424 });
419
425
420 };
426 };
421
427
422 // Backwards compatability.
428 // Backwards compatability.
423 IPython.MenuBar = MenuBar;
429 IPython.MenuBar = MenuBar;
424
430
425 return {'MenuBar': MenuBar};
431 return {'MenuBar': MenuBar};
426 });
432 });
@@ -1,318 +1,319 b''
1 {% extends "page.html" %}
1 {% extends "page.html" %}
2
2
3 {% block stylesheet %}
3 {% block stylesheet %}
4
4
5 {% if mathjax_url %}
5 {% if mathjax_url %}
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
6 <script type="text/javascript" src="{{mathjax_url}}?config=TeX-AMS_HTML-full&delayStartupUntil=configured" charset="utf-8"></script>
7 {% endif %}
7 {% endif %}
8 <script type="text/javascript">
8 <script type="text/javascript">
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
9 // MathJax disabled, set as null to distingish from *missing* MathJax,
10 // where it will be undefined, and should prompt a dialog later.
10 // where it will be undefined, and should prompt a dialog later.
11 window.mathjax_url = "{{mathjax_url}}";
11 window.mathjax_url = "{{mathjax_url}}";
12 </script>
12 </script>
13
13
14 <link rel="stylesheet" href="{{ static_url("components/bootstrap-tour/build/css/bootstrap-tour.min.css") }}" type="text/css" />
14 <link rel="stylesheet" href="{{ static_url("components/bootstrap-tour/build/css/bootstrap-tour.min.css") }}" type="text/css" />
15 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
15 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
16
16
17 {{super()}}
17 {{super()}}
18
18
19 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
19 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
20 <link rel="stylesheet" href="" id='kernel-css' type="text/css" />
20 <link rel="stylesheet" href="" id='kernel-css' type="text/css" />
21
21
22 {% endblock %}
22 {% endblock %}
23
23
24 {% block params %}
24 {% block params %}
25
25
26 data-project="{{project}}"
26 data-project="{{project}}"
27 data-base-url="{{base_url}}"
27 data-base-url="{{base_url}}"
28 data-ws-url="{{ws_url}}"
28 data-ws-url="{{ws_url}}"
29 data-notebook-name="{{notebook_name}}"
29 data-notebook-name="{{notebook_name}}"
30 data-notebook-path="{{notebook_path}}"
30 data-notebook-path="{{notebook_path}}"
31 class="notebook_app"
31 class="notebook_app"
32
32
33 {% endblock %}
33 {% endblock %}
34
34
35
35
36 {% block headercontainer %}
36 {% block headercontainer %}
37
37
38
38
39 <span id="save_widget" class="pull-left save_widget">
39 <span id="save_widget" class="pull-left save_widget">
40 <span class="filename"></span>
40 <span class="filename"></span>
41 <span class="checkpoint_status"></span>
41 <span class="checkpoint_status"></span>
42 <span class="autosave_status"></span>
42 <span class="autosave_status"></span>
43 </span>
43 </span>
44
44
45 <span id="kernel_logo_widget">
45 <span id="kernel_logo_widget">
46 <img class="current_kernel_logo" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/>
46 <img class="current_kernel_logo" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/>
47 </span>
47 </span>
48
48
49 {% endblock headercontainer %}
49 {% endblock headercontainer %}
50
50
51 {% block header %}
51 {% block header %}
52 <div id="menubar-container" class="container">
52 <div id="menubar-container" class="container">
53 <div id="menubar">
53 <div id="menubar">
54 <div id="menus" class="navbar navbar-default" role="navigation">
54 <div id="menus" class="navbar navbar-default" role="navigation">
55 <div class="container-fluid">
55 <div class="container-fluid">
56 <button type="button" class="btn btn-default navbar-btn navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
56 <button type="button" class="btn btn-default navbar-btn navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
57 <i class="fa fa-bars"></i>
57 <i class="fa fa-bars"></i>
58 <span class="navbar-text">Menu</span>
58 <span class="navbar-text">Menu</span>
59 </button>
59 </button>
60 <p id="kernel_indicator" class="navbar-text">
60 <p id="kernel_indicator" class="navbar-text">
61 <span class="kernel_indicator_name">Kernel</span>
61 <span class="kernel_indicator_name">Kernel</span>
62 <i id="kernel_indicator_icon"></i>
62 <i id="kernel_indicator_icon"></i>
63 </p>
63 </p>
64 <i id="modal_indicator" class="navbar-text"></i>
64 <i id="modal_indicator" class="navbar-text"></i>
65 <span id="notification_area"></span>
65 <span id="notification_area"></span>
66 <div class="navbar-collapse collapse">
66 <div class="navbar-collapse collapse">
67 <ul class="nav navbar-nav">
67 <ul class="nav navbar-nav">
68 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
68 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
69 <ul id="file_menu" class="dropdown-menu">
69 <ul id="file_menu" class="dropdown-menu">
70 <li id="new_notebook"
70 <li id="new_notebook" class="dropdown-submenu">
71 title="Make a new notebook (Opens a new window)">
71 <a href="#">New Notebook</a>
72 <a href="#">New</a></li>
72 <ul class="dropdown-menu" id="menu-new-notebook-submenu"></ul>
73 </li>
73 <li id="open_notebook"
74 <li id="open_notebook"
74 title="Opens a new window with the Dashboard view">
75 title="Opens a new window with the Dashboard view">
75 <a href="#">Open...</a></li>
76 <a href="#">Open...</a></li>
76 <!-- <hr/> -->
77 <!-- <hr/> -->
77 <li class="divider"></li>
78 <li class="divider"></li>
78 <li id="copy_notebook"
79 <li id="copy_notebook"
79 title="Open a copy of this notebook's contents and start a new kernel">
80 title="Open a copy of this notebook's contents and start a new kernel">
80 <a href="#">Make a Copy...</a></li>
81 <a href="#">Make a Copy...</a></li>
81 <li id="rename_notebook"><a href="#">Rename...</a></li>
82 <li id="rename_notebook"><a href="#">Rename...</a></li>
82 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
83 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
83 <!-- <hr/> -->
84 <!-- <hr/> -->
84 <li class="divider"></li>
85 <li class="divider"></li>
85 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
86 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
86 <ul class="dropdown-menu">
87 <ul class="dropdown-menu">
87 <li><a href="#"></a></li>
88 <li><a href="#"></a></li>
88 <li><a href="#"></a></li>
89 <li><a href="#"></a></li>
89 <li><a href="#"></a></li>
90 <li><a href="#"></a></li>
90 <li><a href="#"></a></li>
91 <li><a href="#"></a></li>
91 <li><a href="#"></a></li>
92 <li><a href="#"></a></li>
92 </ul>
93 </ul>
93 </li>
94 </li>
94 <li class="divider"></li>
95 <li class="divider"></li>
95 <li id="print_preview"><a href="#">Print Preview</a></li>
96 <li id="print_preview"><a href="#">Print Preview</a></li>
96 <li class="dropdown-submenu"><a href="#">Download as</a>
97 <li class="dropdown-submenu"><a href="#">Download as</a>
97 <ul class="dropdown-menu">
98 <ul class="dropdown-menu">
98 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
99 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
99 <li id="download_script"><a href="#">Script</a></li>
100 <li id="download_script"><a href="#">Script</a></li>
100 <li id="download_html"><a href="#">HTML (.html)</a></li>
101 <li id="download_html"><a href="#">HTML (.html)</a></li>
101 <li id="download_rst"><a href="#">reST (.rst)</a></li>
102 <li id="download_rst"><a href="#">reST (.rst)</a></li>
102 <li id="download_pdf"><a href="#">PDF (.pdf)</a></li>
103 <li id="download_pdf"><a href="#">PDF (.pdf)</a></li>
103 </ul>
104 </ul>
104 </li>
105 </li>
105 <li class="divider"></li>
106 <li class="divider"></li>
106 <li id="trust_notebook"
107 <li id="trust_notebook"
107 title="Trust the output of this notebook">
108 title="Trust the output of this notebook">
108 <a href="#" >Trust Notebook</a></li>
109 <a href="#" >Trust Notebook</a></li>
109 <li class="divider"></li>
110 <li class="divider"></li>
110 <li id="kill_and_exit"
111 <li id="kill_and_exit"
111 title="Shutdown this notebook's kernel, and close this window">
112 title="Shutdown this notebook's kernel, and close this window">
112 <a href="#" >Close and halt</a></li>
113 <a href="#" >Close and halt</a></li>
113 </ul>
114 </ul>
114 </li>
115 </li>
115 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
116 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
116 <ul id="edit_menu" class="dropdown-menu">
117 <ul id="edit_menu" class="dropdown-menu">
117 <li id="cut_cell"><a href="#">Cut Cell</a></li>
118 <li id="cut_cell"><a href="#">Cut Cell</a></li>
118 <li id="copy_cell"><a href="#">Copy Cell</a></li>
119 <li id="copy_cell"><a href="#">Copy Cell</a></li>
119 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
120 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
120 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
121 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
121 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
122 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
122 <li id="delete_cell"><a href="#">Delete Cell</a></li>
123 <li id="delete_cell"><a href="#">Delete Cell</a></li>
123 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
124 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
124 <li class="divider"></li>
125 <li class="divider"></li>
125 <li id="split_cell"><a href="#">Split Cell</a></li>
126 <li id="split_cell"><a href="#">Split Cell</a></li>
126 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
127 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
127 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
128 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
128 <li class="divider"></li>
129 <li class="divider"></li>
129 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
130 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
130 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
131 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
131 <li class="divider"></li>
132 <li class="divider"></li>
132 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
133 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
133 </ul>
134 </ul>
134 </li>
135 </li>
135 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
136 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
136 <ul id="view_menu" class="dropdown-menu">
137 <ul id="view_menu" class="dropdown-menu">
137 <li id="toggle_header"
138 <li id="toggle_header"
138 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
139 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
139 <a href="#">Toggle Header</a></li>
140 <a href="#">Toggle Header</a></li>
140 <li id="toggle_toolbar"
141 <li id="toggle_toolbar"
141 title="Show/Hide the action icons (below menu bar)">
142 title="Show/Hide the action icons (below menu bar)">
142 <a href="#">Toggle Toolbar</a></li>
143 <a href="#">Toggle Toolbar</a></li>
143 </ul>
144 </ul>
144 </li>
145 </li>
145 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
146 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
146 <ul id="insert_menu" class="dropdown-menu">
147 <ul id="insert_menu" class="dropdown-menu">
147 <li id="insert_cell_above"
148 <li id="insert_cell_above"
148 title="Insert an empty Code cell above the currently active cell">
149 title="Insert an empty Code cell above the currently active cell">
149 <a href="#">Insert Cell Above</a></li>
150 <a href="#">Insert Cell Above</a></li>
150 <li id="insert_cell_below"
151 <li id="insert_cell_below"
151 title="Insert an empty Code cell below the currently active cell">
152 title="Insert an empty Code cell below the currently active cell">
152 <a href="#">Insert Cell Below</a></li>
153 <a href="#">Insert Cell Below</a></li>
153 </ul>
154 </ul>
154 </li>
155 </li>
155 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
156 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
156 <ul id="cell_menu" class="dropdown-menu">
157 <ul id="cell_menu" class="dropdown-menu">
157 <li id="run_cell" title="Run this cell, and move cursor to the next one">
158 <li id="run_cell" title="Run this cell, and move cursor to the next one">
158 <a href="#">Run</a></li>
159 <a href="#">Run</a></li>
159 <li id="run_cell_select_below" title="Run this cell, select below">
160 <li id="run_cell_select_below" title="Run this cell, select below">
160 <a href="#">Run and Select Below</a></li>
161 <a href="#">Run and Select Below</a></li>
161 <li id="run_cell_insert_below" title="Run this cell, insert below">
162 <li id="run_cell_insert_below" title="Run this cell, insert below">
162 <a href="#">Run and Insert Below</a></li>
163 <a href="#">Run and Insert Below</a></li>
163 <li id="run_all_cells" title="Run all cells in the notebook">
164 <li id="run_all_cells" title="Run all cells in the notebook">
164 <a href="#">Run All</a></li>
165 <a href="#">Run All</a></li>
165 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
166 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
166 <a href="#">Run All Above</a></li>
167 <a href="#">Run All Above</a></li>
167 <li id="run_all_cells_below" title="Run this cell and all cells below it">
168 <li id="run_all_cells_below" title="Run this cell and all cells below it">
168 <a href="#">Run All Below</a></li>
169 <a href="#">Run All Below</a></li>
169 <li class="divider"></li>
170 <li class="divider"></li>
170 <li id="change_cell_type" class="dropdown-submenu"
171 <li id="change_cell_type" class="dropdown-submenu"
171 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
172 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
172 <a href="#">Cell Type</a>
173 <a href="#">Cell Type</a>
173 <ul class="dropdown-menu">
174 <ul class="dropdown-menu">
174 <li id="to_code"
175 <li id="to_code"
175 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
176 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
176 <a href="#">Code</a></li>
177 <a href="#">Code</a></li>
177 <li id="to_markdown"
178 <li id="to_markdown"
178 title="Contents will be rendered as HTML and serve as explanatory text">
179 title="Contents will be rendered as HTML and serve as explanatory text">
179 <a href="#">Markdown</a></li>
180 <a href="#">Markdown</a></li>
180 <li id="to_raw"
181 <li id="to_raw"
181 title="Contents will pass through nbconvert unmodified">
182 title="Contents will pass through nbconvert unmodified">
182 <a href="#">Raw NBConvert</a></li>
183 <a href="#">Raw NBConvert</a></li>
183 </ul>
184 </ul>
184 </li>
185 </li>
185 <li class="divider"></li>
186 <li class="divider"></li>
186 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
187 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
187 <ul class="dropdown-menu">
188 <ul class="dropdown-menu">
188 <li id="toggle_current_output"
189 <li id="toggle_current_output"
189 title="Hide/Show the output of the current cell">
190 title="Hide/Show the output of the current cell">
190 <a href="#">Toggle</a>
191 <a href="#">Toggle</a>
191 </li>
192 </li>
192 <li id="toggle_current_output_scroll"
193 <li id="toggle_current_output_scroll"
193 title="Scroll the output of the current cell">
194 title="Scroll the output of the current cell">
194 <a href="#">Toggle Scrolling</a>
195 <a href="#">Toggle Scrolling</a>
195 </li>
196 </li>
196 <li id="clear_current_output"
197 <li id="clear_current_output"
197 title="Clear the output of the current cell">
198 title="Clear the output of the current cell">
198 <a href="#">Clear</a>
199 <a href="#">Clear</a>
199 </li>
200 </li>
200 </ul>
201 </ul>
201 </li>
202 </li>
202 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
203 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
203 <ul class="dropdown-menu">
204 <ul class="dropdown-menu">
204 <li id="toggle_all_output"
205 <li id="toggle_all_output"
205 title="Hide/Show the output of all cells">
206 title="Hide/Show the output of all cells">
206 <a href="#">Toggle</a>
207 <a href="#">Toggle</a>
207 </li>
208 </li>
208 <li id="toggle_all_output_scroll"
209 <li id="toggle_all_output_scroll"
209 title="Scroll the output of all cells">
210 title="Scroll the output of all cells">
210 <a href="#">Toggle Scrolling</a>
211 <a href="#">Toggle Scrolling</a>
211 </li>
212 </li>
212 <li id="clear_all_output"
213 <li id="clear_all_output"
213 title="Clear the output of all cells">
214 title="Clear the output of all cells">
214 <a href="#">Clear</a>
215 <a href="#">Clear</a>
215 </li>
216 </li>
216 </ul>
217 </ul>
217 </li>
218 </li>
218 </ul>
219 </ul>
219 </li>
220 </li>
220 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
221 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
221 <ul id="kernel_menu" class="dropdown-menu">
222 <ul id="kernel_menu" class="dropdown-menu">
222 <li id="int_kernel"
223 <li id="int_kernel"
223 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
224 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
224 <a href="#">Interrupt</a>
225 <a href="#">Interrupt</a>
225 </li>
226 </li>
226 <li id="restart_kernel"
227 <li id="restart_kernel"
227 title="Restart the Kernel">
228 title="Restart the Kernel">
228 <a href="#">Restart</a>
229 <a href="#">Restart</a>
229 </li>
230 </li>
230 <li id="reconnect_kernel"
231 <li id="reconnect_kernel"
231 title="Reconnect to the Kernel">
232 title="Reconnect to the Kernel">
232 <a href="#">Reconnect</a>
233 <a href="#">Reconnect</a>
233 </li>
234 </li>
234 <li class="divider"></li>
235 <li class="divider"></li>
235 <li id="menu-change-kernel" class="dropdown-submenu">
236 <li id="menu-change-kernel" class="dropdown-submenu">
236 <a href="#">Change kernel</a>
237 <a href="#">Change kernel</a>
237 <ul class="dropdown-menu" id="menu-change-kernel-submenu"></ul>
238 <ul class="dropdown-menu" id="menu-change-kernel-submenu"></ul>
238 </li>
239 </li>
239 </ul>
240 </ul>
240 </li>
241 </li>
241 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
242 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
242 <ul id="help_menu" class="dropdown-menu">
243 <ul id="help_menu" class="dropdown-menu">
243 <li id="notebook_tour" title="A quick tour of the notebook user interface"><a href="#">User Interface Tour</a></li>
244 <li id="notebook_tour" title="A quick tour of the notebook user interface"><a href="#">User Interface Tour</a></li>
244 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
245 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
245 <li class="divider"></li>
246 <li class="divider"></li>
246 {% set
247 {% set
247 sections = (
248 sections = (
248 (
249 (
249 ("http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Index.ipynb", "Notebook Help", True),
250 ("http://nbviewer.ipython.org/github/ipython/ipython/blob/2.x/examples/Index.ipynb", "Notebook Help", True),
250 ("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
251 ("http://help.github.com/articles/github-flavored-markdown","Markdown",True),
251 ),
252 ),
252 )
253 )
253 %}
254 %}
254
255
255 {% for helplinks in sections %}
256 {% for helplinks in sections %}
256 {% for link in helplinks %}
257 {% for link in helplinks %}
257 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
258 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
258 {{'<i class="fa fa-external-link menu-icon pull-right"></i>' if link[2]}}
259 {{'<i class="fa fa-external-link menu-icon pull-right"></i>' if link[2]}}
259 {{link[1]}}
260 {{link[1]}}
260 </a></li>
261 </a></li>
261 {% endfor %}
262 {% endfor %}
262 {% if not loop.last %}
263 {% if not loop.last %}
263 <li class="divider"></li>
264 <li class="divider"></li>
264 {% endif %}
265 {% endif %}
265 {% endfor %}
266 {% endfor %}
266 <li class="divider"></li>
267 <li class="divider"></li>
267 <li title="About IPython Notebook"><a id="notebook_about" href="#">About</a></li>
268 <li title="About IPython Notebook"><a id="notebook_about" href="#">About</a></li>
268 </ul>
269 </ul>
269 </li>
270 </li>
270 </ul>
271 </ul>
271 </div>
272 </div>
272 </div>
273 </div>
273 </div>
274 </div>
274 </div>
275 </div>
275
276
276 <div id="maintoolbar" class="navbar">
277 <div id="maintoolbar" class="navbar">
277 <div class="toolbar-inner navbar-inner navbar-nobg">
278 <div class="toolbar-inner navbar-inner navbar-nobg">
278 <div id="maintoolbar-container" class="container"></div>
279 <div id="maintoolbar-container" class="container"></div>
279 </div>
280 </div>
280 </div>
281 </div>
281 </div>
282 </div>
282
283
283 <div class="lower-header-bar"></div>
284 <div class="lower-header-bar"></div>
284 {% endblock header %}
285 {% endblock header %}
285
286
286 {% block site %}
287 {% block site %}
287
288
288
289
289 <div id="ipython-main-app">
290 <div id="ipython-main-app">
290 <div id="notebook_panel">
291 <div id="notebook_panel">
291 <div id="notebook"></div>
292 <div id="notebook"></div>
292 </div>
293 </div>
293 </div>
294 </div>
294
295
295 <div id="pager">
296 <div id="pager">
296 <div id="pager-contents">
297 <div id="pager-contents">
297 <div id="pager-container" class="container"></div>
298 <div id="pager-container" class="container"></div>
298 </div>
299 </div>
299 <div id='pager-button-area'></div>
300 <div id='pager-button-area'></div>
300 </div>
301 </div>
301
302
302 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
303 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
303
304
304
305
305 {% endblock %}
306 {% endblock %}
306
307
307
308
308 {% block script %}
309 {% block script %}
309 {{super()}}
310 {{super()}}
310 <script type="text/javascript">
311 <script type="text/javascript">
311 sys_info = {{sys_info}};
312 sys_info = {{sys_info}};
312 </script>
313 </script>
313
314
314 <script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
315 <script src="{{ static_url("components/text-encoding/lib/encoding.js") }}" charset="utf-8"></script>
315
316
316 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
317 <script src="{{ static_url("notebook/js/main.js") }}" charset="utf-8"></script>
317
318
318 {% endblock %}
319 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now