Show More
@@ -560,5 +560,4 b' define([' | |||
|
560 | 560 | IPython.Cell = Cell; |
|
561 | 561 | |
|
562 | 562 | return {'Cell': Cell}; |
|
563 | ||
|
564 | 563 | }); |
@@ -11,8 +11,9 b' define([' | |||
|
11 | 11 | 'notebook/js/outputarea', |
|
12 | 12 | 'notebook/js/completer', |
|
13 | 13 | 'notebook/js/celltoolbar', |
|
14 |
], function(IPython, $, utils, |
|
|
14 | ], function(IPython, $, utils, tooltip, keyboard, cell, outputarea, completer, celltoolbar) { | |
|
15 | 15 | "use strict"; |
|
16 | var Cell = cell.Cell; | |
|
16 | 17 | |
|
17 | 18 | /* local util for codemirror */ |
|
18 | 19 | var posEq = function(a, b) {return a.line == b.line && a.ch == b.ch;}; |
@@ -76,7 +77,7 b' define([' | |||
|
76 | 77 | |
|
77 | 78 | options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options}); |
|
78 | 79 | |
|
79 |
|
|
|
80 | Cell.apply(this,[options, keyboard_manager, events]); | |
|
80 | 81 | |
|
81 | 82 | // Attributes we want to override in this subclass. |
|
82 | 83 | this.cell_type = "code"; |
@@ -106,7 +107,7 b' define([' | |||
|
106 | 107 | |
|
107 | 108 | CodeCell.msg_cells = {}; |
|
108 | 109 | |
|
109 |
CodeCell.prototype = new |
|
|
110 | CodeCell.prototype = new Cell(); | |
|
110 | 111 | |
|
111 | 112 | /** |
|
112 | 113 | * @method auto_highlight |
@@ -117,7 +118,7 b' define([' | |||
|
117 | 118 | |
|
118 | 119 | /** @method create_element */ |
|
119 | 120 | CodeCell.prototype.create_element = function () { |
|
120 |
|
|
|
121 | Cell.prototype.create_element.apply(this, arguments); | |
|
121 | 122 | |
|
122 | 123 | var cell = $('<div></div>').addClass('cell border-box-sizing code_cell'); |
|
123 | 124 | cell.attr('tabindex','2'); |
@@ -161,7 +162,7 b' define([' | |||
|
161 | 162 | |
|
162 | 163 | /** @method bind_events */ |
|
163 | 164 | CodeCell.prototype.bind_events = function () { |
|
164 |
|
|
|
165 | Cell.prototype.bind_events.apply(this); | |
|
165 | 166 | var that = this; |
|
166 | 167 | |
|
167 | 168 | this.element.focusout( |
@@ -243,7 +244,7 b' define([' | |||
|
243 | 244 | |
|
244 | 245 | // keyboard event wasn't one of those unique to code cells, let's see |
|
245 | 246 | // if it's one of the generic ones (i.e. check edit mode shortcuts) |
|
246 |
return |
|
|
247 | return Cell.prototype.handle_codemirror_keyevent.apply(this, [editor, event]); | |
|
247 | 248 | }; |
|
248 | 249 | |
|
249 | 250 | // Kernel related calls. |
@@ -336,7 +337,7 b' define([' | |||
|
336 | 337 | // Basic cell manipulation. |
|
337 | 338 | |
|
338 | 339 | CodeCell.prototype.select = function () { |
|
339 |
var cont = |
|
|
340 | var cont = Cell.prototype.select.apply(this); | |
|
340 | 341 | if (cont) { |
|
341 | 342 | this.code_mirror.refresh(); |
|
342 | 343 | this.auto_highlight(); |
@@ -345,7 +346,7 b' define([' | |||
|
345 | 346 | }; |
|
346 | 347 | |
|
347 | 348 | CodeCell.prototype.render = function () { |
|
348 |
var cont = |
|
|
349 | var cont = Cell.prototype.render.apply(this); | |
|
349 | 350 | // Always execute, even if we are already in the rendered state |
|
350 | 351 | return cont; |
|
351 | 352 | }; |
@@ -448,7 +449,7 b' define([' | |||
|
448 | 449 | // JSON serialization |
|
449 | 450 | |
|
450 | 451 | CodeCell.prototype.fromJSON = function (data) { |
|
451 |
|
|
|
452 | Cell.prototype.fromJSON.apply(this, arguments); | |
|
452 | 453 | if (data.cell_type === 'code') { |
|
453 | 454 | if (data.input !== undefined) { |
|
454 | 455 | this.set_text(data.input); |
@@ -476,7 +477,7 b' define([' | |||
|
476 | 477 | |
|
477 | 478 | |
|
478 | 479 | CodeCell.prototype.toJSON = function () { |
|
479 |
var data = |
|
|
480 | var data = Cell.prototype.toJSON.apply(this); | |
|
480 | 481 | data.input = this.get_text(); |
|
481 | 482 | // is finite protect against undefined and '*' value |
|
482 | 483 | if (isFinite(this.input_prompt_number)) { |
@@ -496,7 +497,7 b' define([' | |||
|
496 | 497 | * @return is the action being taken |
|
497 | 498 | */ |
|
498 | 499 | CodeCell.prototype.unselect = function () { |
|
499 |
var cont = |
|
|
500 | var cont = Cell.prototype.unselect.apply(this); | |
|
500 | 501 | if (cont) { |
|
501 | 502 | // When a code cell is usnelected, make sure that the corresponding |
|
502 | 503 | // tooltip and completer to that cell is closed. |
@@ -22,19 +22,19 b' require([' | |||
|
22 | 22 | ], function( |
|
23 | 23 | IPython, |
|
24 | 24 | $, |
|
25 |
|
|
|
25 | notebook, | |
|
26 | 26 | utils, |
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
27 | page, | |
|
28 | layoutmanager, | |
|
29 | events, | |
|
30 | loginwidget, | |
|
31 | maintoolbar, | |
|
32 | pager, | |
|
33 | quickhelp, | |
|
34 | menubar, | |
|
35 | notificationarea, | |
|
36 | savewidget, | |
|
37 | keyboardmanager, | |
|
38 | 38 | config |
|
39 | 39 | ) { |
|
40 | 40 | "use strict"; |
@@ -6,11 +6,11 b' define([' | |||
|
6 | 6 | 'jquery', |
|
7 | 7 | 'notebook/js/toolbar', |
|
8 | 8 | 'notebook/js/celltoolbar', |
|
9 |
], function(IPython, $, |
|
|
9 | ], function(IPython, $, toolbar, celltoolbar) { | |
|
10 | 10 | "use strict"; |
|
11 | 11 | |
|
12 | 12 | var MainToolBar = function (selector, layout_manager, notebook, events) { |
|
13 |
toolbar.Tool |
|
|
13 | toolbar.ToolBar.apply(this, arguments); | |
|
14 | 14 | this.events = events; |
|
15 | 15 | this.notebook = notebook; |
|
16 | 16 | this.construct(); |
@@ -19,16 +19,17 b' define([' | |||
|
19 | 19 | this.bind_events(); |
|
20 | 20 | }; |
|
21 | 21 | |
|
22 |
MainToolBar.prototype = new toolbar.Tool |
|
|
22 | MainToolBar.prototype = new toolbar.ToolBar(); | |
|
23 | 23 | |
|
24 | 24 | MainToolBar.prototype.construct = function () { |
|
25 | var that = this; | |
|
25 | 26 | this.add_buttons_group([ |
|
26 | 27 | { |
|
27 | 28 | id : 'save_b', |
|
28 | 29 | label : 'Save and Checkpoint', |
|
29 | 30 | icon : 'icon-save', |
|
30 | 31 | callback : function () { |
|
31 |
th |
|
|
32 | that.notebook.save_checkpoint(); | |
|
32 | 33 | } |
|
33 | 34 | } |
|
34 | 35 | ]); |
@@ -39,9 +40,9 b' define([' | |||
|
39 | 40 | label : 'Insert Cell Below', |
|
40 | 41 | icon : 'icon-plus-sign', |
|
41 | 42 | callback : function () { |
|
42 |
th |
|
|
43 |
th |
|
|
44 |
th |
|
|
43 | that.notebook.insert_cell_below('code'); | |
|
44 | that.notebook.select_next(); | |
|
45 | that.notebook.focus_cell(); | |
|
45 | 46 | } |
|
46 | 47 | } |
|
47 | 48 | ],'insert_above_below'); |
@@ -52,7 +53,7 b' define([' | |||
|
52 | 53 | label : 'Cut Cell', |
|
53 | 54 | icon : 'icon-cut', |
|
54 | 55 | callback : function () { |
|
55 |
th |
|
|
56 | that.notebook.cut_cell(); | |
|
56 | 57 | } |
|
57 | 58 | }, |
|
58 | 59 | { |
@@ -60,7 +61,7 b' define([' | |||
|
60 | 61 | label : 'Copy Cell', |
|
61 | 62 | icon : 'icon-copy', |
|
62 | 63 | callback : function () { |
|
63 |
th |
|
|
64 | that.notebook.copy_cell(); | |
|
64 | 65 | } |
|
65 | 66 | }, |
|
66 | 67 | { |
@@ -68,7 +69,7 b' define([' | |||
|
68 | 69 | label : 'Paste Cell Below', |
|
69 | 70 | icon : 'icon-paste', |
|
70 | 71 | callback : function () { |
|
71 |
th |
|
|
72 | that.notebook.paste_cell_below(); | |
|
72 | 73 | } |
|
73 | 74 | } |
|
74 | 75 | ],'cut_copy_paste'); |
@@ -79,7 +80,7 b' define([' | |||
|
79 | 80 | label : 'Move Cell Up', |
|
80 | 81 | icon : 'icon-arrow-up', |
|
81 | 82 | callback : function () { |
|
82 |
th |
|
|
83 | that.notebook.move_cell_up(); | |
|
83 | 84 | } |
|
84 | 85 | }, |
|
85 | 86 | { |
@@ -87,7 +88,7 b' define([' | |||
|
87 | 88 | label : 'Move Cell Down', |
|
88 | 89 | icon : 'icon-arrow-down', |
|
89 | 90 | callback : function () { |
|
90 |
th |
|
|
91 | that.notebook.move_cell_down(); | |
|
91 | 92 | } |
|
92 | 93 | } |
|
93 | 94 | ],'move_up_down'); |
@@ -100,7 +101,7 b' define([' | |||
|
100 | 101 | icon : 'icon-play', |
|
101 | 102 | callback : function () { |
|
102 | 103 | // emulate default shift-enter behavior |
|
103 |
th |
|
|
104 | that.notebook.execute_cell_and_select_below(); | |
|
104 | 105 | } |
|
105 | 106 | }, |
|
106 | 107 | { |
@@ -108,7 +109,7 b' define([' | |||
|
108 | 109 | label : 'Interrupt', |
|
109 | 110 | icon : 'icon-stop', |
|
110 | 111 | callback : function () { |
|
111 |
th |
|
|
112 | that.notebook.session.interrupt_kernel(); | |
|
112 | 113 | } |
|
113 | 114 | }, |
|
114 | 115 | { |
@@ -116,7 +117,7 b' define([' | |||
|
116 | 117 | label : 'Restart Kernel', |
|
117 | 118 | icon : 'icon-repeat', |
|
118 | 119 | callback : function () { |
|
119 |
th |
|
|
120 | that.notebook.restart_kernel(); | |
|
120 | 121 | } |
|
121 | 122 | } |
|
122 | 123 | ],'run_int'); |
@@ -153,11 +154,11 b' define([' | |||
|
153 | 154 | var val = $(this).val(); |
|
154 | 155 | if (val ==='') { |
|
155 | 156 | celltoolbar.CellToolbar.global_hide(); |
|
156 |
delete th |
|
|
157 | delete that.notebook.metadata.celltoolbar; | |
|
157 | 158 | } else { |
|
158 | 159 | celltoolbar.CellToolbar.global_show(); |
|
159 | 160 | celltoolbar.CellToolbar.activate_preset(val); |
|
160 |
th |
|
|
161 | that.notebook.metadata.celltoolbar = val; | |
|
161 | 162 | } |
|
162 | 163 | }); |
|
163 | 164 | // Setup the currently registered presets. |
@@ -185,23 +186,23 b' define([' | |||
|
185 | 186 | this.element.find('#cell_type').change(function () { |
|
186 | 187 | var cell_type = $(this).val(); |
|
187 | 188 | if (cell_type === 'code') { |
|
188 |
th |
|
|
189 | that.notebook.to_code(); | |
|
189 | 190 | } else if (cell_type === 'markdown') { |
|
190 |
th |
|
|
191 | that.notebook.to_markdown(); | |
|
191 | 192 | } else if (cell_type === 'raw') { |
|
192 |
th |
|
|
193 | that.notebook.to_raw(); | |
|
193 | 194 | } else if (cell_type === 'heading1') { |
|
194 |
th |
|
|
195 | that.notebook.to_heading(undefined, 1); | |
|
195 | 196 | } else if (cell_type === 'heading2') { |
|
196 |
th |
|
|
197 | that.notebook.to_heading(undefined, 2); | |
|
197 | 198 | } else if (cell_type === 'heading3') { |
|
198 |
th |
|
|
199 | that.notebook.to_heading(undefined, 3); | |
|
199 | 200 | } else if (cell_type === 'heading4') { |
|
200 |
th |
|
|
201 | that.notebook.to_heading(undefined, 4); | |
|
201 | 202 | } else if (cell_type === 'heading5') { |
|
202 |
th |
|
|
203 | that.notebook.to_heading(undefined, 5); | |
|
203 | 204 | } else if (cell_type === 'heading6') { |
|
204 |
th |
|
|
205 | that.notebook.to_heading(undefined, 6); | |
|
205 | 206 | } |
|
206 | 207 | }); |
|
207 | 208 | this.events.on('selected_cell_type_changed.Notebook', function (event, data) { |
@@ -810,11 +810,11 b' define([' | |||
|
810 | 810 | cell = new codecell.CodeCell(this.kernel, this.options, this.events, this.config, this.keyboard_manager, this); |
|
811 | 811 | cell.set_input_prompt(); |
|
812 | 812 | } else if (type === 'markdown') { |
|
813 |
cell = new cells |
|
|
813 | cell = new cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this); | |
|
814 | 814 | } else if (type === 'raw') { |
|
815 |
cell = new cells |
|
|
815 | cell = new cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this); | |
|
816 | 816 | } else if (type === 'heading') { |
|
817 |
cell = new cells |
|
|
817 | cell = new cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this); | |
|
818 | 818 | } |
|
819 | 819 | |
|
820 | 820 | if(this._insert_element_at_index(cell.element,index)) { |
@@ -929,7 +929,7 b' define([' | |||
|
929 | 929 | if (this.is_valid_cell_index(i)) { |
|
930 | 930 | var source_element = this.get_cell_element(i); |
|
931 | 931 | var source_cell = source_element.data("cell"); |
|
932 | if (!(source_cell instanceof CodeCell)) { | |
|
932 | if (!(source_cell instanceof codecell.CodeCell)) { | |
|
933 | 933 | var target_cell = this.insert_cell_below('code',i); |
|
934 | 934 | var text = source_cell.get_text(); |
|
935 | 935 | if (text === source_cell.placeholder) { |
@@ -959,7 +959,7 b' define([' | |||
|
959 | 959 | if (this.is_valid_cell_index(i)) { |
|
960 | 960 | var source_element = this.get_cell_element(i); |
|
961 | 961 | var source_cell = source_element.data("cell"); |
|
962 |
if (!(source_cell instanceof cells. |
|
|
962 | if (!(source_cell instanceof cells.MarkdownCell)) { | |
|
963 | 963 | var target_cell = this.insert_cell_below('markdown',i); |
|
964 | 964 | var text = source_cell.get_text(); |
|
965 | 965 | if (text === source_cell.placeholder) { |
@@ -973,7 +973,7 b' define([' | |||
|
973 | 973 | target_cell.code_mirror.clearHistory(); |
|
974 | 974 | source_element.remove(); |
|
975 | 975 | this.select(i); |
|
976 |
if ((source_cell instanceof cells |
|
|
976 | if ((source_cell instanceof cells.TextCell) && source_cell.rendered) { | |
|
977 | 977 | target_cell.render(); |
|
978 | 978 | } |
|
979 | 979 | var cursor = source_cell.code_mirror.getCursor(); |
@@ -995,7 +995,7 b' define([' | |||
|
995 | 995 | var source_element = this.get_cell_element(i); |
|
996 | 996 | var source_cell = source_element.data("cell"); |
|
997 | 997 | var target_cell = null; |
|
998 |
if (!(source_cell instanceof cells. |
|
|
998 | if (!(source_cell instanceof cells.RawCell)) { | |
|
999 | 999 | target_cell = this.insert_cell_below('raw',i); |
|
1000 | 1000 | var text = source_cell.get_text(); |
|
1001 | 1001 | if (text === source_cell.placeholder) { |
@@ -1030,7 +1030,7 b' define([' | |||
|
1030 | 1030 | var source_element = this.get_cell_element(i); |
|
1031 | 1031 | var source_cell = source_element.data("cell"); |
|
1032 | 1032 | var target_cell = null; |
|
1033 |
if (source_cell instanceof cells. |
|
|
1033 | if (source_cell instanceof cells.HeadingCell) { | |
|
1034 | 1034 | source_cell.set_level(level); |
|
1035 | 1035 | } else { |
|
1036 | 1036 | target_cell = this.insert_cell_below('heading',i); |
@@ -1049,7 +1049,7 b' define([' | |||
|
1049 | 1049 | this.select(i); |
|
1050 | 1050 | var cursor = source_cell.code_mirror.getCursor(); |
|
1051 | 1051 | target_cell.code_mirror.setCursor(cursor); |
|
1052 |
if ((source_cell instanceof cells |
|
|
1052 | if ((source_cell instanceof cells.TextCell) && source_cell.rendered) { | |
|
1053 | 1053 | target_cell.render(); |
|
1054 | 1054 | } |
|
1055 | 1055 | } |
@@ -1168,13 +1168,13 b' define([' | |||
|
1168 | 1168 | * @method split_cell |
|
1169 | 1169 | */ |
|
1170 | 1170 | Notebook.prototype.split_cell = function () { |
|
1171 |
var mdc = cells. |
|
|
1172 |
var rc = cells. |
|
|
1171 | var mdc = cells.MarkdownCell; | |
|
1172 | var rc = cells.RawCell; | |
|
1173 | 1173 | var cell = this.get_selected_cell(); |
|
1174 | 1174 | if (cell.is_splittable()) { |
|
1175 | 1175 | var texta = cell.get_pre_cursor(); |
|
1176 | 1176 | var textb = cell.get_post_cursor(); |
|
1177 | if (cell instanceof CodeCell) { | |
|
1177 | if (cell instanceof codecell.CodeCell) { | |
|
1178 | 1178 | // In this case the operations keep the notebook in its existing mode |
|
1179 | 1179 | // so we don't need to do any post-op mode changes. |
|
1180 | 1180 | cell.set_text(textb); |
@@ -1197,8 +1197,8 b' define([' | |||
|
1197 | 1197 | * @method merge_cell_above |
|
1198 | 1198 | */ |
|
1199 | 1199 | Notebook.prototype.merge_cell_above = function () { |
|
1200 |
var mdc = cells. |
|
|
1201 |
var rc = cells. |
|
|
1200 | var mdc = cells.MarkdownCell; | |
|
1201 | var rc = cells.RawCell; | |
|
1202 | 1202 | var index = this.get_selected_index(); |
|
1203 | 1203 | var cell = this.get_cell(index); |
|
1204 | 1204 | var render = cell.rendered; |
@@ -1212,7 +1212,7 b' define([' | |||
|
1212 | 1212 | } |
|
1213 | 1213 | var upper_text = upper_cell.get_text(); |
|
1214 | 1214 | var text = cell.get_text(); |
|
1215 | if (cell instanceof CodeCell) { | |
|
1215 | if (cell instanceof codecell.CodeCell) { | |
|
1216 | 1216 | cell.set_text(upper_text+'\n'+text); |
|
1217 | 1217 | } else if ((cell instanceof mdc) || (cell instanceof rc)) { |
|
1218 | 1218 | cell.unrender(); // Must unrender before we set_text. |
@@ -1234,8 +1234,8 b' define([' | |||
|
1234 | 1234 | * @method merge_cell_below |
|
1235 | 1235 | */ |
|
1236 | 1236 | Notebook.prototype.merge_cell_below = function () { |
|
1237 |
var mdc = cells. |
|
|
1238 |
var rc = cells. |
|
|
1237 | var mdc = cells.MarkdownCell; | |
|
1238 | var rc = cells.RawCell; | |
|
1239 | 1239 | var index = this.get_selected_index(); |
|
1240 | 1240 | var cell = this.get_cell(index); |
|
1241 | 1241 | var render = cell.rendered; |
@@ -1249,7 +1249,7 b' define([' | |||
|
1249 | 1249 | } |
|
1250 | 1250 | var lower_text = lower_cell.get_text(); |
|
1251 | 1251 | var text = cell.get_text(); |
|
1252 | if (cell instanceof CodeCell) { | |
|
1252 | if (cell instanceof codecell.CodeCell) { | |
|
1253 | 1253 | cell.set_text(text+'\n'+lower_text); |
|
1254 | 1254 | } else if ((cell instanceof mdc) || (cell instanceof rc)) { |
|
1255 | 1255 | cell.unrender(); // Must unrender before we set_text. |
@@ -1277,7 +1277,7 b' define([' | |||
|
1277 | 1277 | Notebook.prototype.collapse_output = function (index) { |
|
1278 | 1278 | var i = this.index_or_selected(index); |
|
1279 | 1279 | var cell = this.get_cell(i); |
|
1280 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1280 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1281 | 1281 | cell.collapse_output(); |
|
1282 | 1282 | this.set_dirty(true); |
|
1283 | 1283 | } |
@@ -1290,7 +1290,7 b' define([' | |||
|
1290 | 1290 | */ |
|
1291 | 1291 | Notebook.prototype.collapse_all_output = function () { |
|
1292 | 1292 | $.map(this.get_cells(), function (cell, i) { |
|
1293 | if (cell instanceof CodeCell) { | |
|
1293 | if (cell instanceof codecell.CodeCell) { | |
|
1294 | 1294 | cell.collapse_output(); |
|
1295 | 1295 | } |
|
1296 | 1296 | }); |
@@ -1307,7 +1307,7 b' define([' | |||
|
1307 | 1307 | Notebook.prototype.expand_output = function (index) { |
|
1308 | 1308 | var i = this.index_or_selected(index); |
|
1309 | 1309 | var cell = this.get_cell(i); |
|
1310 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1310 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1311 | 1311 | cell.expand_output(); |
|
1312 | 1312 | this.set_dirty(true); |
|
1313 | 1313 | } |
@@ -1320,7 +1320,7 b' define([' | |||
|
1320 | 1320 | */ |
|
1321 | 1321 | Notebook.prototype.expand_all_output = function () { |
|
1322 | 1322 | $.map(this.get_cells(), function (cell, i) { |
|
1323 | if (cell instanceof CodeCell) { | |
|
1323 | if (cell instanceof codecell.CodeCell) { | |
|
1324 | 1324 | cell.expand_output(); |
|
1325 | 1325 | } |
|
1326 | 1326 | }); |
@@ -1337,7 +1337,7 b' define([' | |||
|
1337 | 1337 | Notebook.prototype.clear_output = function (index) { |
|
1338 | 1338 | var i = this.index_or_selected(index); |
|
1339 | 1339 | var cell = this.get_cell(i); |
|
1340 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1340 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1341 | 1341 | cell.clear_output(); |
|
1342 | 1342 | this.set_dirty(true); |
|
1343 | 1343 | } |
@@ -1350,7 +1350,7 b' define([' | |||
|
1350 | 1350 | */ |
|
1351 | 1351 | Notebook.prototype.clear_all_output = function () { |
|
1352 | 1352 | $.map(this.get_cells(), function (cell, i) { |
|
1353 | if (cell instanceof CodeCell) { | |
|
1353 | if (cell instanceof codecell.CodeCell) { | |
|
1354 | 1354 | cell.clear_output(); |
|
1355 | 1355 | } |
|
1356 | 1356 | }); |
@@ -1366,7 +1366,7 b' define([' | |||
|
1366 | 1366 | Notebook.prototype.scroll_output = function (index) { |
|
1367 | 1367 | var i = this.index_or_selected(index); |
|
1368 | 1368 | var cell = this.get_cell(i); |
|
1369 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1369 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1370 | 1370 | cell.scroll_output(); |
|
1371 | 1371 | this.set_dirty(true); |
|
1372 | 1372 | } |
@@ -1379,7 +1379,7 b' define([' | |||
|
1379 | 1379 | */ |
|
1380 | 1380 | Notebook.prototype.scroll_all_output = function () { |
|
1381 | 1381 | $.map(this.get_cells(), function (cell, i) { |
|
1382 | if (cell instanceof CodeCell) { | |
|
1382 | if (cell instanceof codecell.CodeCell) { | |
|
1383 | 1383 | cell.scroll_output(); |
|
1384 | 1384 | } |
|
1385 | 1385 | }); |
@@ -1395,7 +1395,7 b' define([' | |||
|
1395 | 1395 | Notebook.prototype.toggle_output = function (index) { |
|
1396 | 1396 | var i = this.index_or_selected(index); |
|
1397 | 1397 | var cell = this.get_cell(i); |
|
1398 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1398 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1399 | 1399 | cell.toggle_output(); |
|
1400 | 1400 | this.set_dirty(true); |
|
1401 | 1401 | } |
@@ -1408,7 +1408,7 b' define([' | |||
|
1408 | 1408 | */ |
|
1409 | 1409 | Notebook.prototype.toggle_all_output = function () { |
|
1410 | 1410 | $.map(this.get_cells(), function (cell, i) { |
|
1411 | if (cell instanceof CodeCell) { | |
|
1411 | if (cell instanceof codecell.CodeCell) { | |
|
1412 | 1412 | cell.toggle_output(); |
|
1413 | 1413 | } |
|
1414 | 1414 | }); |
@@ -1425,7 +1425,7 b' define([' | |||
|
1425 | 1425 | Notebook.prototype.toggle_output_scroll = function (index) { |
|
1426 | 1426 | var i = this.index_or_selected(index); |
|
1427 | 1427 | var cell = this.get_cell(i); |
|
1428 | if (cell !== null && (cell instanceof CodeCell)) { | |
|
1428 | if (cell !== null && (cell instanceof codecell.CodeCell)) { | |
|
1429 | 1429 | cell.toggle_output_scroll(); |
|
1430 | 1430 | this.set_dirty(true); |
|
1431 | 1431 | } |
@@ -1438,7 +1438,7 b' define([' | |||
|
1438 | 1438 | */ |
|
1439 | 1439 | Notebook.prototype.toggle_all_output_scroll = function () { |
|
1440 | 1440 | $.map(this.get_cells(), function (cell, i) { |
|
1441 | if (cell instanceof CodeCell) { | |
|
1441 | if (cell instanceof codecell.CodeCell) { | |
|
1442 | 1442 | cell.toggle_output_scroll(); |
|
1443 | 1443 | } |
|
1444 | 1444 | }); |
@@ -1480,7 +1480,7 b' define([' | |||
|
1480 | 1480 | var ncells = this.ncells(); |
|
1481 | 1481 | for (var i=0; i<ncells; i++) { |
|
1482 | 1482 | var cell = this.get_cell(i); |
|
1483 | if (cell instanceof CodeCell) { | |
|
1483 | if (cell instanceof codecell.CodeCell) { | |
|
1484 | 1484 | cell.set_kernel(this.session.kernel); |
|
1485 | 1485 | } |
|
1486 | 1486 | } |
@@ -2044,14 +2044,14 b' define([' | |||
|
2044 | 2044 | |
|
2045 | 2045 | Notebook.prototype.rename_error = function (xhr, status, error) { |
|
2046 | 2046 | var that = this; |
|
2047 | var dialog = $('<div/>').append( | |
|
2047 | var dialog_body = $('<div/>').append( | |
|
2048 | 2048 | $("<p/>").addClass("rename-message") |
|
2049 | 2049 | .text('This notebook name already exists.') |
|
2050 | 2050 | ); |
|
2051 | 2051 | this.events.trigger('notebook_rename_failed.Notebook', [xhr, status, error]); |
|
2052 | 2052 | dialog.modal({ |
|
2053 | 2053 | title: "Notebook Rename Error!", |
|
2054 | body: dialog, | |
|
2054 | body: dialog_body, | |
|
2055 | 2055 | buttons : { |
|
2056 | 2056 | "Cancel": {}, |
|
2057 | 2057 | "OK": { |
@@ -73,8 +73,8 b' define([' | |||
|
73 | 73 | $(this.shortcut_dialog).modal("toggle"); |
|
74 | 74 | return; |
|
75 | 75 | } |
|
76 | var command_shortcuts = keyboard_manager.command_shortcuts.help(); | |
|
77 | var edit_shortcuts = keyboard_manager.edit_shortcuts.help(); | |
|
76 | var command_shortcuts = this.keyboard_manager.command_shortcuts.help(); | |
|
77 | var edit_shortcuts = this.keyboard_manager.edit_shortcuts.help(); | |
|
78 | 78 | var help, shortcut; |
|
79 | 79 | var i, half, n; |
|
80 | 80 | var element = $('<div/>'); |
@@ -113,7 +113,7 b' define([' | |||
|
113 | 113 | }; |
|
114 | 114 | |
|
115 | 115 | QuickHelp.prototype.build_command_help = function () { |
|
116 | var command_shortcuts = keyboard_manager.command_shortcuts.help(); | |
|
116 | var command_shortcuts = this.keyboard_manager.command_shortcuts.help(); | |
|
117 | 117 | return build_div('<h4>Command Mode (press <code>Esc</code> to enable)</h4>', command_shortcuts); |
|
118 | 118 | }; |
|
119 | 119 | |
@@ -137,7 +137,7 b' define([' | |||
|
137 | 137 | }; |
|
138 | 138 | |
|
139 | 139 | QuickHelp.prototype.build_edit_help = function (cm_shortcuts) { |
|
140 | var edit_shortcuts = keyboard_manager.edit_shortcuts.help(); | |
|
140 | var edit_shortcuts = this.keyboard_manager.edit_shortcuts.help(); | |
|
141 | 141 | jQuery.merge(cm_shortcuts, edit_shortcuts); |
|
142 | 142 | return build_div('<h4>Edit Mode (press <code>Enter</code> to enable)</h4>', cm_shortcuts); |
|
143 | 143 | }; |
@@ -67,7 +67,7 b' define([' | |||
|
67 | 67 | |
|
68 | 68 | SaveWidget.prototype.rename_notebook = function () { |
|
69 | 69 | var that = this; |
|
70 | var dialog = $('<div/>').append( | |
|
70 | var dialog_body = $('<div/>').append( | |
|
71 | 71 | $("<p/>").addClass("rename-message") |
|
72 | 72 | .text('Enter a new notebook name:') |
|
73 | 73 | ).append( |
@@ -78,7 +78,7 b' define([' | |||
|
78 | 78 | ); |
|
79 | 79 | dialog.modal({ |
|
80 | 80 | title: "Rename Notebook", |
|
81 | body: dialog, | |
|
81 | body: dialog_body, | |
|
82 | 82 | buttons : { |
|
83 | 83 | "Cancel": {}, |
|
84 | 84 | "OK": { |
@@ -10,6 +10,7 b' define([' | |||
|
10 | 10 | 'notebook/js/celltoolbar', |
|
11 | 11 | ], function(IPython, $, cell, security, mathjaxutils, celltoolbar) { |
|
12 | 12 | "use strict"; |
|
13 | var Cell = cell.Cell; | |
|
13 | 14 | |
|
14 | 15 | /** |
|
15 | 16 | * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text' |
@@ -41,12 +42,12 b' define([' | |||
|
41 | 42 | this.cell_type = this.cell_type || 'text'; |
|
42 | 43 | mathjaxutils = mathjaxutils; |
|
43 | 44 | |
|
44 |
|
|
|
45 | Cell.apply(this, [options, keyboard_manager, events]); | |
|
45 | 46 | |
|
46 | 47 | this.rendered = false; |
|
47 | 48 | }; |
|
48 | 49 | |
|
49 |
TextCell.prototype = new |
|
|
50 | TextCell.prototype = new Cell(); | |
|
50 | 51 | |
|
51 | 52 | TextCell.options_default = { |
|
52 | 53 | cm_config : { |
@@ -63,7 +64,7 b' define([' | |||
|
63 | 64 | * @private |
|
64 | 65 | */ |
|
65 | 66 | TextCell.prototype.create_element = function () { |
|
66 |
|
|
|
67 | Cell.prototype.create_element.apply(this, arguments); | |
|
67 | 68 | |
|
68 | 69 | var cell = $("<div>").addClass('cell text_cell border-box-sizing'); |
|
69 | 70 | cell.attr('tabindex','2'); |
@@ -91,7 +92,7 b' define([' | |||
|
91 | 92 | * @method bind_event |
|
92 | 93 | */ |
|
93 | 94 | TextCell.prototype.bind_events = function () { |
|
94 |
|
|
|
95 | Cell.prototype.bind_events.apply(this); | |
|
95 | 96 | var that = this; |
|
96 | 97 | |
|
97 | 98 | this.element.dblclick(function () { |
@@ -108,7 +109,7 b' define([' | |||
|
108 | 109 | // Cell level actions |
|
109 | 110 | |
|
110 | 111 | TextCell.prototype.select = function () { |
|
111 |
var cont = |
|
|
112 | var cont = Cell.prototype.select.apply(this); | |
|
112 | 113 | if (cont) { |
|
113 | 114 | if (this.mode === 'edit') { |
|
114 | 115 | this.code_mirror.refresh(); |
@@ -119,7 +120,7 b' define([' | |||
|
119 | 120 | |
|
120 | 121 | TextCell.prototype.unrender = function () { |
|
121 | 122 | if (this.read_only) return; |
|
122 |
var cont = |
|
|
123 | var cont = Cell.prototype.unrender.apply(this); | |
|
123 | 124 | if (cont) { |
|
124 | 125 | var text_cell = this.element; |
|
125 | 126 | var output = text_cell.find("div.text_cell_render"); |
@@ -182,7 +183,7 b' define([' | |||
|
182 | 183 | * @method fromJSON |
|
183 | 184 | */ |
|
184 | 185 | TextCell.prototype.fromJSON = function (data) { |
|
185 |
|
|
|
186 | Cell.prototype.fromJSON.apply(this, arguments); | |
|
186 | 187 | if (data.cell_type === this.cell_type) { |
|
187 | 188 | if (data.source !== undefined) { |
|
188 | 189 | this.set_text(data.source); |
@@ -202,7 +203,7 b' define([' | |||
|
202 | 203 | * @return {object} cell data serialised to json |
|
203 | 204 | */ |
|
204 | 205 | TextCell.prototype.toJSON = function () { |
|
205 |
var data = |
|
|
206 | var data = Cell.prototype.toJSON.apply(this); | |
|
206 | 207 | data.source = this.get_text(); |
|
207 | 208 | if (data.source == this.placeholder) { |
|
208 | 209 | data.source = ""; |
@@ -246,7 +247,7 b' define([' | |||
|
246 | 247 | math = text_and_math[1]; |
|
247 | 248 | var html = marked.parser(marked.lexer(text)); |
|
248 | 249 | html = mathjaxutils.replace_math(html, math); |
|
249 |
html = security. |
|
|
250 | html = security.sanitize_html(html); | |
|
250 | 251 | html = $($.parseHTML(html)); |
|
251 | 252 | // links in markdown cells should open in new tabs |
|
252 | 253 | html.find("a[href]").not('[href^="#"]').attr("target", "_blank"); |
@@ -417,7 +418,7 b' define([' | |||
|
417 | 418 | math = text_and_math[1]; |
|
418 | 419 | var html = marked.parser(marked.lexer(text)); |
|
419 | 420 | html = mathjaxutils.replace_math(html, math); |
|
420 |
html = security. |
|
|
421 | html = security.sanitize_html(html); | |
|
421 | 422 | var h = $($.parseHTML(html)); |
|
422 | 423 | // add id and linkback anchor |
|
423 | 424 | var hash = h.text().replace(/ /g, '-'); |
@@ -22,7 +22,9 b' define([' | |||
|
22 | 22 | |
|
23 | 23 | var NotebookTour = function (notebook, events) { |
|
24 | 24 | var that = this; |
|
25 | this.notebook = notebook; | |
|
25 | 26 | this.step_duration = 0; |
|
27 | this.events = events; | |
|
26 | 28 | this.tour_steps = [ |
|
27 | 29 | { |
|
28 | 30 | title: "Welcome to the Notebook Tour", |
@@ -51,31 +53,31 b' define([' | |||
|
51 | 53 | title: "Mode Indicator", |
|
52 | 54 | placement: 'bottom', |
|
53 | 55 | content: "The Notebook has two modes: Edit Mode and Command Mode. In this area, an indicator can appear to tell you which mode you are in.", |
|
54 | onShow: function(tour) { command_icon_hack(); } | |
|
56 | onShow: function(tour) { that.command_icon_hack(); } | |
|
55 | 57 | }, { |
|
56 | 58 | element: "#modal_indicator", |
|
57 | 59 | title: "Command Mode", |
|
58 | 60 | placement: 'bottom', |
|
59 |
onShow: function(tour) { |
|
|
60 | onNext: function(tour) { edit_mode(); }, | |
|
61 | onShow: function(tour) { notebook.command_mode(); that.command_icon_hack(); }, | |
|
62 | onNext: function(tour) { that.edit_mode(); }, | |
|
61 | 63 | content: "Right now you are in Command Mode, and many keyboard shortcuts are available. In this mode, no icon is displayed in the indicator area." |
|
62 | 64 | }, { |
|
63 | 65 | element: "#modal_indicator", |
|
64 | 66 | title: "Edit Mode", |
|
65 | 67 | placement: 'bottom', |
|
66 | onShow: function(tour) { edit_mode(); }, | |
|
68 | onShow: function(tour) { that.edit_mode(); }, | |
|
67 | 69 | content: "Pressing <code>Enter</code> or clicking in the input text area of the cell switches to Edit Mode." |
|
68 | 70 | }, { |
|
69 | 71 | element: '.selected', |
|
70 | 72 | title: "Edit Mode", |
|
71 | 73 | placement: 'bottom', |
|
72 | onShow: function(tour) { edit_mode(); }, | |
|
74 | onShow: function(tour) { that.edit_mode(); }, | |
|
73 | 75 | content: "Notice that the border around the currently active cell changed color. Typing will insert text into the currently active cell." |
|
74 | 76 | }, { |
|
75 | 77 | element: '.selected', |
|
76 | 78 | title: "Back to Command Mode", |
|
77 | 79 | placement: 'bottom', |
|
78 |
onShow: function(tour) { |
|
|
80 | onShow: function(tour) { notebook.command_mode(); }, | |
|
79 | 81 | onHide: function(tour) { $('#help_menu').parent().children('a').click(); }, |
|
80 | 82 | content: "Pressing <code>Esc</code> or clicking outside of the input text area takes you back to Command Mode." |
|
81 | 83 | }, { |
@@ -12,7 +12,7 b' define([' | |||
|
12 | 12 | notebooklist.NotebookList.call(this, selector, options, 'running', session_list); |
|
13 | 13 | }; |
|
14 | 14 | |
|
15 | KernelList.prototype = Object.create(NotebookList.prototype); | |
|
15 | KernelList.prototype = Object.create(notebooklist.NotebookList.prototype); | |
|
16 | 16 | |
|
17 | 17 | KernelList.prototype.sessions_loaded = function (d) { |
|
18 | 18 | this.sessions = d; |
@@ -82,10 +82,10 b' define([' | |||
|
82 | 82 | that.add_upload_button(nbitem); |
|
83 | 83 | }; |
|
84 | 84 | } else { |
|
85 | var dialog = 'Uploaded notebooks must be .ipynb files'; | |
|
85 | var dialog_body = 'Uploaded notebooks must be .ipynb files'; | |
|
86 | 86 | dialog.modal({ |
|
87 | 87 | title : 'Invalid file type', |
|
88 | body : dialog, | |
|
88 | body : dialog_body, | |
|
89 | 89 | buttons : {'OK' : {'class' : 'btn-primary'}} |
|
90 | 90 | }); |
|
91 | 91 | } |
@@ -12,16 +12,16 b' define([' | |||
|
12 | 12 | "widgets/js/widget_selection", |
|
13 | 13 | "widgets/js/widget_selectioncontainer", |
|
14 | 14 | "widgets/js/widget_string", |
|
15 |
], function( |
|
|
15 | ], function(widgetmanager) { | |
|
16 | 16 | |
|
17 | 17 | // Register all of the loaded views with the widget manager. |
|
18 | 18 | for (var i = 1; i < arguments.length; i++) { |
|
19 | 19 | for (var target_name in arguments[i]) { |
|
20 | 20 | if (arguments[i].hasOwnProperty(target_name)) { |
|
21 | WidgetManager.register_widget_view(target_name, arguments[i][target_name]); | |
|
21 | widgetmanager.WidgetManager.register_widget_view(target_name, arguments[i][target_name]); | |
|
22 | 22 | } |
|
23 | 23 | } |
|
24 | 24 | } |
|
25 | 25 | |
|
26 | return {'WidgetManager': WidgetManager}; | |
|
26 | return {'WidgetManager': widgetmanager.WidgetManager}; | |
|
27 | 27 | }); |
General Comments 0
You need to be logged in to leave comments.
Login now