Skip to content

Commit

Permalink
✨ Add rule.displaySelectorParents for hide/show
Browse files Browse the repository at this point in the history
  • Loading branch information
richardfrost committed Aug 19, 2022
1 parent 40c6ea7 commit 35b987a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/script/lib/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface AudioRule {
displayElementLevels?: number; // [Watcher] Number of levels (ancestors) to get _displayElement
displayHide?: string; // [Element,ElementChild,Watcher] Display style for hiding captions (Default: 'none')
displaySelector?: string; // [Element,ElementChild,Watcher] Alternate selector to hide/show captions
displaySelectorParents?: number; // [Element,ElementChild,Watcher] Number of levels to go above displaySelector's element
displayShow?: string; // [Element,ElementChild,Watcher] Display style for showing captions (Default: '')
displayVisibility?: boolean; // [Watcher*] Use visibility to show/hide caption container
dynamicClasslist?: string; // [Dynamic] Set when a dynamicTextKey is found
Expand Down
8 changes: 5 additions & 3 deletions src/script/webAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ export default class WebAudio {
} else if (rule.displaySelector) {
const root = rule.rootNode && subtitles && subtitles[0] ? subtitles[0].getRootNode() : document;
if (root) {
const container = getElement(rule.displaySelector, root);
let container = getElement(rule.displaySelector, root);
if (container && rule.displaySelectorParents) container = getParent(container, rule.displaySelectorParents);
if (container) {
// Save the original display style if none was included in the rule
if (
Expand Down Expand Up @@ -922,8 +923,9 @@ export default class WebAudio {
} else if (rule.displaySelector) {
const root = rule.rootNode && subtitles && subtitles[0] ? subtitles[0].getRootNode() : document;
if (root) {
const container = getElement(rule.displaySelector, root);
if (container) { container.style.setProperty('display', rule.displayShow); }
let container = getElement(rule.displaySelector, root);
if (container && rule.displaySelectorParents) container = getParent(container, rule.displaySelectorParents);
if (container) container.style.setProperty('display', rule.displayShow);
}
}
}
Expand Down

0 comments on commit 35b987a

Please sign in to comment.