mirror of
https://github.com/discourse/discourse.git
synced 2025-03-04 18:29:20 +00:00
A11Y: add keyboard support to youtube embeds (#18710)
This commit is contained in:
parent
0a33c507d9
commit
595fc3ef22
plugins/lazy-yt/assets
@ -51,7 +51,7 @@ export default function initLazyYt($) {
|
|||||||
//
|
//
|
||||||
// This HTML will be placed inside 'lazyYT' container
|
// This HTML will be placed inside 'lazyYT' container
|
||||||
|
|
||||||
innerHtml.push('<div class="ytp-thumbnail">');
|
innerHtml.push('<div class="ytp-thumbnail" tabIndex="0">');
|
||||||
|
|
||||||
// Play button from YouTube (exactly as it is in YouTube)
|
// Play button from YouTube (exactly as it is in YouTube)
|
||||||
innerHtml.push('<div class="ytp-large-play-button"');
|
innerHtml.push('<div class="ytp-large-play-button"');
|
||||||
@ -135,7 +135,11 @@ export default function initLazyYt($) {
|
|||||||
$thumb = $el
|
$thumb = $el
|
||||||
.find(".ytp-thumbnail")
|
.find(".ytp-thumbnail")
|
||||||
.addClass("lazyYT-image-loaded")
|
.addClass("lazyYT-image-loaded")
|
||||||
.on("click", function (e) {
|
.on("keypress click", function (e) {
|
||||||
|
// Only support Enter for keypress
|
||||||
|
if (e.type === "keypress" && e.keyCode !== 13) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
@ -113,6 +113,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lazyYT-image-loaded:hover .ytp-large-play-button-svg,
|
.lazyYT-image-loaded:hover .ytp-large-play-button-svg,
|
||||||
|
.lazyYT-image-loaded:focus .ytp-large-play-button-svg,
|
||||||
.ytp-large-play-button:focus .ytp-large-play-button-svg {
|
.ytp-large-play-button:focus .ytp-large-play-button-svg {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
fill: #cc181e;
|
fill: #cc181e;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user