Skip to content

Commit 90ba2ca

Browse files
committed
#26246: update copybutton.js after JQuery update. Patch by Liang-Bo Wang.
1 parent 9491272 commit 90ba2ca

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Doc/tools/static/copybutton.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,24 @@ $(document).ready(function() {
3838
});
3939

4040
// define the behavior of the button when it's clicked
41-
$('.copybutton').toggle(
42-
function() {
43-
var button = $(this);
41+
$('.copybutton').click(function(e){
42+
e.preventDefault();
43+
var button = $(this);
44+
if (button.data('hidden') === 'false') {
45+
// hide the code output
4446
button.parent().find('.go, .gp, .gt').hide();
4547
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
4648
button.css('text-decoration', 'line-through');
4749
button.attr('title', show_text);
48-
},
49-
function() {
50-
var button = $(this);
50+
button.data('hidden', 'true');
51+
} else {
52+
// show the code output
5153
button.parent().find('.go, .gp, .gt').show();
5254
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
5355
button.css('text-decoration', 'none');
5456
button.attr('title', hide_text);
55-
});
57+
button.data('hidden', 'false');
58+
}
59+
});
5660
});
5761

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ Kevin Walzer
14781478
Rodrigo Steinmuller Wanderley
14791479
Dingyuan Wang
14801480
Ke Wang
1481+
Liang-Bo Wang
14811482
Greg Ward
14821483
Tom Wardill
14831484
Zachary Ware

0 commit comments

Comments
 (0)