summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2017-07-29 01:03:47 +0200
committerGitHub <noreply@github.com>2017-07-29 01:03:47 +0200
commitbc3b4b8383d4cd676fe75b7ca8c3e11d6afa8d97 (patch)
tree82e4533aa467f2a5b9e61448a4ea913d1cdeea25
parent31c86007636790c1b8a6edd29e02d9f0beab250d (diff)
parenta8aa8a6aad1524c9577a861fc4faa82d6c167138 (diff)
downloadscipy-sphinx-theme-bc3b4b8383d4cd676fe75b7ca8c3e11d6afa8d97.tar.gz
Merge pull request #6 from CalebBell/master
Updated copybutton.js to work in recent Sphinx versions
-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');
+ }
+ });
});