Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds new file custom-preload that is loaded in a different order than custom.js before the main.js script is executed #155

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions nbclassic/static/custom/custom-preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// leave at least 2 line with only a star on it below, or doc generation fails
/**
*
*
* Same goal as custom.js, but loaded in a different order, before the main.js script is executed
*
*
* @module IPython
* @namespace IPython
* @class custompreloadjs
* @static
*/

1 change: 1 addition & 0 deletions nbclassic/static/edit/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ requirejs([
'edit/js/notificationarea',
'bidi/bidi',
'auth/js/loginwidget',
'custom-preload'
], function(
$,
contents_service,
Expand Down
3 changes: 2 additions & 1 deletion nbclassic/static/notebook/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ requirejs([
'notebook/js/searchandreplace',
'notebook/js/clipboard',
'bidi/bidi',
'notebook/js/celltoolbarpresets/tags'
'notebook/js/celltoolbarpresets/tags',
'custom-preload'
], function(
$,
contents_service,
Expand Down
1 change: 1 addition & 0 deletions nbclassic/static/terminal/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ requirejs([
'auth/js/loginwidget',
'services/config',
'terminal/js/terminado',
'custom-preload'
], function(
$,
utils,
Expand Down
1 change: 1 addition & 0 deletions nbclassic/static/tree/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ requirejs([
'tree/js/shutdownbutton',
'auth/js/loginwidget',
'bidi/bidi',
'custom-preload'
], function(
$,
contents_service,
Expand Down
13 changes: 13 additions & 0 deletions nbclassic/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
paths: {
'auth/js/main': 'auth/js/main.min',
custom : '{{ base_url }}custom',
'custom-preload' : '{{ base_url }}custom-preload',
nbextensions : '{{ base_url }}nbextensions',
kernelspecs : '{{ base_url }}kernelspecs',
underscore : 'components/underscore/underscore-min',
Expand Down Expand Up @@ -99,6 +100,18 @@
}
})

// error-catching custom-preload.js shim.
define("custom-preload", function (require, exports, module) {
try {
var custom = require('custom/custom-preload');
console.debug('loaded custom-preload.js');
return custom;
} catch (e) {
console.error("error loading custom-preload.js", e);
return {};
}
})

document.nbjs_translations = {{ nbjs_translations|safe }};
document.documentElement.lang = navigator.language.toLowerCase();
</script>
Expand Down
5 changes: 4 additions & 1 deletion tools/build-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var rjs_config = {
"xtermjs-fit": 'components/xterm.js-fit/index',
"jquery-typeahead": 'components/jquery-typeahead/dist/jquery.typeahead.min',
contents: 'empty:',
custom: 'empty:',
custom: 'empty:',
'custom-preload': 'empty:',

},
map: { // for backward compatibility
"*": {
Expand Down Expand Up @@ -60,6 +62,7 @@ var rjs_config = {

exclude: [
"custom/custom",
"custom/custom-preload",
]
};

Expand Down