Aria tidy up

This commit is contained in:
Sam Potts
2015-02-28 17:00:40 +11:00
parent b2ffd7d3ca
commit 30d6a0cd5f
9 changed files with 34 additions and 28 deletions

View File

@ -1,6 +1,6 @@
// ==========================================================================
// Plyr
// plyr.js v1.0.15
// plyr.js v1.0.16
// https://github.com/sampotts/plyr
// ==========================================================================
// Credits: http://paypal.github.io/accessible-html5-video-player/
@ -432,11 +432,8 @@
// Need to do a default?
var html = config.html;
// Replace aria label instances
html = _replaceAll(html, "{aria-label}", config.playAriaLabel);
// Replace seek time instances
html = _replaceAll(html, "{seek-time}", config.seekTime);
html = _replaceAll(html, "{seektime}", config.seekTime);
// Replace all id references
html = _replaceAll(html, "{id}", player.random);
@ -490,6 +487,18 @@
}
}
// Setup aria attributes
function _setupAria() {
var label = player.buttons.play.innerText;
// If there's a media title set, use that for the label
if (typeof(config.title) !== "undefined" && config.title.length) {
label = player.buttons.play.innerText + ", " + config.title;
}
player.buttons.play.setAttribute("aria-label", label);
}
// Setup media
function _setupMedia() {
player.media = player.container.querySelectorAll("audio, video")[0];
@ -1058,14 +1067,6 @@
return false;
}
// Set up aria-label for Play button with the title option
if (typeof(config.title) === "undefined" || !config.title.length) {
config.playAriaLabel = "Play";
}
else {
config.playAriaLabel = "Play " + config.title;
}
// Setup media
_setupMedia();
@ -1080,6 +1081,9 @@
return false;
}
// Set up aria-label for Play button with the title option
_setupAria();
// Captions
_setupCaptions();