##// END OF EJS Templates
In person review with @ellisonbg
jon -
Show More
@@ -38,23 +38,24 b' define(['
38 * @param {object|undefined} [options]
38 * @param {object|undefined} [options]
39 * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters
39 * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters
40 */
40 */
41 var Cell = function (options, keyboard_manager, events) {
41 var Cell = function (options) {
42 this.keyboard_manager = keyboard_manager;
42 options = options || {};
43 this.events = events;
43 this.keyboard_manager = options.keyboard_manager;
44 options = this.mergeopt(Cell, options);
44 this.events = options.events;
45 var config = this.mergeopt(Cell, options.config);
45 // superclass default overwrite our default
46 // superclass default overwrite our default
46
47
47 this.placeholder = options.placeholder || '';
48 this.placeholder = config.placeholder || '';
48 this.read_only = options.cm_config.readOnly;
49 this.read_only = config.cm_config.readOnly;
49 this.selected = false;
50 this.selected = false;
50 this.rendered = false;
51 this.rendered = false;
51 this.mode = 'command';
52 this.mode = 'command';
52 this.metadata = {};
53 this.metadata = {};
53 // load this from metadata later ?
54 // load this from metadata later ?
54 this.user_highlight = 'auto';
55 this.user_highlight = 'auto';
55 this.cm_config = options.cm_config;
56 this.cm_config = config.cm_config;
56 this.cell_id = utils.uuid();
57 this.cell_id = utils.uuid();
57 this._options = options;
58 this._options = config;
58
59
59 // For JS VM engines optimization, attributes should be all set (even
60 // For JS VM engines optimization, attributes should be all set (even
60 // to null) in the constructor, and if possible, if different subclass
61 // to null) in the constructor, and if possible, if different subclass
@@ -54,13 +54,14 b' define(['
54 * @param {object|undefined} [options]
54 * @param {object|undefined} [options]
55 * @param [options.cm_config] {object} config to pass to CodeMirror
55 * @param [options.cm_config] {object} config to pass to CodeMirror
56 */
56 */
57 var CodeCell = function (kernel, options, events, config, keyboard_manager, notebook) {
57 var CodeCell = function (kernel, options) {
58 options = options || {};
58 this.kernel = kernel || null;
59 this.kernel = kernel || null;
59 this.notebook = notebook;
60 this.notebook = options.notebook;
60 this.collapsed = false;
61 this.collapsed = false;
61 this.tooltip = new tooltip.Tooltip(events);
62 this.events = options.events;
62 this.events = events;
63 this.tooltip = new tooltip.Tooltip(this.events);
63 this.config = config;
64 this.config = options.config;
64
65
65 // create all attributed in constructor function
66 // create all attributed in constructor function
66 // even if null for V8 VM optimisation
67 // even if null for V8 VM optimisation
@@ -75,9 +76,11 b' define(['
75 onKeyEvent: $.proxy(this.handle_keyevent,this)
76 onKeyEvent: $.proxy(this.handle_keyevent,this)
76 };
77 };
77
78
78 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
79 var config = this.mergeopt(CodeCell, this.config, {cm_config: cm_overwrite_options});
79
80 Cell.apply(this,[{
80 Cell.apply(this,[options, keyboard_manager, events]);
81 config: config,
82 keyboard_manager: options.keyboard_manager,
83 events: this.events}]);
81
84
82 // Attributes we want to override in this subclass.
85 // Attributes we want to override in this subclass.
83 this.cell_type = "code";
86 this.cell_type = "code";
@@ -15,17 +15,17 b' define(['
15 // Main keyboard manager for the notebook
15 // Main keyboard manager for the notebook
16 var keycodes = keyboard.keycodes;
16 var keycodes = keyboard.keycodes;
17
17
18 var KeyboardManager = function (pager, events) {
18 var KeyboardManager = function (options) {
19 this.mode = 'command';
19 this.mode = 'command';
20 this.enabled = true;
20 this.enabled = true;
21 this.pager = pager;
21 this.pager = options.pager;
22 this.quick_help = undefined;
22 this.quick_help = undefined;
23 this.notebook = undefined;
23 this.notebook = undefined;
24 this.bind_events();
24 this.bind_events();
25 this.command_shortcuts = new keyboard.ShortcutManager(undefined, events);
25 this.command_shortcuts = new keyboard.ShortcutManager(undefined, options.events);
26 this.command_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
26 this.command_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
27 this.command_shortcuts.add_shortcuts(this.get_default_command_shortcuts());
27 this.command_shortcuts.add_shortcuts(this.get_default_command_shortcuts());
28 this.edit_shortcuts = new keyboard.ShortcutManager(undefined, events);
28 this.edit_shortcuts = new keyboard.ShortcutManager(undefined, options.events);
29 this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
29 this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts());
30 this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts());
30 this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts());
31 };
31 };
@@ -42,7 +42,7 b' require(['
42 $('#ipython-main-app').addClass('border-box-sizing');
42 $('#ipython-main-app').addClass('border-box-sizing');
43 $('div#notebook_panel').addClass('border-box-sizing');
43 $('div#notebook_panel').addClass('border-box-sizing');
44
44
45 var options = {
45 var common_options = {
46 base_url : utils.get_body_data("baseUrl"),
46 base_url : utils.get_body_data("baseUrl"),
47 notebook_path : utils.get_body_data("notebookPath"),
47 notebook_path : utils.get_body_data("notebookPath"),
48 notebook_name : utils.get_body_data('notebookName')
48 notebook_name : utils.get_body_data('notebookName')
@@ -52,15 +52,38 b' require(['
52 var page = new page.Page();
52 var page = new page.Page();
53 var layout_manager = new layoutmanager.LayoutManager();
53 var layout_manager = new layoutmanager.LayoutManager();
54 var events = $([new events.Events()]);
54 var events = $([new events.Events()]);
55 var pager = new pager.Pager('div#pager', 'div#pager_splitter', layout_manager, events);
55 var pager = new pager.Pager('div#pager', 'div#pager_splitter', {
56 var keyboard_manager = new keyboardmanager.KeyboardManager(pager, events);
56 layout_manager: layout_manager,
57 events: events});
58 var keyboard_manager = new keyboardmanager.KeyboardManager({
59 pager: pager,
60 events: events});
57 var save_widget = new savewidget.SaveWidget('span#save_widget', events);
61 var save_widget = new savewidget.SaveWidget('span#save_widget', events);
58 var notebook = new notebook.Notebook('div#notebook', options, events, keyboard_manager, save_widget, user_config);
62 var notebook = new notebook.Notebook('div#notebook', $.extend({
59 var login_widget = new loginwidget.LoginWidget('span#login_widget', options);
63 events: events,
60 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', layout_manager, notebook, events);
64 keyboard_manager: keyboard_manager,
61 var quick_help = new quickhelp.QuickHelp(undefined, keyboard_manager, events);
65 save_widget: save_widget,
62 var menubar = new menubar.MenuBar('#menubar', options, notebook, layout_manager, events, save_widget, quick_help);
66 config: user_config},
63 var notification_area = new notificationarea.NotificationArea('#notification_area', events, save_widget, notebook);
67 common_options));
68 var login_widget = new loginwidget.LoginWidget('span#login_widget', common_options);
69 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', {
70 notebook: notebook,
71 events: events});
72 var quick_help = new quickhelp.QuickHelp({
73 keyboard_manager: keyboard_manager,
74 events: events});
75 var menubar = new menubar.MenuBar('#menubar', $.extend({
76 notebook: notebook,
77 layout_manager: layout_manager,
78 events: events,
79 save_widget: save_widget,
80 quick_help: quick_help},
81 common_options));
82 var notification_area = new notificationarea.NotificationArea(
83 '#notification_area', {
84 events: events,
85 save_widget: save_widget,
86 notebook: notebook});
64 notification_area.init_notification_widgets();
87 notification_area.init_notification_widgets();
65
88
66 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
89 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
@@ -91,7 +114,7 b' require(['
91
114
92 events.on('notebook_loaded.Notebook', first_load);
115 events.on('notebook_loaded.Notebook', first_load);
93 events.trigger('app_initialized.NotebookApp');
116 events.trigger('app_initialized.NotebookApp');
94 notebook.load_notebook(options.notebook_name, options.notebook_path);
117 notebook.load_notebook(common_options.notebook_name, common_options.notebook_path);
95
118
96 ipython.page = page;
119 ipython.page = page;
97 ipython.layout_manager = layout_manager;
120 ipython.layout_manager = layout_manager;
@@ -9,10 +9,10 b' define(['
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, options) {
13 toolbar.ToolBar.apply(this, arguments);
13 toolbar.ToolBar.apply(this, arguments);
14 this.events = events;
14 this.events = options.events;
15 this.notebook = notebook;
15 this.notebook = options.notebook;
16 this.construct();
16 this.construct();
17 this.add_celltype_list();
17 this.add_celltype_list();
18 this.add_celltoolbar_list();
18 this.add_celltoolbar_list();
@@ -24,18 +24,18 b' define(['
24 * $('body').data('baseUrl');
24 * $('body').data('baseUrl');
25 * does not support change for now is set through this option
25 * does not support change for now is set through this option
26 */
26 */
27 var MenuBar = function (selector, options, notebook, layout_manager, events, save_widget, quick_help) {
27 var MenuBar = function (selector, options) {
28 options = options || {};
28 options = options || {};
29 this.base_url = options.base_url || utils.get_body_data("baseUrl");
29 this.base_url = options.base_url || utils.get_body_data("baseUrl");
30 this.selector = selector;
30 this.selector = selector;
31 this.notebook = notebook;
31 this.notebook = options.notebook;
32 this.layout_manager = layout_manager;
32 this.layout_manager = options.layout_manager;
33 this.events = events;
33 this.events = options.events;
34 this.save_widget = save_widget;
34 this.save_widget = options.save_widget;
35 this.quick_help = quick_help;
35 this.quick_help = options.quick_help;
36
36
37 try {
37 try {
38 this.tour = new tour.Tour(notebook, events);
38 this.tour = new tour.Tour(this.notebook, this.events);
39 } catch (e) {
39 } catch (e) {
40 this.tour = undefined;
40 this.tour = undefined;
41 console.log("Failed to instantiate Notebook Tour", e);
41 console.log("Failed to instantiate Notebook Tour", e);
@@ -38,15 +38,18 b' define(['
38 * @param {Object} [options] A config object
38 * @param {Object} [options] A config object
39 * @param {Object} [events] An events object
39 * @param {Object} [events] An events object
40 */
40 */
41 var Notebook = function (selector, options, events, keyboard_manager, save_widget, config) {
41 var Notebook = function (selector, options) {
42 this.config = config;
42 this.config = options.config || {};
43 this.events = events;
43 this.base_url = options.base_url;
44 this.keyboard_manager = keyboard_manager;
44 this.notebook_path = options.notebook_path;
45 this.notebook_name = options.notebook_name;
46 this.events = options.events;
47 this.keyboard_manager = options.keyboard_manager;
48 this.save_widget = options.save_widget;
45 // TODO: This code smells (and the other `= this` line a couple lines down)
49 // TODO: This code smells (and the other `= this` line a couple lines down)
46 // We need a better way to deal with circular instance references.
50 // We need a better way to deal with circular instance references.
47 keyboard_manager.notebook = this;
51 this.keyboard_manager.notebook = this;
48 this.save_widget = save_widget;
52 this.save_widget.notebook = this;
49 save_widget.notebook = this;
50
53
51 mathjaxutils.init();
54 mathjaxutils.init();
52
55
@@ -76,10 +79,6 b' define(['
76 IPython.save_widget = this.save_widget;
79 IPython.save_widget = this.save_widget;
77 IPython.keyboard = this.keyboard;
80 IPython.keyboard = this.keyboard;
78
81
79 this.options = options = options || {};
80 this.base_url = options.base_url;
81 this.notebook_path = options.notebook_path;
82 this.notebook_name = options.notebook_name;
83 this.element = $(selector);
82 this.element = $(selector);
84 this.element.scroll();
83 this.element.scroll();
85 this.element.data("notebook", this);
84 this.element.data("notebook", this);
@@ -806,15 +805,24 b' define(['
806 type = type || this.get_selected_cell().cell_type;
805 type = type || this.get_selected_cell().cell_type;
807
806
808 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
807 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
808 var cell_options = {
809 base_url: base_url,
810 notebook_path: notebook_path,
811 notebook_name: notebook_name,
812 events: this.events,
813 config: this.config,
814 keyboard_manager: this.keyboard_manager,
815 notebook: this
816 };
809 if (type === 'code') {
817 if (type === 'code') {
810 cell = new codecell.CodeCell(this.kernel, this.options, this.events, this.config, this.keyboard_manager, this);
818 cell = new codecell.CodeCell(this.kernel, cell_options);
811 cell.set_input_prompt();
819 cell.set_input_prompt();
812 } else if (type === 'markdown') {
820 } else if (type === 'markdown') {
813 cell = new cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this);
821 cell = new cells.MarkdownCell(cell_options);
814 } else if (type === 'raw') {
822 } else if (type === 'raw') {
815 cell = new cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this);
823 cell = new cells.RawCell(cell_options);
816 } else if (type === 'heading') {
824 } else if (type === 'heading') {
817 cell = new cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this);
825 cell = new cells.HeadingCell(cell_options);
818 }
826 }
819
827
820 if(this._insert_element_at_index(cell.element,index)) {
828 if(this._insert_element_at_index(cell.element,index)) {
@@ -1465,7 +1473,11 b' define(['
1465 * @method start_session
1473 * @method start_session
1466 */
1474 */
1467 Notebook.prototype.start_session = function () {
1475 Notebook.prototype.start_session = function () {
1468 this.session = new session.Session(this, this.options);
1476 this.session = new session.Session(this, {
1477 base_url: base_url,
1478 notebook_path: notebook_path,
1479 notebook_name: notebook_name,
1480 notebook: this});
1469 this.session.start($.proxy(this._session_started, this));
1481 this.session.start($.proxy(this._session_started, this));
1470 };
1482 };
1471
1483
@@ -10,11 +10,11 b' define(['
10 ], function(IPython, $, utils, dialog, notificationwidget) {
10 ], function(IPython, $, utils, dialog, notificationwidget) {
11 "use strict";
11 "use strict";
12
12
13 var NotificationArea = function (selector, events, save_widget, notebook) {
13 var NotificationArea = function (selector, options) {
14 this.selector = selector;
14 this.selector = selector;
15 this.events = events;
15 this.events = options.events;
16 this.save_widget = save_widget;
16 this.save_widget = options.save_widget;
17 this.notebook = notebook;
17 this.notebook = options.notebook;
18 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
19 this.element = $(selector);
19 this.element = $(selector);
20 }
20 }
@@ -8,13 +8,13 b' define(['
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var Pager = function (pager_selector, pager_splitter_selector, layout_manager, events) {
11 var Pager = function (pager_selector, pager_splitter_selector, options) {
12 this.events = events;
12 this.events = options.events;
13 this.pager_element = $(pager_selector);
13 this.pager_element = $(pager_selector);
14 this.pager_button_area = $('#pager_button_area');
14 this.pager_button_area = $('#pager_button_area');
15 var that = this;
15 var that = this;
16 this.percentage_height = 0.40;
16 this.percentage_height = 0.40;
17 layout_manager.pager = this;
17 options.layout_manager.pager = this;
18 this.pager_splitter_element = $(pager_splitter_selector)
18 this.pager_splitter_element = $(pager_splitter_selector)
19 .draggable({
19 .draggable({
20 containment: 'window',
20 containment: 'window',
@@ -23,7 +23,7 b' define(['
23 drag: function(event, ui) {
23 drag: function(event, ui) {
24 // recalculate the amount of space the pager should take
24 // recalculate the amount of space the pager should take
25 var pheight = ($(document.body).height()-event.clientY-4);
25 var pheight = ($(document.body).height()-event.clientY-4);
26 var downprct = pheight/layout_manager.app_height();
26 var downprct = pheight/options.layout_manager.app_height();
27 downprct = Math.min(0.9, downprct);
27 downprct = Math.min(0.9, downprct);
28 if (downprct < 0.1) {
28 if (downprct < 0.1) {
29 that.percentage_height = 0.1;
29 that.percentage_height = 0.1;
@@ -32,7 +32,7 b' define(['
32 that.percentage_height = downprct;
32 that.percentage_height = downprct;
33 that.expand({'duration':0});
33 that.expand({'duration':0});
34 }
34 }
35 layout_manager.do_resize();
35 options.layout_manager.do_resize();
36 }
36 }
37 });
37 });
38 this.expanded = false;
38 this.expanded = false;
@@ -10,10 +10,10 b' define(['
10 "use strict";
10 "use strict";
11 var platform = utils.platform;
11 var platform = utils.platform;
12
12
13 var QuickHelp = function (selector, keyboard_manager, events) {
13 var QuickHelp = function (options) {
14 this.keyboard_manager = keyboard_manager;
14 this.keyboard_manager = options.keyboard_manager;
15 keyboard_manager.quick_help = this;
15 this.keyboard_manager.quick_help = this;
16 this.events = events;
16 this.events = options.events;
17 };
17 };
18
18
19 var cmd_ctrl = 'Ctrl-';
19 var cmd_ctrl = 'Ctrl-';
@@ -24,27 +24,28 b' define(['
24 * @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config
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)
25 * @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass)
26 */
26 */
27 var TextCell = function (options, events, config, keyboard_manager, notebook) {
27 var TextCell = function (options) {
28 options = options || {};
28 // in all TextCell/Cell subclasses
29 // in all TextCell/Cell subclasses
29 // do not assign most of members here, just pass it down
30 // do not assign most of members here, just pass it down
30 // in the options dict potentially overwriting what you wish.
31 // in the options dict potentially overwriting what you wish.
31 // they will be assigned in the base class.
32 // they will be assigned in the base class.
32 this.notebook = notebook;
33 this.notebook = options.notebook;
33 this.events = events;
34 this.events = options.events;
34 this.config = config;
35 this.config = options.config;
35
36
36 // we cannot put this as a class key as it has handle to "this".
37 // we cannot put this as a class key as it has handle to "this".
37 var cm_overwrite_options = {
38 var cm_overwrite_options = {
38 onKeyEvent: $.proxy(this.handle_keyevent,this)
39 onKeyEvent: $.proxy(this.handle_keyevent,this)
39 };
40 };
40
41 var config = this.mergeopt(TextCell, this.config, {cm_config:cm_overwrite_options});
41 options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options});
42 Cell.apply(this, [{
43 config: config,
44 keyboard_manager: options.keyboard_manager,
45 events: events}]);
42
46
43 this.cell_type = this.cell_type || 'text';
47 this.cell_type = this.cell_type || 'text';
44 mathjaxutils = mathjaxutils;
48 mathjaxutils = mathjaxutils;
45
46 Cell.apply(this, [options, keyboard_manager, events]);
47
48 this.rendered = false;
49 this.rendered = false;
49 };
50 };
50
51
@@ -218,11 +219,12 b' define(['
218 * @constructor MarkdownCell
219 * @constructor MarkdownCell
219 * @extends IPython.HTMLCell
220 * @extends IPython.HTMLCell
220 */
221 */
221 var MarkdownCell = function (options, events, config, keyboard_manager) {
222 var MarkdownCell = function (options) {
222 options = this.mergeopt(MarkdownCell, options);
223 options = options || {};
224 var config = this.mergeopt(MarkdownCell, options.config);
225 TextCell.apply(this, [$.extend({}, options, {config: config})]);
223
226
224 this.cell_type = 'markdown';
227 this.cell_type = 'markdown';
225 TextCell.apply(this, [options, events, config, keyboard_manager]);
226 };
228 };
227
229
228 MarkdownCell.options_default = {
230 MarkdownCell.options_default = {
@@ -268,13 +270,14 b' define(['
268 * @constructor RawCell
270 * @constructor RawCell
269 * @extends TextCell
271 * @extends TextCell
270 */
272 */
271 var RawCell = function (options, events, config, keyboard_manager) {
273 var RawCell = function (options) {
274 options = options || {};
275 var config = this.mergeopt(RawCell, options.config);
276 TextCell.apply(this, [$.extend({}, options, {config: config})]);
272
277
273 options = this.mergeopt(RawCell,options);
274 TextCell.apply(this, [options, events, config, keyboard_manager]);
275 this.cell_type = 'raw';
276 // RawCell should always hide its rendered div
278 // RawCell should always hide its rendered div
277 this.element.find('div.text_cell_render').hide();
279 this.element.find('div.text_cell_render').hide();
280 this.cell_type = 'raw';
278 };
281 };
279
282
280 RawCell.options_default = {
283 RawCell.options_default = {
@@ -327,17 +330,13 b' define(['
327 * @constructor HeadingCell
330 * @constructor HeadingCell
328 * @extends TextCell
331 * @extends TextCell
329 */
332 */
330 var HeadingCell = function (options, events, config, keyboard_manager) {
333 var HeadingCell = function (options) {
331 options = this.mergeopt(HeadingCell, options);
334 options = options || {};
335 var config = this.mergeopt(HeadingCell, options.config);
336 TextCell.apply(this, [$.extend({}, options, {config: config})]);
332
337
333 this.level = 1;
338 this.level = 1;
334 this.cell_type = 'heading';
339 this.cell_type = 'heading';
335 TextCell.apply(this, [options, events, config, keyboard_manager]);
336
337 /**
338 * heading level of the cell, use getter and setter to access
339 * @property level
340 */
341 };
340 };
342
341
343 HeadingCell.options_default = {
342 HeadingCell.options_default = {
@@ -9,10 +9,10 b' define(['
9 ], function(IPython, $, utils, kernel) {
9 ], function(IPython, $, utils, kernel) {
10 "use strict";
10 "use strict";
11
11
12 var Session = function(notebook, options){
12 var Session = function(options){
13 this.kernel = null;
13 this.kernel = null;
14 this.id = null;
14 this.id = null;
15 this.notebook = notebook;
15 this.notebook = options.notebook;
16 this.name = notebook.notebook_name;
16 this.name = notebook.notebook_name;
17 this.path = notebook.notebook_path;
17 this.path = notebook.notebook_path;
18 this.base_url = notebook.base_url;
18 this.base_url = notebook.base_url;
@@ -8,8 +8,10 b' define(['
8 ], function(IPython, $, notebooklist) {
8 ], function(IPython, $, notebooklist) {
9 "use strict";
9 "use strict";
10
10
11 var KernelList = function (selector, options, session_list) {
11 var KernelList = function (selector, options) {
12 notebooklist.NotebookList.call(this, selector, options, 'running', session_list);
12 notebooklist.NotebookList.call(this, selector, $.extend({
13 element_name: 'running'},
14 options));
13 };
15 };
14
16
15 KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
17 KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
@@ -1,7 +1,6 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 var ipython = ipython || {};
5 require([
4 require([
6 'base/js/namespace',
5 'base/js/namespace',
7 'jquery',
6 'jquery',
@@ -29,16 +28,22 b' require(['
29
28
30 page = new page.Page();
29 page = new page.Page();
31
30
32 var opts = {
31 var common_options = {
33 base_url: utils.get_body_data("baseUrl"),
32 base_url: utils.get_body_data("baseUrl"),
34 notebook_path: utils.get_body_data("notebookPath"),
33 notebook_path: utils.get_body_data("notebookPath"),
35 };
34 };
36 events = $([new events.Events()]);
35 events = $([new events.Events()]);
37 session_list = new sesssionlist.SesssionList(opts, events);
36 session_list = new sesssionlist.SesssionList($.extend({
38 notebook_list = new notebooklist.NotebookList('#notebook_list', opts, undefined, session_list);
37 events: events},
39 cluster_list = new clusterlist.ClusterList('#cluster_list', opts);
38 common_options));
40 kernel_list = new kernellist.KernelList('#running_list', opts, session_list);
39 notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
41 login_widget = new loginwidget.LoginWidget('#login_widget', opts);
40 session_list: session_list},
41 common_options));
42 cluster_list = new clusterlist.ClusterList('#cluster_list', common_options);
43 kernel_list = new kernellist.KernelList('#running_list', $.extend({
44 session_list: session_list},
45 common_options));
46 login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
42
47
43 $('#new_notebook').button().click(function (e) {
48 $('#new_notebook').button().click(function (e) {
44 notebook_list.new_notebook();
49 notebook_list.new_notebook();
@@ -104,11 +109,11 b' require(['
104 }
109 }
105
110
106 // For backwards compatability.
111 // For backwards compatability.
107 ipython.page = page;
112 IPython.page = page;
108 ipython.notebook_list = notebook_list;
113 IPython.notebook_list = notebook_list;
109 ipython.cluster_list = cluster_list;
114 IPython.cluster_list = cluster_list;
110 ipython.session_list = session_list;
115 IPython.session_list = session_list;
111 ipython.kernel_list = kernel_list;
116 IPython.kernel_list = kernel_list;
112 ipython.login_widget = login_widget;
117 IPython.login_widget = login_widget;
113 ipython.events = events;
118 IPython.events = events;
114 });
119 });
@@ -9,11 +9,11 b' define(['
9 ], function(IPython, $, utils, dialog) {
9 ], function(IPython, $, utils, dialog) {
10 "use strict";
10 "use strict";
11
11
12 var NotebookList = function (selector, options, element_name, session_list) {
12 var NotebookList = function (selector, options) {
13 var that = this;
13 var that = this;
14 this.session_list = session_list;
14 this.session_list = options.session_list;
15 // allow code re-use by just changing element_name in kernellist.js
15 // allow code re-use by just changing element_name in kernellist.js
16 this.element_name = element_name || 'notebook';
16 this.element_name = options.element_name || 'notebook';
17 this.selector = selector;
17 this.selector = selector;
18 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
19 this.element = $(selector);
19 this.element = $(selector);
@@ -9,7 +9,7 b' define(['
9 "use strict";
9 "use strict";
10
10
11 var SesssionList = function (options, events) {
11 var SesssionList = function (options, events) {
12 this.events = events;
12 this.events = options.events;
13 this.sessions = {};
13 this.sessions = {};
14 this.base_url = options.base_url || utils.get_body_data("baseUrl");
14 this.base_url = options.base_url || utils.get_body_data("baseUrl");
15 };
15 };
General Comments 0
You need to be logged in to leave comments. Login now