diff --git a/IPython/html/static/auth/js/loginwidget.js b/IPython/html/static/auth/js/loginwidget.js index 81d3d79b7..3a22ceec0 100644 --- a/IPython/html/static/auth/js/loginwidget.js +++ b/IPython/html/static/auth/js/loginwidget.js @@ -4,7 +4,7 @@ define([ 'base/js/namespace', 'base/js/utils', - 'components/jquery/jquery.min', + 'jquery', ], function(IPython, utils, $){ "use strict"; diff --git a/IPython/html/static/base/js/dialog.js b/IPython/html/static/base/js/dialog.js index 9d184f57b..4a6630267 100644 --- a/IPython/html/static/base/js/dialog.js +++ b/IPython/html/static/base/js/dialog.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', ], function(IPython, $) { "use strict"; @@ -146,7 +146,7 @@ define([ modal.on('shown.bs.modal', function(){ editor.refresh(); }); }; - Dialog = { + var Dialog = { modal : modal, edit_metadata : edit_metadata, }; diff --git a/IPython/html/static/base/js/keyboard.js b/IPython/html/static/base/js/keyboard.js index 08cd729b3..222b3a314 100644 --- a/IPython/html/static/base/js/keyboard.js +++ b/IPython/html/static/base/js/keyboard.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/base/js/page.js b/IPython/html/static/base/js/page.js index 1b694e706..b852c1906 100644 --- a/IPython/html/static/base/js/page.js +++ b/IPython/html/static/base/js/page.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'components/jquery-ui/ui/minified/jquery-ui.min', 'components/bootstrap/js/bootstrap.min', 'auth/js/loginwidget' diff --git a/IPython/html/static/base/js/security.js b/IPython/html/static/base/js/security.js index 11843352c..97121f7e1 100644 --- a/IPython/html/static/base/js/security.js +++ b/IPython/html/static/base/js/security.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'components/google-caja/html-css-sanitizer-minified', ], function(IPython, $) { "use strict"; diff --git a/IPython/html/static/base/js/utils.js b/IPython/html/static/base/js/utils.js index c6dce7c58..cf76c632f 100644 --- a/IPython/html/static/base/js/utils.js +++ b/IPython/html/static/base/js/utils.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', ], function(IPython, $){ "use strict"; diff --git a/IPython/html/static/notebook/js/cell.js b/IPython/html/static/notebook/js/cell.js index 12edc2594..e3d94ee1f 100644 --- a/IPython/html/static/notebook/js/cell.js +++ b/IPython/html/static/notebook/js/cell.js @@ -3,35 +3,15 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', - 'components/codemirror/lib/codemirror.js', + 'jquery', 'base/js/utils', - - // Set codemirror version. - // CodeMirror.modeURL = '{{ static_url("components/codemirror/mode/%N/%N.js", include_version=False) }}'; - 'components/codemirror/addon/mode/loadmode.js', - 'components/codemirror/addon/mode/multiplex.js', - 'components/codemirror/addon/mode/overlay.js', - 'components/codemirror/addon/edit/matchbrackets.js', - 'components/codemirror/addon/edit/closebrackets.js', - 'components/codemirror/addon/comment/comment.js', - 'components/codemirror/mode/htmlmixed/htmlmixed.js', - 'components/codemirror/mode/xml/xml.js', - 'components/codemirror/mode/javascript/javascript.js', - 'components/codemirror/mode/css/css.js', - 'components/codemirror/mode/rst/rst.js', - 'components/codemirror/mode/markdown/markdown.js', - 'components/codemirror/mode/python/python.js', - 'notebook/js/codemirror-ipython.js', - 'notebook/js/codemirror-ipythongfm.js', -], function(IPython, $, CodeMirror, utils) { +], function(IPython, $, utils) { "use strict"; // monkey patch CM to be able to syntax highlight cell magics // bug reported upstream, // see https://github.com/marijnh/CodeMirror2/issues/670 if(CodeMirror.getMode(1,'text/plain').indent === undefined ){ - console.log('patching CM for undefined indent'); CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0;}}; }; @@ -58,8 +38,9 @@ define([ * @param {object|undefined} [options] * @param [options.cm_config] {object} config to pass to CodeMirror, will extend default parameters */ - var Cell = function (keyboard_manager) { + var Cell = function (options, keyboard_manager, events) { this.keyboard_manager = keyboard_manager; + this.events = events; options = this.mergeopt(Cell, options); // superclass default overwrite our default diff --git a/IPython/html/static/notebook/js/celltoolbar.js b/IPython/html/static/notebook/js/celltoolbar.js index fa6c91a84..4104fed33 100644 --- a/IPython/html/static/notebook/js/celltoolbar.js +++ b/IPython/html/static/notebook/js/celltoolbar.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'notebook/js/textcell', ], function(IPython, $, TextCell) { "use strict"; @@ -220,7 +220,9 @@ define([ CellToolbar.rebuild_all(); } - this.events.trigger('preset_activated.CellToolbar', {name: preset_name}); + if (this.events) { + this.events.trigger('preset_activated.CellToolbar', {name: preset_name}); + } }; diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index 4fb45a8a5..80b0f6e46 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -3,14 +3,15 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'notebook/js/tooltip', 'base/js/keyboard', 'notebook/js/cell', 'notebook/js/outputarea', 'notebook/js/completer', -], function(IPython, $, utils, Tooltip, keyboard, Cell, OutputArea, Completer) { + 'notebook/js/celltoolbar', +], function(IPython, $, utils, Tooltip, keyboard, Cell, OutputArea, Completer, CellToolbar) { "use strict"; /* local util for codemirror */ @@ -52,8 +53,9 @@ define([ * @param {object|undefined} [options] * @param [options.cm_config] {object} config to pass to CodeMirror */ - var CodeCell = function (kernel, options, events, config, keyboard_manager) { + var CodeCell = function (kernel, options, events, config, keyboard_manager, notebook) { this.kernel = kernel || null; + this.notebook = notebook; this.collapsed = false; this.tooltip = new Tooltip(events); this.events = events; @@ -74,7 +76,7 @@ define([ options = this.mergeopt(CodeCell, options, {cm_config:cm_overwrite_options}); - Cell.apply(this,[options, keyboard_manager]); + Cell.apply(this,[options, keyboard_manager, events]); // Attributes we want to override in this subclass. this.cell_type = "code"; @@ -123,7 +125,7 @@ define([ var input = $('
').addClass('input'); var prompt = $('
').addClass('prompt input_prompt'); var inner_cell = $('
').addClass('inner_cell'); - this.celltoolbar = new CellToolbar(this); + this.celltoolbar = new CellToolbar(this, this.events, 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); diff --git a/IPython/html/static/notebook/js/completer.js b/IPython/html/static/notebook/js/completer.js index b8796347f..39cbc79c1 100644 --- a/IPython/html/static/notebook/js/completer.js +++ b/IPython/html/static/notebook/js/completer.js @@ -3,9 +3,10 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/keyboard', + 'notebook/js/contexthint', ], function(IPython, $, utils, keyboard) { "use strict"; diff --git a/IPython/html/static/notebook/js/contexthint.js b/IPython/html/static/notebook/js/contexthint.js index 27ce4fea0..d819f4624 100644 --- a/IPython/html/static/notebook/js/contexthint.js +++ b/IPython/html/static/notebook/js/contexthint.js @@ -1,12 +1,15 @@ +// Copyright (c) IPython Development Team. +// Distributed under the terms of the Modified BSD License. + // highly adapted for codemiror jshint -(function () { +define([], function() { "use strict"; - function forEach(arr, f) { + var forEach = function(arr, f) { for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]); - } + }; - function arrayContains(arr, item) { + var arrayContains = function(arr, item) { if (!Array.prototype.indexOf) { var i = arr.length; while (i--) { @@ -17,7 +20,7 @@ return false; } return arr.indexOf(item) != -1; - } + }; CodeMirror.contextHint = function (editor) { // Find the token at the cursor @@ -26,7 +29,7 @@ tprop = token; // If it's not a 'word-style' token, ignore the token. // If it is a property, find out what it is a property of. - var list = new Array(); + var list = []; var clist = getCompletions(token, editor); for (var i = 0; i < clist.length; i++) { list.push({ @@ -40,55 +43,56 @@ line: cur.line, ch: token.end } - }) + }); } return list; - } + }; // find all 'words' of current cell var getAllTokens = function (editor) { - var found = []; + var found = []; - // add to found if not already in it + // add to found if not already in it - function maybeAdd(str) { - if (!arrayContains(found, str)) found.push(str); - } + function maybeAdd(str) { + if (!arrayContains(found, str)) found.push(str); + } - // loop through all token on all lines - var lineCount = editor.lineCount(); - // loop on line - for (var l = 0; l < lineCount; l++) { - var line = editor.getLine(l); - //loop on char - for (var c = 1; c < line.length; c++) { - var tk = editor.getTokenAt({ - line: l, - ch: c - }); - // if token has a class, it has geat chances of beeing - // of interest. Add it to the list of possible completions. - // we could skip token of ClassName 'comment' - // or 'number' and 'operator' - if (tk.className != null) { - maybeAdd(tk.string); - } - // jump to char after end of current token - c = tk.end; + // loop through all token on all lines + var lineCount = editor.lineCount(); + // loop on line + for (var l = 0; l < lineCount; l++) { + var line = editor.getLine(l); + //loop on char + for (var c = 1; c < line.length; c++) { + var tk = editor.getTokenAt({ + line: l, + ch: c + }); + // if token has a class, it has geat chances of beeing + // of interest. Add it to the list of possible completions. + // we could skip token of ClassName 'comment' + // or 'number' and 'operator' + if (tk.className !== null) { + maybeAdd(tk.string); } + // jump to char after end of current token + c = tk.end; } - return found; } + return found; + }; - - function getCompletions(token, editor) { + var getCompletions = function(token, editor) { var candidates = getAllTokens(editor); // filter all token that have a common start (but nox exactly) the lenght of the current token var lambda = function (x) { - return (x.indexOf(token.string) == 0 && x != token.string) + return (x.indexOf(token.string) === 0 && x != token.string); }; var filterd = candidates.filter(lambda); return filterd; - } -})(); + }; + + return CodeMirror.contextHint; +}); diff --git a/IPython/html/static/notebook/js/keyboardmanager.js b/IPython/html/static/notebook/js/keyboardmanager.js index a3f56804c..45c2fca43 100644 --- a/IPython/html/static/notebook/js/keyboardmanager.js +++ b/IPython/html/static/notebook/js/keyboardmanager.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/keyboard', ], function(IPython, $, utils, keyboard) { @@ -15,24 +15,24 @@ define([ // Main keyboard manager for the notebook var keycodes = keyboard.keycodes; - var KeyboardManager = function (pager) { + var KeyboardManager = function (pager, events) { this.mode = 'command'; this.enabled = true; this.pager = pager; this.quick_help = undefined; this.notebook = undefined; this.bind_events(); - this.command_shortcuts = new keyboard.ShortcutManager(); + this.command_shortcuts = new keyboard.ShortcutManager(undefined, events); this.command_shortcuts.add_shortcuts(this.get_default_common_shortcuts()); this.command_shortcuts.add_shortcuts(this.get_default_command_shortcuts()); - this.edit_shortcuts = new keyboard.ShortcutManager(); + this.edit_shortcuts = new keyboard.ShortcutManager(undefined, events); this.edit_shortcuts.add_shortcuts(this.get_default_common_shortcuts()); this.edit_shortcuts.add_shortcuts(this.get_default_edit_shortcuts()); }; KeyboardManager.prototype.get_default_common_shortcuts = function() { var that = this; - shortcuts = { + var shortcuts = { 'shift' : { help : '', help_index : '', diff --git a/IPython/html/static/notebook/js/main.js b/IPython/html/static/notebook/js/main.js index d94321329..215279edc 100644 --- a/IPython/html/static/notebook/js/main.js +++ b/IPython/html/static/notebook/js/main.js @@ -4,7 +4,7 @@ var ipython = ipython || {}; require([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'notebook/js/notebook', 'base/js/utils', 'base/js/page', @@ -18,6 +18,7 @@ require([ 'notebook/js/notificationarea', 'notebook/js/savewidget', 'notebook/js/keyboardmanager', + 'notebook/js/config', ], function( IPython, $, @@ -33,32 +34,33 @@ require([ MenuBar, NotificationArea, SaveWidget, - KeyboardManager + KeyboardManager, + config ) { "use strict"; $('#ipython-main-app').addClass('border-box-sizing'); $('div#notebook_panel').addClass('border-box-sizing'); - var opts = { + var options = { base_url : utils.get_body_data("baseUrl"), notebook_path : utils.get_body_data("notebookPath"), notebook_name : utils.get_body_data('notebookName') }; - page = new Page(); - layout_manager = new LayoutManager(); - events = $([new Events()]); - pager = new Pager('div#pager', 'div#pager_splitter', layout_manager, events); - keyboard_manager = new KeyboardManager(pager); - save_widget = new SaveWidget('span#save_widget', events, keyboard); - notebook = new Notebook('div#notebook', opts, events, keyboard_manager, save_widget, keyboard); - login_widget = new LoginWidget('span#login_widget', opts); - toolbar = new MainToolBar('#maintoolbar-container', notebook, events); - quick_help = new QuickHelp(undefined, keyboard_manager, events); - menubar = new MenuBar('#menubar', opts, notebook, layout_manager, events, save_widget, quick_help); - - notification_area = new NotificationArea('#notification_area', events, save_widget, notebook); + var user_config = $.extend({}, config.default_config); + var page = new Page(); + var layout_manager = new LayoutManager(); + var events = $([new Events()]); + var pager = new Pager('div#pager', 'div#pager_splitter', layout_manager, events); + var keyboard_manager = new KeyboardManager(pager, events); + var save_widget = new SaveWidget('span#save_widget', events); + var notebook = new Notebook('div#notebook', options, events, keyboard_manager, save_widget, user_config); + var login_widget = new LoginWidget('span#login_widget', options); + var toolbar = new MainToolBar('#maintoolbar-container', layout_manager, notebook, events); + var quick_help = new QuickHelp(undefined, keyboard_manager, events); + var menubar = new MenuBar('#menubar', options, notebook, layout_manager, events, save_widget, quick_help); + var notification_area = new NotificationArea('#notification_area', events, save_widget, notebook); notification_area.init_notification_widgets(); layout_manager.do_resize(); @@ -91,7 +93,7 @@ require([ events.on('notebook_loaded.Notebook', first_load); events.trigger('app_initialized.NotebookApp'); - notebook.load_notebook(opts.notebook_name, opts.notebook_path); + notebook.load_notebook(options.notebook_name, options.notebook_path); ipython.page = page; ipython.layout_manager = layout_manager; @@ -105,5 +107,5 @@ require([ ipython.events = events; ipython.keyboard_manager = keyboard_manager; ipython.save_widget = save_widget; - ipython.keyboard = keyboard; + ipython.config = user_config; }); diff --git a/IPython/html/static/notebook/js/maintoolbar.js b/IPython/html/static/notebook/js/maintoolbar.js index 361e5ef9b..82f2c6d62 100644 --- a/IPython/html/static/notebook/js/maintoolbar.js +++ b/IPython/html/static/notebook/js/maintoolbar.js @@ -3,14 +3,14 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'notebook/js/toolbar', 'notebook/js/celltoolbar', ], function(IPython, $, Toolbar, CellToolbar) { "use strict"; var MainToolBar = function (selector, layout_manager, notebook, events) { - ToolBar.apply(this, arguments); + Toolbar.apply(this, arguments); this.events = events; this.notebook = notebook; this.construct(); @@ -19,7 +19,7 @@ define([ this.bind_events(); }; - MainToolBar.prototype = new ToolBar(); + MainToolBar.prototype = new Toolbar(); MainToolBar.prototype.construct = function () { this.add_buttons_group([ diff --git a/IPython/html/static/notebook/js/mathjaxutils.js b/IPython/html/static/notebook/js/mathjaxutils.js index 477837ff6..d64b7ae55 100644 --- a/IPython/html/static/notebook/js/mathjaxutils.js +++ b/IPython/html/static/notebook/js/mathjaxutils.js @@ -2,7 +2,7 @@ // Distributed under the terms of the Modified BSD License. define([ - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', ], function($, utils, Dialog) { diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js index 03df77ca6..58020ab39 100644 --- a/IPython/html/static/notebook/js/menubar.js +++ b/IPython/html/static/notebook/js/menubar.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'notebook/js/tour', 'components/bootstrap-tour/build/js/bootstrap-tour.min', @@ -49,12 +49,13 @@ define([ }; MenuBar.prototype.style = function () { + var that = this; this.element.addClass('border-box-sizing'); this.element.find("li").click(function (event, ui) { // The selected cell loses focus when the menu is entered, so we // re-select it upon selection. - var i = this.notebook.get_selected_index(); - this.notebook.select(i); + var i = that.notebook.get_selected_index(); + that.notebook.select(i); } ); }; diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index f55c7edca..bf51ec977 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', 'notebook/js/textcell', @@ -38,8 +38,8 @@ define([ * @param {Object} [options] A config object * @param {Object} [events] An events object */ - var Notebook = function (selector, options, events, keyboard_manager, save_widget) { - this.config = undefined; // TODO + var Notebook = function (selector, options, events, keyboard_manager, save_widget, config) { + this.config = config; this.events = events; this.keyboard_manager = keyboard_manager; keyboard_manager.notebook = this; @@ -807,14 +807,14 @@ define([ if (ncells === 0 || this.is_valid_cell_index(index) || index === ncells) { if (type === 'code') { - cell = new CodeCell(this.kernel, undefined, this.events, this.config, this.keyboard_manager); + cell = new CodeCell(this.kernel, this.options, this.events, this.config, this.keyboard_manager, this); cell.set_input_prompt(); } else if (type === 'markdown') { - cell = new Cells.MarkdownCell(); + cell = new Cells.MarkdownCell(this.options, this.events, this.config, this.keyboard_manager, this); } else if (type === 'raw') { - cell = new Cells.RawCell(); + cell = new Cells.RawCell(this.options, this.events, this.config, this.keyboard_manager, this); } else if (type === 'heading') { - cell = new Cells.HeadingCell(); + cell = new Cells.HeadingCell(this.options, this.events, this.config, this.keyboard_manager, this); } 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 ca24ccd69..c29d26bf3 100644 --- a/IPython/html/static/notebook/js/notificationarea.js +++ b/IPython/html/static/notebook/js/notificationarea.js @@ -3,10 +3,11 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', -], function(IPython, $, utils, Dialog) { + 'notebook/js/notificationwidget', +], function(IPython, $, utils, Dialog, NotificationWidget) { "use strict"; var NotificationArea = function (selector, events, save_widget, notebook) { @@ -61,7 +62,7 @@ define([ } var div = $('
').attr('id','notification_'+name); $(this.selector).append(div); - this.widget_dict[name] = new IPython.NotificationWidget('#notification_'+name); + this.widget_dict[name] = new NotificationWidget('#notification_'+name); return this.widget_dict[name]; }; @@ -228,5 +229,5 @@ define([ IPython.NotificationArea = NotificationArea; - return IPython; + return NotificationArea; }); diff --git a/IPython/html/static/notebook/js/notificationwidget.js b/IPython/html/static/notebook/js/notificationwidget.js index 51764ea84..98ce1ba8c 100644 --- a/IPython/html/static/notebook/js/notificationwidget.js +++ b/IPython/html/static/notebook/js/notificationwidget.js @@ -1,18 +1,11 @@ -//---------------------------------------------------------------------------- -// Copyright (C) 2008-2011 The IPython Development Team -// -// Distributed under the terms of the BSD License. The full license is in -// the file COPYING, distributed as part of this software. -//---------------------------------------------------------------------------- +// Copyright (c) IPython Development Team. +// Distributed under the terms of the Modified BSD License. -//============================================================================ -// Notification widget -//============================================================================ - -var IPython = (function (IPython) { +define([ + 'base/js/namespace', + 'jquery', +], function(IPython, $) { "use strict"; - var utils = IPython.utils; - var NotificationWidget = function (selector) { this.selector = selector; @@ -31,7 +24,6 @@ var IPython = (function (IPython) { }; - NotificationWidget.prototype.style = function () { this.element.addClass('notification_widget pull-right'); this.element.addClass('border-box-sizing'); @@ -44,7 +36,7 @@ var IPython = (function (IPython) { // 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) { - var opts = opts || {}; + opts = opts || {}; var callback = click_callback || function() {return false;}; var that = this; this.inner.attr('class', opts.icon); @@ -62,7 +54,7 @@ var IPython = (function (IPython) { }, timeout); } else { this.element.click(function() { - if( callback() != false ) { + if( callback() !== false ) { that.element.fadeOut(100, function () {that.inner.text('');}); that.element.unbind('click'); } @@ -74,15 +66,12 @@ var IPython = (function (IPython) { } }; - NotificationWidget.prototype.get_message = function () { return this.inner.html(); }; - + // For backwards compatability. IPython.NotificationWidget = NotificationWidget; - return IPython; - -}(IPython)); - + return NotificationWidget; +}); diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 29489f67c..2b8790e79 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/security', 'base/js/keyboard', diff --git a/IPython/html/static/notebook/js/pager.js b/IPython/html/static/notebook/js/pager.js index 050376dcb..deff08fa0 100644 --- a/IPython/html/static/notebook/js/pager.js +++ b/IPython/html/static/notebook/js/pager.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/notebook/js/quickhelp.js b/IPython/html/static/notebook/js/quickhelp.js index 7b2a14b68..feb05f3be 100644 --- a/IPython/html/static/notebook/js/quickhelp.js +++ b/IPython/html/static/notebook/js/quickhelp.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', ], function(IPython, $, utils, Dialog) { diff --git a/IPython/html/static/notebook/js/savewidget.js b/IPython/html/static/notebook/js/savewidget.js index 76a5d3e78..0841ab32d 100644 --- a/IPython/html/static/notebook/js/savewidget.js +++ b/IPython/html/static/notebook/js/savewidget.js @@ -3,10 +3,11 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', 'base/js/keyboard', + 'dateformat/date.format', ], 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 2e1d17819..44565e769 100644 --- a/IPython/html/static/notebook/js/textcell.js +++ b/IPython/html/static/notebook/js/textcell.js @@ -3,10 +3,12 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'notebook/js/cell', 'base/js/security', -], function(IPython, $, Cell, Security) { + 'notebook/js/mathjaxutils', + 'notebook/js/celltoolbar', +], function(IPython, $, Cell, Security, mathjaxutils, CellToolbar) { "use strict"; /** @@ -20,13 +22,15 @@ 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, mathjaxutils) { - // TODO: Config is IPython.config + var TextCell = function (options, events, config, keyboard_manager, notebook) { // 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; + // we cannot put this as a class key as it has handle to "this". var cm_overwrite_options = { onKeyEvent: $.proxy(this.handle_keyevent,this) @@ -35,9 +39,9 @@ define([ options = this.mergeopt(TextCell,options,{cm_config:cm_overwrite_options}); this.cell_type = this.cell_type || 'text'; - this.mathjaxutils = mathjaxutils; + mathjaxutils = mathjaxutils; - Cell.apply(this, [options], events); + Cell.apply(this, [options, keyboard_manager, events]); this.rendered = false; }; @@ -67,7 +71,7 @@ define([ var prompt = $('
').addClass('prompt input_prompt'); cell.append(prompt); var inner_cell = $('
').addClass('inner_cell'); - this.celltoolbar = new CellToolbar(this); + this.celltoolbar = new CellToolbar(this, this.events, 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); @@ -158,7 +162,6 @@ define([ /** * setter :{{#crossLink "TextCell/set_rendered"}}{{/crossLink}} * @method get_rendered - * @return {html} html of rendered element * */ TextCell.prototype.get_rendered = function() { return this.element.find('div.text_cell_render').html(); @@ -213,11 +216,11 @@ define([ * @constructor MarkdownCell * @extends IPython.HTMLCell */ - var MarkdownCell = function (options) { + var MarkdownCell = function (options, events, config, keyboard_manager) { options = this.mergeopt(MarkdownCell, options); this.cell_type = 'markdown'; - TextCell.apply(this, [options]); + TextCell.apply(this, [options, events, config, keyboard_manager]); }; MarkdownCell.options_default = { @@ -238,11 +241,11 @@ define([ var text = this.get_text(); var math = null; if (text === "") { text = this.placeholder; } - var text_and_math = this.mathjaxutils.remove_math(text); + var text_and_math = mathjaxutils.remove_math(text); text = text_and_math[0]; math = text_and_math[1]; var html = marked.parser(marked.lexer(text)); - html = this.mathjaxutils.replace_math(html, math); + html = mathjaxutils.replace_math(html, math); html = Security.sanitize_html(html); html = $($.parseHTML(html)); // links in markdown cells should open in new tabs @@ -263,10 +266,10 @@ define([ * @constructor RawCell * @extends TextCell */ - var RawCell = function (options) { + var RawCell = function (options, events, config, keyboard_manager) { options = this.mergeopt(RawCell,options); - TextCell.apply(this, [options]); + TextCell.apply(this, [options, events, config, keyboard_manager]); this.cell_type = 'raw'; // RawCell should always hide its rendered div this.element.find('div.text_cell_render').hide(); @@ -297,7 +300,7 @@ define([ * @method auto_highlight */ RawCell.prototype.auto_highlight = function () { - this._auto_highlight(config.raw_cell_highlight); + this._auto_highlight(this.config.raw_cell_highlight); }; /** @method render **/ @@ -322,12 +325,12 @@ define([ * @constructor HeadingCell * @extends TextCell */ - var HeadingCell = function (options) { + var HeadingCell = function (options, events, config, keyboard_manager) { options = this.mergeopt(HeadingCell, options); this.level = 1; this.cell_type = 'heading'; - TextCell.apply(this, [options]); + TextCell.apply(this, [options, events, config, keyboard_manager]); /** * heading level of the cell, use getter and setter to access @@ -409,11 +412,11 @@ define([ text = text.replace(/\n/g, ' '); if (text === "") { text = this.placeholder; } text = new Array(this.level + 1).join("#") + " " + text; - var text_and_math = this.mathjaxutils.remove_math(text); + var text_and_math = mathjaxutils.remove_math(text); text = text_and_math[0]; math = text_and_math[1]; var html = marked.parser(marked.lexer(text)); - html = this.mathjaxutils.replace_math(html, math); + html = mathjaxutils.replace_math(html, math); html = Security.sanitize_html(html); var h = $($.parseHTML(html)); // add id and linkback anchor @@ -439,7 +442,7 @@ define([ IPython.RawCell = RawCell; IPython.HeadingCell = HeadingCell; - Cells = { + var Cells = { 'TextCell': TextCell, 'MarkdownCell': MarkdownCell, 'RawCell': RawCell, diff --git a/IPython/html/static/notebook/js/toolbar.js b/IPython/html/static/notebook/js/toolbar.js index f5bb7e06b..570c03446 100644 --- a/IPython/html/static/notebook/js/toolbar.js +++ b/IPython/html/static/notebook/js/toolbar.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', ], function(IPython, $) { "use strict"; @@ -97,5 +97,5 @@ define([ // Backwards compatability. IPython.ToolBar = ToolBar; - return Toolbar; + return ToolBar; }); diff --git a/IPython/html/static/notebook/js/tooltip.js b/IPython/html/static/notebook/js/tooltip.js index 63c15963d..c58d7c0cb 100644 --- a/IPython/html/static/notebook/js/tooltip.js +++ b/IPython/html/static/notebook/js/tooltip.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/notebook/js/tour.js b/IPython/html/static/notebook/js/tour.js index 0226dfa66..bc8058c7a 100644 --- a/IPython/html/static/notebook/js/tour.js +++ b/IPython/html/static/notebook/js/tour.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', ], function(IPython, $) { "use strict"; @@ -129,8 +129,8 @@ define([ // TODO: remove the onPause/onResume logic once pi's patch has been // merged upstream to make this work via data-resume-class and // data-resume-text attributes. - onPause: toggle_pause_play, - onResume: toggle_pause_play, + onPause: this.toggle_pause_play, + onResume: this.toggle_pause_play, steps: this.tour_steps, template: tour_style, orphan: true diff --git a/IPython/html/static/services/kernels/js/comm.js b/IPython/html/static/services/kernels/js/comm.js index d735e8e64..4cb24a6fa 100644 --- a/IPython/html/static/services/kernels/js/comm.js +++ b/IPython/html/static/services/kernels/js/comm.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/services/kernels/js/kernel.js b/IPython/html/static/services/kernels/js/kernel.js index c975423b7..6c6ff17ea 100644 --- a/IPython/html/static/services/kernels/js/kernel.js +++ b/IPython/html/static/services/kernels/js/kernel.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'services/kernels/js/comm', 'widgets/js/init', @@ -15,8 +15,8 @@ define([ * A Kernel Class to communicate with the Python kernel * @Class Kernel */ - var Kernel = function (kernel_service_url, events) { - this.events = events; + var Kernel = function (kernel_service_url, notebook) { + this.events = notebook.events; this.kernel_id = null; this.shell_channel = null; this.iopub_channel = null; @@ -39,7 +39,7 @@ define([ this.bind_events(); this.init_iopub_handlers(); this.comm_manager = new comm.CommManager(this); - this.widget_manager = new WidgetManager(this.comm_manager); + this.widget_manager = new WidgetManager(this.comm_manager, notebook); this.last_msg_id = null; this.last_msg_callbacks = {}; @@ -605,8 +605,8 @@ define([ } }; - + // Backwards compatability. IPython.Kernel = Kernel; - return IPython; + return Kernel; }); diff --git a/IPython/html/static/services/sessions/js/session.js b/IPython/html/static/services/sessions/js/session.js index 85d4863ef..405f8d55e 100644 --- a/IPython/html/static/services/sessions/js/session.js +++ b/IPython/html/static/services/sessions/js/session.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'services/kernels/js/kernel', ], function(IPython, $, utils, Kernel) { @@ -87,7 +87,7 @@ define([ Session.prototype._handle_start_success = function (data, status, xhr) { this.id = data.id; var kernel_service_url = utils.url_path_join(this.base_url, "api/kernels"); - this.kernel = new Kernel(kernel_service_url, notebook.events); + this.kernel = new Kernel(kernel_service_url, this.notebook); this.kernel._kernel_started(data.kernel); }; diff --git a/IPython/html/static/tree/js/clusterlist.js b/IPython/html/static/tree/js/clusterlist.js index f3ac75d72..85775f673 100644 --- a/IPython/html/static/tree/js/clusterlist.js +++ b/IPython/html/static/tree/js/clusterlist.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/tree/js/kernellist.js b/IPython/html/static/tree/js/kernellist.js index 16b921635..628946e47 100644 --- a/IPython/html/static/tree/js/kernellist.js +++ b/IPython/html/static/tree/js/kernellist.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'tree/js/notebooklist', ], function(IPython, $, NotebookList) { "use strict"; diff --git a/IPython/html/static/tree/js/main.js b/IPython/html/static/tree/js/main.js index 4ebb1c8f7..0fbee36fd 100644 --- a/IPython/html/static/tree/js/main.js +++ b/IPython/html/static/tree/js/main.js @@ -4,7 +4,7 @@ var ipython = ipython || {}; require([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/events', 'base/js/page', 'base/js/utils', diff --git a/IPython/html/static/tree/js/notebooklist.js b/IPython/html/static/tree/js/notebooklist.js index bac24a63f..bddc88b2c 100644 --- a/IPython/html/static/tree/js/notebooklist.js +++ b/IPython/html/static/tree/js/notebooklist.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', 'base/js/dialog', ], function(IPython, $, utils, Dialog) { diff --git a/IPython/html/static/tree/js/sessionlist.js b/IPython/html/static/tree/js/sessionlist.js index 67ca48826..e5abb5cb4 100644 --- a/IPython/html/static/tree/js/sessionlist.js +++ b/IPython/html/static/tree/js/sessionlist.js @@ -3,7 +3,7 @@ define([ 'base/js/namespace', - 'components/jquery/jquery.min', + 'jquery', 'base/js/utils', ], function(IPython, $, utils) { "use strict"; diff --git a/IPython/html/static/widgets/js/manager.js b/IPython/html/static/widgets/js/manager.js index 2238285d3..64a48cc4d 100644 --- a/IPython/html/static/widgets/js/manager.js +++ b/IPython/html/static/widgets/js/manager.js @@ -9,12 +9,12 @@ define([ //-------------------------------------------------------------------- // WidgetManager class //-------------------------------------------------------------------- - var WidgetManager = function (comm_manager, keyboard_manager, notebook) { + var WidgetManager = function (comm_manager, notebook) { // Public constructor WidgetManager._managers.push(this); // Attach a comm manager to the - this.keyboard_manager = keyboard_manager; + this.keyboard_manager = notebook.keyboard_manager; this.notebook = notebook; this.comm_manager = comm_manager; this._models = {}; /* Dictionary of model ids and model instances */ diff --git a/IPython/html/templates/notebook.html b/IPython/html/templates/notebook.html index af54c86be..e4921cfa7 100644 --- a/IPython/html/templates/notebook.html +++ b/IPython/html/templates/notebook.html @@ -294,6 +294,26 @@ class="notebook_app" {% block script %} + + + + + + + + + + + + + + + + + + {% endblock %} diff --git a/IPython/html/templates/page.html b/IPython/html/templates/page.html index cc2fe48c0..9321b143c 100644 --- a/IPython/html/templates/page.html +++ b/IPython/html/templates/page.html @@ -22,6 +22,7 @@ nbextensions : '{{ base_url }}nbextensions', underscore : 'components/underscore/underscore-min', backbone : 'components/backbone/backbone-min', + jquery: 'components/jquery/jquery.min', }, shim: { underscore: {