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