diff --git a/IPython/html/static/base/js/dialog.js b/IPython/html/static/base/js/dialog.js index 00b8c3b82..246f93f36 100644 --- a/IPython/html/static/base/js/dialog.js +++ b/IPython/html/static/base/js/dialog.js @@ -90,11 +90,11 @@ define([ return modal.modal(options); }; - var edit_metadata = function (md, callback, name, keyboard_manager, notebook) { - name = name || "Cell"; + var edit_metadata = function (options) { + options.name = options.name || "Cell"; var error_div = $('
').css('color', 'red'); var message = - "Manually edit the JSON below to manipulate the metadata for this " + name + "." + + "Manually edit the JSON below to manipulate the metadata for this " + options.name + "." + " We recommend putting custom metadata attributes in an appropriately named sub-structure," + " so they don't conflict with those of others."; @@ -102,7 +102,7 @@ define([ .attr('rows', '13') .attr('cols', '80') .attr('name', 'metadata') - .text(JSON.stringify(md || {}, null, 2)); + .text(JSON.stringify(options.md || {}, null, 2)); var dialogform = $('
').attr('title', 'Edit the metadata') .append( @@ -125,7 +125,7 @@ define([ mode: 'application/json', }); var modal = modal({ - title: "Edit " + name + " Metadata", + title: "Edit " + options.name + " Metadata", body: dialogform, buttons: { OK: { class : "btn-primary", @@ -139,12 +139,14 @@ define([ error_div.text('WARNING: Could not save invalid JSON.'); return false; } - callback(new_md); + options.callback(new_md); } }, Cancel: {} - } - }, keyboard_manager, notebook); + }, + notebook: options.notebook, + keyboard_manager: options.keyboard_manager, + }); modal.on('shown.bs.modal', function(){ editor.refresh(); }); }; @@ -155,7 +157,7 @@ define([ }; // Backwards compatability. - IPython.Dialog = dialog; + IPython.dialog = dialog; return dialog; }); diff --git a/IPython/html/static/base/js/keyboard.js b/IPython/html/static/base/js/keyboard.js index 222b3a314..211ce2a08 100644 --- a/IPython/html/static/base/js/keyboard.js +++ b/IPython/html/static/base/js/keyboard.js @@ -242,7 +242,7 @@ define([ return !( data === undefined || data.handler === undefined ); }; - return { + var keyboard = { keycodes : keycodes, inv_keycodes : inv_keycodes, ShortcutManager : ShortcutManager, @@ -251,4 +251,9 @@ define([ shortcut_to_event : shortcut_to_event, event_to_shortcut : event_to_shortcut }; + + // For backwards compatability. + IPython.keyboard = keyboard; + + return keyboard; }); diff --git a/IPython/html/static/base/js/page.js b/IPython/html/static/base/js/page.js index c52728ff0..2107aa81a 100644 --- a/IPython/html/static/base/js/page.js +++ b/IPython/html/static/base/js/page.js @@ -4,9 +4,6 @@ define([ 'base/js/namespace', 'jquery', - 'components/jquery-ui/ui/minified/jquery-ui.min', - 'components/bootstrap/js/bootstrap.min', - 'auth/js/loginwidget' ], function(IPython, $){ "use strict"; diff --git a/IPython/html/static/base/js/pagemain.js b/IPython/html/static/base/js/pagemain.js index 882d7833f..3f848a133 100644 --- a/IPython/html/static/base/js/pagemain.js +++ b/IPython/html/static/base/js/pagemain.js @@ -1,10 +1,7 @@ // Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. -var ipython = ipython || {}; require(['base/js/page'], function(page) { var page_instance = new page.Page(); page_instance.show(); - - ipython.page = page_instance; }); diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index 64e1e7313..5923256c7 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -551,7 +551,7 @@ define([ }; // Backwards compatability. - IPython.Utils = utils; + IPython.utils = utils; return utils; }); diff --git a/IPython/html/static/notebook/js/celltoolbar.js b/IPython/html/static/notebook/js/celltoolbar.js index a5f4c832f..b17bea80d 100644 --- a/IPython/html/static/notebook/js/celltoolbar.js +++ b/IPython/html/static/notebook/js/celltoolbar.js @@ -8,16 +8,19 @@ define([ ], function(IPython, $, textcell) { "use strict"; - /** - * @constructor - * @class CellToolbar - * @param {The cell to attach the metadata UI to} cell - */ - var CellToolbar = function (cell, events, notebook) { + var CellToolbar = function (options) { + // Constructor + // + // Parameters: + // options: dictionary + // Dictionary of keyword arguments. + // events: $(Events) instance + // cell: Cell instance + // notebook: Notebook instance CellToolbar._instances.push(this); - this.notebook = notebook; - this.events = events; - this.cell = cell; + this.notebook = options.notebook; + this.events = options.events; + this.cell = options.cell; this.create_element(); this.rebuild(); return this; diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index dd5e91750..f1932e78c 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -129,7 +129,10 @@ define([ var input = $('
').addClass('input'); var prompt = $('
').addClass('prompt input_prompt'); var inner_cell = $('
').addClass('inner_cell'); - this.celltoolbar = new celltoolbar.CellToolbar(this, this.events, this.notebook); + this.celltoolbar = new celltoolbar.CellToolbar({ + cell: this, + events: this.events, + notebook: this.notebook}); inner_cell.append(this.celltoolbar.element); var input_area = $('
').addClass('input_area'); this.code_mirror = CodeMirror(input_area.get(0), this.cm_config); @@ -159,7 +162,11 @@ define([ var output = $('
'); cell.append(input).append(widget_area).append(output); this.element = cell; - this.output_area = new outputarea.OutputArea(output, true, this.events, this.keyboard_manager); + this.output_area = new outputarea.OutputArea({ + selector: output, + prompt_area: true, + events: this.events, + keyboard_manager: this.keyboard_manager}); this.completer = new completer.Completer(this, this.events); }; diff --git a/IPython/html/static/notebook/js/main.js b/IPython/html/static/notebook/js/main.js index ab0a1cba7..cb5d13628 100644 --- a/IPython/html/static/notebook/js/main.js +++ b/IPython/html/static/notebook/js/main.js @@ -6,7 +6,6 @@ require([ 'jquery', 'notebook/js/notebook', 'base/js/utils', - 'base/js/keyboard', 'base/js/page', 'notebook/js/layoutmanager', 'base/js/events', @@ -24,7 +23,6 @@ require([ $, notebook, utils, - keyboard, page, layoutmanager, events, @@ -134,5 +132,4 @@ require([ IPython.keyboard_manager = keyboard_manager; IPython.save_widget = save_widget; IPython.config = user_config; - IPython.keyboard = keyboard; }); diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index 3c7a105a3..94b28ae4f 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -192,7 +192,9 @@ define([ that.notebook.move_cell_down(); }); this.element.find('#edit_nb_metadata').click(function () { - that.notebook.edit_metadata(); + that.notebook.edit_metadata({ + notebook: that.notebook, + keyboard_manager: that.notebook.keyboard_manager}); }); // View diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 95b9a4b0a..bbdb22904 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -13,8 +13,6 @@ define([ 'components/marked/lib/marked', 'notebook/js/mathjaxutils', 'base/js/keyboard', - 'components/jquery-ui/ui/minified/jquery-ui.min', - 'components/bootstrap/js/bootstrap.min', ], function ( IPython, $, @@ -80,11 +78,6 @@ define([ }); } - // Backwards compatability. - IPython.keyboard_manager = this.keyboard_manager; - IPython.save_widget = this.save_widget; - IPython.keyboard = this.keyboard; - this.element = $(selector); this.element.scroll(); this.element.data("notebook", this); @@ -314,9 +307,14 @@ define([ Notebook.prototype.edit_metadata = function () { var that = this; - dialog.edit_metadata(this.metadata, function (md) { - that.metadata = md; - }, 'Notebook'); + dialog.edit_metadata({ + md: this.metadata, + callback: function (md) { + that.metadata = md; + }, + name: 'Notebook', + notebook: this, + keyboard_manager: this.keyboard_manager}); }; // Cell indexing, retrieval, etc. diff --git a/IPython/html/static/notebook/js/notificationwidget.js b/IPython/html/static/notebook/js/notificationwidget.js index 0a1f7255a..51c40e7fa 100644 --- a/IPython/html/static/notebook/js/notificationwidget.js +++ b/IPython/html/static/notebook/js/notificationwidget.js @@ -35,12 +35,12 @@ define([ // if timeout <= 0 // click_callback : function called if user click on notification // could return false to prevent the notification to be dismissed - NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, opts) { - opts = opts || {}; + NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, options) { + options = options || {}; var callback = click_callback || function() {return false;}; var that = this; - this.inner.attr('class', opts.icon); - this.inner.attr('title', opts.title); + this.inner.attr('class', options.icon); + this.inner.attr('title', options.title); this.inner.text(msg); this.element.fadeIn(100); if (this.timeout !== null) { diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 6480873a9..2a4f208f6 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -17,20 +17,20 @@ define([ * @constructor */ - var OutputArea = function (selector, prompt_area, events, keyboard_manager) { - this.selector = selector; - this.events = events; - this.keyboard_manager = keyboard_manager; - this.wrapper = $(selector); + var OutputArea = function (options) { + this.selector = options.selector; + this.events = options.events; + this.keyboard_manager = options.keyboard_manager; + this.wrapper = $(options.selector); this.outputs = []; this.collapsed = false; this.scrolled = false; this.trusted = true; this.clear_queued = null; - if (prompt_area === undefined) { + if (options.prompt_area === undefined) { this.prompt_area = true; } else { - this.prompt_area = prompt_area; + this.prompt_area = options.prompt_area; } this.create_elements(); this.style(); diff --git a/IPython/html/static/notebook/js/savewidget.js b/IPython/html/static/notebook/js/savewidget.js index f66941c41..b57abd855 100644 --- a/IPython/html/static/notebook/js/savewidget.js +++ b/IPython/html/static/notebook/js/savewidget.js @@ -7,7 +7,7 @@ define([ 'base/js/utils', 'base/js/dialog', 'base/js/keyboard', - 'dateformat/date.format', + 'dateformat', ], function(IPython, $, utils, dialog, keyboard) { "use strict"; diff --git a/IPython/html/static/notebook/js/textcell.js b/IPython/html/static/notebook/js/textcell.js index 393a9fb64..b99455de0 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -76,7 +76,10 @@ define([ var prompt = $('
').addClass('prompt input_prompt'); cell.append(prompt); var inner_cell = $('
').addClass('inner_cell'); - this.celltoolbar = new celltoolbar.CellToolbar(this, this.events, this.notebook); + this.celltoolbar = new celltoolbar.CellToolbar({ + cell: this, + events: this.events, + notebook: this.notebook}); inner_cell.append(this.celltoolbar.element); var input_area = $('
').addClass('input_area'); this.code_mirror = new CodeMirror(input_area.get(0), this.cm_config); @@ -451,11 +454,11 @@ define([ IPython.RawCell = RawCell; IPython.HeadingCell = HeadingCell; - var Cells = { + var textcell = { 'TextCell': TextCell, 'MarkdownCell': MarkdownCell, 'RawCell': RawCell, 'HeadingCell': HeadingCell, }; - return Cells; + return textcell; }); diff --git a/IPython/html/templates/page.html b/IPython/html/templates/page.html index a693ac0a0..49763e7bd 100644 --- a/IPython/html/templates/page.html +++ b/IPython/html/templates/page.html @@ -24,6 +24,7 @@ backbone : 'components/backbone/backbone-min', jquery: 'components/jquery/jquery.min', bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min', + dateformat: 'dateformat/date.format', }, shim: { underscore: { @@ -35,6 +36,9 @@ }, bootstraptour: { exports: "Tour" + }, + dateformat: { + exports: "dateFormat" } } });