Make sure requirejs can't be set more than once.

This commit is contained in:
Jonathan Frederic 2015-08-21 11:43:07 -07:00
parent 8c8c95ceca
commit 467ae32b05
3 changed files with 23 additions and 8 deletions

View File

@ -8,8 +8,19 @@
* This module handles the global loading of those tools.
*/
module.exports = new Promise(function(resolve, reject) {
if (window.hasOwnProperty('jquery')) {
resolve();
}
requirejs(['jquery'], function($) {
window.$ = window.jQuery = $;
var jQueryProperty = {
get: function() {
return $;
},
configurable: false
};
Object.defineProperty(window, '$', jQueryProperty);
Object.defineProperty(window, 'jQuery', jQueryProperty);
console.log('jQuery loaded and available in global namespace');
requirejs(['jqueryui', 'bootstrap'], function() {
@ -19,7 +30,7 @@ module.exports = new Promise(function(resolve, reject) {
reject(new Error('bootstrap not injected into jQuery prototype'));
}
if ($.prototype.draggable) {
if ($.prototype.draggable && $.prototype.resizable) {
console.log('jQueryUI loaded and injected into jQuery\'s namespace');
} else {
reject(new Error('jQueryUI not injected into jQuery prototype'));
@ -43,7 +54,13 @@ module.exports = new Promise(function(resolve, reject) {
'notebook/js/codemirror-ipython',
'notebook/js/codemirror-ipythongfm'
], function(CodeMirror) {
window.CodeMirror = CodeMirror;
var codeMirrorProperty = {
get: function() {
return CodeMirror;
},
configurable: false
};
Object.defineProperty(window, 'CodeMirror', codeMirrorProperty);
console.log('CodeMirror loaded and available in global namespace');
resolve();

View File

@ -4,8 +4,7 @@
"use strict";
var QH = require("notebook/js/quickhelp");
var $ = require("jquery");
/**
* Humanize the action name to be consumed by user.
* internaly the actions anem are of the form

View File

@ -12,7 +12,8 @@
"clean": "npm run clean:js && npm run clean:css",
"clean:css": "rimraf notebook/static/style/ipython.min.css && rimraf notebook/static/style/style.min.css",
"clean:js": "rimraf notebook/static/auth/js && rimraf notebook/static/base/js && rimraf notebook/static/edit/js && rimraf notebook/static/notebook/js && rimraf notebook/static/terminal/js && rimraf notebook/static/tree/js && rimraf notebook/static/services",
"postinstall": "npm run bower",
"uninstall": "npm run clean && rimraf notebook/static/components && rimraf node_modules",
"postinstall": "npm run bower && npm run build",
"bower": "bower install --allow-root --config.interactive=false",
"build": "concurrent \"npm run build:css\" \"npm run build:js\"",
"build:css": "concurrent \"npm run build:css:ipython\" \"npm run build:css:style\"",
@ -30,10 +31,8 @@
"devDependencies": {
"aliasify": "^1.7.2",
"amd-wrap-legacy": "^0.2.0",
"backbone": "~1.2",
"bower": "*",
"browserify": "^11.0.1",
"codemirror": "~5.5",
"concurrently": "^0.1.1",
"glob": "^5.0.14",
"less": "~2",