annotate Doc/tools/sphinxext/static/copybutton.js @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 76aa98f69251
children ca0230c21c79
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73195
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
1 $(document).ready(function() {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
2 /* Add a [>>>] button on the top-right corner of code samples to hide
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
3 * the >>> and ... prompts and the output and thus make the code
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
4 * copyable. */
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
5 var div = $('.highlight-python .highlight,' +
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
6 '.highlight-python3 .highlight')
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
7 var pre = div.find('pre');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
8
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
9 // get the styles from the current theme
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
10 pre.parent().parent().css('position', 'relative');
74396
76aa98f69251 update part of sphinxext
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73195
diff changeset
11 var hide_text = 'Hide the prompts and output';
76aa98f69251 update part of sphinxext
Sandro Tosi <sandro.tosi@gmail.com>
parents: 73195
diff changeset
12 var show_text = 'Show the prompts and output';
73195
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
13 var border_width = pre.css('border-top-width');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
14 var border_style = pre.css('border-top-style');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
15 var border_color = pre.css('border-top-color');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
16 var button_styles = {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
17 'cursor':'pointer', 'position': 'absolute', 'top': '0', 'right': '0',
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
18 'border-color': border_color, 'border-style': border_style,
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
19 'border-width': border_width, 'color': border_color, 'text-size': '75%',
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
20 'font-family': 'monospace', 'padding-left': '0.2em', 'padding-right': '0.2em'
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
21 }
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
22
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
23 // create and add the button to all the code blocks that contain >>>
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
24 div.each(function(index) {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
25 var jthis = $(this);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
26 if (jthis.find('.gp').length > 0) {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
27 var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
28 button.css(button_styles)
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
29 button.attr('title', hide_text);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
30 jthis.prepend(button);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
31 }
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
32 // tracebacks (.gt) contain bare text elements that need to be
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
33 // wrapped in a span to work with .nextUntil() (see later)
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
34 jthis.find('pre:has(.gt)').contents().filter(function() {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
35 return ((this.nodeType == 3) && (this.data.trim().length > 0));
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
36 }).wrap('<span>');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
37 });
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
38
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
39 // define the behavior of the button when it's clicked
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
40 $('.copybutton').toggle(
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
41 function() {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
42 var button = $(this);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
43 button.parent().find('.go, .gp, .gt').hide();
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
44 button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
45 button.css('text-decoration', 'line-through');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
46 button.attr('title', show_text);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
47 },
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
48 function() {
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
49 var button = $(this);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
50 button.parent().find('.go, .gp, .gt').show();
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
51 button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
52 button.css('text-decoration', 'none');
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
53 button.attr('title', hide_text);
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
54 });
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
55 });
18bbfed9aafa Add a button to the code examples in the doc to show/hide the prompts and output.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
diff changeset
56