mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-31 13:40:29 +08:00
Use requirejs
vs. require
This commit is contained in:
parent
ee419c0a17
commit
4d258a8e4e
@ -5,7 +5,7 @@
|
||||
// before all other objects so it exists when others register event handlers.
|
||||
// To register an event handler:
|
||||
//
|
||||
// require(['base/js/events'], function (events) {
|
||||
// requirejs(['base/js/events'], function (events) {
|
||||
// events.on("event.Namespace", function () { do_stuff(); });
|
||||
// });
|
||||
|
||||
|
@ -7,8 +7,8 @@ var Jupyter = 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);
|
||||
console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'")`');
|
||||
return requirejs(module_path);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
@ -18,8 +18,8 @@ var jprop = function(name, module_path){
|
||||
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];
|
||||
console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'").'+name+'`');
|
||||
return requirejs(module_path)[name];
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: false
|
||||
|
@ -15,7 +15,7 @@ define(['bidi/numericshaping'], function(numericshaping) {
|
||||
document.body.dir = 'rtl';
|
||||
}
|
||||
|
||||
require(['moment'], function (moment) {
|
||||
requirejs(['moment'], function (moment) {
|
||||
console.log('Loaded moment locale', moment.locale(_uiLang()));
|
||||
});
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
||||
* 'base/js/events'
|
||||
* ], function(events) {
|
||||
* events.on('app_initialized.DashboardApp', function(){
|
||||
* require(['custom/unofficial_extension.js'])
|
||||
* requirejs(['custom/unofficial_extension.js'])
|
||||
* });
|
||||
* });
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
require([
|
||||
requirejs([
|
||||
'jquery',
|
||||
'contents',
|
||||
'base/js/namespace',
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
require([
|
||||
requirejs([
|
||||
'jquery',
|
||||
'base/js/dialog',
|
||||
'base/js/i18n',
|
||||
|
@ -36,8 +36,8 @@ define([
|
||||
Object.seal(this);
|
||||
};
|
||||
|
||||
var $ = require('jquery');
|
||||
var events = require('base/js/events');
|
||||
var $ = requirejs('jquery');
|
||||
var events = requirejs('base/js/events');
|
||||
|
||||
/**
|
||||
* A bunch of predefined `Simple Actions` used by Jupyter.
|
||||
|
@ -5,8 +5,8 @@
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
|
||||
mod(require("codemirror/lib/codemirror"),
|
||||
require("codemirror/mode/python/python")
|
||||
mod(requirejs("codemirror/lib/codemirror"),
|
||||
requirejs("codemirror/mode/python/python")
|
||||
);
|
||||
} else if (typeof define == "function" && define.amd){ // AMD
|
||||
define(["codemirror/lib/codemirror",
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object"){ // CommonJS
|
||||
mod(require("codemirror/lib/codemirror")
|
||||
,require("codemirror/addon/mode/multiplex")
|
||||
,require("codemirror/mode/gfm/gfm")
|
||||
,require("codemirror/mode/stex/stex")
|
||||
mod(requirejs("codemirror/lib/codemirror")
|
||||
,requirejs("codemirror/addon/mode/multiplex")
|
||||
,requirejs("codemirror/mode/gfm/gfm")
|
||||
,requirejs("codemirror/mode/stex/stex")
|
||||
);
|
||||
} else if (typeof define == "function" && define.amd){ // AMD
|
||||
define(["codemirror/lib/codemirror"
|
||||
|
@ -20,7 +20,7 @@ var bind = function bind(obj) {
|
||||
Function.prototype.bind = Function.prototype.bind || bind ;
|
||||
|
||||
|
||||
require([
|
||||
requirejs([
|
||||
'jquery',
|
||||
'contents',
|
||||
'base/js/namespace',
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
'./toolbar',
|
||||
'./celltoolbar',
|
||||
'base/js/i18n'
|
||||
], function($, require, toolbar, celltoolbar, i18n) {
|
||||
], function($, requirejs, toolbar, celltoolbar, i18n) {
|
||||
"use strict";
|
||||
|
||||
var MainToolBar = function (selector, options) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
define(function(require) {
|
||||
define(function(requirejs) {
|
||||
"use strict";
|
||||
|
||||
var $ = require('jquery');
|
||||
var utils = require('base/js/utils');
|
||||
var $ = requirejs('jquery');
|
||||
var utils = requirejs('base/js/utils');
|
||||
|
||||
var Contents = function(options) {
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) Jupyter Development Team.
|
||||
// Distributed under the terms of the Modified BSD License.
|
||||
|
||||
require([
|
||||
requirejs([
|
||||
'jquery',
|
||||
'base/js/utils',
|
||||
'base/js/page',
|
||||
|
@ -20,7 +20,7 @@ var bind = function bind(obj) {
|
||||
Function.prototype.bind = Function.prototype.bind || bind ;
|
||||
|
||||
|
||||
require([
|
||||
requirejs([
|
||||
'jquery',
|
||||
'contents',
|
||||
'base/js/namespace',
|
||||
|
Loading…
x
Reference in New Issue
Block a user