Skip to content

Commit db25dcc

Browse files
authored
Merge pull request #1128 from jcb91/bugfix
[various] bugfix toolbar buttons with id
2 parents 58bcf8c + f783aae commit db25dcc

File tree

19 files changed

+67
-92
lines changed

19 files changed

+67
-92
lines changed

src/jupyter_contrib_nbextensions/nbextensions/datestamper/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@ define([
2626
};
2727

2828
var load_ipython_extension = function () {
29-
IPython.toolbar.add_buttons_group([{
30-
id: 'datestamp',
31-
action: IPython.keyboard_manager.actions.register ({
29+
IPython.toolbar.add_buttons_group([
30+
IPython.keyboard_manager.actions.register ({
3231
help : 'insert datestamp',
3332
icon : 'fa-calendar',
3433
handler: datestamp
3534
}, 'insert-datestamp', 'datestamp')
36-
}]);
35+
]);
3736
};
3837

3938
var extension = {

src/jupyter_contrib_nbextensions/nbextensions/equation-numbering/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ define([
1313
var MathJax = window.MathJax;
1414

1515
var load_ipython_extension = function() {
16-
Jupyter.toolbar.add_buttons_group([{
17-
id: 'reset_numbering',
18-
action: Jupyter.keyboard_manager.actions.register ({
16+
var btn_grp = Jupyter.toolbar.add_buttons_group([
17+
Jupyter.keyboard_manager.actions.register ({
1918
help : 'Reset equation numbering',
2019
icon : 'fa-sort-numeric-asc',
2120
handler: function () {
@@ -27,7 +26,8 @@ define([
2726
$('#reset_numbering').blur();
2827
}
2928
}, 'reset-numbering', 'equation_numbering')
30-
}]);
29+
]);
30+
$(btn_grp).find('.btn').attr('id', 'reset_numbering');
3131
MathJax.Hub.Config({
3232
TeX: { equationNumbers: { autoNumber: "AMS" } }
3333
});

src/jupyter_contrib_nbextensions/nbextensions/exercise/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,16 @@ define([
131131
}
132132

133133
function load_ipython_extension(){
134-
IPython.toolbar.add_buttons_group([{
135-
id: 'hide_solutions',
136-
action: IPython.keyboard_manager.actions.register ({
134+
IPython.toolbar.add_buttons_group([
135+
IPython.keyboard_manager.actions.register ({
137136
help : 'Exercise: Create/Remove solutions',
138137
icon : 'fa-mortar-board',
139138
handler : function () {
140139
//console.log(IPython.notebook.get_selected_cells())
141140
hide_solutions();
142141
}
143142
}, 'hide_solutions', 'exercise')
144-
}]);
143+
]);
145144

146145
/**
147146
* load css file and append to document

src/jupyter_contrib_nbextensions/nbextensions/exercise2/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,15 @@ id=\"myCheck' + cbx + '\" >\
127127
}
128128

129129
function load_ipython_extension(){
130-
IPython.toolbar.add_buttons_group([{
131-
id: 'process_solution',
132-
action: IPython.keyboard_manager.actions.register ({
130+
IPython.toolbar.add_buttons_group([
131+
IPython.keyboard_manager.actions.register ({
133132
help : 'Exercise2: Create/Remove solution',
134133
icon : 'fa-toggle-on',
135134
handler : function () {
136135
process_solution();
137136
}
138137
}, 'process_solution', 'exercise2')
139-
}]);
138+
]);
140139

141140

142141

src/jupyter_contrib_nbextensions/nbextensions/export_embedded/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ define([
3333

3434
/* Add also a Button, currently disabled */
3535
/*
36-
Jupyter.toolbar.add_buttons_group([{
37-
id: 'export_embeddedhtml',
38-
action: Jupyter.keyboard_manager.actions.register ({
36+
Jupyter.toolbar.add_buttons_group([
37+
Jupyter.keyboard_manager.actions.register ({
3938
help : 'Embedded HTML Export',
4039
icon : 'fa-save',
4140
handler: function() {
4241
Jupyter.menubar._nbconvert('html_embed', true);
4342
}
4443
}, 'export-embedded-html', 'export_embedded')
45-
}]);
44+
]);
4645
*/
4746
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
4847
// notebook_loaded.Notebook event has already happened

src/jupyter_contrib_nbextensions/nbextensions/freeze/main.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,23 @@ define([
160160
}
161161

162162
function load_extension () {
163-
Jupyter.toolbar.add_buttons_group([{
164-
id: 'make_normal',
165-
action: Jupyter.keyboard_manager.actions.register ({
163+
Jupyter.toolbar.add_buttons_group([
164+
Jupyter.keyboard_manager.actions.register ({
166165
help : 'lift restrictions from selected cells',
167166
icon : 'fa-unlock-alt',
168167
handler : make_normal_selected
169-
}, 'make-cells-normal', mod_name)
170-
}, {
171-
id: 'make_read_only',
172-
action: Jupyter.keyboard_manager.actions.register({
168+
}, 'make-cells-normal', mod_name),
169+
Jupyter.keyboard_manager.actions.register({
173170
help : 'make selected cells read-only',
174171
icon: 'fa-lock',
175172
handler : make_read_only_selected
176173
}, 'make-cells-read-only', mod_name),
177-
}, {
178-
id: 'freeze_cells',
179-
action: Jupyter.keyboard_manager.actions.register({
174+
Jupyter.keyboard_manager.actions.register({
180175
help : 'freeze selected cells',
181176
icon : 'fa-asterisk',
182177
handler : make_frozen_selected
183178
}, 'freeze-cells', mod_name)
184-
}]);
179+
]);
185180

186181
patch_CodeCell_execute();
187182
patch_MarkdownCell_unrender();

src/jupyter_contrib_nbextensions/nbextensions/help_panel/help_panel.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ define([
5353
var initialize = function () {
5454
update_params();
5555
if (params.help_panel_add_toolbar_button) {
56-
IPython.toolbar.add_buttons_group([{
57-
id: 'btn_help_panel',
58-
action: IPython.keyboard_manager.actions.register({
56+
$(IPython.toolbar.add_buttons_group([
57+
IPython.keyboard_manager.actions.register({
5958
help : 'Show help panel',
6059
icon : 'fa-book',
6160
handler: function() {
@@ -64,8 +63,8 @@ define([
6463
setTimeout(function() { btn.blur(); }, 500);
6564
}
6665
}, 'show-help-panel', 'help_panel'),
67-
}]);
68-
$('#btn_help_panel').attr({
66+
])).find('.btn').attr({
67+
id: 'btn_help_panel',
6968
'data-toggle': 'button',
7069
'aria-pressed': 'false'
7170
});

src/jupyter_contrib_nbextensions/nbextensions/hide_input/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@ define([
3030
var load_ipython_extension = function() {
3131

3232
// Add a button to the toolbar
33-
Jupyter.toolbar.add_buttons_group([{
34-
id: 'btn-hide-input',
35-
action: Jupyter.keyboard_manager.actions.register ({
33+
$(Jupyter.toolbar.add_buttons_group([
34+
Jupyter.keyboard_manager.actions.register({
3635
help : 'Toggle selected cell input display',
3736
icon : 'fa-chevron-up',
3837
handler: function() {
3938
toggle_selected_input();
4039
setTimeout(function() { $('#btn-hide-input').blur(); }, 500);
4140
}
4241
}, 'toggle-cell-input-display', 'hide_input')
43-
}]);
42+
])).find('.btn').attr('id', 'btn-hide-input');
4443
// Collapse all cells that are marked as hidden
4544
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
4645
// notebook already loaded. Update directly

src/jupyter_contrib_nbextensions/nbextensions/hide_input_all/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@ define([
3636
}
3737

3838
var load_ipython_extension = function() {
39-
Jupyter.toolbar.add_buttons_group([{
40-
id: 'toggle_codecells',
41-
action: Jupyter.keyboard_manager.actions.register ({
39+
$(Jupyter.toolbar.add_buttons_group([
40+
Jupyter.keyboard_manager.actions.register({
4241
help : 'Hide codecell inputs',
4342
icon : 'fa-eye',
4443
handler: function() {
4544
toggle();
4645
setTimeout(function() { $('#toggle_codecells').blur(); }, 500);
4746
}
4847
}, 'hide-codecell-inputs', 'hide_input_all'),
49-
}]);
48+
])).find('.btn').attr('id', 'toggle_codecells');
5049
if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
5150
// notebook_loaded.Notebook event has already happened
5251
initialize();

src/jupyter_contrib_nbextensions/nbextensions/nbTranslate/main.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,18 @@ define(function(require, exports, module) {
5959

6060
function showToolbar() {
6161
if ($('#showToolbar').length == 0) {
62-
Jupyter.toolbar.add_buttons_group([
63-
{
64-
id: 'showToolbar',
65-
action: Jupyter.keyboard_manager.actions.register ({
66-
'help' : 'Translate current cell',
67-
'icon' : 'fa-language',
68-
'handler': translateCurrentCell,
69-
}, 'translate-cell', 'nbTranslate'),
70-
},
71-
Jupyter.keyboard_manager.actions.register ({
62+
$(Jupyter.toolbar.add_buttons_group([
63+
Jupyter.keyboard_manager.actions.register({
64+
'help' : 'Translate current cell',
65+
'icon' : 'fa-language',
66+
'handler': translateCurrentCell,
67+
}, 'translate-cell', 'nbTranslate'),
68+
Jupyter.keyboard_manager.actions.register({
7269
'help' : 'nbTranslate: Configuration (toggle toolbar)',
7370
'icon' : 'fa-wrench',
7471
'handler': translateToolbarToggle //translateToolbar
7572
}, 'show-nbTranslate-toolbar', 'nbTranslate'),
76-
]);
73+
])).find('.btn').eq(0).attr('id', 'showToolbar');
7774
}
7875
}
7976

0 commit comments

Comments
 (0)