Show More
@@ -27,18 +27,17 define([ | |||
|
27 | 27 | }; |
|
28 | 28 | // end monkey patching CodeMirror |
|
29 | 29 | |
|
30 | /** | |
|
31 | * The Base `Cell` class from which to inherit | |
|
32 | * @class Cell | |
|
33 | **/ | |
|
34 | ||
|
35 | /* | |
|
36 | * @constructor | |
|
37 | * | |
|
38 | * @param {object|undefined} [options] | |
|
39 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters | |
|
40 | */ | |
|
41 | 30 | var Cell = function (options) { |
|
31 | // Constructor | |
|
32 | // | |
|
33 | // The Base `Cell` class from which to inherit. | |
|
34 | // | |
|
35 | // Parameters: | |
|
36 | // options: dictionary | |
|
37 | // Dictionary of keyword arguments. | |
|
38 | // events: $(Events) instance | |
|
39 | // config: dictionary | |
|
40 | // keyboard_manager: KeyboardManager instance | |
|
42 | 41 | options = options || {}; |
|
43 | 42 | this.keyboard_manager = options.keyboard_manager; |
|
44 | 43 | this.events = options.events; |
@@ -41,21 +41,21 define([ | |||
|
41 | 41 | |
|
42 | 42 | var keycodes = keyboard.keycodes; |
|
43 | 43 | |
|
44 | /** | |
|
45 | * A Cell conceived to write code. | |
|
46 | * | |
|
47 | * The kernel doesn't have to be set at creation time, in that case | |
|
48 | * it will be null and set_kernel has to be called later. | |
|
49 | * @class CodeCell | |
|
50 | * @extends Cell | |
|
51 | * | |
|
52 | * @constructor | |
|
53 | * @param {Object|null} kernel | |
|
54 | * @param {object|undefined} [options] | |
|
55 | * @param [options.cm_config] {object} config to pass to CodeMirror | |
|
56 | */ | |
|
57 | 44 | var CodeCell = function (kernel, options) { |
|
58 | options = options || {}; | |
|
45 | // Constructor | |
|
46 | // | |
|
47 | // A Cell conceived to write code. | |
|
48 | // | |
|
49 | // Parameters: | |
|
50 | // kernel: Kernel instance | |
|
51 | // The kernel doesn't have to be set at creation time, in that case | |
|
52 | // it will be null and set_kernel has to be called later. | |
|
53 | // options: dictionary | |
|
54 | // Dictionary of keyword arguments. | |
|
55 | // events: $(Events) instance | |
|
56 | // config: dictionary | |
|
57 | // keyboard_manager: KeyboardManager instance | |
|
58 | // notebook: Notebook instance | |
|
59 | 59 | this.kernel = kernel || null; |
|
60 | 60 | this.notebook = options.notebook; |
|
61 | 61 | this.collapsed = false; |
@@ -16,6 +16,13 define([ | |||
|
16 | 16 | var keycodes = keyboard.keycodes; |
|
17 | 17 | |
|
18 | 18 | var KeyboardManager = function (options) { |
|
19 | // Constructor | |
|
20 | // | |
|
21 | // Parameters: | |
|
22 | // options: dictionary | |
|
23 | // Dictionary of keyword arguments. | |
|
24 | // events: $(Events) instance | |
|
25 | // pager: Pager instance | |
|
19 | 26 | this.mode = 'command'; |
|
20 | 27 | this.enabled = true; |
|
21 | 28 | this.pager = options.pager; |
@@ -10,6 +10,14 define([ | |||
|
10 | 10 | "use strict"; |
|
11 | 11 | |
|
12 | 12 | var MainToolBar = function (selector, options) { |
|
13 | // Constructor | |
|
14 | // | |
|
15 | // Parameters: | |
|
16 | // selector: string | |
|
17 | // options: dictionary | |
|
18 | // Dictionary of keyword arguments. | |
|
19 | // events: $(Events) instance | |
|
20 | // notebook: Notebook instance | |
|
13 | 21 | toolbar.ToolBar.apply(this, arguments); |
|
14 | 22 | this.events = options.events; |
|
15 | 23 | this.notebook = options.notebook; |
@@ -2,10 +2,11 | |||
|
2 | 2 | // Distributed under the terms of the Modified BSD License. |
|
3 | 3 | |
|
4 | 4 | define([ |
|
5 | 'base/js/namespace', | |
|
5 | 6 | 'jquery', |
|
6 | 7 | 'base/js/utils', |
|
7 | 8 | 'base/js/dialog', |
|
8 | ], function($, utils, dialog) { | |
|
9 | ], function(IPython, $, utils, dialog) { | |
|
9 | 10 | "use strict"; |
|
10 | 11 | |
|
11 | 12 | var init = function () { |
@@ -235,9 +236,13 define([ | |||
|
235 | 236 | return text; |
|
236 | 237 | }; |
|
237 | 238 | |
|
238 | return { | |
|
239 | var mathjaxutils = { | |
|
239 | 240 | init : init, |
|
240 | 241 | remove_math : remove_math, |
|
241 | 242 | replace_math : replace_math |
|
242 | 243 | }; |
|
244 | ||
|
245 | IPython.mathjaxutils = mathjaxutils; | |
|
246 | ||
|
247 | return mathjaxutils; | |
|
243 | 248 | }); |
@@ -6,25 +6,26 define([ | |||
|
6 | 6 | 'jquery', |
|
7 | 7 | 'base/js/utils', |
|
8 | 8 | 'notebook/js/tour', |
|
9 | 'components/bootstrap-tour/build/js/bootstrap-tour.min', | |
|
10 | 9 | ], function(IPython, $, utils, tour) { |
|
11 | 10 | "use strict"; |
|
12 | 11 | |
|
13 | /** | |
|
14 | * A MenuBar Class to generate the menubar of IPython notebook | |
|
15 | * @Class MenuBar | |
|
16 | * | |
|
17 | * @constructor | |
|
18 | * | |
|
19 | * | |
|
20 | * @param selector {string} selector for the menubar element in DOM | |
|
21 | * @param {object} [options] | |
|
22 | * @param [options.base_url] {String} String to use for the | |
|
23 | * base project url. Default is to inspect | |
|
24 | * $('body').data('baseUrl'); | |
|
25 | * does not support change for now is set through this option | |
|
26 | */ | |
|
27 | 12 | var MenuBar = function (selector, options) { |
|
13 | // Constructor | |
|
14 | // | |
|
15 | // A MenuBar Class to generate the menubar of IPython notebook | |
|
16 | // | |
|
17 | // Parameters: | |
|
18 | // selector: string | |
|
19 | // options: dictionary | |
|
20 | // Dictionary of keyword arguments. | |
|
21 | // notebook: Notebook instance | |
|
22 | // layout_manager: LayoutManager instance | |
|
23 | // events: $(Events) instance | |
|
24 | // save_widget: SaveWidget instance | |
|
25 | // quick_help: QuickHelp instance | |
|
26 | // base_url : string | |
|
27 | // notebook_path : string | |
|
28 | // notebook_name : string | |
|
28 | 29 | options = options || {}; |
|
29 | 30 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
|
30 | 31 | this.selector = selector; |
@@ -20,7 +20,7 define([ | |||
|
20 | 20 | $, |
|
21 | 21 | utils, |
|
22 | 22 | dialog, |
|
23 |
cell |
|
|
23 | textcell, | |
|
24 | 24 | codecell, |
|
25 | 25 | session, |
|
26 | 26 | celltoolbar, |
@@ -29,16 +29,22 define([ | |||
|
29 | 29 | keyboard |
|
30 | 30 | ) { |
|
31 | 31 | |
|
32 | /** | |
|
33 | * A notebook contains and manages cells. | |
|
34 | * | |
|
35 | * @class Notebook | |
|
36 | * @constructor | |
|
37 | * @param {String} selector A jQuery selector for the notebook's DOM element | |
|
38 | * @param {Object} [options] A config object | |
|
39 | * @param {Object} [events] An events object | |
|
40 | */ | |
|
41 | 32 | var Notebook = function (selector, options) { |
|
33 | // Constructor | |
|
34 | // | |
|
35 | // A notebook contains and manages cells. | |
|
36 | // | |
|
37 | // Parameters: | |
|
38 | // selector: string | |
|
39 | // options: dictionary | |
|
40 | // Dictionary of keyword arguments. | |
|
41 | // events: $(Events) instance | |
|
42 | // keyboard_manager: KeyboardManager instance | |
|
43 | // save_widget: SaveWidget instance | |
|
44 | // config: dictionary | |
|
45 | // base_url : string | |
|
46 | // notebook_path : string | |
|
47 | // notebook_name : string | |
|
42 | 48 | this.config = options.config || {}; |
|
43 | 49 | this.base_url = options.base_url; |
|
44 | 50 | this.notebook_path = options.notebook_path; |
@@ -806,9 +812,6 define([ | |||
|
806 | 812 | |
|
807 | 813 | if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { |
|
808 | 814 | var cell_options = { |
|
809 | base_url: base_url, | |
|
810 | notebook_path: notebook_path, | |
|
811 | notebook_name: notebook_name, | |
|
812 | 815 | events: this.events, |
|
813 | 816 | config: this.config, |
|
814 | 817 | keyboard_manager: this.keyboard_manager, |
@@ -818,11 +821,11 define([ | |||
|
818 | 821 | cell = new codecell.CodeCell(this.kernel, cell_options); |
|
819 | 822 | cell.set_input_prompt(); |
|
820 | 823 | } else if (type === 'markdown') { |
|
821 |
cell = new cell |
|
|
824 | cell = new textcell.MarkdownCell(cell_options); | |
|
822 | 825 | } else if (type === 'raw') { |
|
823 |
cell = new cell |
|
|
826 | cell = new textcell.RawCell(cell_options); | |
|
824 | 827 | } else if (type === 'heading') { |
|
825 |
cell = new cell |
|
|
828 | cell = new textcell.HeadingCell(cell_options); | |
|
826 | 829 | } |
|
827 | 830 | |
|
828 | 831 | if(this._insert_element_at_index(cell.element,index)) { |
@@ -967,7 +970,7 define([ | |||
|
967 | 970 | if (this.is_valid_cell_index(i)) { |
|
968 | 971 | var source_element = this.get_cell_element(i); |
|
969 | 972 | var source_cell = source_element.data("cell"); |
|
970 |
if (!(source_cell instanceof cell |
|
|
973 | if (!(source_cell instanceof textcell.MarkdownCell)) { | |
|
971 | 974 | var target_cell = this.insert_cell_below('markdown',i); |
|
972 | 975 | var text = source_cell.get_text(); |
|
973 | 976 | if (text === source_cell.placeholder) { |
@@ -981,7 +984,7 define([ | |||
|
981 | 984 | target_cell.code_mirror.clearHistory(); |
|
982 | 985 | source_element.remove(); |
|
983 | 986 | this.select(i); |
|
984 |
if ((source_cell instanceof cell |
|
|
987 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { | |
|
985 | 988 | target_cell.render(); |
|
986 | 989 | } |
|
987 | 990 | var cursor = source_cell.code_mirror.getCursor(); |
@@ -1003,7 +1006,7 define([ | |||
|
1003 | 1006 | var source_element = this.get_cell_element(i); |
|
1004 | 1007 | var source_cell = source_element.data("cell"); |
|
1005 | 1008 | var target_cell = null; |
|
1006 |
if (!(source_cell instanceof cell |
|
|
1009 | if (!(source_cell instanceof textcell.RawCell)) { | |
|
1007 | 1010 | target_cell = this.insert_cell_below('raw',i); |
|
1008 | 1011 | var text = source_cell.get_text(); |
|
1009 | 1012 | if (text === source_cell.placeholder) { |
@@ -1038,7 +1041,7 define([ | |||
|
1038 | 1041 | var source_element = this.get_cell_element(i); |
|
1039 | 1042 | var source_cell = source_element.data("cell"); |
|
1040 | 1043 | var target_cell = null; |
|
1041 |
if (source_cell instanceof cell |
|
|
1044 | if (source_cell instanceof textcell.HeadingCell) { | |
|
1042 | 1045 | source_cell.set_level(level); |
|
1043 | 1046 | } else { |
|
1044 | 1047 | target_cell = this.insert_cell_below('heading',i); |
@@ -1057,7 +1060,7 define([ | |||
|
1057 | 1060 | this.select(i); |
|
1058 | 1061 | var cursor = source_cell.code_mirror.getCursor(); |
|
1059 | 1062 | target_cell.code_mirror.setCursor(cursor); |
|
1060 |
if ((source_cell instanceof cell |
|
|
1063 | if ((source_cell instanceof textcell.TextCell) && source_cell.rendered) { | |
|
1061 | 1064 | target_cell.render(); |
|
1062 | 1065 | } |
|
1063 | 1066 | } |
@@ -1176,8 +1179,8 define([ | |||
|
1176 | 1179 | * @method split_cell |
|
1177 | 1180 | */ |
|
1178 | 1181 | Notebook.prototype.split_cell = function () { |
|
1179 |
var mdc = cell |
|
|
1180 |
var rc = cell |
|
|
1182 | var mdc = textcell.MarkdownCell; | |
|
1183 | var rc = textcell.RawCell; | |
|
1181 | 1184 | var cell = this.get_selected_cell(); |
|
1182 | 1185 | if (cell.is_splittable()) { |
|
1183 | 1186 | var texta = cell.get_pre_cursor(); |
@@ -1205,8 +1208,8 define([ | |||
|
1205 | 1208 | * @method merge_cell_above |
|
1206 | 1209 | */ |
|
1207 | 1210 | Notebook.prototype.merge_cell_above = function () { |
|
1208 |
var mdc = cell |
|
|
1209 |
var rc = cell |
|
|
1211 | var mdc = textcell.MarkdownCell; | |
|
1212 | var rc = textcell.RawCell; | |
|
1210 | 1213 | var index = this.get_selected_index(); |
|
1211 | 1214 | var cell = this.get_cell(index); |
|
1212 | 1215 | var render = cell.rendered; |
@@ -1242,8 +1245,8 define([ | |||
|
1242 | 1245 | * @method merge_cell_below |
|
1243 | 1246 | */ |
|
1244 | 1247 | Notebook.prototype.merge_cell_below = function () { |
|
1245 |
var mdc = cell |
|
|
1246 |
var rc = cell |
|
|
1248 | var mdc = textcell.MarkdownCell; | |
|
1249 | var rc = textcell.RawCell; | |
|
1247 | 1250 | var index = this.get_selected_index(); |
|
1248 | 1251 | var cell = this.get_cell(index); |
|
1249 | 1252 | var render = cell.rendered; |
@@ -11,6 +11,15 define([ | |||
|
11 | 11 | "use strict"; |
|
12 | 12 | |
|
13 | 13 | var NotificationArea = function (selector, options) { |
|
14 | // Constructor | |
|
15 | // | |
|
16 | // Parameters: | |
|
17 | // selector: string | |
|
18 | // options: dictionary | |
|
19 | // Dictionary of keyword arguments. | |
|
20 | // notebook: Notebook instance | |
|
21 | // events: $(Events) instance | |
|
22 | // save_widget: SaveWidget instance | |
|
14 | 23 | this.selector = selector; |
|
15 | 24 | this.events = options.events; |
|
16 | 25 | this.save_widget = options.save_widget; |
@@ -9,6 +9,15 define([ | |||
|
9 | 9 | "use strict"; |
|
10 | 10 | |
|
11 | 11 | var Pager = function (pager_selector, pager_splitter_selector, options) { |
|
12 | // Constructor | |
|
13 | // | |
|
14 | // Parameters: | |
|
15 | // pager_selector: string | |
|
16 | // pager_splitter_selector: string | |
|
17 | // options: dictionary | |
|
18 | // Dictionary of keyword arguments. | |
|
19 | // events: $(Events) instance | |
|
20 | // layout_manager: LayoutManager instance | |
|
12 | 21 | this.events = options.events; |
|
13 | 22 | this.pager_element = $(pager_selector); |
|
14 | 23 | this.pager_button_area = $('#pager_button_area'); |
@@ -11,6 +11,13 define([ | |||
|
11 | 11 | var platform = utils.platform; |
|
12 | 12 | |
|
13 | 13 | var QuickHelp = function (options) { |
|
14 | // Constructor | |
|
15 | // | |
|
16 | // Parameters: | |
|
17 | // options: dictionary | |
|
18 | // Dictionary of keyword arguments. | |
|
19 | // events: $(Events) instance | |
|
20 | // keyboard_manager: KeyboardManager instance | |
|
14 | 21 | this.keyboard_manager = options.keyboard_manager; |
|
15 | 22 | this.keyboard_manager.quick_help = this; |
|
16 | 23 | this.events = options.events; |
@@ -12,6 +12,7 define([ | |||
|
12 | 12 | "use strict"; |
|
13 | 13 | |
|
14 | 14 | var SaveWidget = function (selector, events) { |
|
15 | // TODO: Remove circulat ref. | |
|
15 | 16 | this.notebook = undefined; |
|
16 | 17 | this.selector = selector; |
|
17 | 18 | this.events = events; |
@@ -13,19 +13,21 define([ | |||
|
13 | 13 | "use strict"; |
|
14 | 14 | var Cell = cell.Cell; |
|
15 | 15 | |
|
16 | /** | |
|
17 | * Construct a new TextCell, codemirror mode is by default 'htmlmixed', and cell type is 'text' | |
|
18 | * cell start as not redered. | |
|
19 | * | |
|
20 | * @class TextCell | |
|
21 | * @constructor TextCell | |
|
22 | * @extend Cell | |
|
23 | * @param {object|undefined} [options] | |
|
24 | * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config | |
|
25 | * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass) | |
|
26 | */ | |
|
27 | 16 | var TextCell = function (options) { |
|
17 | // Constructor | |
|
18 | // | |
|
19 | // Construct a new TextCell, codemirror mode is by default 'htmlmixed', | |
|
20 | // and cell type is 'text' cell start as not redered. | |
|
21 | // | |
|
22 | // Parameters: | |
|
23 | // options: dictionary | |
|
24 | // Dictionary of keyword arguments. | |
|
25 | // events: $(Events) instance | |
|
26 | // config: dictionary | |
|
27 | // keyboard_manager: KeyboardManager instance | |
|
28 | // notebook: Notebook instance | |
|
28 | 29 | options = options || {}; |
|
30 | ||
|
29 | 31 | // in all TextCell/Cell subclasses |
|
30 | 32 | // do not assign most of members here, just pass it down |
|
31 | 33 | // in the options dict potentially overwriting what you wish. |
@@ -214,12 +216,16 define([ | |||
|
214 | 216 | }; |
|
215 | 217 | |
|
216 | 218 | |
|
217 | /** | |
|
218 | * @class MarkdownCell | |
|
219 | * @constructor MarkdownCell | |
|
220 | * @extends IPython.HTMLCell | |
|
221 | */ | |
|
222 | 219 | var MarkdownCell = function (options) { |
|
220 | // Constructor | |
|
221 | // | |
|
222 | // Parameters: | |
|
223 | // options: dictionary | |
|
224 | // Dictionary of keyword arguments. | |
|
225 | // events: $(Events) instance | |
|
226 | // config: dictionary | |
|
227 | // keyboard_manager: KeyboardManager instance | |
|
228 | // notebook: Notebook instance | |
|
223 | 229 | options = options || {}; |
|
224 | 230 | var config = this.mergeopt(MarkdownCell, options.config); |
|
225 | 231 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
@@ -263,14 +269,16 define([ | |||
|
263 | 269 | }; |
|
264 | 270 | |
|
265 | 271 | |
|
266 | // RawCell | |
|
267 | ||
|
268 | /** | |
|
269 | * @class RawCell | |
|
270 | * @constructor RawCell | |
|
271 | * @extends TextCell | |
|
272 | */ | |
|
273 | 272 | var RawCell = function (options) { |
|
273 | // Constructor | |
|
274 | // | |
|
275 | // Parameters: | |
|
276 | // options: dictionary | |
|
277 | // Dictionary of keyword arguments. | |
|
278 | // events: $(Events) instance | |
|
279 | // config: dictionary | |
|
280 | // keyboard_manager: KeyboardManager instance | |
|
281 | // notebook: Notebook instance | |
|
274 | 282 | options = options || {}; |
|
275 | 283 | var config = this.mergeopt(RawCell, options.config); |
|
276 | 284 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
@@ -321,16 +329,16 define([ | |||
|
321 | 329 | }; |
|
322 | 330 | |
|
323 | 331 | |
|
324 | /** | |
|
325 | * @class HeadingCell | |
|
326 | * @extends TextCell | |
|
327 | */ | |
|
328 | ||
|
329 | /** | |
|
330 | * @constructor HeadingCell | |
|
331 | * @extends TextCell | |
|
332 | */ | |
|
333 | 332 | var HeadingCell = function (options) { |
|
333 | // Constructor | |
|
334 | // | |
|
335 | // Parameters: | |
|
336 | // options: dictionary | |
|
337 | // Dictionary of keyword arguments. | |
|
338 | // events: $(Events) instance | |
|
339 | // config: dictionary | |
|
340 | // keyboard_manager: KeyboardManager instance | |
|
341 | // notebook: Notebook instance | |
|
334 | 342 | options = options || {}; |
|
335 | 343 | var config = this.mergeopt(HeadingCell, options.config); |
|
336 | 344 | TextCell.apply(this, [$.extend({}, options, {config: config})]); |
@@ -4,7 +4,8 | |||
|
4 | 4 | define([ |
|
5 | 5 | 'base/js/namespace', |
|
6 | 6 | 'jquery', |
|
7 | ], function(IPython, $) { | |
|
7 | 'components/bootstrap-tour/build/js/bootstrap-tour.min', | |
|
8 | ], function(IPython, $, Tour) { | |
|
8 | 9 | "use strict"; |
|
9 | 10 | |
|
10 | 11 | var tour_style = "<div class='popover tour'>\n" + |
@@ -9,6 +9,15 define([ | |||
|
9 | 9 | "use strict"; |
|
10 | 10 | |
|
11 | 11 | var KernelList = function (selector, options) { |
|
12 | // Constructor | |
|
13 | // | |
|
14 | // Parameters: | |
|
15 | // selector: string | |
|
16 | // options: dictionary | |
|
17 | // Dictionary of keyword arguments. | |
|
18 | // session_list: SessionList instance | |
|
19 | // base_url: string | |
|
20 | // notebook_path: string | |
|
12 | 21 | notebooklist.NotebookList.call(this, selector, $.extend({ |
|
13 | 22 | element_name: 'running'}, |
|
14 | 23 | options)); |
@@ -10,6 +10,16 define([ | |||
|
10 | 10 | "use strict"; |
|
11 | 11 | |
|
12 | 12 | var NotebookList = function (selector, options) { |
|
13 | // Constructor | |
|
14 | // | |
|
15 | // Parameters: | |
|
16 | // selector: string | |
|
17 | // options: dictionary | |
|
18 | // Dictionary of keyword arguments. | |
|
19 | // session_list: SessionList instance | |
|
20 | // element_name: string | |
|
21 | // base_url: string | |
|
22 | // notebook_path: string | |
|
13 | 23 | var that = this; |
|
14 | 24 | this.session_list = options.session_list; |
|
15 | 25 | // allow code re-use by just changing element_name in kernellist.js |
@@ -8,7 +8,14 define([ | |||
|
8 | 8 | ], function(IPython, $, utils) { |
|
9 | 9 | "use strict"; |
|
10 | 10 | |
|
11 |
var SesssionList = function (options |
|
|
11 | var SesssionList = function (options) { | |
|
12 | // Constructor | |
|
13 | // | |
|
14 | // Parameters: | |
|
15 | // options: dictionary | |
|
16 | // Dictionary of keyword arguments. | |
|
17 | // events: $(Events) instance | |
|
18 | // base_url : string | |
|
12 | 19 | this.events = options.events; |
|
13 | 20 | this.sessions = {}; |
|
14 | 21 | this.base_url = options.base_url || utils.get_body_data("baseUrl"); |
General Comments 0
You need to be logged in to leave comments.
Login now