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