Show More
@@ -0,0 +1,58 b'' | |||||
|
1 | //---------------------------------------------------------------------------- | |||
|
2 | // Copyright (C) 2012 The IPython Development Team | |||
|
3 | // | |||
|
4 | // Distributed under the terms of the BSD License. The full license is in | |||
|
5 | // the file COPYING, distributed as part of this software. | |||
|
6 | //---------------------------------------------------------------------------- | |||
|
7 | ||||
|
8 | //============================================================================ | |||
|
9 | //CellToolbar Example | |||
|
10 | //============================================================================ | |||
|
11 | ||||
|
12 | /** | |||
|
13 | * $.getScript('/static/js/celltoolbarpresets/slideshow.js'); | |||
|
14 | * ``` | |||
|
15 | * or more generally | |||
|
16 | * ``` | |||
|
17 | * $.getScript('url to this file'); | |||
|
18 | * ``` | |||
|
19 | */ | |||
|
20 | // IIFE without asignement, we don't modifiy the IPython namespace | |||
|
21 | (function (IPython) { | |||
|
22 | "use strict"; | |||
|
23 | ||||
|
24 | var CellToolbar = IPython.CellToolbar; | |||
|
25 | var slideshow_preset = []; | |||
|
26 | ||||
|
27 | var select_type = CellToolbar.utils.select_ui_generator([ | |||
|
28 | ["-" ,undefined ], | |||
|
29 | ["Slide" ,"slide" ], | |||
|
30 | ["Sub-Slide" ,"subslide" ], | |||
|
31 | ["Fragment" ,"fragment" ], | |||
|
32 | ["Skip" ,"skip" ], | |||
|
33 | ["Notes" ,"notes" ], | |||
|
34 | ], | |||
|
35 | // setter | |||
|
36 | function(cell, value){ | |||
|
37 | // we check that the slideshow namespace exist and create it if needed | |||
|
38 | if (cell.metadata.slideshow == undefined){cell.metadata.slideshow = {}} | |||
|
39 | // set the value | |||
|
40 | cell.metadata.slideshow.slide_type = value | |||
|
41 | }, | |||
|
42 | //geter | |||
|
43 | function(cell){ var ns = cell.metadata.slideshow; | |||
|
44 | // if the slideshow namespace does not exist return `undefined` | |||
|
45 | // (will be interpreted as `false` by checkbox) otherwise | |||
|
46 | // return the value | |||
|
47 | return (ns == undefined)? undefined: ns.slide_type | |||
|
48 | }, | |||
|
49 | "Slide Type"); | |||
|
50 | ||||
|
51 | CellToolbar.register_callback('slideshow.select',select_type); | |||
|
52 | ||||
|
53 | slideshow_preset.push('slideshow.select'); | |||
|
54 | ||||
|
55 | CellToolbar.register_preset('Slideshow',slideshow_preset); | |||
|
56 | console.log('Slideshow extension for metadata editing loaded.'); | |||
|
57 | ||||
|
58 | }(IPython)); |
@@ -225,5 +225,6 b' data-notebook-id={{notebook_id}}' | |||||
225 | <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script> |
|
225 | <script src="{{ static_url("js/contexthint.js") }}" charset="utf-8"></script> | |
226 |
|
226 | |||
227 | <script src="{{ static_url("js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script> |
|
227 | <script src="{{ static_url("js/celltoolbarpresets/default.js") }}" type="text/javascript" charset="utf-8"></script> | |
|
228 | <script src="{{ static_url("js/celltoolbarpresets/slideshow.js") }}" type="text/javascript" charset="utf-8"></script> | |||
228 |
|
229 | |||
229 | {% endblock %} |
|
230 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now