##// END OF EJS Templates
Merge pull request #4985 from damianavila/closebrackets...
Min RK -
r15464:6dfa8a77 merge
parent child Browse files
Show More
@@ -1,570 +1,571 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // CodeCell
9 // CodeCell
10 //============================================================================
10 //============================================================================
11 /**
11 /**
12 * An extendable module that provide base functionnality to create cell for notebook.
12 * An extendable module that provide base functionnality to create cell for notebook.
13 * @module IPython
13 * @module IPython
14 * @namespace IPython
14 * @namespace IPython
15 * @submodule CodeCell
15 * @submodule CodeCell
16 */
16 */
17
17
18
18
19 /* local util for codemirror */
19 /* local util for codemirror */
20 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;};
20 var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;};
21
21
22 /**
22 /**
23 *
23 *
24 * function to delete until previous non blanking space character
24 * function to delete until previous non blanking space character
25 * or first multiple of 4 tabstop.
25 * or first multiple of 4 tabstop.
26 * @private
26 * @private
27 */
27 */
28 CodeMirror.commands.delSpaceToPrevTabStop = function(cm){
28 CodeMirror.commands.delSpaceToPrevTabStop = function(cm){
29 var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
29 var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
30 if (!posEq(from, to)) { cm.replaceRange("", from, to); return; }
30 if (!posEq(from, to)) { cm.replaceRange("", from, to); return; }
31 var cur = cm.getCursor(), line = cm.getLine(cur.line);
31 var cur = cm.getCursor(), line = cm.getLine(cur.line);
32 var tabsize = cm.getOption('tabSize');
32 var tabsize = cm.getOption('tabSize');
33 var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
33 var chToPrevTabStop = cur.ch-(Math.ceil(cur.ch/tabsize)-1)*tabsize;
34 from = {ch:cur.ch-chToPrevTabStop,line:cur.line};
34 from = {ch:cur.ch-chToPrevTabStop,line:cur.line};
35 var select = cm.getRange(from,cur);
35 var select = cm.getRange(from,cur);
36 if( select.match(/^\ +$/) !== null){
36 if( select.match(/^\ +$/) !== null){
37 cm.replaceRange("",from,cur);
37 cm.replaceRange("",from,cur);
38 } else {
38 } else {
39 cm.deleteH(-1,"char");
39 cm.deleteH(-1,"char");
40 }
40 }
41 };
41 };
42
42
43
43
44 var IPython = (function (IPython) {
44 var IPython = (function (IPython) {
45 "use strict";
45 "use strict";
46
46
47 var utils = IPython.utils;
47 var utils = IPython.utils;
48 var key = IPython.utils.keycodes;
48 var key = IPython.utils.keycodes;
49
49
50 /**
50 /**
51 * A Cell conceived to write code.
51 * A Cell conceived to write code.
52 *
52 *
53 * The kernel doesn't have to be set at creation time, in that case
53 * The kernel doesn't have to be set at creation time, in that case
54 * it will be null and set_kernel has to be called later.
54 * it will be null and set_kernel has to be called later.
55 * @class CodeCell
55 * @class CodeCell
56 * @extends IPython.Cell
56 * @extends IPython.Cell
57 *
57 *
58 * @constructor
58 * @constructor
59 * @param {Object|null} kernel
59 * @param {Object|null} kernel
60 * @param {object|undefined} [options]
60 * @param {object|undefined} [options]
61 * @param [options.cm_config] {object} config to pass to CodeMirror
61 * @param [options.cm_config] {object} config to pass to CodeMirror
62 */
62 */
63 var CodeCell = function (kernel, options) {
63 var CodeCell = function (kernel, options) {
64 this.kernel = kernel || null;
64 this.kernel = kernel || null;
65 this.collapsed = false;
65 this.collapsed = false;
66
66
67 // create all attributed in constructor function
67 // create all attributed in constructor function
68 // even if null for V8 VM optimisation
68 // even if null for V8 VM optimisation
69 this.input_prompt_number = null;
69 this.input_prompt_number = null;
70 this.celltoolbar = null;
70 this.celltoolbar = null;
71 this.output_area = null;
71 this.output_area = null;
72 this.last_msg_id = null;
72 this.last_msg_id = null;
73 this.completer = null;
73 this.completer = null;
74
74
75
75
76 var cm_overwrite_options = {
76 var cm_overwrite_options = {
77 onKeyEvent: $.proxy(this.handle_keyevent,this)
77 onKeyEvent: $.proxy(this.handle_keyevent,this)
78 };
78 };
79
79
80 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
80 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
81
81
82 IPython.Cell.apply(this,[options]);
82 IPython.Cell.apply(this,[options]);
83
83
84 // Attributes we want to override in this subclass.
84 // Attributes we want to override in this subclass.
85 this.cell_type = "code";
85 this.cell_type = "code";
86
86
87 var that = this;
87 var that = this;
88 this.element.focusout(
88 this.element.focusout(
89 function() { that.auto_highlight(); }
89 function() { that.auto_highlight(); }
90 );
90 );
91 };
91 };
92
92
93 CodeCell.options_default = {
93 CodeCell.options_default = {
94 cm_config : {
94 cm_config : {
95 extraKeys: {
95 extraKeys: {
96 "Tab" : "indentMore",
96 "Tab" : "indentMore",
97 "Shift-Tab" : "indentLess",
97 "Shift-Tab" : "indentLess",
98 "Backspace" : "delSpaceToPrevTabStop",
98 "Backspace" : "delSpaceToPrevTabStop",
99 "Cmd-/" : "toggleComment",
99 "Cmd-/" : "toggleComment",
100 "Ctrl-/" : "toggleComment"
100 "Ctrl-/" : "toggleComment"
101 },
101 },
102 mode: 'ipython',
102 mode: 'ipython',
103 theme: 'ipython',
103 theme: 'ipython',
104 matchBrackets: true
104 matchBrackets: true,
105 autoCloseBrackets: true
105 }
106 }
106 };
107 };
107
108
108 CodeCell.msg_cells = {};
109 CodeCell.msg_cells = {};
109
110
110 CodeCell.prototype = new IPython.Cell();
111 CodeCell.prototype = new IPython.Cell();
111
112
112 /**
113 /**
113 * @method auto_highlight
114 * @method auto_highlight
114 */
115 */
115 CodeCell.prototype.auto_highlight = function () {
116 CodeCell.prototype.auto_highlight = function () {
116 this._auto_highlight(IPython.config.cell_magic_highlight);
117 this._auto_highlight(IPython.config.cell_magic_highlight);
117 };
118 };
118
119
119 /** @method create_element */
120 /** @method create_element */
120 CodeCell.prototype.create_element = function () {
121 CodeCell.prototype.create_element = function () {
121 IPython.Cell.prototype.create_element.apply(this, arguments);
122 IPython.Cell.prototype.create_element.apply(this, arguments);
122
123
123 var cell = $('<div></div>').addClass('cell border-box-sizing code_cell');
124 var cell = $('<div></div>').addClass('cell border-box-sizing code_cell');
124 cell.attr('tabindex','2');
125 cell.attr('tabindex','2');
125
126
126 var input = $('<div></div>').addClass('input');
127 var input = $('<div></div>').addClass('input');
127 var prompt = $('<div/>').addClass('prompt input_prompt');
128 var prompt = $('<div/>').addClass('prompt input_prompt');
128 var inner_cell = $('<div/>').addClass('inner_cell');
129 var inner_cell = $('<div/>').addClass('inner_cell');
129 this.celltoolbar = new IPython.CellToolbar(this);
130 this.celltoolbar = new IPython.CellToolbar(this);
130 inner_cell.append(this.celltoolbar.element);
131 inner_cell.append(this.celltoolbar.element);
131 var input_area = $('<div/>').addClass('input_area');
132 var input_area = $('<div/>').addClass('input_area');
132 this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
133 this.code_mirror = CodeMirror(input_area.get(0), this.cm_config);
133 $(this.code_mirror.getInputField()).attr("spellcheck", "false");
134 $(this.code_mirror.getInputField()).attr("spellcheck", "false");
134 inner_cell.append(input_area);
135 inner_cell.append(input_area);
135 input.append(prompt).append(inner_cell);
136 input.append(prompt).append(inner_cell);
136
137
137 var widget_area = $('<div/>')
138 var widget_area = $('<div/>')
138 .addClass('widget-area')
139 .addClass('widget-area')
139 .hide();
140 .hide();
140 this.widget_area = widget_area;
141 this.widget_area = widget_area;
141 var widget_prompt = $('<div/>')
142 var widget_prompt = $('<div/>')
142 .addClass('prompt')
143 .addClass('prompt')
143 .appendTo(widget_area);
144 .appendTo(widget_area);
144 var widget_subarea = $('<div/>')
145 var widget_subarea = $('<div/>')
145 .addClass('widget-subarea')
146 .addClass('widget-subarea')
146 .appendTo(widget_area);
147 .appendTo(widget_area);
147 this.widget_subarea = widget_subarea;
148 this.widget_subarea = widget_subarea;
148 var widget_clear_buton = $('<button />')
149 var widget_clear_buton = $('<button />')
149 .addClass('close')
150 .addClass('close')
150 .html('&times;')
151 .html('&times;')
151 .click(function() {
152 .click(function() {
152 widget_area.slideUp('', function(){ widget_subarea.html(''); });
153 widget_area.slideUp('', function(){ widget_subarea.html(''); });
153 })
154 })
154 .appendTo(widget_prompt);
155 .appendTo(widget_prompt);
155
156
156 var output = $('<div></div>');
157 var output = $('<div></div>');
157 cell.append(input).append(widget_area).append(output);
158 cell.append(input).append(widget_area).append(output);
158 this.element = cell;
159 this.element = cell;
159 this.output_area = new IPython.OutputArea(output, true);
160 this.output_area = new IPython.OutputArea(output, true);
160 this.completer = new IPython.Completer(this);
161 this.completer = new IPython.Completer(this);
161 };
162 };
162
163
163 /** @method bind_events */
164 /** @method bind_events */
164 CodeCell.prototype.bind_events = function () {
165 CodeCell.prototype.bind_events = function () {
165 IPython.Cell.prototype.bind_events.apply(this);
166 IPython.Cell.prototype.bind_events.apply(this);
166 var that = this;
167 var that = this;
167
168
168 this.element.focusout(
169 this.element.focusout(
169 function() { that.auto_highlight(); }
170 function() { that.auto_highlight(); }
170 );
171 );
171 };
172 };
172
173
173 CodeCell.prototype.handle_keyevent = function (editor, event) {
174 CodeCell.prototype.handle_keyevent = function (editor, event) {
174
175
175 // console.log('CM', this.mode, event.which, event.type)
176 // console.log('CM', this.mode, event.which, event.type)
176
177
177 if (this.mode === 'command') {
178 if (this.mode === 'command') {
178 return true;
179 return true;
179 } else if (this.mode === 'edit') {
180 } else if (this.mode === 'edit') {
180 return this.handle_codemirror_keyevent(editor, event);
181 return this.handle_codemirror_keyevent(editor, event);
181 }
182 }
182 };
183 };
183
184
184 /**
185 /**
185 * This method gets called in CodeMirror's onKeyDown/onKeyPress
186 * This method gets called in CodeMirror's onKeyDown/onKeyPress
186 * handlers and is used to provide custom key handling. Its return
187 * handlers and is used to provide custom key handling. Its return
187 * value is used to determine if CodeMirror should ignore the event:
188 * value is used to determine if CodeMirror should ignore the event:
188 * true = ignore, false = don't ignore.
189 * true = ignore, false = don't ignore.
189 * @method handle_codemirror_keyevent
190 * @method handle_codemirror_keyevent
190 */
191 */
191 CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) {
192 CodeCell.prototype.handle_codemirror_keyevent = function (editor, event) {
192
193
193 var that = this;
194 var that = this;
194 // whatever key is pressed, first, cancel the tooltip request before
195 // whatever key is pressed, first, cancel the tooltip request before
195 // they are sent, and remove tooltip if any, except for tab again
196 // they are sent, and remove tooltip if any, except for tab again
196 var tooltip_closed = null;
197 var tooltip_closed = null;
197 if (event.type === 'keydown' && event.which != key.TAB ) {
198 if (event.type === 'keydown' && event.which != key.TAB ) {
198 tooltip_closed = IPython.tooltip.remove_and_cancel_tooltip();
199 tooltip_closed = IPython.tooltip.remove_and_cancel_tooltip();
199 }
200 }
200
201
201 var cur = editor.getCursor();
202 var cur = editor.getCursor();
202 if (event.keyCode === key.ENTER){
203 if (event.keyCode === key.ENTER){
203 this.auto_highlight();
204 this.auto_highlight();
204 }
205 }
205
206
206 if (event.keyCode === key.ENTER && (event.shiftKey || event.ctrlKey || event.altKey)) {
207 if (event.keyCode === key.ENTER && (event.shiftKey || event.ctrlKey || event.altKey)) {
207 // Always ignore shift-enter in CodeMirror as we handle it.
208 // Always ignore shift-enter in CodeMirror as we handle it.
208 return true;
209 return true;
209 } else if (event.which === 40 && event.type === 'keypress' && IPython.tooltip.time_before_tooltip >= 0) {
210 } else if (event.which === 40 && event.type === 'keypress' && IPython.tooltip.time_before_tooltip >= 0) {
210 // triger on keypress (!) otherwise inconsistent event.which depending on plateform
211 // triger on keypress (!) otherwise inconsistent event.which depending on plateform
211 // browser and keyboard layout !
212 // browser and keyboard layout !
212 // Pressing '(' , request tooltip, don't forget to reappend it
213 // Pressing '(' , request tooltip, don't forget to reappend it
213 // The second argument says to hide the tooltip if the docstring
214 // The second argument says to hide the tooltip if the docstring
214 // is actually empty
215 // is actually empty
215 IPython.tooltip.pending(that, true);
216 IPython.tooltip.pending(that, true);
216 } else if (event.which === key.UPARROW && event.type === 'keydown') {
217 } else if (event.which === key.UPARROW && event.type === 'keydown') {
217 // If we are not at the top, let CM handle the up arrow and
218 // If we are not at the top, let CM handle the up arrow and
218 // prevent the global keydown handler from handling it.
219 // prevent the global keydown handler from handling it.
219 if (!that.at_top()) {
220 if (!that.at_top()) {
220 event.stop();
221 event.stop();
221 return false;
222 return false;
222 } else {
223 } else {
223 return true;
224 return true;
224 }
225 }
225 } else if (event.which === key.ESC && event.type === 'keydown') {
226 } else if (event.which === key.ESC && event.type === 'keydown') {
226 // First see if the tooltip is active and if so cancel it.
227 // First see if the tooltip is active and if so cancel it.
227 if (tooltip_closed) {
228 if (tooltip_closed) {
228 // The call to remove_and_cancel_tooltip above in L177 doesn't pass
229 // The call to remove_and_cancel_tooltip above in L177 doesn't pass
229 // force=true. Because of this it won't actually close the tooltip
230 // force=true. Because of this it won't actually close the tooltip
230 // if it is in sticky mode. Thus, we have to check again if it is open
231 // if it is in sticky mode. Thus, we have to check again if it is open
231 // and close it with force=true.
232 // and close it with force=true.
232 if (!IPython.tooltip._hidden) {
233 if (!IPython.tooltip._hidden) {
233 IPython.tooltip.remove_and_cancel_tooltip(true);
234 IPython.tooltip.remove_and_cancel_tooltip(true);
234 }
235 }
235 // If we closed the tooltip, don't let CM or the global handlers
236 // If we closed the tooltip, don't let CM or the global handlers
236 // handle this event.
237 // handle this event.
237 event.stop();
238 event.stop();
238 return true;
239 return true;
239 }
240 }
240 if (that.code_mirror.options.keyMap === "vim-insert") {
241 if (that.code_mirror.options.keyMap === "vim-insert") {
241 // vim keyMap is active and in insert mode. In this case we leave vim
242 // vim keyMap is active and in insert mode. In this case we leave vim
242 // insert mode, but remain in notebook edit mode.
243 // insert mode, but remain in notebook edit mode.
243 // Let' CM handle this event and prevent global handling.
244 // Let' CM handle this event and prevent global handling.
244 event.stop();
245 event.stop();
245 return false;
246 return false;
246 } else {
247 } else {
247 // vim keyMap is not active. Leave notebook edit mode.
248 // vim keyMap is not active. Leave notebook edit mode.
248 // Don't let CM handle the event, defer to global handling.
249 // Don't let CM handle the event, defer to global handling.
249 return true;
250 return true;
250 }
251 }
251 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
252 } else if (event.which === key.DOWNARROW && event.type === 'keydown') {
252 // If we are not at the bottom, let CM handle the down arrow and
253 // If we are not at the bottom, let CM handle the down arrow and
253 // prevent the global keydown handler from handling it.
254 // prevent the global keydown handler from handling it.
254 if (!that.at_bottom()) {
255 if (!that.at_bottom()) {
255 event.stop();
256 event.stop();
256 return false;
257 return false;
257 } else {
258 } else {
258 return true;
259 return true;
259 }
260 }
260 } else if (event.keyCode === key.TAB && event.type === 'keydown' && event.shiftKey) {
261 } else if (event.keyCode === key.TAB && event.type === 'keydown' && event.shiftKey) {
261 if (editor.somethingSelected()){
262 if (editor.somethingSelected()){
262 var anchor = editor.getCursor("anchor");
263 var anchor = editor.getCursor("anchor");
263 var head = editor.getCursor("head");
264 var head = editor.getCursor("head");
264 if( anchor.line != head.line){
265 if( anchor.line != head.line){
265 return false;
266 return false;
266 }
267 }
267 }
268 }
268 IPython.tooltip.request(that);
269 IPython.tooltip.request(that);
269 event.stop();
270 event.stop();
270 return true;
271 return true;
271 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
272 } else if (event.keyCode === key.TAB && event.type == 'keydown') {
272 // Tab completion.
273 // Tab completion.
273 IPython.tooltip.remove_and_cancel_tooltip();
274 IPython.tooltip.remove_and_cancel_tooltip();
274 if (editor.somethingSelected()) {
275 if (editor.somethingSelected()) {
275 return false;
276 return false;
276 }
277 }
277 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
278 var pre_cursor = editor.getRange({line:cur.line,ch:0},cur);
278 if (pre_cursor.trim() === "") {
279 if (pre_cursor.trim() === "") {
279 // Don't autocomplete if the part of the line before the cursor
280 // Don't autocomplete if the part of the line before the cursor
280 // is empty. In this case, let CodeMirror handle indentation.
281 // is empty. In this case, let CodeMirror handle indentation.
281 return false;
282 return false;
282 } else {
283 } else {
283 event.stop();
284 event.stop();
284 this.completer.startCompletion();
285 this.completer.startCompletion();
285 return true;
286 return true;
286 }
287 }
287 } else {
288 } else {
288 // keypress/keyup also trigger on TAB press, and we don't want to
289 // keypress/keyup also trigger on TAB press, and we don't want to
289 // use those to disable tab completion.
290 // use those to disable tab completion.
290 return false;
291 return false;
291 }
292 }
292 return false;
293 return false;
293 };
294 };
294
295
295 // Kernel related calls.
296 // Kernel related calls.
296
297
297 CodeCell.prototype.set_kernel = function (kernel) {
298 CodeCell.prototype.set_kernel = function (kernel) {
298 this.kernel = kernel;
299 this.kernel = kernel;
299 };
300 };
300
301
301 /**
302 /**
302 * Execute current code cell to the kernel
303 * Execute current code cell to the kernel
303 * @method execute
304 * @method execute
304 */
305 */
305 CodeCell.prototype.execute = function () {
306 CodeCell.prototype.execute = function () {
306 this.output_area.clear_output();
307 this.output_area.clear_output();
307
308
308 // Clear widget area
309 // Clear widget area
309 this.widget_subarea.html('');
310 this.widget_subarea.html('');
310 this.widget_subarea.height('');
311 this.widget_subarea.height('');
311 this.widget_area.height('');
312 this.widget_area.height('');
312 this.widget_area.hide();
313 this.widget_area.hide();
313
314
314 this.set_input_prompt('*');
315 this.set_input_prompt('*');
315 this.element.addClass("running");
316 this.element.addClass("running");
316 if (this.last_msg_id) {
317 if (this.last_msg_id) {
317 this.kernel.clear_callbacks_for_msg(this.last_msg_id);
318 this.kernel.clear_callbacks_for_msg(this.last_msg_id);
318 }
319 }
319 var callbacks = this.get_callbacks();
320 var callbacks = this.get_callbacks();
320
321
321 var old_msg_id = this.last_msg_id;
322 var old_msg_id = this.last_msg_id;
322 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
323 this.last_msg_id = this.kernel.execute(this.get_text(), callbacks, {silent: false, store_history: true});
323 if (old_msg_id) {
324 if (old_msg_id) {
324 delete CodeCell.msg_cells[old_msg_id];
325 delete CodeCell.msg_cells[old_msg_id];
325 }
326 }
326 CodeCell.msg_cells[this.last_msg_id] = this;
327 CodeCell.msg_cells[this.last_msg_id] = this;
327 };
328 };
328
329
329 /**
330 /**
330 * Construct the default callbacks for
331 * Construct the default callbacks for
331 * @method get_callbacks
332 * @method get_callbacks
332 */
333 */
333 CodeCell.prototype.get_callbacks = function () {
334 CodeCell.prototype.get_callbacks = function () {
334 return {
335 return {
335 shell : {
336 shell : {
336 reply : $.proxy(this._handle_execute_reply, this),
337 reply : $.proxy(this._handle_execute_reply, this),
337 payload : {
338 payload : {
338 set_next_input : $.proxy(this._handle_set_next_input, this),
339 set_next_input : $.proxy(this._handle_set_next_input, this),
339 page : $.proxy(this._open_with_pager, this)
340 page : $.proxy(this._open_with_pager, this)
340 }
341 }
341 },
342 },
342 iopub : {
343 iopub : {
343 output : $.proxy(this.output_area.handle_output, this.output_area),
344 output : $.proxy(this.output_area.handle_output, this.output_area),
344 clear_output : $.proxy(this.output_area.handle_clear_output, this.output_area),
345 clear_output : $.proxy(this.output_area.handle_clear_output, this.output_area),
345 },
346 },
346 input : $.proxy(this._handle_input_request, this)
347 input : $.proxy(this._handle_input_request, this)
347 };
348 };
348 };
349 };
349
350
350 CodeCell.prototype._open_with_pager = function (payload) {
351 CodeCell.prototype._open_with_pager = function (payload) {
351 $([IPython.events]).trigger('open_with_text.Pager', payload);
352 $([IPython.events]).trigger('open_with_text.Pager', payload);
352 };
353 };
353
354
354 /**
355 /**
355 * @method _handle_execute_reply
356 * @method _handle_execute_reply
356 * @private
357 * @private
357 */
358 */
358 CodeCell.prototype._handle_execute_reply = function (msg) {
359 CodeCell.prototype._handle_execute_reply = function (msg) {
359 this.set_input_prompt(msg.content.execution_count);
360 this.set_input_prompt(msg.content.execution_count);
360 this.element.removeClass("running");
361 this.element.removeClass("running");
361 $([IPython.events]).trigger('set_dirty.Notebook', {value: true});
362 $([IPython.events]).trigger('set_dirty.Notebook', {value: true});
362 };
363 };
363
364
364 /**
365 /**
365 * @method _handle_set_next_input
366 * @method _handle_set_next_input
366 * @private
367 * @private
367 */
368 */
368 CodeCell.prototype._handle_set_next_input = function (payload) {
369 CodeCell.prototype._handle_set_next_input = function (payload) {
369 var data = {'cell': this, 'text': payload.text};
370 var data = {'cell': this, 'text': payload.text};
370 $([IPython.events]).trigger('set_next_input.Notebook', data);
371 $([IPython.events]).trigger('set_next_input.Notebook', data);
371 };
372 };
372
373
373 /**
374 /**
374 * @method _handle_input_request
375 * @method _handle_input_request
375 * @private
376 * @private
376 */
377 */
377 CodeCell.prototype._handle_input_request = function (msg) {
378 CodeCell.prototype._handle_input_request = function (msg) {
378 this.output_area.append_raw_input(msg);
379 this.output_area.append_raw_input(msg);
379 };
380 };
380
381
381
382
382 // Basic cell manipulation.
383 // Basic cell manipulation.
383
384
384 CodeCell.prototype.select = function () {
385 CodeCell.prototype.select = function () {
385 var cont = IPython.Cell.prototype.select.apply(this);
386 var cont = IPython.Cell.prototype.select.apply(this);
386 if (cont) {
387 if (cont) {
387 this.code_mirror.refresh();
388 this.code_mirror.refresh();
388 this.auto_highlight();
389 this.auto_highlight();
389 }
390 }
390 return cont;
391 return cont;
391 };
392 };
392
393
393 CodeCell.prototype.render = function () {
394 CodeCell.prototype.render = function () {
394 var cont = IPython.Cell.prototype.render.apply(this);
395 var cont = IPython.Cell.prototype.render.apply(this);
395 // Always execute, even if we are already in the rendered state
396 // Always execute, even if we are already in the rendered state
396 return cont;
397 return cont;
397 };
398 };
398
399
399 CodeCell.prototype.unrender = function () {
400 CodeCell.prototype.unrender = function () {
400 // CodeCell is always rendered
401 // CodeCell is always rendered
401 return false;
402 return false;
402 };
403 };
403
404
404 CodeCell.prototype.edit_mode = function () {
405 CodeCell.prototype.edit_mode = function () {
405 var cont = IPython.Cell.prototype.edit_mode.apply(this);
406 var cont = IPython.Cell.prototype.edit_mode.apply(this);
406 if (cont) {
407 if (cont) {
407 this.focus_editor();
408 this.focus_editor();
408 }
409 }
409 return cont;
410 return cont;
410 }
411 }
411
412
412 CodeCell.prototype.select_all = function () {
413 CodeCell.prototype.select_all = function () {
413 var start = {line: 0, ch: 0};
414 var start = {line: 0, ch: 0};
414 var nlines = this.code_mirror.lineCount();
415 var nlines = this.code_mirror.lineCount();
415 var last_line = this.code_mirror.getLine(nlines-1);
416 var last_line = this.code_mirror.getLine(nlines-1);
416 var end = {line: nlines-1, ch: last_line.length};
417 var end = {line: nlines-1, ch: last_line.length};
417 this.code_mirror.setSelection(start, end);
418 this.code_mirror.setSelection(start, end);
418 };
419 };
419
420
420
421
421 CodeCell.prototype.collapse_output = function () {
422 CodeCell.prototype.collapse_output = function () {
422 this.collapsed = true;
423 this.collapsed = true;
423 this.output_area.collapse();
424 this.output_area.collapse();
424 };
425 };
425
426
426
427
427 CodeCell.prototype.expand_output = function () {
428 CodeCell.prototype.expand_output = function () {
428 this.collapsed = false;
429 this.collapsed = false;
429 this.output_area.expand();
430 this.output_area.expand();
430 this.output_area.unscroll_area();
431 this.output_area.unscroll_area();
431 };
432 };
432
433
433 CodeCell.prototype.scroll_output = function () {
434 CodeCell.prototype.scroll_output = function () {
434 this.output_area.expand();
435 this.output_area.expand();
435 this.output_area.scroll_if_long();
436 this.output_area.scroll_if_long();
436 };
437 };
437
438
438 CodeCell.prototype.toggle_output = function () {
439 CodeCell.prototype.toggle_output = function () {
439 this.collapsed = Boolean(1 - this.collapsed);
440 this.collapsed = Boolean(1 - this.collapsed);
440 this.output_area.toggle_output();
441 this.output_area.toggle_output();
441 };
442 };
442
443
443 CodeCell.prototype.toggle_output_scroll = function () {
444 CodeCell.prototype.toggle_output_scroll = function () {
444 this.output_area.toggle_scroll();
445 this.output_area.toggle_scroll();
445 };
446 };
446
447
447
448
448 CodeCell.input_prompt_classical = function (prompt_value, lines_number) {
449 CodeCell.input_prompt_classical = function (prompt_value, lines_number) {
449 var ns;
450 var ns;
450 if (prompt_value == undefined) {
451 if (prompt_value == undefined) {
451 ns = "&nbsp;";
452 ns = "&nbsp;";
452 } else {
453 } else {
453 ns = encodeURIComponent(prompt_value);
454 ns = encodeURIComponent(prompt_value);
454 }
455 }
455 return 'In&nbsp;[' + ns + ']:';
456 return 'In&nbsp;[' + ns + ']:';
456 };
457 };
457
458
458 CodeCell.input_prompt_continuation = function (prompt_value, lines_number) {
459 CodeCell.input_prompt_continuation = function (prompt_value, lines_number) {
459 var html = [CodeCell.input_prompt_classical(prompt_value, lines_number)];
460 var html = [CodeCell.input_prompt_classical(prompt_value, lines_number)];
460 for(var i=1; i < lines_number; i++) {
461 for(var i=1; i < lines_number; i++) {
461 html.push(['...:']);
462 html.push(['...:']);
462 }
463 }
463 return html.join('<br/>');
464 return html.join('<br/>');
464 };
465 };
465
466
466 CodeCell.input_prompt_function = CodeCell.input_prompt_classical;
467 CodeCell.input_prompt_function = CodeCell.input_prompt_classical;
467
468
468
469
469 CodeCell.prototype.set_input_prompt = function (number) {
470 CodeCell.prototype.set_input_prompt = function (number) {
470 var nline = 1;
471 var nline = 1;
471 if (this.code_mirror !== undefined) {
472 if (this.code_mirror !== undefined) {
472 nline = this.code_mirror.lineCount();
473 nline = this.code_mirror.lineCount();
473 }
474 }
474 this.input_prompt_number = number;
475 this.input_prompt_number = number;
475 var prompt_html = CodeCell.input_prompt_function(this.input_prompt_number, nline);
476 var prompt_html = CodeCell.input_prompt_function(this.input_prompt_number, nline);
476 this.element.find('div.input_prompt').html(prompt_html);
477 this.element.find('div.input_prompt').html(prompt_html);
477 };
478 };
478
479
479
480
480 CodeCell.prototype.clear_input = function () {
481 CodeCell.prototype.clear_input = function () {
481 this.code_mirror.setValue('');
482 this.code_mirror.setValue('');
482 };
483 };
483
484
484
485
485 CodeCell.prototype.get_text = function () {
486 CodeCell.prototype.get_text = function () {
486 return this.code_mirror.getValue();
487 return this.code_mirror.getValue();
487 };
488 };
488
489
489
490
490 CodeCell.prototype.set_text = function (code) {
491 CodeCell.prototype.set_text = function (code) {
491 return this.code_mirror.setValue(code);
492 return this.code_mirror.setValue(code);
492 };
493 };
493
494
494
495
495 CodeCell.prototype.at_top = function () {
496 CodeCell.prototype.at_top = function () {
496 var cursor = this.code_mirror.getCursor();
497 var cursor = this.code_mirror.getCursor();
497 if (cursor.line === 0 && cursor.ch === 0) {
498 if (cursor.line === 0 && cursor.ch === 0) {
498 return true;
499 return true;
499 } else {
500 } else {
500 return false;
501 return false;
501 }
502 }
502 };
503 };
503
504
504
505
505 CodeCell.prototype.at_bottom = function () {
506 CodeCell.prototype.at_bottom = function () {
506 var cursor = this.code_mirror.getCursor();
507 var cursor = this.code_mirror.getCursor();
507 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
508 if (cursor.line === (this.code_mirror.lineCount()-1) && cursor.ch === this.code_mirror.getLine(cursor.line).length) {
508 return true;
509 return true;
509 } else {
510 } else {
510 return false;
511 return false;
511 }
512 }
512 };
513 };
513
514
514
515
515 CodeCell.prototype.clear_output = function (wait) {
516 CodeCell.prototype.clear_output = function (wait) {
516 this.output_area.clear_output(wait);
517 this.output_area.clear_output(wait);
517 this.set_input_prompt();
518 this.set_input_prompt();
518 };
519 };
519
520
520
521
521 // JSON serialization
522 // JSON serialization
522
523
523 CodeCell.prototype.fromJSON = function (data) {
524 CodeCell.prototype.fromJSON = function (data) {
524 IPython.Cell.prototype.fromJSON.apply(this, arguments);
525 IPython.Cell.prototype.fromJSON.apply(this, arguments);
525 if (data.cell_type === 'code') {
526 if (data.cell_type === 'code') {
526 if (data.input !== undefined) {
527 if (data.input !== undefined) {
527 this.set_text(data.input);
528 this.set_text(data.input);
528 // make this value the starting point, so that we can only undo
529 // make this value the starting point, so that we can only undo
529 // to this state, instead of a blank cell
530 // to this state, instead of a blank cell
530 this.code_mirror.clearHistory();
531 this.code_mirror.clearHistory();
531 this.auto_highlight();
532 this.auto_highlight();
532 }
533 }
533 if (data.prompt_number !== undefined) {
534 if (data.prompt_number !== undefined) {
534 this.set_input_prompt(data.prompt_number);
535 this.set_input_prompt(data.prompt_number);
535 } else {
536 } else {
536 this.set_input_prompt();
537 this.set_input_prompt();
537 }
538 }
538 this.output_area.trusted = data.trusted || false;
539 this.output_area.trusted = data.trusted || false;
539 this.output_area.fromJSON(data.outputs);
540 this.output_area.fromJSON(data.outputs);
540 if (data.collapsed !== undefined) {
541 if (data.collapsed !== undefined) {
541 if (data.collapsed) {
542 if (data.collapsed) {
542 this.collapse_output();
543 this.collapse_output();
543 } else {
544 } else {
544 this.expand_output();
545 this.expand_output();
545 }
546 }
546 }
547 }
547 }
548 }
548 };
549 };
549
550
550
551
551 CodeCell.prototype.toJSON = function () {
552 CodeCell.prototype.toJSON = function () {
552 var data = IPython.Cell.prototype.toJSON.apply(this);
553 var data = IPython.Cell.prototype.toJSON.apply(this);
553 data.input = this.get_text();
554 data.input = this.get_text();
554 // is finite protect against undefined and '*' value
555 // is finite protect against undefined and '*' value
555 if (isFinite(this.input_prompt_number)) {
556 if (isFinite(this.input_prompt_number)) {
556 data.prompt_number = this.input_prompt_number;
557 data.prompt_number = this.input_prompt_number;
557 }
558 }
558 var outputs = this.output_area.toJSON();
559 var outputs = this.output_area.toJSON();
559 data.outputs = outputs;
560 data.outputs = outputs;
560 data.language = 'python';
561 data.language = 'python';
561 data.trusted = this.output_area.trusted;
562 data.trusted = this.output_area.trusted;
562 data.collapsed = this.collapsed;
563 data.collapsed = this.collapsed;
563 return data;
564 return data;
564 };
565 };
565
566
566
567
567 IPython.CodeCell = CodeCell;
568 IPython.CodeCell = CodeCell;
568
569
569 return IPython;
570 return IPython;
570 }(IPython));
571 }(IPython));
@@ -1,351 +1,352 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/codemirror/lib/codemirror.css") }}">
14 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
15
15
16 {{super()}}
16 {{super()}}
17
17
18 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
18 <link rel="stylesheet" href="{{ static_url("notebook/css/override.css") }}" type="text/css" />
19
19
20 {% endblock %}
20 {% endblock %}
21
21
22 {% block params %}
22 {% block params %}
23
23
24 data-project="{{project}}"
24 data-project="{{project}}"
25 data-base-url="{{base_url}}"
25 data-base-url="{{base_url}}"
26 data-notebook-name="{{notebook_name}}"
26 data-notebook-name="{{notebook_name}}"
27 data-notebook-path="{{notebook_path}}"
27 data-notebook-path="{{notebook_path}}"
28 class="notebook_app"
28 class="notebook_app"
29
29
30 {% endblock %}
30 {% endblock %}
31
31
32
32
33 {% block header %}
33 {% block header %}
34
34
35 <span id="save_widget" class="nav pull-left">
35 <span id="save_widget" class="nav pull-left">
36 <span id="notebook_name"></span>
36 <span id="notebook_name"></span>
37 <span id="checkpoint_status"></span>
37 <span id="checkpoint_status"></span>
38 <span id="autosave_status"></span>
38 <span id="autosave_status"></span>
39 </span>
39 </span>
40
40
41 {% endblock %}
41 {% endblock %}
42
42
43
43
44 {% block site %}
44 {% block site %}
45
45
46 <div id="menubar-container" class="container">
46 <div id="menubar-container" class="container">
47 <div id="menubar">
47 <div id="menubar">
48 <div class="navbar">
48 <div class="navbar">
49 <div class="navbar-inner">
49 <div class="navbar-inner">
50 <div class="container">
50 <div class="container">
51 <ul id="menus" class="nav">
51 <ul id="menus" class="nav">
52 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
52 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">File</a>
53 <ul id="file_menu" class="dropdown-menu">
53 <ul id="file_menu" class="dropdown-menu">
54 <li id="new_notebook"
54 <li id="new_notebook"
55 title="Make a new notebook (Opens a new window)">
55 title="Make a new notebook (Opens a new window)">
56 <a href="#">New</a></li>
56 <a href="#">New</a></li>
57 <li id="open_notebook"
57 <li id="open_notebook"
58 title="Opens a new window with the Dashboard view">
58 title="Opens a new window with the Dashboard view">
59 <a href="#">Open...</a></li>
59 <a href="#">Open...</a></li>
60 <!-- <hr/> -->
60 <!-- <hr/> -->
61 <li class="divider"></li>
61 <li class="divider"></li>
62 <li id="copy_notebook"
62 <li id="copy_notebook"
63 title="Open a copy of this notebook's contents and start a new kernel">
63 title="Open a copy of this notebook's contents and start a new kernel">
64 <a href="#">Make a Copy...</a></li>
64 <a href="#">Make a Copy...</a></li>
65 <li id="rename_notebook"><a href="#">Rename...</a></li>
65 <li id="rename_notebook"><a href="#">Rename...</a></li>
66 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
66 <li id="save_checkpoint"><a href="#">Save and Checkpoint</a></li>
67 <!-- <hr/> -->
67 <!-- <hr/> -->
68 <li class="divider"></li>
68 <li class="divider"></li>
69 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
69 <li id="restore_checkpoint" class="dropdown-submenu"><a href="#">Revert to Checkpoint</a>
70 <ul class="dropdown-menu">
70 <ul class="dropdown-menu">
71 <li><a href="#"></a></li>
71 <li><a href="#"></a></li>
72 <li><a href="#"></a></li>
72 <li><a href="#"></a></li>
73 <li><a href="#"></a></li>
73 <li><a href="#"></a></li>
74 <li><a href="#"></a></li>
74 <li><a href="#"></a></li>
75 <li><a href="#"></a></li>
75 <li><a href="#"></a></li>
76 </ul>
76 </ul>
77 </li>
77 </li>
78 <li class="divider"></li>
78 <li class="divider"></li>
79 <li id="print_preview"><a href="#">Print Preview</a></li>
79 <li id="print_preview"><a href="#">Print Preview</a></li>
80 <li class="dropdown-submenu"><a href="#">Download as</a>
80 <li class="dropdown-submenu"><a href="#">Download as</a>
81 <ul class="dropdown-menu">
81 <ul class="dropdown-menu">
82 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
82 <li id="download_ipynb"><a href="#">IPython Notebook (.ipynb)</a></li>
83 <li id="download_py"><a href="#">Python (.py)</a></li>
83 <li id="download_py"><a href="#">Python (.py)</a></li>
84 <li id="download_html"><a href="#">HTML (.html)</a></li>
84 <li id="download_html"><a href="#">HTML (.html)</a></li>
85 <li id="download_rst"><a href="#">reST (.rst)</a></li>
85 <li id="download_rst"><a href="#">reST (.rst)</a></li>
86 </ul>
86 </ul>
87 </li>
87 </li>
88 <li class="divider"></li>
88 <li class="divider"></li>
89
89
90 <li id="kill_and_exit"
90 <li id="kill_and_exit"
91 title="Shutdown this notebook's kernel, and close this window">
91 title="Shutdown this notebook's kernel, and close this window">
92 <a href="#" >Close and halt</a></li>
92 <a href="#" >Close and halt</a></li>
93 </ul>
93 </ul>
94 </li>
94 </li>
95 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
95 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Edit</a>
96 <ul id="edit_menu" class="dropdown-menu">
96 <ul id="edit_menu" class="dropdown-menu">
97 <li id="cut_cell"><a href="#">Cut Cell</a></li>
97 <li id="cut_cell"><a href="#">Cut Cell</a></li>
98 <li id="copy_cell"><a href="#">Copy Cell</a></li>
98 <li id="copy_cell"><a href="#">Copy Cell</a></li>
99 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
99 <li id="paste_cell_above" class="disabled"><a href="#">Paste Cell Above</a></li>
100 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
100 <li id="paste_cell_below" class="disabled"><a href="#">Paste Cell Below</a></li>
101 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
101 <li id="paste_cell_replace" class="disabled"><a href="#">Paste Cell &amp; Replace</a></li>
102 <li id="delete_cell"><a href="#">Delete Cell</a></li>
102 <li id="delete_cell"><a href="#">Delete Cell</a></li>
103 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
103 <li id="undelete_cell" class="disabled"><a href="#">Undo Delete Cell</a></li>
104 <li class="divider"></li>
104 <li class="divider"></li>
105 <li id="split_cell"><a href="#">Split Cell</a></li>
105 <li id="split_cell"><a href="#">Split Cell</a></li>
106 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
106 <li id="merge_cell_above"><a href="#">Merge Cell Above</a></li>
107 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
107 <li id="merge_cell_below"><a href="#">Merge Cell Below</a></li>
108 <li class="divider"></li>
108 <li class="divider"></li>
109 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
109 <li id="move_cell_up"><a href="#">Move Cell Up</a></li>
110 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
110 <li id="move_cell_down"><a href="#">Move Cell Down</a></li>
111 <li class="divider"></li>
111 <li class="divider"></li>
112 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
112 <li id="edit_nb_metadata"><a href="#">Edit Notebook Metadata</a></li>
113 </ul>
113 </ul>
114 </li>
114 </li>
115 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
115 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View</a>
116 <ul id="view_menu" class="dropdown-menu">
116 <ul id="view_menu" class="dropdown-menu">
117 <li id="toggle_header"
117 <li id="toggle_header"
118 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
118 title="Show/Hide the IPython Notebook logo and notebook title (above menu bar)">
119 <a href="#">Toggle Header</a></li>
119 <a href="#">Toggle Header</a></li>
120 <li id="toggle_toolbar"
120 <li id="toggle_toolbar"
121 title="Show/Hide the action icons (below menu bar)">
121 title="Show/Hide the action icons (below menu bar)">
122 <a href="#">Toggle Toolbar</a></li>
122 <a href="#">Toggle Toolbar</a></li>
123 </ul>
123 </ul>
124 </li>
124 </li>
125 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
125 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Insert</a>
126 <ul id="insert_menu" class="dropdown-menu">
126 <ul id="insert_menu" class="dropdown-menu">
127 <li id="insert_cell_above"
127 <li id="insert_cell_above"
128 title="Insert an empty Code cell above the currently active cell">
128 title="Insert an empty Code cell above the currently active cell">
129 <a href="#">Insert Cell Above</a></li>
129 <a href="#">Insert Cell Above</a></li>
130 <li id="insert_cell_below"
130 <li id="insert_cell_below"
131 title="Insert an empty Code cell below the currently active cell">
131 title="Insert an empty Code cell below the currently active cell">
132 <a href="#">Insert Cell Below</a></li>
132 <a href="#">Insert Cell Below</a></li>
133 </ul>
133 </ul>
134 </li>
134 </li>
135 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
135 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Cell</a>
136 <ul id="cell_menu" class="dropdown-menu">
136 <ul id="cell_menu" class="dropdown-menu">
137 <li id="run_cell" title="Run this cell, and move cursor to the next one">
137 <li id="run_cell" title="Run this cell, and move cursor to the next one">
138 <a href="#">Run</a></li>
138 <a href="#">Run</a></li>
139 <li id="run_cell_select_below" title="Run this cell, select below">
139 <li id="run_cell_select_below" title="Run this cell, select below">
140 <a href="#">Run and Select Below</a></li>
140 <a href="#">Run and Select Below</a></li>
141 <li id="run_cell_insert_below" title="Run this cell, insert below">
141 <li id="run_cell_insert_below" title="Run this cell, insert below">
142 <a href="#">Run and Insert Below</a></li>
142 <a href="#">Run and Insert Below</a></li>
143 <li id="run_all_cells" title="Run all cells in the notebook">
143 <li id="run_all_cells" title="Run all cells in the notebook">
144 <a href="#">Run All</a></li>
144 <a href="#">Run All</a></li>
145 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
145 <li id="run_all_cells_above" title="Run all cells above (but not including) this cell">
146 <a href="#">Run All Above</a></li>
146 <a href="#">Run All Above</a></li>
147 <li id="run_all_cells_below" title="Run this cell and all cells below it">
147 <li id="run_all_cells_below" title="Run this cell and all cells below it">
148 <a href="#">Run All Below</a></li>
148 <a href="#">Run All Below</a></li>
149 <li class="divider"></li>
149 <li class="divider"></li>
150 <li id="change_cell_type" class="dropdown-submenu"
150 <li id="change_cell_type" class="dropdown-submenu"
151 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
151 title="All cells in the notebook have a cell type. By default, new cells are created as 'Code' cells">
152 <a href="#">Cell Type</a>
152 <a href="#">Cell Type</a>
153 <ul class="dropdown-menu">
153 <ul class="dropdown-menu">
154 <li id="to_code"
154 <li id="to_code"
155 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
155 title="Contents will be sent to the kernel for execution, and output will display in the footer of cell">
156 <a href="#">Code</a></li>
156 <a href="#">Code</a></li>
157 <li id="to_markdown"
157 <li id="to_markdown"
158 title="Contents will be rendered as HTML and serve as explanatory text">
158 title="Contents will be rendered as HTML and serve as explanatory text">
159 <a href="#">Markdown</a></li>
159 <a href="#">Markdown</a></li>
160 <li id="to_raw"
160 <li id="to_raw"
161 title="Contents will pass through nbconvert unmodified">
161 title="Contents will pass through nbconvert unmodified">
162 <a href="#">Raw NBConvert</a></li>
162 <a href="#">Raw NBConvert</a></li>
163 <li id="to_heading1"><a href="#">Heading 1</a></li>
163 <li id="to_heading1"><a href="#">Heading 1</a></li>
164 <li id="to_heading2"><a href="#">Heading 2</a></li>
164 <li id="to_heading2"><a href="#">Heading 2</a></li>
165 <li id="to_heading3"><a href="#">Heading 3</a></li>
165 <li id="to_heading3"><a href="#">Heading 3</a></li>
166 <li id="to_heading4"><a href="#">Heading 4</a></li>
166 <li id="to_heading4"><a href="#">Heading 4</a></li>
167 <li id="to_heading5"><a href="#">Heading 5</a></li>
167 <li id="to_heading5"><a href="#">Heading 5</a></li>
168 <li id="to_heading6"><a href="#">Heading 6</a></li>
168 <li id="to_heading6"><a href="#">Heading 6</a></li>
169 </ul>
169 </ul>
170 </li>
170 </li>
171 <li class="divider"></li>
171 <li class="divider"></li>
172 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
172 <li id="current_outputs" class="dropdown-submenu"><a href="#">Current Output</a>
173 <ul class="dropdown-menu">
173 <ul class="dropdown-menu">
174 <li id="toggle_current_output"
174 <li id="toggle_current_output"
175 title="Hide/Show the output of the current cell">
175 title="Hide/Show the output of the current cell">
176 <a href="#">Toggle</a>
176 <a href="#">Toggle</a>
177 </li>
177 </li>
178 <li id="toggle_current_output_scroll"
178 <li id="toggle_current_output_scroll"
179 title="Scroll the output of the current cell">
179 title="Scroll the output of the current cell">
180 <a href="#">Toggle Scrolling</a>
180 <a href="#">Toggle Scrolling</a>
181 </li>
181 </li>
182 <li id="clear_current_output"
182 <li id="clear_current_output"
183 title="Clear the output of the current cell">
183 title="Clear the output of the current cell">
184 <a href="#">Clear</a>
184 <a href="#">Clear</a>
185 </li>
185 </li>
186 </ul>
186 </ul>
187 </li>
187 </li>
188 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
188 <li id="all_outputs" class="dropdown-submenu"><a href="#">All Output</a>
189 <ul class="dropdown-menu">
189 <ul class="dropdown-menu">
190 <li id="toggle_all_output"
190 <li id="toggle_all_output"
191 title="Hide/Show the output of all cells">
191 title="Hide/Show the output of all cells">
192 <a href="#">Toggle</a>
192 <a href="#">Toggle</a>
193 </li>
193 </li>
194 <li id="toggle_all_output_scroll"
194 <li id="toggle_all_output_scroll"
195 title="Scroll the output of all cells">
195 title="Scroll the output of all cells">
196 <a href="#">Toggle Scrolling</a>
196 <a href="#">Toggle Scrolling</a>
197 </li>
197 </li>
198 <li id="clear_all_output"
198 <li id="clear_all_output"
199 title="Clear the output of all cells">
199 title="Clear the output of all cells">
200 <a href="#">Clear</a>
200 <a href="#">Clear</a>
201 </li>
201 </li>
202 </ul>
202 </ul>
203 </li>
203 </li>
204 </ul>
204 </ul>
205 </li>
205 </li>
206 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
206 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Kernel</a>
207 <ul id="kernel_menu" class="dropdown-menu">
207 <ul id="kernel_menu" class="dropdown-menu">
208 <li id="int_kernel"
208 <li id="int_kernel"
209 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
209 title="Send KeyboardInterrupt (CTRL-C) to the Kernel">
210 <a href="#">Interrupt</a></li>
210 <a href="#">Interrupt</a></li>
211 <li id="restart_kernel"
211 <li id="restart_kernel"
212 title="Restart the Kernel">
212 title="Restart the Kernel">
213 <a href="#">Restart</a></li>
213 <a href="#">Restart</a></li>
214 </ul>
214 </ul>
215 </li>
215 </li>
216 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
216 <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Help</a>
217 <ul id="help_menu" class="dropdown-menu">
217 <ul id="help_menu" class="dropdown-menu">
218 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
218 <li id="keyboard_shortcuts" title="Opens a tooltip with all keyboard shortcuts"><a href="#">Keyboard Shortcuts</a></li>
219 <li class="divider"></li>
219 <li class="divider"></li>
220 {% set
220 {% set
221 sections = (
221 sections = (
222 (
222 (
223 ("http://ipython.org/documentation.html","IPython Help",True),
223 ("http://ipython.org/documentation.html","IPython Help",True),
224 ("http://nbviewer.ipython.org/github/ipython/ipython/tree/master/examples/notebooks/", "Notebook Examples", True),
224 ("http://nbviewer.ipython.org/github/ipython/ipython/tree/master/examples/notebooks/", "Notebook Examples", True),
225 ("http://ipython.org/ipython-doc/stable/interactive/notebook.html","Notebook Help",True),
225 ("http://ipython.org/ipython-doc/stable/interactive/notebook.html","Notebook Help",True),
226 ("http://ipython.org/ipython-doc/dev/interactive/cm_keyboard.html","Editor Shortcuts",True),
226 ("http://ipython.org/ipython-doc/dev/interactive/cm_keyboard.html","Editor Shortcuts",True),
227 ),(
227 ),(
228 ("http://docs.python.org","Python",True),
228 ("http://docs.python.org","Python",True),
229 ("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
229 ("http://docs.scipy.org/doc/numpy/reference/","NumPy",True),
230 ("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
230 ("http://docs.scipy.org/doc/scipy/reference/","SciPy",True),
231 ("http://matplotlib.org/contents.html","Matplotlib",True),
231 ("http://matplotlib.org/contents.html","Matplotlib",True),
232 ("http://docs.sympy.org/dev/index.html","SymPy",True),
232 ("http://docs.sympy.org/dev/index.html","SymPy",True),
233 ("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
233 ("http://pandas.pydata.org/pandas-docs/stable/","pandas", True)
234 )
234 )
235 )
235 )
236 %}
236 %}
237
237
238 {% for helplinks in sections %}
238 {% for helplinks in sections %}
239 {% for link in helplinks %}
239 {% for link in helplinks %}
240 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
240 <li><a href="{{link[0]}}" {{'target="_blank" title="Opens in a new window"' if link[2]}}>
241 {{'<i class="icon-external-link menu-icon pull-right"></i>' if link[2]}}
241 {{'<i class="icon-external-link menu-icon pull-right"></i>' if link[2]}}
242 {{link[1]}}
242 {{link[1]}}
243 </a></li>
243 </a></li>
244 {% endfor %}
244 {% endfor %}
245 {% if not loop.last %}
245 {% if not loop.last %}
246 <li class="divider"></li>
246 <li class="divider"></li>
247 {% endif %}
247 {% endif %}
248 {% endfor %}
248 {% endfor %}
249 </li>
249 </li>
250 </ul>
250 </ul>
251 </li>
251 </li>
252 </ul>
252 </ul>
253 <div id="kernel_indicator" class="indicator_area pull-right">
253 <div id="kernel_indicator" class="indicator_area pull-right">
254 <i id="kernel_indicator_icon"></i>
254 <i id="kernel_indicator_icon"></i>
255 </div>
255 </div>
256 <div id="modal_indicator" class="indicator_area pull-right">
256 <div id="modal_indicator" class="indicator_area pull-right">
257 <i id="modal_indicator_icon"></i>
257 <i id="modal_indicator_icon"></i>
258 </div>
258 </div>
259 <div id="notification_area"></div>
259 <div id="notification_area"></div>
260 </div>
260 </div>
261 </div>
261 </div>
262 </div>
262 </div>
263 </div>
263 </div>
264 <div id="maintoolbar" class="navbar">
264 <div id="maintoolbar" class="navbar">
265 <div class="toolbar-inner navbar-inner navbar-nobg">
265 <div class="toolbar-inner navbar-inner navbar-nobg">
266 <div id="maintoolbar-container" class="container"></div>
266 <div id="maintoolbar-container" class="container"></div>
267 </div>
267 </div>
268 </div>
268 </div>
269 </div>
269 </div>
270
270
271 <div id="ipython-main-app">
271 <div id="ipython-main-app">
272
272
273 <div id="notebook_panel">
273 <div id="notebook_panel">
274 <div id="notebook"></div>
274 <div id="notebook"></div>
275 <div id="pager_splitter"></div>
275 <div id="pager_splitter"></div>
276 <div id="pager">
276 <div id="pager">
277 <div id='pager_button_area'>
277 <div id='pager_button_area'>
278 </div>
278 </div>
279 <div id="pager-container" class="container"></div>
279 <div id="pager-container" class="container"></div>
280 </div>
280 </div>
281 </div>
281 </div>
282
282
283 </div>
283 </div>
284 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
284 <div id='tooltip' class='ipython_tooltip' style='display:none'></div>
285
285
286
286
287 {% endblock %}
287 {% endblock %}
288
288
289
289
290 {% block script %}
290 {% block script %}
291
291
292 {{super()}}
292 {{super()}}
293
293
294 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
294 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
295 <script type="text/javascript">
295 <script type="text/javascript">
296 CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}";
296 CodeMirror.modeURL = "{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}";
297 </script>
297 </script>
298 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
298 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
299 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
299 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
300 <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script>
300 <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script>
301 <script src="{{ static_url("components/codemirror/addon/edit/matchbrackets.js") }}" charset="utf-8"></script>
301 <script src="{{ static_url("components/codemirror/addon/edit/matchbrackets.js") }}" charset="utf-8"></script>
302 <script src="{{ static_url("components/codemirror/addon/edit/closebrackets.js") }}" charset="utf-8"></script>
302 <script src="{{ static_url("components/codemirror/addon/comment/comment.js") }}" charset="utf-8"></script>
303 <script src="{{ static_url("components/codemirror/addon/comment/comment.js") }}" charset="utf-8"></script>
303 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
304 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
304 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
305 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
305 <script src="{{ static_url("components/codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
306 <script src="{{ static_url("components/codemirror/mode/javascript/javascript.js") }}" charset="utf-8"></script>
306 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
307 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
307 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
308 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
308 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
309 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
309 <script src="{{ static_url("components/codemirror/mode/gfm/gfm.js") }}" charset="utf-8"></script>
310 <script src="{{ static_url("components/codemirror/mode/gfm/gfm.js") }}" charset="utf-8"></script>
310 <script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script>
311 <script src="{{ static_url("components/codemirror/mode/python/python.js") }}" charset="utf-8"></script>
311 <script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script>
312 <script src="{{ static_url("notebook/js/codemirror-ipython.js") }}" charset="utf-8"></script>
312
313
313 <script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
314 <script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
314
315
315 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
316 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
316
317
317 <script src="{{ static_url("base/js/events.js") }}" type="text/javascript" charset="utf-8"></script>
318 <script src="{{ static_url("base/js/events.js") }}" type="text/javascript" charset="utf-8"></script>
318 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
319 <script src="{{ static_url("base/js/utils.js") }}" type="text/javascript" charset="utf-8"></script>
319 <script src="{{ static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
320 <script src="{{ static_url("base/js/dialog.js") }}" type="text/javascript" charset="utf-8"></script>
320 <script src="{{ static_url("services/kernels/js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
321 <script src="{{ static_url("services/kernels/js/kernel.js") }}" type="text/javascript" charset="utf-8"></script>
321 <script src="{{ static_url("services/kernels/js/comm.js") }}" type="text/javascript" charset="utf-8"></script>
322 <script src="{{ static_url("services/kernels/js/comm.js") }}" type="text/javascript" charset="utf-8"></script>
322 <script src="{{ static_url("services/sessions/js/session.js") }}" type="text/javascript" charset="utf-8"></script>
323 <script src="{{ static_url("services/sessions/js/session.js") }}" type="text/javascript" charset="utf-8"></script>
323 <script src="{{ static_url("notebook/js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
324 <script src="{{ static_url("notebook/js/layoutmanager.js") }}" type="text/javascript" charset="utf-8"></script>
324 <script src="{{ static_url("notebook/js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
325 <script src="{{ static_url("notebook/js/mathjaxutils.js") }}" type="text/javascript" charset="utf-8"></script>
325 <script src="{{ static_url("notebook/js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
326 <script src="{{ static_url("notebook/js/outputarea.js") }}" type="text/javascript" charset="utf-8"></script>
326 <script src="{{ static_url("notebook/js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
327 <script src="{{ static_url("notebook/js/cell.js") }}" type="text/javascript" charset="utf-8"></script>
327 <script src="{{ static_url("notebook/js/celltoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
328 <script src="{{ static_url("notebook/js/celltoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
328 <script src="{{ static_url("notebook/js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
329 <script src="{{ static_url("notebook/js/codecell.js") }}" type="text/javascript" charset="utf-8"></script>
329 <script src="{{ static_url("notebook/js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
330 <script src="{{ static_url("notebook/js/completer.js") }}" type="text/javascript" charset="utf-8"></script>
330 <script src="{{ static_url("notebook/js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
331 <script src="{{ static_url("notebook/js/textcell.js") }}" type="text/javascript" charset="utf-8"></script>
331 <script src="{{ static_url("notebook/js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
332 <script src="{{ static_url("notebook/js/savewidget.js") }}" type="text/javascript" charset="utf-8"></script>
332 <script src="{{ static_url("notebook/js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
333 <script src="{{ static_url("notebook/js/quickhelp.js") }}" type="text/javascript" charset="utf-8"></script>
333 <script src="{{ static_url("notebook/js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
334 <script src="{{ static_url("notebook/js/pager.js") }}" type="text/javascript" charset="utf-8"></script>
334 <script src="{{ static_url("notebook/js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
335 <script src="{{ static_url("notebook/js/menubar.js") }}" type="text/javascript" charset="utf-8"></script>
335 <script src="{{ static_url("notebook/js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
336 <script src="{{ static_url("notebook/js/toolbar.js") }}" type="text/javascript" charset="utf-8"></script>
336 <script src="{{ static_url("notebook/js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
337 <script src="{{ static_url("notebook/js/maintoolbar.js") }}" type="text/javascript" charset="utf-8"></script>
337 <script src="{{ static_url("notebook/js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
338 <script src="{{ static_url("notebook/js/notebook.js") }}" type="text/javascript" charset="utf-8"></script>
338 <script src="{{ static_url("notebook/js/keyboardmanager.js") }}" type="text/javascript" charset="utf-8"></script>
339 <script src="{{ static_url("notebook/js/keyboardmanager.js") }}" type="text/javascript" charset="utf-8"></script>
339 <script src="{{ static_url("notebook/js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
340 <script src="{{ static_url("notebook/js/notificationwidget.js") }}" type="text/javascript" charset="utf-8"></script>
340 <script src="{{ static_url("notebook/js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
341 <script src="{{ static_url("notebook/js/notificationarea.js") }}" type="text/javascript" charset="utf-8"></script>
341 <script src="{{ static_url("notebook/js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
342 <script src="{{ static_url("notebook/js/tooltip.js") }}" type="text/javascript" charset="utf-8"></script>
342 <script src="{{ static_url("notebook/js/config.js") }}" type="text/javascript" charset="utf-8"></script>
343 <script src="{{ static_url("notebook/js/config.js") }}" type="text/javascript" charset="utf-8"></script>
343 <script src="{{ static_url("notebook/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
344 <script src="{{ static_url("notebook/js/main.js") }}" type="text/javascript" charset="utf-8"></script>
344
345
345 <script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
346 <script src="{{ static_url("notebook/js/contexthint.js") }}" charset="utf-8"></script>
346
347
347 <script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
348 <script src="{{ static_url("notebook/js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script>
348 <script src="{{ static_url("notebook/js/celltoolbarpresets/rawcell.js") }}" type="text/javascript" charset="utf-8"></script>
349 <script src="{{ static_url("notebook/js/celltoolbarpresets/rawcell.js") }}" type="text/javascript" charset="utf-8"></script>
349 <script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
350 <script src="{{ static_url("notebook/js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script>
350
351
351 {% endblock %}
352 {% endblock %}
General Comments 0
You need to be logged in to leave comments. Login now