diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 05562a12e..1ebc203dc 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -38,9 +38,9 @@ define([ * @param {object|undefined} [options] * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters */ - var Cell = function (options, keyboard_manager, events) { - this.keyboard_manager = keyboard_manager; - this.events = events; + var Cell = function (options) { + this.keyboard_manager = options.keyboard_manager; + this.events = options.events; options = this.mergeopt(Cell, options); // superclass default overwrite our default diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index b5a63efdb..2f6442ebe 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -54,13 +54,13 @@ define([ * @param {object|undefined} [options] * @param [options.cm_config] {object} config to pass to CodeMirror */ - var CodeCell = function (kernel, options, events, config, keyboard_manager, notebook) { + var CodeCell = function (kernel, options) { this.kernel = kernel || null; - this.notebook = notebook; + this.notebook = options.notebook; this.collapsed = false; - this.tooltip = new tooltip.Tooltip(events); - this.events = events; - this.config = config; + this.tooltip = new tooltip.Tooltip(options.events); + this.events = options.events; + this.config = options.config; // create all attributed in constructor function // even if null for V8 VM optimisation @@ -77,7 +77,7 @@ define([ options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options}); - Cell.apply(this,[options, keyboard_manager, events]); + Cell.apply(this,[options]); // Attributes we want to override in this subclass. this.cell_type = "code"; diff --git a/IPython/html/static/notebook/js/main.js b/IPython/html/static/notebook/js/main.js index 53e1d936b..1c1a7a819 100644 --- a/IPython/html/static/notebook/js/main.js +++ b/IPython/html/static/notebook/js/main.js @@ -1,7 +1,6 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. -var ipython = ipython || {}; require([ 'base/js/namespace', 'jquery', @@ -49,18 +48,25 @@ require([ }; var user_config = $.extend({}, config.default_config); + options.user_config = user_config; var page = new page.Page(); var layout_manager = new layoutmanager.LayoutManager(); + options.layout_manager = layout_manager; var events = $([new events.Events()]); + options.events = events; var pager = new pager.Pager('div#pager', 'div#pager_splitter', layout_manager, events); var keyboard_manager = new keyboardmanager.KeyboardManager(pager, events); + options.keyboard_manager = keyboard_manager; var save_widget = new savewidget.SaveWidget('span#save_widget', events); - var notebook = new notebook.Notebook('div#notebook', options, events, keyboard_manager, save_widget, user_config); + options.save_widget = save_widget; + var notebook = new notebook.Notebook('div#notebook', options); + options.notebook = notebook; var login_widget = new loginwidget.LoginWidget('span#login_widget', options); - var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', layout_manager, notebook, events); - var quick_help = new quickhelp.QuickHelp(undefined, keyboard_manager, events); - var menubar = new menubar.MenuBar('#menubar', options, notebook, layout_manager, events, save_widget, quick_help); - var notification_area = new notificationarea.NotificationArea('#notification_area', events, save_widget, notebook); + var toolbar = new maintoolbar.MainToolBar('#maintoolbar-container', options); + var quick_help = new quickhelp.QuickHelp(undefined, options); + options.quick_help = quick_help; + var menubar = new menubar.MenuBar('#menubar', options); + var notification_area = new notificationarea.NotificationArea('#notification_area', options); notification_area.init_notification_widgets(); $('body').append('
x'+
@@ -93,17 +99,17 @@ require([
events.trigger('app_initialized.NotebookApp');
notebook.load_notebook(options.notebook_name, options.notebook_path);
- ipython.page = page;
- ipython.layout_manager = layout_manager;
- ipython.notebook = notebook;
- ipython.pager = pager;
- ipython.quick_help = quick_help;
- ipython.login_widget = login_widget;
- ipython.menubar = menubar;
- ipython.toolbar = toolbar;
- ipython.notification_area = notification_area;
- ipython.events = events;
- ipython.keyboard_manager = keyboard_manager;
- ipython.save_widget = save_widget;
- ipython.config = user_config;
+ IPython.page = page;
+ IPython.layout_manager = layout_manager;
+ IPython.notebook = notebook;
+ IPython.pager = pager;
+ IPython.quick_help = quick_help;
+ IPython.login_widget = login_widget;
+ IPython.menubar = menubar;
+ IPython.toolbar = toolbar;
+ IPython.notification_area = notification_area;
+ IPython.events = events;
+ IPython.keyboard_manager = keyboard_manager;
+ IPython.save_widget = save_widget;
+ IPython.config = user_config;
});
diff --git a/IPython/html/static/notebook/js/maintoolbar.js b/IPython/html/static/notebook/js/maintoolbar.js
index f899f7da9..e14e93f83 100644
--- a/IPython/html/static/notebook/js/maintoolbar.js
+++ b/IPython/html/static/notebook/js/maintoolbar.js
@@ -9,10 +9,10 @@ define([
], function(IPython, $, toolbar, celltoolbar) {
"use strict";
- var MainToolBar = function (selector, layout_manager, notebook, events) {
+ var MainToolBar = function (selector, options) {
toolbar.ToolBar.apply(this, arguments);
- this.events = events;
- this.notebook = notebook;
+ this.events = options.events;
+ this.notebook = options.notebook;
this.construct();
this.add_celltype_list();
this.add_celltoolbar_list();
diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js
index c0d79ddc0..c39e52d0f 100644
--- a/IPython/html/static/notebook/js/menubar.js
+++ b/IPython/html/static/notebook/js/menubar.js
@@ -24,18 +24,18 @@ define([
* $('body').data('baseUrl');
* does not support change for now is set through this option
*/
- var MenuBar = function (selector, options, notebook, layout_manager, events, save_widget, quick_help) {
+ var MenuBar = function (selector, options) {
options = options || {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.selector = selector;
- this.notebook = notebook;
- this.layout_manager = layout_manager;
- this.events = events;
- this.save_widget = save_widget;
- this.quick_help = quick_help;
+ this.notebook = options.notebook;
+ this.layout_manager = options.layout_manager;
+ this.events = options.events;
+ this.save_widget = options.save_widget;
+ this.quick_help = options.quick_help;
try {
- this.tour = new tour.Tour(notebook, events);
+ this.tour = new tour.Tour(options.notebook, options.events);
} catch (e) {
this.tour = undefined;
console.log("Failed to instantiate Notebook Tour", e);
diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js
index 0a190b389..784fd2f10 100644
--- a/IPython/html/static/notebook/js/notebook.js
+++ b/IPython/html/static/notebook/js/notebook.js
@@ -38,15 +38,15 @@ define([
* @param {Object} [options] A config object
* @param {Object} [events] An events object
*/
- var Notebook = function (selector, options, events, keyboard_manager, save_widget, config) {
- this.config = config;
- this.events = events;
- this.keyboard_manager = keyboard_manager;
+ var Notebook = function (selector, options) {
+ this.config = options.config;
+ this.events = options.events;
+ this.keyboard_manager = options.keyboard_manager;
// TODO: This code smells (and the other `= this` line a couple lines down)
// We need a better way to deal with circular instance references.
- keyboard_manager.notebook = this;
- this.save_widget = save_widget;
- save_widget.notebook = this;
+ this.keyboard_manager.notebook = this;
+ this.save_widget = options.save_widget;
+ options.save_widget.notebook = this;
mathjaxutils.init();
@@ -807,14 +807,14 @@ define([
if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) {
if (type === 'code') {
- cell = new codecell.CodeCell(this.kernel, this.options, this.events, this.config, this.keyboard_manager, this);
+ cell = new codecell.CodeCell(this.kernel, this.options);
cell.set_input_prompt();
} else if (type === 'markdown') {
- cell = new cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this);
+ cell = new cells.MarkdownCell(this.options);
} else if (type === 'raw') {
- cell = new cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this);
+ cell = new cells.RawCell(this.options);
} else if (type === 'heading') {
- cell = new cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this);
+ cell = new cells.HeadingCell(this.options);
}
if(this._insert_element_at_index(cell.element,index)) {
diff --git a/IPython/html/static/notebook/js/notificationarea.js b/IPython/html/static/notebook/js/notificationarea.js
index 563615fbc..59d3a8c5b 100644
--- a/IPython/html/static/notebook/js/notificationarea.js
+++ b/IPython/html/static/notebook/js/notificationarea.js
@@ -10,11 +10,11 @@ define([
], function(IPython, $, utils, dialog, notificationwidget) {
"use strict";
- var NotificationArea = function (selector, events, save_widget, notebook) {
+ var NotificationArea = function (selector, options) {
this.selector = selector;
- this.events = events;
- this.save_widget = save_widget;
- this.notebook = notebook;
+ this.events = options.events;
+ this.save_widget = options.save_widget;
+ this.notebook = options.notebook;
if (this.selector !== undefined) {
this.element = $(selector);
}
diff --git a/IPython/html/static/notebook/js/quickhelp.js b/IPython/html/static/notebook/js/quickhelp.js
index 316208db5..fa752473d 100644
--- a/IPython/html/static/notebook/js/quickhelp.js
+++ b/IPython/html/static/notebook/js/quickhelp.js
@@ -10,10 +10,11 @@ define([
"use strict";
var platform = utils.platform;
- var QuickHelp = function (selector, keyboard_manager, events) {
- this.keyboard_manager = keyboard_manager;
- keyboard_manager.quick_help = this;
- this.events = events;
+ var QuickHelp = function (selector, options) {
+ this.keyboard_manager = options.keyboard_manager;
+ // TODO: Remove circular reference.
+ options.keyboard_manager.quick_help = this;
+ this.events = options.events;
};
var cmd_ctrl = 'Ctrl-';
diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js
index f1db79a9e..9b954f51e 100644
--- a/IPython/html/static/notebook/js/textcell.js
+++ b/IPython/html/static/notebook/js/textcell.js
@@ -24,14 +24,14 @@ define([
* @param [options.cm_config] {object} config to pass to CodeMirror, will extend/overwrite default config
* @param [options.placeholder] {string} default string to use when souce in empty for rendering (only use in some TextCell subclass)
*/
- var TextCell = function (options, events, config, keyboard_manager, notebook) {
+ var TextCell = function (options) {
// in all TextCell/Cell subclasses
// do not assign most of members here, just pass it down
// in the options dict potentially overwriting what you wish.
// they will be assigned in the base class.
- this.notebook = notebook;
- this.events = events;
- this.config = config;
+ this.notebook = options.notebook;
+ this.events = options.events;
+ this.config = options.config;
// we cannot put this as a class key as it has handle to "this".
var cm_overwrite_options = {
@@ -43,7 +43,7 @@ define([
this.cell_type = this.cell_type || 'text';
mathjaxutils = mathjaxutils;
- Cell.apply(this, [options, keyboard_manager, events]);
+ Cell.apply(this, [options]);
this.rendered = false;
};
@@ -218,11 +218,11 @@ define([
* @constructor MarkdownCell
* @extends IPython.HTMLCell
*/
- var MarkdownCell = function (options, events, config, keyboard_manager) {
+ var MarkdownCell = function (options) {
options = this.mergeopt(MarkdownCell, options);
this.cell_type = 'markdown';
- TextCell.apply(this, [options, events, config, keyboard_manager]);
+ TextCell.apply(this, [options]);
};
MarkdownCell.options_default = {
@@ -268,10 +268,10 @@ define([
* @constructor RawCell
* @extends TextCell
*/
- var RawCell = function (options, events, config, keyboard_manager) {
+ var RawCell = function (options) {
options = this.mergeopt(RawCell,options);
- TextCell.apply(this, [options, events, config, keyboard_manager]);
+ TextCell.apply(this, [options]);
this.cell_type = 'raw';
// RawCell should always hide its rendered div
this.element.find('div.text_cell_render').hide();
@@ -327,12 +327,12 @@ define([
* @constructor HeadingCell
* @extends TextCell
*/
- var HeadingCell = function (options, events, config, keyboard_manager) {
+ var HeadingCell = function (options) {
options = this.mergeopt(HeadingCell, options);
this.level = 1;
this.cell_type = 'heading';
- TextCell.apply(this, [options, events, config, keyboard_manager]);
+ TextCell.apply(this, [options]);
/**
* heading level of the cell, use getter and setter to access
diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js
index b2e4e7088..aeb5d5851 100644
--- a/IPython/html/static/tree/js/kernellist.js
+++ b/IPython/html/static/tree/js/kernellist.js
@@ -8,8 +8,8 @@ define([
], function(IPython, $, notebooklist) {
"use strict";
- var KernelList = function (selector, options, session_list) {
- notebooklist.NotebookList.call(this, selector, options, 'running', session_list);
+ var KernelList = function (selector, options) {
+ notebooklist.NotebookList.call(this, selector, options, 'running', options.session_list);
};
KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js
index c93bb1def..46a7dccda 100644
--- a/IPython/html/static/tree/js/main.js
+++ b/IPython/html/static/tree/js/main.js
@@ -1,7 +1,6 @@
// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.
-var ipython = ipython || {};
require([
'base/js/namespace',
'jquery',
@@ -29,16 +28,19 @@ require([
page = new page.Page();
- var opts = {
+ var options = {
base_url: utils.get_body_data("baseUrl"),
notebook_path: utils.get_body_data("notebookPath"),
};
+
events = $([new events.Events()]);
- session_list = new sesssionlist.SesssionList(opts, events);
- notebook_list = new notebooklist.NotebookList('#notebook_list', opts, undefined, session_list);
- cluster_list = new clusterlist.ClusterList('#cluster_list', opts);
- kernel_list = new kernellist.KernelList('#running_list', opts, session_list);
- login_widget = new loginwidget.LoginWidget('#login_widget', opts);
+ options.events = events;
+ session_list = new sesssionlist.SesssionList(options);
+ options.session_list = session_list;
+ notebook_list = new notebooklist.NotebookList('#notebook_list', options, undefined);
+ cluster_list = new clusterlist.ClusterList('#cluster_list', options);
+ kernel_list = new kernellist.KernelList('#running_list', options);
+ login_widget = new loginwidget.LoginWidget('#login_widget', options);
$('#new_notebook').button().click(function (e) {
notebook_list.new_notebook();
@@ -104,11 +106,11 @@ require([
}
// For backwards compatability.
- ipython.page = page;
- ipython.notebook_list = notebook_list;
- ipython.cluster_list = cluster_list;
- ipython.session_list = session_list;
- ipython.kernel_list = kernel_list;
- ipython.login_widget = login_widget;
- ipython.events = events;
+ IPython.page = page;
+ IPython.notebook_list = notebook_list;
+ IPython.cluster_list = cluster_list;
+ IPython.session_list = session_list;
+ IPython.kernel_list = kernel_list;
+ IPython.login_widget = login_widget;
+ IPython.events = events;
});
diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js
index e5e376590..6d60e40a4 100644
--- a/IPython/html/static/tree/js/notebooklist.js
+++ b/IPython/html/static/tree/js/notebooklist.js
@@ -9,9 +9,9 @@ define([
], function(IPython, $, utils, dialog) {
"use strict";
- var NotebookList = function (selector, options, element_name, session_list) {
+ var NotebookList = function (selector, options, element_name) {
var that = this;
- this.session_list = session_list;
+ this.session_list = options.session_list;
// allow code re-use by just changing element_name in kernellist.js
this.element_name = element_name || 'notebook';
this.selector = selector;
diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js
index 93822d016..cbd153088 100644
--- a/IPython/html/static/tree/js/sessionlist.js
+++ b/IPython/html/static/tree/js/sessionlist.js
@@ -8,8 +8,8 @@ define([
], function(IPython, $, utils) {
"use strict";
- var SesssionList = function (options, events) {
- this.events = events;
+ var SesssionList = function (options) {
+ this.events = options.events;
this.sessions = {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
};