1
0
mirror of https://github.com/videojs/video.js.git synced 2025-02-04 11:43:27 +02:00

fix(a11y): fix hidden Control Text in Progress bar (Fixes #5251) (#5655)

- Update the Control Text in the load-progress-bar during loading, remove unnecessary Control Text from the play-progress-bar, and hide the time-tooltip feature from Assistive Technology using ARIA.
- Add a span around the vjs-control-text-loaded-percentage in load-progress-bar, and use that for the text to update.
- Hide the time-tooltip feature from Assistive Technology using ARIA

Fixes #5251
This commit is contained in:
Owen Edwards 2018-12-11 08:26:12 -08:00 committed by Gary Katsevman
parent 893261186b
commit 70a71ae81e
3 changed files with 19 additions and 6 deletions

View File

@ -35,7 +35,7 @@ class LoadProgressBar extends Component {
createEl() { createEl() {
return super.createEl('div', { return super.createEl('div', {
className: 'vjs-load-progress', className: 'vjs-load-progress',
innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>` innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: <span class="vjs-control-text-loaded-percentage">0%</span></span>`
}); });
} }
@ -59,18 +59,28 @@ class LoadProgressBar extends Component {
const duration = liveTracker.isLive() ? liveTracker.seekableEnd() : this.player_.duration(); const duration = liveTracker.isLive() ? liveTracker.seekableEnd() : this.player_.duration();
const bufferedEnd = this.player_.bufferedEnd(); const bufferedEnd = this.player_.bufferedEnd();
const children = this.partEls_; const children = this.partEls_;
const controlTextPercentage = this.$('.vjs-control-text-loaded-percentage');
// get the percent width of a time compared to the total end // get the percent width of a time compared to the total end
const percentify = function(time, end) { const percentify = function(time, end, rounded) {
// no NaN // no NaN
const percent = (time / end) || 0; let percent = (time / end) || 0;
return ((percent >= 1 ? 1 : percent) * 100) + '%'; percent = (percent >= 1 ? 1 : percent) * 100;
if (rounded) {
percent = percent.toFixed(2);
}
return percent + '%';
}; };
// update the width of the progress bar // update the width of the progress bar
this.el_.style.width = percentify(bufferedEnd, duration); this.el_.style.width = percentify(bufferedEnd, duration);
// update the control-text
Dom.textContent(controlTextPercentage, percentify(bufferedEnd, duration, true));
// add child elements to represent the individual buffered time ranges // add child elements to represent the individual buffered time ranges
for (let i = 0; i < buffered.length; i++) { for (let i = 0; i < buffered.length; i++) {
const start = buffered.start(i); const start = buffered.start(i);

View File

@ -22,8 +22,9 @@ class PlayProgressBar extends Component {
*/ */
createEl() { createEl() {
return super.createEl('div', { return super.createEl('div', {
className: 'vjs-play-progress vjs-slider-bar', className: 'vjs-play-progress vjs-slider-bar'
innerHTML: `<span class="vjs-control-text"><span>${this.localize('Progress')}</span>: 0%</span>` }, {
'aria-hidden': 'true'
}); });
} }

View File

@ -21,6 +21,8 @@ class TimeTooltip extends Component {
createEl() { createEl() {
return super.createEl('div', { return super.createEl('div', {
className: 'vjs-time-tooltip' className: 'vjs-time-tooltip'
}, {
'aria-hidden': 'true'
}); });
} }