From 7717a986d115c4db68a482d8e233f4adc06b49ec Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Fri, 21 Aug 2015 17:28:34 -0700 Subject: [PATCH] Load underscore globally --- notebook/static-src/base/js/globals.js | 17 ++++++++++++++++- notebook/static-src/base/js/keyboard.js | 1 - notebook/static-src/notebook/js/about.js | 1 - .../static-src/services/kernels/serialize.js | 2 -- package.json | 3 +-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/notebook/static-src/base/js/globals.js b/notebook/static-src/base/js/globals.js index 69804b818..678c34ea8 100644 --- a/notebook/static-src/base/js/globals.js +++ b/notebook/static-src/base/js/globals.js @@ -63,7 +63,22 @@ module.exports = new Promise(function(resolve, reject) { Object.defineProperty(window, 'CodeMirror', codeMirrorProperty); console.log('CodeMirror loaded and available in global namespace'); - resolve(); + + requirejs(['underscore'], function(_) { + var underscoreProperty = { + get: function() { + return _; + }, + configurable: false + }; + Object.defineProperty(window, '_', underscoreProperty); + console.log('underscore loaded and available in global namespace'); + + resolve(); + }, function(err) { + console.error('could not load underscore'); + reject(err); + }); }, function(err) { console.error('could not load CodeMirror and/or it\'s plugins'); reject(err); diff --git a/notebook/static-src/base/js/keyboard.js b/notebook/static-src/base/js/keyboard.js index 44d74849e..2aeb8dac2 100644 --- a/notebook/static-src/base/js/keyboard.js +++ b/notebook/static-src/base/js/keyboard.js @@ -11,7 +11,6 @@ "use strict"; var utils = require('base/js/utils'); - var _ = require('underscore'); /** diff --git a/notebook/static-src/notebook/js/about.js b/notebook/static-src/notebook/js/about.js index fd4274ce7..a7df87154 100644 --- a/notebook/static-src/notebook/js/about.js +++ b/notebook/static-src/notebook/js/about.js @@ -3,7 +3,6 @@ 'use strict'; var dialog = require('base/js/dialog'); - var _ = require('underscore'); var IPython = require('base/js/namespace'); $('#notebook_about').click(function () { diff --git a/notebook/static-src/services/kernels/serialize.js b/notebook/static-src/services/kernels/serialize.js index 2bcf7e704..5b7bf0ad2 100644 --- a/notebook/static-src/services/kernels/serialize.js +++ b/notebook/static-src/services/kernels/serialize.js @@ -2,8 +2,6 @@ // Distributed under the terms of the Modified BSD License. "use strict"; - var _ = require('underscore'); - var _deserialize_array_buffer = function (buf) { var data = new DataView(buf); // read the header: 1 + nbufs 32b integers diff --git a/package.json b/package.json index 1c7f89ab2..895dfbce8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "rimraf": "^2.4.2", "term.js": "~0.0.4", "text-encoding": "~0.1", - "typeahead": "^0.2.0", - "underscore": "~1.5" + "typeahead": "^0.2.0" } }