Skip to content

Commit

Permalink
adds new file custom-preload that is loaded in a different order befo…
Browse files Browse the repository at this point in the history
…re the main.js script is executed
  • Loading branch information
lneves12 committed Oct 11, 2022
1 parent f456061 commit 85c68b1
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 2 deletions.
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

0 comments on commit 85c68b1

Please sign in to comment.