Skip to content

Commit 2f7bbce

Browse files
authored
Center images in sections and add video.js to personalize video controls (#420)
2 parents 58d3acb + f453247 commit 2f7bbce

8 files changed

Lines changed: 150 additions & 14 deletions

File tree

doc/_static/css/custom_styles.css

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
/* Increase bottom margin for images */
7373

7474
section img {
75-
margin-bottom: 1rem;
75+
display: block;
76+
margin: 1rem auto;
7677
}
7778

7879
/* Style for Font Awesome that only styles the icons before elements */
@@ -282,19 +283,6 @@ div.video-container-container + p {
282283
margin-top: 1em;
283284
}
284285

285-
/* Style for video tags */
286-
287-
video {
288-
display: block;
289-
height: auto;
290-
margin-left: auto;
291-
margin-right: auto;
292-
max-width: 100%;
293-
object-fit: contain;
294-
object-position: center;
295-
width: 100%;
296-
}
297-
298286
/* Style for adding icons to the installers table */
299287

300288
table.installer-table td {

doc/_static/css/video-js.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/_static/css/video_player.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* Layout tweaks for sphinxcontrib-video + Video.js (do not override vjs-tech positioning) */
2+
3+
.bd-article .sphinx-contrib-video-container {
4+
clear: both;
5+
display: block;
6+
float: none;
7+
margin: 1.5rem auto;
8+
max-width: 100%;
9+
width: 100%;
10+
}
11+
12+
.bd-article .sphinx-contrib-video-container.align-left,
13+
.bd-article .sphinx-contrib-video-container.align-right {
14+
float: none;
15+
margin-left: auto;
16+
margin-right: auto;
17+
}
18+
19+
.bd-article .sphinx-contrib-video-container .video-js {
20+
max-width: 100%;
21+
width: 100%;
22+
}
23+
24+
/* Keep controls visible (paired with inactivityTimeout: 0 in video_player.js) */
25+
.bd-article .sphinx-contrib-video-container .video-js.vjs-user-inactive .vjs-control-bar {
26+
opacity: 1;
27+
visibility: visible;
28+
}
29+
30+
.bd-article .sphinx-contrib-video-container + p,
31+
.bd-article .sphinx-contrib-video-container + img {
32+
margin-top: 1rem;
33+
}

doc/_static/js/video.min.js

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/_static/js/video_player.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Initialize Video.js on documentation screencasts (sphinxcontrib-video output).
2+
3+
(function () {
4+
"use strict";
5+
6+
const PLAYER_OPTIONS = {
7+
controls: true,
8+
fluid: true,
9+
inactivityTimeout: 0,
10+
preload: "auto",
11+
controlBar: {
12+
children: [
13+
"playToggle",
14+
"volumePanel",
15+
"currentTimeDisplay",
16+
"timeDivider",
17+
"durationDisplay",
18+
"progressControl",
19+
"fullscreenToggle",
20+
],
21+
},
22+
};
23+
24+
function initDocVideos() {
25+
if (typeof videojs === "undefined") {
26+
return;
27+
}
28+
29+
document
30+
.querySelectorAll(".sphinx-contrib-video-container video")
31+
.forEach(function (el) {
32+
if (videojs.getPlayer(el)) {
33+
return;
34+
}
35+
36+
el.classList.add("video-js");
37+
38+
const player = videojs(el, PLAYER_OPTIONS);
39+
40+
player.one("loadedmetadata", function () {
41+
const w = player.videoWidth();
42+
const h = player.videoHeight();
43+
if (w && h) {
44+
player.aspectRatio(w + ":" + h);
45+
}
46+
});
47+
});
48+
}
49+
50+
document.addEventListener("DOMContentLoaded", initDocVideos);
51+
})();

doc/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,16 @@
184184
# Custom CSS for the site
185185
html_css_files = [
186186
"css/driver.min.css",
187+
"css/video-js.min.css",
188+
"css/video_player.css",
187189
"css/custom_styles.css",
188190
]
189191

190192
# Custom Javascript for the site
191193
html_js_files = [
192194
"js/driver.min.js",
195+
"js/video.min.js",
196+
"js/video_player.js",
193197
"js/custom_scripts.js",
194198
"js/language-switcher.js",
195199
]

doc/panes/debugging.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You can fully control debugger execution from the :guilabel:`Debug` menu, :guila
2222

2323
.. video:: /images/debugging/debugging-commands.webm
2424
:loop:
25+
:nocontrols:
2526
:alt: A Spyder IPython console window, showing debugging from toolbar
2627

2728
Additionally, the :ref:`panes-editor` shows the line of code the debugger is currently stopped on with an arrow.
@@ -37,6 +38,7 @@ Use the up and down arrows to recall previous commands, and press :kbd:`Tab` to
3738

3839
.. video:: /images/debugging/debugging-autocompletion.webm
3940
:loop:
41+
:nocontrols:
4042
:alt: A Spyder IPython console window, showing autocompletion when debugging
4143

4244
Furthermore, IPython's `magic functions`_ are available in debugging mode.
@@ -51,6 +53,7 @@ Finally, you can enter and execute multiline statements in Spyder's debugger jus
5153

5254
.. video:: /images/debugging/debugging-multiline.webm
5355
:loop:
56+
:nocontrols:
5457
:alt: Debugger showing multiline debugger
5558

5659

@@ -78,6 +81,7 @@ There are several different ways to set and clear breakpoints:
7881

7982
.. video:: /images/debugging/debugging-breakpoints.webm
8083
:loop:
84+
:nocontrols:
8185
:alt: Spyder showing setting conditional breakpoint
8286

8387
You can access and edit local and global variables at each breakpoint through the :ref:`panes-variables`.
@@ -125,6 +129,7 @@ Use the ``%matplotlib`` magic to change to an interactive backend (e.g. ``%matpl
125129

126130
.. video:: /images/debugging/debugging-matplotlib.webm
127131
:loop:
132+
:nocontrols:
128133
:alt: Debugger showing matplotlib interactive backend
129134

130135

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = [
1515
globals: {
1616
browser: true,
1717
jquery: true,
18+
videojs: "readonly",
1819
},
1920
},
2021
linterOptions: {

0 commit comments

Comments
 (0)