Skip to content

Commit 3aa4242

Browse files
committed
[ExecuteTime] Bugfixes for menu items
* Fix the toggle visibility, which was returning too early :/ * Don't prevent click-event propagation, as otherwise it prevents the menu from closing. * add href to submenu to get correct cursor. Add click handler to prevent following the href :P
1 parent c082b94 commit 3aa4242

File tree

1 file changed

+4
-6
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/execute_time

1 file changed

+4
-6
lines changed

src/jupyter_contrib_nbextensions/nbextensions/execute_time/ExecuteTime.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ define([
102102
vis = !timing_area.is(':visible');
103103
}
104104
timing_area.toggle(vis);
105-
return vis;
106105
}
107106
}
108107
}
108+
return vis;
109109
}
110110

111111
function clear_timing_data (cells) {
@@ -125,7 +125,9 @@ define([
125125
var timings_menu_item = $('<li/>')
126126
.addClass('dropdown-submenu')
127127
.append(
128-
$('<a/>').text('Execution Timings')
128+
$('<a href="#">')
129+
.text('Execution Timings')
130+
.on('click', function (evt) { evt.preventDefault(); })
129131
)
130132
.appendTo($('#cell_menu'));
131133

@@ -140,7 +142,6 @@ define([
140142
.text('Toggle visibility (selected)')
141143
.on('click', function (evt) {
142144
evt.preventDefault();
143-
evt.stopPropagation();
144145
toggle_timing_display(Jupyter.notebook.get_selected_cells());
145146
})
146147
)
@@ -153,7 +154,6 @@ define([
153154
.text('Toggle visibility (all)')
154155
.on('click', function (evt) {
155156
evt.preventDefault();
156-
evt.stopPropagation();
157157
toggle_timing_display(Jupyter.notebook.get_cells());
158158
})
159159
)
@@ -166,7 +166,6 @@ define([
166166
.text('Clear (selected)')
167167
.on('click', function (evt) {
168168
evt.preventDefault();
169-
evt.stopPropagation();
170169
clear_timing_data(Jupyter.notebook.get_selected_cells());
171170
})
172171
)
@@ -179,7 +178,6 @@ define([
179178
.text('Clear (all)')
180179
.on('click', function (evt) {
181180
evt.preventDefault();
182-
evt.stopPropagation();
183181
clear_timing_data(Jupyter.notebook.get_cells());
184182
})
185183
)

0 commit comments

Comments
 (0)