##// END OF EJS Templates
Google hangout review comments.
Jonathan Frederic -
Show More
@@ -38,9 +38,9 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 this.keyboard_manager = options.keyboard_manager;
43 this.events = events;
43 this.events = options.events;
44 options = this.mergeopt(Cell, options);
44 options = this.mergeopt(Cell, options);
45 // superclass default overwrite our default
45 // superclass default overwrite our default
46
46
@@ -54,13 +54,13 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 this.kernel = kernel || null;
58 this.kernel = kernel || null;
59 this.notebook = notebook;
59 this.notebook = options.notebook;
60 this.collapsed = false;
60 this.collapsed = false;
61 this.tooltip = new tooltip.Tooltip(events);
61 this.tooltip = new tooltip.Tooltip(options.events);
62 this.events = events;
62 this.events = options.events;
63 this.config = config;
63 this.config = options.config;
64
64
65 // create all attributed in constructor function
65 // create all attributed in constructor function
66 // even if null for V8 VM optimisation
66 // even if null for V8 VM optimisation
@@ -77,7 +77,7 b' define(['
77
77
78 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
78 options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options});
79
79
80 Cell.apply(this,[options, keyboard_manager, events]);
80 Cell.apply(this,[options]);
81
81
82 // Attributes we want to override in this subclass.
82 // Attributes we want to override in this subclass.
83 this.cell_type = "code";
83 this.cell_type = "code";
@@ -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',
@@ -49,18 +48,25 b' require(['
49 };
48 };
50
49
51 var user_config = $.extend({}, config.default_config);
50 var user_config = $.extend({}, config.default_config);
51 options.user_config = user_config;
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 options.layout_manager = layout_manager;
54 var events = $([new events.Events()]);
55 var events = $([new events.Events()]);
56 options.events = events;
55 var pager = new pager.Pager('div#pager', 'div#pager_splitter', layout_manager, events);
57 var pager = new pager.Pager('div#pager', 'div#pager_splitter', layout_manager, events);
56 var keyboard_manager = new keyboardmanager.KeyboardManager(pager, events);
58 var keyboard_manager = new keyboardmanager.KeyboardManager(pager, events);
59 options.keyboard_manager = keyboard_manager;
57 var save_widget = new savewidget.SaveWidget('span#save_widget', events);
60 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);
61 options.save_widget = save_widget;
62 var notebook = new notebook.Notebook('div#notebook', options);
63 options.notebook = notebook;
59 var login_widget = new loginwidget.LoginWidget('span#login_widget', options);
64 var login_widget = new loginwidget.LoginWidget('span#login_widget', options);
60 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', layout_manager, notebook, events);
65 var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', options);
61 var quick_help = new quickhelp.QuickHelp(undefined, keyboard_manager, events);
66 var quick_help = new quickhelp.QuickHelp(undefined, options);
62 var menubar = new menubar.MenuBar('#menubar', options, notebook, layout_manager, events, save_widget, quick_help);
67 options.quick_help = quick_help;
63 var notification_area = new notificationarea.NotificationArea('#notification_area', events, save_widget, notebook);
68 var menubar = new menubar.MenuBar('#menubar', options);
69 var notification_area = new notificationarea.NotificationArea('#notification_area', options);
64 notification_area.init_notification_widgets();
70 notification_area.init_notification_widgets();
65
71
66 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
72 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
@@ -93,17 +99,17 b' require(['
93 events.trigger('app_initialized.NotebookApp');
99 events.trigger('app_initialized.NotebookApp');
94 notebook.load_notebook(options.notebook_name, options.notebook_path);
100 notebook.load_notebook(options.notebook_name, options.notebook_path);
95
101
96 ipython.page = page;
102 IPython.page = page;
97 ipython.layout_manager = layout_manager;
103 IPython.layout_manager = layout_manager;
98 ipython.notebook = notebook;
104 IPython.notebook = notebook;
99 ipython.pager = pager;
105 IPython.pager = pager;
100 ipython.quick_help = quick_help;
106 IPython.quick_help = quick_help;
101 ipython.login_widget = login_widget;
107 IPython.login_widget = login_widget;
102 ipython.menubar = menubar;
108 IPython.menubar = menubar;
103 ipython.toolbar = toolbar;
109 IPython.toolbar = toolbar;
104 ipython.notification_area = notification_area;
110 IPython.notification_area = notification_area;
105 ipython.events = events;
111 IPython.events = events;
106 ipython.keyboard_manager = keyboard_manager;
112 IPython.keyboard_manager = keyboard_manager;
107 ipython.save_widget = save_widget;
113 IPython.save_widget = save_widget;
108 ipython.config = user_config;
114 IPython.config = user_config;
109 });
115 });
@@ -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(options.notebook, options.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,15 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.events = options.events;
44 this.keyboard_manager = keyboard_manager;
44 this.keyboard_manager = options.keyboard_manager;
45 // TODO: This code smells (and the other `= this` line a couple lines down)
45 // 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.
46 // We need a better way to deal with circular instance references.
47 keyboard_manager.notebook = this;
47 this.keyboard_manager.notebook = this;
48 this.save_widget = save_widget;
48 this.save_widget = options.save_widget;
49 save_widget.notebook = this;
49 options.save_widget.notebook = this;
50
50
51 mathjaxutils.init();
51 mathjaxutils.init();
52
52
@@ -807,14 +807,14 b' define(['
807
807
808 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
808 if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
809 if (type === 'code') {
809 if (type === 'code') {
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);
811 cell.set_input_prompt();
811 cell.set_input_prompt();
812 } else if (type === 'markdown') {
812 } else if (type === 'markdown') {
813 cell = new cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this);
813 cell = new cells.MarkdownCell(this.options);
814 } else if (type === 'raw') {
814 } else if (type === 'raw') {
815 cell = new cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this);
815 cell = new cells.RawCell(this.options);
816 } else if (type === 'heading') {
816 } else if (type === 'heading') {
817 cell = new cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this);
817 cell = new cells.HeadingCell(this.options);
818 }
818 }
819
819
820 if(this._insert_element_at_index(cell.element,index)) {
820 if(this._insert_element_at_index(cell.element,index)) {
@@ -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 }
@@ -10,10 +10,11 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 (selector, options) {
14 this.keyboard_manager = keyboard_manager;
14 this.keyboard_manager = options.keyboard_manager;
15 keyboard_manager.quick_help = this;
15 // TODO: Remove circular reference.
16 this.events = events;
16 options.keyboard_manager.quick_help = this;
17 this.events = options.events;
17 };
18 };
18
19
19 var cmd_ctrl = 'Ctrl-';
20 var cmd_ctrl = 'Ctrl-';
@@ -24,14 +24,14 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 // in all TextCell/Cell subclasses
28 // in all TextCell/Cell subclasses
29 // do not assign most of members here, just pass it down
29 // do not assign most of members here, just pass it down
30 // in the options dict potentially overwriting what you wish.
30 // in the options dict potentially overwriting what you wish.
31 // they will be assigned in the base class.
31 // they will be assigned in the base class.
32 this.notebook = notebook;
32 this.notebook = options.notebook;
33 this.events = events;
33 this.events = options.events;
34 this.config = config;
34 this.config = options.config;
35
35
36 // we cannot put this as a class key as it has handle to "this".
36 // we cannot put this as a class key as it has handle to "this".
37 var cm_overwrite_options = {
37 var cm_overwrite_options = {
@@ -43,7 +43,7 b' define(['
43 this.cell_type = this.cell_type || 'text';
43 this.cell_type = this.cell_type || 'text';
44 mathjaxutils = mathjaxutils;
44 mathjaxutils = mathjaxutils;
45
45
46 Cell.apply(this, [options, keyboard_manager, events]);
46 Cell.apply(this, [options]);
47
47
48 this.rendered = false;
48 this.rendered = false;
49 };
49 };
@@ -218,11 +218,11 b' define(['
218 * @constructor MarkdownCell
218 * @constructor MarkdownCell
219 * @extends IPython.HTMLCell
219 * @extends IPython.HTMLCell
220 */
220 */
221 var MarkdownCell = function (options, events, config, keyboard_manager) {
221 var MarkdownCell = function (options) {
222 options = this.mergeopt(MarkdownCell, options);
222 options = this.mergeopt(MarkdownCell, options);
223
223
224 this.cell_type = 'markdown';
224 this.cell_type = 'markdown';
225 TextCell.apply(this, [options, events, config, keyboard_manager]);
225 TextCell.apply(this, [options]);
226 };
226 };
227
227
228 MarkdownCell.options_default = {
228 MarkdownCell.options_default = {
@@ -268,10 +268,10 b' define(['
268 * @constructor RawCell
268 * @constructor RawCell
269 * @extends TextCell
269 * @extends TextCell
270 */
270 */
271 var RawCell = function (options, events, config, keyboard_manager) {
271 var RawCell = function (options) {
272
272
273 options = this.mergeopt(RawCell,options);
273 options = this.mergeopt(RawCell,options);
274 TextCell.apply(this, [options, events, config, keyboard_manager]);
274 TextCell.apply(this, [options]);
275 this.cell_type = 'raw';
275 this.cell_type = 'raw';
276 // RawCell should always hide its rendered div
276 // RawCell should always hide its rendered div
277 this.element.find('div.text_cell_render').hide();
277 this.element.find('div.text_cell_render').hide();
@@ -327,12 +327,12 b' define(['
327 * @constructor HeadingCell
327 * @constructor HeadingCell
328 * @extends TextCell
328 * @extends TextCell
329 */
329 */
330 var HeadingCell = function (options, events, config, keyboard_manager) {
330 var HeadingCell = function (options) {
331 options = this.mergeopt(HeadingCell, options);
331 options = this.mergeopt(HeadingCell, options);
332
332
333 this.level = 1;
333 this.level = 1;
334 this.cell_type = 'heading';
334 this.cell_type = 'heading';
335 TextCell.apply(this, [options, events, config, keyboard_manager]);
335 TextCell.apply(this, [options]);
336
336
337 /**
337 /**
338 * heading level of the cell, use getter and setter to access
338 * heading level of the cell, use getter and setter to access
@@ -8,8 +8,8 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, options, 'running', options.session_list);
13 };
13 };
14
14
15 KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
15 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,19 b' require(['
29
28
30 page = new page.Page();
29 page = new page.Page();
31
30
32 var opts = {
31 var 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 };
35
36 events = $([new events.Events()]);
36 events = $([new events.Events()]);
37 session_list = new sesssionlist.SesssionList(opts, events);
37 options.events = events;
38 notebook_list = new notebooklist.NotebookList('#notebook_list', opts, undefined, session_list);
38 session_list = new sesssionlist.SesssionList(options);
39 cluster_list = new clusterlist.ClusterList('#cluster_list', opts);
39 options.session_list = session_list;
40 kernel_list = new kernellist.KernelList('#running_list', opts, session_list);
40 notebook_list = new notebooklist.NotebookList('#notebook_list', options, undefined);
41 login_widget = new loginwidget.LoginWidget('#login_widget', opts);
41 cluster_list = new clusterlist.ClusterList('#cluster_list', options);
42 kernel_list = new kernellist.KernelList('#running_list', options);
43 login_widget = new loginwidget.LoginWidget('#login_widget', options);
42
44
43 $('#new_notebook').button().click(function (e) {
45 $('#new_notebook').button().click(function (e) {
44 notebook_list.new_notebook();
46 notebook_list.new_notebook();
@@ -104,11 +106,11 b' require(['
104 }
106 }
105
107
106 // For backwards compatability.
108 // For backwards compatability.
107 ipython.page = page;
109 IPython.page = page;
108 ipython.notebook_list = notebook_list;
110 IPython.notebook_list = notebook_list;
109 ipython.cluster_list = cluster_list;
111 IPython.cluster_list = cluster_list;
110 ipython.session_list = session_list;
112 IPython.session_list = session_list;
111 ipython.kernel_list = kernel_list;
113 IPython.kernel_list = kernel_list;
112 ipython.login_widget = login_widget;
114 IPython.login_widget = login_widget;
113 ipython.events = events;
115 IPython.events = events;
114 });
116 });
@@ -9,9 +9,9 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, element_name) {
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 = element_name || 'notebook';
17 this.selector = selector;
17 this.selector = selector;
@@ -8,8 +8,8 b' define(['
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var SesssionList = function (options, events) {
11 var SesssionList = function (options) {
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