custom.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // leave at least 2 line with only a star on it below, or doc generation fails
  2. /**
  3. *
  4. *
  5. * Placeholder for custom user javascript
  6. * mainly to be overridden in profile/static/custom/custom.js
  7. * This will always be an empty file in IPython
  8. *
  9. * User could add any javascript in the `profile/static/custom/custom.js` file.
  10. * It will be executed by the ipython notebook at load time.
  11. *
  12. * Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook.
  13. *
  14. *
  15. * The object available at load time depend on the version of IPython in use.
  16. * there is no guaranties of API stability.
  17. *
  18. * The example below explain the principle, and might not be valid.
  19. *
  20. * Instances are created after the loading of this file and might need to be accessed using events:
  21. * define([
  22. * 'base/js/namespace',
  23. * 'base/js/promises'
  24. * ], function(IPython, promises) {
  25. * promises.app_initialized.then(function (appName) {
  26. * if (appName !== 'NotebookApp') return;
  27. * IPython.keyboard_manager....
  28. * });
  29. * });
  30. *
  31. * __Example 1:__
  32. *
  33. * Create a custom button in toolbar that execute `%qtconsole` in kernel
  34. * and hence open a qtconsole attached to the same kernel as the current notebook
  35. *
  36. * define([
  37. * 'base/js/namespace',
  38. * 'base/js/promises'
  39. * ], function(IPython, promises) {
  40. * promises.app_initialized.then(function (appName) {
  41. * if (appName !== 'NotebookApp') return;
  42. * IPython.toolbar.add_buttons_group([
  43. * {
  44. * 'label' : 'run qtconsole',
  45. * 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
  46. * 'callback': function () {
  47. * IPython.notebook.kernel.execute('%qtconsole')
  48. * }
  49. * }
  50. * // add more button here if needed.
  51. * ]);
  52. * });
  53. * });
  54. *
  55. * __Example 2:__
  56. *
  57. * At the completion of the dashboard loading, load an unofficial javascript extension
  58. * that is installed in profile/static/custom/
  59. *
  60. * define([
  61. * 'base/js/events'
  62. * ], function(events) {
  63. * events.on('app_initialized.DashboardApp', function(){
  64. * requirejs(['custom/unofficial_extension.js'])
  65. * });
  66. * });
  67. *
  68. *
  69. *
  70. * @module IPython
  71. * @namespace IPython
  72. * @class customjs
  73. * @static
  74. */