From 3fb25c5915f974955b7d3a42dd098502caadec68 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Thu, 4 Feb 2016 15:01:27 -0800 Subject: [PATCH] Explicitly use requirejs where requirejs should be used --- notebook/static/base/js/namespace.js | 4 ++-- notebook/static/base/js/utils.js | 6 +++--- notebook/static/notebook/js/kernelselector.js | 9 ++++----- notebook/static/notebook/js/menubar.js | 2 +- notebook/static/terminal/js/main.js | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/notebook/static/base/js/namespace.js b/notebook/static/base/js/namespace.js index 1778937c4..b4bbf9b28 100644 --- a/notebook/static/base/js/namespace.js +++ b/notebook/static/base/js/namespace.js @@ -8,7 +8,7 @@ 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); + return requirejs(module_path); }, enumerable: true, configurable: false @@ -19,7 +19,7 @@ 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]; + return requirejs(module_path)[name]; }, enumerable: true, configurable: false diff --git a/notebook/static/base/js/utils.js b/notebook/static/base/js/utils.js index 9e3f20ae2..f4514180c 100644 --- a/notebook/static/base/js/utils.js +++ b/notebook/static/base/js/utils.js @@ -20,7 +20,7 @@ define([ var load_extension = function (extension) { return new Promise(function(resolve, reject) { var ext_path = "nbextensions/" + extension; - require([ext_path], function(module) { + requirejs([ext_path], function(module) { try { if (extensions_loaded.indexOf(ext_path) < 0) { console.log("Loading extension: " + extension); @@ -622,7 +622,7 @@ define([ CodeMirror.findModeByMIME(modename) || {mode: modename, mime: modename}; - require([ + requirejs([ // might want to use CodeMirror.modeURL here ['codemirror/mode', info.mode, info.mode].join('/'), ], function() { @@ -709,7 +709,7 @@ define([ // Try loading the view module using require.js if (module_name) { - require([module_name], function(module) { + requirejs([module_name], function(module) { if (module[class_name] === undefined) { reject(new Error('Class '+class_name+' not found in module '+module_name)); } else { diff --git a/notebook/static/notebook/js/kernelselector.js b/notebook/static/notebook/js/kernelselector.js index 7f7b9d73b..787349ea9 100644 --- a/notebook/static/notebook/js/kernelselector.js +++ b/notebook/static/notebook/js/kernelselector.js @@ -4,9 +4,8 @@ define([ 'base/js/namespace', 'base/js/dialog', - 'base/js/utils', - 'require', -], function(IPython, dialog, utils, require) { + 'base/js/utils' +], function(IPython, dialog, utils) { "use strict"; var KernelSelector = function(selector, notebook) { @@ -154,8 +153,8 @@ define([ // // > Uncaught (in promise) TypeError: require is not a function // - console.info('Dynamically requiring kernel.js, `require` is ', require); - require([ks.resources['kernel.js']], + console.info('Dynamically requiring kernel.js, `requirejs` is ', requirejs); + requirejs([ks.resources['kernel.js']], function (kernel_mod) { if (kernel_mod && kernel_mod.onload) { kernel_mod.onload(); diff --git a/notebook/static/notebook/js/menubar.js b/notebook/static/notebook/js/menubar.js index 28cc15361..cb6bcd175 100644 --- a/notebook/static/notebook/js/menubar.js +++ b/notebook/static/notebook/js/menubar.js @@ -398,7 +398,7 @@ define([ .append($("") .attr('target', '_blank') .attr('title', 'Opens in a new window') - .attr('href', require.toUrl(link.url)) + .attr('href', requirejs.toUrl(link.url)) .append($("") .addClass("fa fa-external-link menu-icon pull-right") ) diff --git a/notebook/static/terminal/js/main.js b/notebook/static/terminal/js/main.js index 7d6f0885f..8f3bf78e8 100644 --- a/notebook/static/terminal/js/main.js +++ b/notebook/static/terminal/js/main.js @@ -1,14 +1,13 @@ // Copyright (c) Jupyter Development Team. // Distributed under the terms of the Modified BSD License. +requirejs(['termjs'], function(termjs) { require([ - 'termjs', 'base/js/utils', 'base/js/page', 'services/config', 'terminal/js/terminado', ], function( - termjs, utils, page, configmod, @@ -62,3 +61,4 @@ require([ window.terminal = terminal; }); +});