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