Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(subs-caps-button): captions items should hide icon from SR #4158

Merged
merged 3 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/css/components/_control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
width: 4em;
@include flex(none);

& .vjs-icon-placeholder:before {
& > .vjs-icon-placeholder:before {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it so that only direct descendants of vjs-control gets these defaults for icon-placeholder.
In IE11, with the subs-caps menu, the icon-placeholder gets this font-size and the font-size from below applied in that order, so, the menu ends up overflowing and disappearing or looking weird.

font-size: 1.8em;
line-height: 1.67;

Expand Down
9 changes: 6 additions & 3 deletions src/css/components/_subs-caps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
@extend .vjs-icon-subtitles;
}

.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text:after {
content: " \f10d";
.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text .vjs-icon-placeholder {
position: absolute;
}
.video-js .vjs-subs-caps-button + .vjs-menu .vjs-captions-menu-item .vjs-menu-item-text .vjs-icon-placeholder:before {
font-family: VideoJS;
vertical-align: bottom;
content: "\f10d";
font-size: 1.5em;
line-height: inherit;
}
3 changes: 2 additions & 1 deletion src/js/control-bar/text-track-controls/subs-caps-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import TextTrackButton from './text-track-button.js';
import Component from '../../component.js';
import CaptionSettingsMenuItem from './caption-settings-menu-item.js';
import SubsCapsMenuItem from './subs-caps-menu-item.js';
import toTitleCase from '../../utils/to-title-case.js';
/**
* The button component for toggling and selecting captions and/or subtitles
Expand Down Expand Up @@ -79,7 +80,7 @@ class SubsCapsButton extends TextTrackButton {
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.label_}));
}

items = super.createItems(items);
items = super.createItems(items, SubsCapsMenuItem);
return items;
}

Expand Down
37 changes: 37 additions & 0 deletions src/js/control-bar/text-track-controls/subs-caps-menu-item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file subs-caps-menu-item.js
*/
import TextTrackMenuItem from './text-track-menu-item.js';
import Component from '../../component.js';
import {assign} from '../../utils/obj';

/**
* SubsCapsMenuItem has an [cc] icon to distinguish captions from subtitles
* in the SubsCapsMenu.
*
* @extends TextTrackMenuItem
*/
class SubsCapsMenuItem extends TextTrackMenuItem {

createEl(type, props, attrs) {
let innerHTML = `<span class="vjs-menu-item-text">${this.localize(this.options_.label)}`;

if (this.options_.track.kind === 'captions') {
innerHTML += `
<span aria-hidden="true" class="vjs-icon-placeholder"></span>
<span class="vjs-control-text"> ${this.localize('Captions')}</span>
`;
}

innerHTML += '</span>';

const el = super.createEl(type, assign({
innerHTML
}, props), attrs);

return el;
}
}

Component.registerComponent('SubsCapsMenuItem', SubsCapsMenuItem);
export default SubsCapsMenuItem;
4 changes: 2 additions & 2 deletions src/js/control-bar/text-track-controls/text-track-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class TextTrackButton extends TrackButton {
* @return {TextTrackMenuItem[]}
* Array of menu items that were created
*/
createItems(items = []) {
createItems(items = [], TrackMenuItem = TextTrackMenuItem) {

// Label is an overide for the [track] off label
// USed to localise captions/subtitles
Expand All @@ -64,7 +64,7 @@ class TextTrackButton extends TrackButton {

// only add tracks that are of an appropriate kind and have a label
if (this.kinds_.indexOf(track.kind) > -1) {
const item = new TextTrackMenuItem(this.player_, {
const item = new TrackMenuItem(this.player_, {
track,
// MenuItem is selectable
selectable: true
Expand Down