Skip to content

Commit

Permalink
Updated cusomtization file to work with updated ableplayer.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltan-dulac committed Feb 5, 2025
1 parent c6ab4c4 commit 9fbbdeb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
25 changes: 16 additions & 9 deletions js/modules/ablePlayerCustomizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,26 @@ function ablePlayerCustomizations($, extraCustomizations) {
// set before audio description functionality is initialized. After
// initialization, adjust layout of page if transcript is visible.
AblePlayer.prototype.initDescription = function() {
let deferred = new $.Deferred();
let promise = deferred.promise();

setDescriptionCookies();
this.oldInitDescription();
adjustTranscriptVisibility(this);


// Ensure all media players have a unique aria-label
const ariaLabels = [ 'video player', 'audio player'];
for (let i=0; i<ariaLabels.length; i++) {
const query = `[aria-label="${ariaLabels[i]}"]`;
document.querySelectorAll(query).forEach((el, j) => {
el.setAttribute('aria-label', `${ariaLabels[i]} ${j}`);
});
}
// Ensure all media players have a unique aria-label
const ariaLabels = [ 'video player', 'audio player'];
for (let i=0; i<ariaLabels.length; i++) {
const query = `[aria-label="${ariaLabels[i]}"]`;
document.querySelectorAll(query).forEach((el, j) => {
el.setAttribute('aria-label', `${ariaLabels[i]} ${j}`);
});
}


deferred.resolve();
return promise;
}

// Resolves issue where transcript visibility is not set properly when only captions are present.
Expand Down Expand Up @@ -115,6 +122,6 @@ function ablePlayerCustomizations($, extraCustomizations) {

}

//ablePlayerCustomizations(jQuery);
ablePlayerCustomizations(jQuery);

export { ablePlayerCustomizations, AblePlayerInstances };
27 changes: 18 additions & 9 deletions js/modules/es4/ablePlayerCustomizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,26 @@ function ablePlayerCustomizations($, extraCustomizations) {
// set before audio description functionality is initialized. After
// initialization, adjust layout of page if transcript is visible.
AblePlayer.prototype.initDescription = function() {
let deferred = new $.Deferred();
let promise = deferred.promise();

setDescriptionCookies();
this.oldInitDescription();
adjustTranscriptVisibility(this);


// Ensure all media players have a unique aria-label
const ariaLabels = [ 'video player', 'audio player'];
for (let i=0; i<ariaLabels.length; i++) {
const query = `[aria-label="${ariaLabels[i]}"]`;
document.querySelectorAll(query).forEach((el, j) => {
el.setAttribute('aria-label', `${ariaLabels[i]} ${j}`);
});
}
// Ensure all media players have a unique aria-label
const ariaLabels = [ 'video player', 'audio player'];
for (let i=0; i<ariaLabels.length; i++) {
const query = `[aria-label="${ariaLabels[i]}"]`;
document.querySelectorAll(query).forEach((el, j) => {
el.setAttribute('aria-label', `${ariaLabels[i]} ${j}`);
});
}


deferred.resolve();
return promise;
}

// Resolves issue where transcript visibility is not set properly when only captions are present.
Expand Down Expand Up @@ -109,4 +116,6 @@ function ablePlayerCustomizations($, extraCustomizations) {
extraCustomizations();
}

}
}

ablePlayerCustomizations(jQuery);

0 comments on commit 9fbbdeb

Please sign in to comment.