1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-19 10:54:16 +02:00

fix: don't add captions settings menu item when TextTrackSettings is disabled (#5002)

Removes the CaptionsSettingsMenuItem when TextTrackSettings is not included.

Fixes #4996
This commit is contained in:
Viktor S 2018-03-13 17:03:39 +01:00 committed by Gary Katsevman
parent 43b5a6dc5f
commit ba6a71eb01
3 changed files with 13 additions and 2 deletions

View File

@ -51,7 +51,8 @@ class CaptionsButton extends TextTrackButton {
createItems() {
const items = [];
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks) &&
this.player().getChild('textTrackSettings')) {
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.kind_}));
this.hideThreshold_ += 1;

View File

@ -48,7 +48,8 @@ class SubsCapsButton extends TextTrackButton {
createItems() {
let items = [];
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks) &&
this.player().getChild('textTrackSettings')) {
items.push(new CaptionSettingsMenuItem(this.player_, {kind: this.label_}));
this.hideThreshold_ += 1;

View File

@ -3,6 +3,7 @@ import TextTrackSettings from '../../../src/js/tracks/text-track-settings.js';
import TestHelpers from '../test-helpers.js';
import * as Events from '../../../src/js/utils/events.js';
import safeParseTuple from 'safe-json-parse/tuple';
import sinon from 'sinon';
import window from 'global/window';
import Component from '../../../src/js/component.js';
@ -174,26 +175,34 @@ QUnit.test('should restore default settings', function(assert) {
});
QUnit.test('should open on click', function(assert) {
const clock = sinon.useFakeTimers();
const player = TestHelpers.makePlayer({
tracks
});
clock.tick(1);
Events.trigger(player.$('.vjs-texttrack-settings'), 'click');
assert.ok(!player.textTrackSettings.hasClass('vjs-hidden'), 'settings open');
player.dispose();
clock.restore();
});
QUnit.test('should close on done click', function(assert) {
const clock = sinon.useFakeTimers();
const player = TestHelpers.makePlayer({
tracks
});
clock.tick(1);
Events.trigger(player.$('.vjs-texttrack-settings'), 'click');
Events.trigger(player.$('.vjs-done-button'), 'click');
assert.ok(player.textTrackSettings.hasClass('vjs-hidden'), 'settings closed');
player.dispose();
clock.restore();
});
QUnit.test('if persist option is set, restore settings on init', function(assert) {