forked from mne-tools/mne-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ENH: Try envs * FIX: Fix AppVeyor * FIX: Fix GUIs * w * FIX: Skip problematic tests for OSX * FIX: Put PySurfer back * FIX: Fix doc * FIX: Switch to 3.6 * FIX: Fix Travis * STY: Fix naming [ci skip] * FIX: Fix instructions
- Loading branch information
Showing
21 changed files
with
318 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2014 PSF. Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 | ||
// File originates from the cpython source found in Doc/tools/sphinxext/static/copybutton.js | ||
|
||
$(document).ready(function() { | ||
/* Add a [>>>] button on the top-right corner of code samples to hide | ||
* 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'); | ||
|
||
// get the styles from the current theme | ||
pre.parent().parent().css('position', 'relative'); | ||
var hide_text = 'Hide the prompts and output'; | ||
var show_text = 'Show the prompts and output'; | ||
var border_width = pre.css('border-top-width'); | ||
var border_style = pre.css('border-top-style'); | ||
var border_color = pre.css('border-top-color'); | ||
var button_styles = { | ||
'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0', | ||
'border-color': border_color, 'border-style': border_style, | ||
'border-width': border_width, 'color': border_color, 'text-size': '75%', | ||
'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em', | ||
'border-radius': '0 3px 0 0' | ||
} | ||
|
||
// create and add the button to all the code blocks that contain >>> | ||
div.each(function(index) { | ||
var jthis = $(this); | ||
if (jthis.find('.gp').length > 0) { | ||
var button = $('<span class="copybutton">>>></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 | ||
// wrapped in a span to work with .nextUntil() (see later) | ||
jthis.find('pre:has(.gt)').contents().filter(function() { | ||
return ((this.nodeType == 3) && (this.data.trim().length > 0)); | ||
}).wrap('<span>'); | ||
}); | ||
|
||
// define the behavior of the button when it's clicked | ||
$('.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); | ||
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'); | ||
} | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.