diff --git a/notebook/build.js b/notebook/build.js index f958bd91d..70350ab0d 100644 --- a/notebook/build.js +++ b/notebook/build.js @@ -4,16 +4,6 @@ var browserify = require('browserify'); var aliasifyConfig = { aliases: { - // underscore : 'components/underscore/underscore-min', - // backbone : 'components/backbone/backbone-min', - // jquery: 'components/jquery/jquery.min', - bootstrap: 'components/bootstrap/js/bootstrap.min', - bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min', - // jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min', - // moment: 'components/moment/moment', - // codemirror: 'components/codemirror', - // termjs: 'components/term.js/src/term' - jqueryui: 'jquery-ui', termjs: 'term.js' }, diff --git a/notebook/static-src/base/js/namespace.js b/notebook/static-src/base/js/namespace.js index e4604a063..37a4a84fa 100644 --- a/notebook/static-src/base/js/namespace.js +++ b/notebook/static-src/base/js/namespace.js @@ -3,34 +3,42 @@ "use strict"; - var Jupyter = Jupyter || {}; + var Jupyter = window.Jupyter || {}; - var jprop = function(name, module_path){ - Object.defineProperty(Jupyter, name, { - get: function() { - console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`'); - return require(module_path); - }, - enumerable: true, - configurable: false + var jprop = function(name, module_path) { + requirejs([module_path], function(loaded) { + if (!Jupyter.hasOwnProperty(name)) { + Object.defineProperty(Jupyter, name, { + get: function() { + console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'")`'); + return loaded; + }, + enumerable: true, + configurable: false + }); + } }); - } + }; var jglobal = function(name, module_path){ - Object.defineProperty(Jupyter, name, { - get: function() { - console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`'); - return require(module_path)[name]; - }, - enumerable: true, - configurable: false + requirejs([module_path], function(loaded) { + if (!Jupyter.hasOwnProperty(name)) { + Object.defineProperty(Jupyter, name, { + get: function() { + console.warn('accessing `'+name+'` is deprecated. Use `require("'+module_path+'").'+name+'`'); + return loaded[name]; + }, + enumerable: true, + configurable: false + }); + } }); } // expose modules - jprop('utils','base/js/utils') + jprop('utils','base/js/utils'); //Jupyter.load_extensions = Jupyter.utils.load_extensions; // @@ -41,8 +49,8 @@ //// exposed constructors - jglobal('CommManager','services/kernels/comm') - jglobal('Comm','services/kernels/comm') + jglobal('CommManager','services/kernels/comm'); + jglobal('Comm','services/kernels/comm'); jglobal('NotificationWidget','base/js/notificationwidget'); jglobal('Kernel','services/kernels/kernel'); @@ -76,6 +84,7 @@ Jupyter._target = '_blank'; module.exports = Jupyter; - + window.Jupyter = Jupyter; + // deprecated since 4.0, remove in 5+ window.IPython = Jupyter; diff --git a/notebook/static-src/base/js/security.js b/notebook/static-src/base/js/security.js index 68e10c3f2..d1cb3f81d 100644 --- a/notebook/static-src/base/js/security.js +++ b/notebook/static-src/base/js/security.js @@ -4,7 +4,7 @@ "use strict"; var $ = require('jquery'); - var sanitize = require('components/google-caja/html-css-sanitizer-minified'); + var sanitize = require('sanitizer'); var noop = function (x) { return x; }; diff --git a/notebook/static-src/edit/js/main.js b/notebook/static-src/edit/js/main.js index 934f440b1..d3af4cfd0 100644 --- a/notebook/static-src/edit/js/main.js +++ b/notebook/static-src/edit/js/main.js @@ -16,7 +16,7 @@ requirejs(['contents', 'bootstrap'], function(contents_service) { var menubar = require('edit/js/menubar'); var savewidget = require('edit/js/savewidget'); var notificationarea = require('edit/js/notificationarea'); - require('custom/custom'); + requirejs(['custom/custom'], function() {}); page = new page.Page(); diff --git a/notebook/static-src/edit/js/menubar.js b/notebook/static-src/edit/js/menubar.js index 20af744fa..43ab8474b 100644 --- a/notebook/static-src/edit/js/menubar.js +++ b/notebook/static-src/edit/js/menubar.js @@ -8,7 +8,7 @@ var dialog = require('base/js/dialog'); var CodeMirror = require('codemirror/lib/codemirror'); require('codemirror/mode/meta'); - require('bootstrap'); + requirejs(['bootstrap'], function() {}); var MenuBar = function (selector, options) { /** diff --git a/notebook/static-src/notebook/js/main.js b/notebook/static-src/notebook/js/main.js index 534b7fc3d..8aa997fe1 100644 --- a/notebook/static-src/notebook/js/main.js +++ b/notebook/static-src/notebook/js/main.js @@ -28,13 +28,7 @@ requirejs(['contents', 'jquery'], function(contents_service) { var typeahead = require('typeahead'); var searchandreplace = 'notebook/js/searchandreplace'; // only loaded, not used, please keep sure this is loaded last - var custom = require('custom/custom'); - - // BEGIN HARDCODED WIDGETS HACK - utils.load_extension('widgets/notebook/js/extension').catch(function () { - console.warn('ipywidgets package not installed. Widgets are not available.'); - }); - // END HARDCODED WIDGETS HACK + requirejs(['custom/custom'], function() {}); // compat with old IPython, remove for IPython > 3.0 window.CodeMirror = CodeMirror; @@ -139,6 +133,12 @@ requirejs(['contents', 'jquery'], function(contents_service) { IPython.save_widget = save_widget; IPython.tooltip = notebook.tooltip; + // BEGIN HARDCODED WIDGETS HACK + utils.load_extension('widgets/notebook/js/extension').catch(function (err) { + console.warn('ipywidgets package not loaded. Widgets are not available. (Maybe they aren\'t installed)', err); + }); + // END HARDCODED WIDGETS HACK + events.trigger('app_initialized.NotebookApp'); utils.load_extensions_from_config(config_section); utils.load_extensions_from_config(common_config); diff --git a/notebook/static-src/notebook/js/menubar.js b/notebook/static-src/notebook/js/menubar.js index 8ead382fd..819fe689c 100644 --- a/notebook/static-src/notebook/js/menubar.js +++ b/notebook/static-src/notebook/js/menubar.js @@ -7,8 +7,8 @@ var dialog = require('base/js/dialog'); var utils = require('base/js/utils'); var tour = require('notebook/js/tour'); - var bootstrap = require('bootstrap'); var moment = require('moment'); + requirejs(['bootstrap'], function() {}); var MenuBar = function (selector, options) { /** diff --git a/notebook/static-src/notebook/js/notebook.js b/notebook/static-src/notebook/js/notebook.js index 7a3ba36a3..235a708b0 100644 --- a/notebook/static-src/notebook/js/notebook.js +++ b/notebook/static-src/notebook/js/notebook.js @@ -17,7 +17,7 @@ var configmod = require('services/config'); var session = require('services/sessions/session'); var celltoolbar = require('notebook/js/celltoolbar'); - var marked = require('components/marked/lib/marked'); + var marked = require('marked'); var CodeMirror = require('codemirror/lib/codemirror'); var runMode = require('codemirror/addon/runmode/runmode'); var mathjaxutils = require('notebook/js/mathjaxutils'); diff --git a/notebook/static-src/notebook/js/outputarea.js b/notebook/static-src/notebook/js/outputarea.js index 0d0256876..915b90093 100644 --- a/notebook/static-src/notebook/js/outputarea.js +++ b/notebook/static-src/notebook/js/outputarea.js @@ -8,7 +8,7 @@ var security = require('base/js/security'); var keyboard = require('base/js/keyboard'); var mathjaxutils = require('notebook/js/mathjaxutils'); - var marked = require('components/marked/lib/marked'); + var marked = require('marked'); /** * @class OutputArea diff --git a/notebook/static-src/notebook/js/textcell.js b/notebook/static-src/notebook/js/textcell.js index 4c2a904c4..19ece9b27 100644 --- a/notebook/static-src/notebook/js/textcell.js +++ b/notebook/static-src/notebook/js/textcell.js @@ -9,7 +9,7 @@ var configmod = require('services/config'); var mathjaxutils = require('notebook/js/mathjaxutils'); var celltoolbar = require('notebook/js/celltoolbar'); - var marked = require('components/marked/lib/marked'); + var marked = require('marked'); var CodeMirror = require('codemirror/lib/codemirror'); var gfm = require('codemirror/mode/gfm/gfm'); var ipgfm = require('notebook/js/codemirror-ipythongfm'); diff --git a/notebook/static-src/notebook/js/tour.js b/notebook/static-src/notebook/js/tour.js index 7b4fc223f..b2c823a92 100644 --- a/notebook/static-src/notebook/js/tour.js +++ b/notebook/static-src/notebook/js/tour.js @@ -3,7 +3,7 @@ "use strict"; var $ = require('jquery'); - var Tour = require('bootstraptour'); + var tour_style = "
\n" + "
\n" + @@ -114,21 +114,24 @@ } ]; - this.tour = new Tour({ - storage: false, // start tour from beginning every time - debug: true, - reflex: true, // click on element to continue tour - animation: false, - duration: this.step_duration, - onStart: function() { console.log('tour started'); }, - // 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: this.toggle_pause_play, - onResume: this.toggle_pause_play, - steps: this.tour_steps, - template: tour_style, - orphan: true + var that = this; + requirejs(['bootstraptour'], function(Tour) { + that.tour = new Tour({ + storage: false, // start tour from beginning every time + debug: true, + reflex: true, // click on element to continue tour + animation: false, + duration: that.step_duration, + onStart: function() { console.log('tour started'); }, + // 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: that.toggle_pause_play, + onResume: that.toggle_pause_play, + steps: that.tour_steps, + template: tour_style, + orphan: true + }); }); }; @@ -157,3 +160,4 @@ }; exports.Tour = NotebookTour; + \ No newline at end of file diff --git a/notebook/static-src/terminal/js/main.js b/notebook/static-src/terminal/js/main.js index 8c4300dcf..1e8b77ff1 100644 --- a/notebook/static-src/terminal/js/main.js +++ b/notebook/static-src/terminal/js/main.js @@ -7,7 +7,7 @@ var page = require('base/js/page'); var configmod = require('services/config'); var terminado = require('terminal/js/terminado'); - require('custom/custom'); + requirejs(['custom/custom'], function() {}); page = new page.Page(); diff --git a/notebook/static-src/tree/js/main.js b/notebook/static-src/tree/js/main.js index a2c7f2673..b09cfe981 100644 --- a/notebook/static-src/tree/js/main.js +++ b/notebook/static-src/tree/js/main.js @@ -5,7 +5,7 @@ // Contents must be loaded at runtime. // jQuery must also be loaded at runtime and available globally // in order for bootstrap to work... -requirejs(['contents', 'jquery'], function(contents_service) { +requirejs(['contents', 'jquery', 'bootstrap'], function(contents_service) { var $ = require('jquery'); var IPython = require('base/js/namespace'); @@ -22,8 +22,7 @@ requirejs(['contents', 'jquery'], function(contents_service) { var loginwidget = require('auth/js/loginwidget'); require('jqueryui'); - require('bootstrap'); - require('custom/custom'); + requirejs(['custom/custom'], function() {}); IPython.NotebookList = notebooklist.NotebookList; diff --git a/notebook/templates/page.html b/notebook/templates/page.html index e147643dc..2cf74efb5 100644 --- a/notebook/templates/page.html +++ b/notebook/templates/page.html @@ -38,6 +38,8 @@ moment: 'components/moment/moment', codemirror: 'components/codemirror', termjs: 'components/term.js/src/term', + marked: 'components/marked/marked.min', + sanitizer: 'components/google-caja/caja-minified' }, shim: { underscore: { diff --git a/package.json b/package.json index 67ed9da93..4bfeecf3b 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "mkdirp": "^0.5.1", "moment": "~2.8.4", "rimraf": "^2.4.2", + "sanitizer": "^0.1.2", "term.js": "~0.0.4", "text-encoding": "~0.1", "underscore": "~1.5"