Skip to content

Commit

Permalink
Use requirejs vs. require
Browse files Browse the repository at this point in the history
  • Loading branch information
gnestor committed Nov 30, 2017
1 parent b9ee02d commit 50ac4b3
Show file tree
Hide file tree
Showing 44 changed files with 165 additions and 165 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define([
'base/js/namespace',
'jquery',
'require',
'requirejs',
'base/js/events',
'base/js/utils',
], function(Jupyter, $, require, events, configmod, utils) {
], function(Jupyter, $, requirejs, events, configmod, utils) {
"use strict";

var load_extension = function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// Based on: https://github.com/jfbercher/code_prettify and
// https://gist.github.com/takluyver/c8839593c615bb2f6e80

define(function(require, exports, module) {
define(function(requirejs, exports, module) {
'use strict';

var kernel_exec_on_cell = require('./kernel_exec_on_cell');
var kernel_exec_on_cell = requirejs('./kernel_exec_on_cell');

var mod_name = '2to3';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Distributed under the terms of the Modified BSD License.
// Authors: @kenkoooo, @jfbercher and @jcb91

define(function(require, exports, module) {
define(function(requirejs, exports, module) {
'use strict';

var kernel_exec_on_cell = require('./kernel_exec_on_cell');
var kernel_exec_on_cell = requirejs('./kernel_exec_on_cell');

var mod_name = 'autopep8';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Distributed under the terms of the Modified BSD License.
// Authors: @jfbercher and @jcb91

define(function(require, exports, module) {
define(function(requirejs, exports, module) {
'use strict';

var kernel_exec_on_cell = require('./kernel_exec_on_cell');
var kernel_exec_on_cell = requirejs('./kernel_exec_on_cell');

var mod_name = 'code_prettify';

Expand Down Expand Up @@ -41,7 +41,7 @@ define(function(require, exports, module) {
"postfix": ", output=FALSE)[['text.tidy']], collapse='\n')))"
},
"javascript": {
"library": "jsbeautify = require(" + "'js-beautify')",
"library": "jsbeautify = requirejs(" + "'js-beautify')",
// we do this + trick to prevent require.js attempting to load js-beautify when processing the AMI-style load for this module
"prefix": "console.log(JSON.stringify(jsbeautify.js_beautify(",
"postfix": ")));"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Jupyter-Contrib Team.
// Distributed under the terms of the Modified BSD License.

define(function(require, exports, module) {
define(function(requirejs, exports, module) {
'use strict';

var $ = require('jquery');
var Jupyter = require('base/js/namespace');
var events = require('base/js/events');
var CodeCell = require('notebook/js/codecell').CodeCell;
var $ = requirejs('jquery');
var Jupyter = requirejs('base/js/namespace');
var events = requirejs('base/js/events');
var CodeCell = requirejs('notebook/js/codecell').CodeCell;

// this wrapper function allows config & hotkeys to be per-plugin
function KernelExecOnCells(mod_name, cfg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
define([
'base/js/namespace',
'jquery',
'require',
'requirejs',
'base/js/events',
'services/config',
'notebook/js/codecell',
Expand All @@ -21,7 +21,7 @@ define([
'codemirror/addon/fold/foldgutter',
'codemirror/addon/fold/brace-fold',
'codemirror/addon/fold/indent-fold'
], function (Jupyter, $, require, events, configmod, codecell, CodeMirror) {
], function (Jupyter, $, requirejs, events, configmod, codecell, CodeMirror) {
"use strict";

// define default config parameter values
Expand Down Expand Up @@ -221,7 +221,7 @@ define([
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = require.toUrl(name, 'css');
link.href = requirejs.toUrl(name, 'css');
document.getElementsByTagName("head")[0].appendChild(link);
};

Expand Down Expand Up @@ -256,7 +256,7 @@ define([

if (Jupyter.notebook) {
/* require our additional custom codefolding modes before initialising fully */
require(['./firstline-fold', './magic-fold'], function () {
requirejs(['./firstline-fold', './magic-fold'], function () {
if (Jupyter.notebook._fully_loaded) {
setTimeout(function () {
console.log('Codefolding: Wait for', params.init_delay, 'ms');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(require.specified('base/js/namespace') ? define : function (deps, callback) {
(requirejs.specified('base/js/namespace') ? define : function (deps, callback) {
// if here, the Jupyter namespace hasn't been specified to be loaded.
// This means that we're probably embedded in a page, so we need to make
// our definition with a specific module name
return define('nbextensions/collapsible_headings/main', deps, callback);
})(['jquery', 'require'], function ($, require) {
})(['jquery', 'requirejs'], function ($, requirejs) {
"use strict";

var mod_name = 'collapsible_headings';
Expand Down Expand Up @@ -55,7 +55,7 @@
// object, but in a non-live notebook, we must construct our own version
var events;
try {
events = require('base/js/events');
events = requirejs('base/js/events');
}
catch (err) {
// in non-live notebook, there's no events structure, so we make our own
Expand Down Expand Up @@ -528,7 +528,7 @@
*/
function patch_Notebook () {
return new Promise(function (resolve, reject) {
require(['notebook/js/notebook'], function on_success (notebook) {
requirejs(['notebook/js/notebook'], function on_success (notebook) {
console.debug(log_prefix, 'patching Notebook.protoype');

// we have to patch select, since the select.Cell event is only fired
Expand Down Expand Up @@ -577,7 +577,7 @@
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
require(['notebook/js/tooltip'], function on_success (tooltip) {
requirejs(['notebook/js/tooltip'], function on_success (tooltip) {
console.debug(log_prefix, 'patching Tooltip.prototype');

var orig_tooltip__show = tooltip.Tooltip.prototype._show;
Expand Down Expand Up @@ -607,7 +607,7 @@
*/
function patch_actions () {
return new Promise(function (resolve, reject) {
require(['notebook/js/tooltip'], function on_success (tooltip) {
requirejs(['notebook/js/tooltip'], function on_success (tooltip) {
console.debug(log_prefix, 'patching Jupyter up/down actions');

var kbm = Jupyter.keyboard_manager;
Expand Down Expand Up @@ -927,7 +927,7 @@
}

return new Promise (function (resolve, reject) {
require(['base/js/events'], function on_success (events) {
requirejs(['base/js/events'], function on_success (events) {

// ensure events are detached while notebook loads, in order to
// speed up loading (otherwise headings are updated for every
Expand Down Expand Up @@ -1000,13 +1000,13 @@
id: 'collapsible_headings_css',
rel: 'stylesheet',
type: 'text/css',
href: require.toUrl('./main.css')
href: requirejs.toUrl('./main.css')
})
.appendTo('head');

// ensure Jupyter module is defined before proceeding further
new Promise(function (resolve, reject) {
require(['base/js/namespace'], function (Jupyter_mod) {
requirejs(['base/js/namespace'], function (Jupyter_mod) {
live_notebook = true;
Jupyter = Jupyter_mod;
resolve(Jupyter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

define(["require"], function(require) {
define(["requirejs"], function(requirejs) {

/**
* @param element {} DOM element to which add controls
Expand Down Expand Up @@ -36,7 +36,7 @@ define(["require"], function(require) {
var cmtm = styles[val].cm || 'ipyhton';
if(cmtm != undefined){
try{
$tlink.attr('href',require.toUrl('../../components/codemirror/theme/'+cmtm+'.css'))
$tlink.attr('href',requirejs.toUrl('../../components/codemirror/theme/'+cmtm+'.css'))
.attr('rel','stylesheet')
.attr('type','text/css')

Expand All @@ -45,7 +45,7 @@ define(["require"], function(require) {
}
} catch(e){}
}
$link.attr('href',require.toUrl('./css/'+val+'.css'))
$link.attr('href',requirejs.toUrl('./css/'+val+'.css'))
.attr('rel','stylesheet')
.attr('type','text/css');
field.css = [val];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
define([
'base/js/namespace',
'jquery',
'require',
'requirejs',
'notebook/js/textcell',
'base/js/utils',
], function(Jupyter, $, require, textcell, utils) {
], function(Jupyter, $, requirejs, textcell, utils) {
"use strict";

var MathJax = window.MathJax;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
// A double click on the timing box makes it disappear

define([
'require',
'requirejs',
'jquery',
'moment',
'base/js/namespace',
'base/js/events',
'notebook/js/codecell'
], function (
require,
requirejs,
$,
moment,
Jupyter,
Expand Down Expand Up @@ -286,7 +286,7 @@ define([
$('<link/>')
.attr({
rel: 'stylesheet',
href: require.toUrl(url),
href: requirejs.toUrl(url),
type: 'text/css'
})
.appendTo('head');
Expand All @@ -295,9 +295,9 @@ define([
function load_jupyter_extension () {
// try to load jquery-ui
if ($.ui === undefined && options.highlight.use) {
require(['jquery-ui'], function ($) {}, function (err) {
requirejs(['jquery-ui'], function ($) {}, function (err) {
// try to load using the older, non-standard name (without hyphen)
require(['jqueryui'], function ($) {}, function (err) {
requirejs(['jqueryui'], function ($) {}, function (err) {
console.log(log_prefix, 'couldn\'t find jquery-ui, so no animations');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Then clicking on the toolbar button transforms these cells into a "solution" whi
define([
'base/js/namespace',
'jquery',
'require',
'requirejs',
'base/js/events',
'nbextensions/rubberband/main'
], function(IPython, $, require, events, rubberband) {
], function(IPython, $, requirejs, events, rubberband) {
"use strict";

/**
Expand Down Expand Up @@ -153,7 +153,7 @@ function load_ipython_extension(){
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = require.toUrl(name);
link.href = requirejs.toUrl(name);
document.getElementsByTagName("head")[0].appendChild(link);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
define([
'base/js/namespace',
'jquery',
'require',
'requirejs',
'base/js/events',
'nbextensions/rubberband/main'
], function(IPython, $, require, events, rubberband) {
], function(IPython, $, requirejs, events, rubberband) {
"use strict";

var cbx=0;
Expand Down Expand Up @@ -150,7 +150,7 @@ function load_ipython_extension(){
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = require.toUrl(name);
link.href = requirejs.toUrl(name);
document.getElementsByTagName("head")[0].appendChild(link);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Add help panel at right side of notebook window

define([
'require',
'requirejs',
'jqueryui',
'base/js/namespace',
'base/js/events',
], function (
require,
requirejs,
$,
IPython,
events
Expand All @@ -19,15 +19,15 @@ define([
* in all Jupyter versions. In this case, we fallback to using jqueryui tooltips.
*/
var have_bs_tooltips = false;
require(
requirejs(
['components/bootstrap/js/tooltip'],
// we don't actually need to do anything with the return
// just ensure that the plugin gets loaded.
function () { have_bs_tooltips = true; },
// The errback, error callback
// The error has a list of modules that failed
function (err) {
var failedId = err.requireModules && err.requireModules[0];
var failedId = err.requirejsModules && err.requirejsModules[0];
if (failedId === 'components/bootstrap/js/tooltip') {
// could do something here, like load a cdn version.
// For now, just ignore it.
Expand Down Expand Up @@ -236,7 +236,7 @@ define([
$('<link/>', {
rel: 'stylesheet',
type:'text/css',
href: require.toUrl('./help_panel.css')
href: requirejs.toUrl('./help_panel.css')
})
);
return IPython.notebook.config.loaded.then(initialize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,23 +294,23 @@ $("#remove_highlights")

//******************************* MAIN FUNCTION **************************

define(["require",
define(["requirejs",
'base/js/namespace'
], function(require, Jupyter) {
], function(requirejs, Jupyter) {

var security = require("base/js/security")
var security = requirejs("base/js/security")

var load_css = function(name) {
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.href = require.toUrl(name);
link.href = requirejs.toUrl(name);
document.getElementsByTagName("head")[0].appendChild(link);

};

//Load_ipython_extension
var load_ipython_extension = require(['base/js/namespace'], function(Jupyter) {
var load_ipython_extension = requirejs(['base/js/namespace'], function(Jupyter) {
"use strict";
if (Jupyter.version[0] < 3) {
console.log("This extension requires Jupyter or IPython >= 3.x")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
define(function (require, exports, module) {
define(function (requirejs, exports, module) {
'use strict';

var $ = require('jquery');
var Jupyter = require('base/js/namespace');
var keyboard = require('base/js/keyboard');
var Cell = require('notebook/js/cell').Cell;
var CodeCell = require('notebook/js/codecell').CodeCell;
var Completer = require('notebook/js/completer').Completer;
var $ = requirejs('jquery');
var Jupyter = requirejs('base/js/namespace');
var keyboard = requirejs('base/js/keyboard');
var Cell = requirejs('notebook/js/cell').Cell;
var CodeCell = requirejs('notebook/js/codecell').CodeCell;
var Completer = requirejs('notebook/js/completer').Completer;

var log_prefix = '[' + module.id + ']';

Expand Down
Loading

0 comments on commit 50ac4b3

Please sign in to comment.