summaryrefslogtreecommitdiffstats
path: root/Doc/tools/static/copybutton.js
diff options
context:
space:
mode:
authorJon Wayne Parrott <jonwayne@google.com>2018-03-01 21:02:50 (GMT)
committerNed Deily <nad@python.org>2018-03-01 21:02:50 (GMT)
commitbf63e8d55fd2853df3bb99d66de7f428107aadb3 (patch)
treeaabf6ec691ee99f0cb56fff1a3ac6ee5bb03ea98 /Doc/tools/static/copybutton.js
parent5da8cfb838fa1bf3529c085c6dce1adf3d1eaf62 (diff)
downloadcpython-bf63e8d55fd2853df3bb99d66de7f428107aadb3.zip
cpython-bf63e8d55fd2853df3bb99d66de7f428107aadb3.tar.gz
cpython-bf63e8d55fd2853df3bb99d66de7f428107aadb3.tar.bz2
bpo-30607: Use external python-doc-theme (GH-2017)
Diffstat (limited to 'Doc/tools/static/copybutton.js')
-rw-r--r--Doc/tools/static/copybutton.js62
1 files changed, 0 insertions, 62 deletions
diff --git a/Doc/tools/static/copybutton.js b/Doc/tools/static/copybutton.js
deleted file mode 100644
index 716c9e4..0000000
--- a/Doc/tools/static/copybutton.js
+++ /dev/null
@@ -1,62 +0,0 @@
-$(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-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">&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
- // 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');
- }
- });
-});
-