summaryrefslogtreecommitdiff
path: root/_theme/scipy/static/js/copybutton.js
diff options
context:
space:
mode:
Diffstat (limited to '_theme/scipy/static/js/copybutton.js')
-rw-r--r--_theme/scipy/static/js/copybutton.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/_theme/scipy/static/js/copybutton.js b/_theme/scipy/static/js/copybutton.js
index ace6922..01ee2ba 100644
--- a/_theme/scipy/static/js/copybutton.js
+++ b/_theme/scipy/static/js/copybutton.js
@@ -6,6 +6,7 @@ $(document).ready(function() {
* the >>> and ... prompts and the output and thus make the code
* copyable. */
var div = $('.highlight-python .highlight,' +
+ '.highlight-default .highlight,' +
'.highlight-python3 .highlight')
var pre = div.find('pre');
@@ -31,6 +32,7 @@ $(document).ready(function() {
var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
button.css(button_styles)
button.attr('title', hide_text);
+ button.data('hidden', 'false');
jthis.prepend(button);
}
// tracebacks (.gt) contain bare text elements that need to be
@@ -41,20 +43,24 @@ $(document).ready(function() {
});
// define the behavior of the button when it's clicked
- $('.copybutton').toggle(
- function() {
- var button = $(this);
+ $('.copybutton').click(function(e){
+ e.preventDefault();
+ var button = $(this);
+ if (button.data('hidden') === 'false') {
+ // hide the code output
button.parent().find('.go, .gp, .gt').hide();
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
button.css('text-decoration', 'line-through');
button.attr('title', show_text);
- },
- function() {
- var button = $(this);
+ button.data('hidden', 'true');
+ } else {
+ // show the code output
button.parent().find('.go, .gp, .gt').show();
button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
button.css('text-decoration', 'none');
button.attr('title', hide_text);
- });
+ button.data('hidden', 'false');
+ }
+ });
});