-
Notifications
You must be signed in to change notification settings - Fork 0
/
toggle_prompt_input_output.js
81 lines (72 loc) · 2.25 KB
/
toggle_prompt_input_output.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
Jupyter.toolbar.add_buttons_group([
// Toggle prompt
{
'id' : 'toggle_prompt',
'label' : 'Show/hide In[x], Out[x]',
'icon' : 'fa-toggle-left',
'callback': function(){
$('#notebook').find('.prompt').toggle(); // toggle prompt (In[x], Out[x])
}
},
// Toggle current input cell
{
'id' : 'toggle_current_input_cell',
'label' : 'Show/hide current input cell',
'icon' : 'fa-angle-up',
'callback': function(){
var cell = Jupyter.notebook.get_selected_cell();
cell.element.find("div.input").toggle('slow');
cell.metadata.input_collapsed = !cell.metadata.input_collapsed;
}
},
// Toggle current output cell
{
'id' : 'toggle_current_output_cell',
'label' : 'Show/hide current output cell',
'icon' : 'fa-angle-down',
'callback': function(){
var cell = Jupyter.notebook.get_selected_cell();
cell.element.find("div.output").toggle('slow');
cell.metadata.output_collapsed = !cell.metadata.output_collapsed;
}
},
// Toggle all input cells
{
'id' : 'toggle_input',
'label' : 'Show/hide all input cells',
'icon' : 'fa-angle-double-up', //'fa-sign-in',
'callback': function(){
//$('.input').slideToggle()
$('#notebook').find('.input').slideToggle();
}
},
// Toggle all output cells
{
'id' : 'toggle_output',
'label' : 'Show/hide all output cells',
'icon' : 'fa-angle-double-down', //'fa-sign-out',
'callback': function(){
$('#notebook').find('.output').slideToggle();
}
},
// Show all input cells
{
'id' : 'show_input',
'label' : 'Show all input cells',
'icon' : 'fa-arrow-circle-up',
// fa-arrow-circle-o-up, fa-arrow-circle-up, fa-arrow-up, fa-caret-square-o-up, fa-caret-up, fa-chevron-circle-up, fa-chevron-up, fa-long-arrow-up
'callback': function(){
$('#notebook').find('.input').show();
}
},
// Show all output cells
{
'id' : 'show_output',
'label' : 'Show all output cells',
'icon' : 'fa-arrow-circle-down',
'callback': function(){
$('#notebook').find('.output').show();
}
},
])
console.log("Custom buttons to show/hide the input/output and to toggle the In/Out text loaded successfully!");