##// END OF EJS Templates
Merge pull request #8036 from jtyberg/8035_custom_js...
Matthias Bussonnier -
r20681:fce658d1 merge
parent child Browse files
Show More
@@ -1,82 +1,82 b''
1 // leave at least 2 line with only a star on it below, or doc generation fails
1 // leave at least 2 line with only a star on it below, or doc generation fails
2 /**
2 /**
3 *
3 *
4 *
4 *
5 * Placeholder for custom user javascript
5 * Placeholder for custom user javascript
6 * mainly to be overridden in profile/static/custom/custom.js
6 * mainly to be overridden in profile/static/custom/custom.js
7 * This will always be an empty file in IPython
7 * This will always be an empty file in IPython
8 *
8 *
9 * User could add any javascript in the `profile/static/custom/custom.js` file
9 * User could add any javascript in the `profile/static/custom/custom.js` file
10 * (and should create it if it does not exist).
10 * (and should create it if it does not exist).
11 * It will be executed by the ipython notebook at load time.
11 * It will be executed by the ipython notebook at load time.
12 *
12 *
13 * Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook.
13 * Same thing with `profile/static/custom/custom.css` to inject custom css into the notebook.
14 *
14 *
15 * Classes and functions are available at load time and may be accessed plainly:
15 * Classes and functions are available at load time and may be accessed plainly:
16 *
16 *
17 * IPython.Cell.options_default.cm_config.extraKeys['Home'] = 'goLineLeft';
17 * IPython.Cell.options_default.cm_config.extraKeys['Home'] = 'goLineLeft';
18 * IPython.Cell.options_default.cm_config.extraKeys['End'] = 'goLineRight';
18 * IPython.Cell.options_default.cm_config.extraKeys['End'] = 'goLineRight';
19 *
19 *
20 * Instances are created later however and must be accessed using events:
20 * Instances are created later however and must be accessed using events:
21 * require([
21 * define([
22 * 'base/js/namespace',
22 * 'base/js/namespace',
23 * 'base/js/events'
23 * 'base/js/events'
24 * ], function(IPython, events) {
24 * ], function(IPython, events) {
25 * events.on("app_initialized.NotebookApp", function () {
25 * events.on("app_initialized.NotebookApp", function () {
26 * IPython.keyboard_manager....
26 * IPython.keyboard_manager....
27 * });
27 * });
28 * });
28 * });
29 *
29 *
30 * __Example 1:__
30 * __Example 1:__
31 *
31 *
32 * Create a custom button in toolbar that execute `%qtconsole` in kernel
32 * Create a custom button in toolbar that execute `%qtconsole` in kernel
33 * and hence open a qtconsole attached to the same kernel as the current notebook
33 * and hence open a qtconsole attached to the same kernel as the current notebook
34 *
34 *
35 * require([
35 * define([
36 * 'base/js/namespace',
36 * 'base/js/namespace',
37 * 'base/js/events'
37 * 'base/js/events'
38 * ], function(IPython, events) {
38 * ], function(IPython, events) {
39 * events.on('app_initialized.NotebookApp', function(){
39 * events.on('app_initialized.NotebookApp', function(){
40 * IPython.toolbar.add_buttons_group([
40 * IPython.toolbar.add_buttons_group([
41 * {
41 * {
42 * 'label' : 'run qtconsole',
42 * 'label' : 'run qtconsole',
43 * 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
43 * 'icon' : 'icon-terminal', // select your icon from http://fortawesome.github.io/Font-Awesome/icons
44 * 'callback': function () {
44 * 'callback': function () {
45 * IPython.notebook.kernel.execute('%qtconsole')
45 * IPython.notebook.kernel.execute('%qtconsole')
46 * }
46 * }
47 * }
47 * }
48 * // add more button here if needed.
48 * // add more button here if needed.
49 * ]);
49 * ]);
50 * });
50 * });
51 * });
51 * });
52 *
52 *
53 * __Example 2:__
53 * __Example 2:__
54 *
54 *
55 * At the completion of the dashboard loading, load an unofficial javascript extension
55 * At the completion of the dashboard loading, load an unofficial javascript extension
56 * that is installed in profile/static/custom/
56 * that is installed in profile/static/custom/
57 *
57 *
58 * require([
58 * define([
59 * 'base/js/events'
59 * 'base/js/events'
60 * ], function(events) {
60 * ], function(events) {
61 * events.on('app_initialized.DashboardApp', function(){
61 * events.on('app_initialized.DashboardApp', function(){
62 * require(['custom/unofficial_extension.js'])
62 * require(['custom/unofficial_extension.js'])
63 * });
63 * });
64 * });
64 * });
65 *
65 *
66 * __Example 3:__
66 * __Example 3:__
67 *
67 *
68 * Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );`
68 * Use `jQuery.getScript(url [, success(script, textStatus, jqXHR)] );`
69 * to load custom script into the notebook.
69 * to load custom script into the notebook.
70 *
70 *
71 * // to load the metadata ui extension example.
71 * // to load the metadata ui extension example.
72 * $.getScript('/static/notebook/js/celltoolbarpresets/example.js');
72 * $.getScript('/static/notebook/js/celltoolbarpresets/example.js');
73 * // or
73 * // or
74 * // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert
74 * // to load the metadata ui extension to control slideshow mode / reveal js for nbconvert
75 * $.getScript('/static/notebook/js/celltoolbarpresets/slideshow.js');
75 * $.getScript('/static/notebook/js/celltoolbarpresets/slideshow.js');
76 *
76 *
77 *
77 *
78 * @module IPython
78 * @module IPython
79 * @namespace IPython
79 * @namespace IPython
80 * @class customjs
80 * @class customjs
81 * @static
81 * @static
82 */
82 */
General Comments 0
You need to be logged in to leave comments. Login now