3 exports.__esModule = true;
5 var _textTrackButton = require('./text-track-button.js');
7 var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
9 var _component = require('../../component.js');
11 var _component2 = _interopRequireDefault(_component);
13 var _fn = require('../../utils/fn.js');
15 var Fn = _interopRequireWildcard(_fn);
17 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
19 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
21 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23 function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
25 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
26 * @file descriptions-button.js
31 * The button component for toggling and selecting descriptions
33 * @extends TextTrackButton
35 var DescriptionsButton = function (_TextTrackButton) {
36 _inherits(DescriptionsButton, _TextTrackButton);
39 * Creates an instance of this class.
41 * @param {Player} player
42 * The `Player` that this class should be attached to.
44 * @param {Object} [options]
45 * The key/value store of player options.
47 * @param {Component~ReadyCallback} [ready]
48 * The function to call when this component is ready.
50 function DescriptionsButton(player, options, ready) {
51 _classCallCheck(this, DescriptionsButton);
53 var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
55 _this.el_.setAttribute('aria-label', 'Descriptions Menu');
57 var tracks = player.textTracks();
60 var changeHandler = Fn.bind(_this, _this.handleTracksChange);
62 tracks.addEventListener('change', changeHandler);
63 _this.on('dispose', function () {
64 tracks.removeEventListener('change', changeHandler);
71 * Handle text track change
73 * @param {EventTarget~Event} event
74 * The event that caused this function to run
76 * @listens TextTrackList#change
80 DescriptionsButton.prototype.handleTracksChange = function handleTracksChange(event) {
81 var tracks = this.player().textTracks();
84 // Check whether a track of a different kind is showing
85 for (var i = 0, l = tracks.length; i < l; i++) {
86 var track = tracks[i];
88 if (track.kind !== this.kind_ && track.mode === 'showing') {
94 // If another track is showing, disable this menu button
103 * Builds the default DOM `className`.
106 * The DOM `className` for this object.
110 DescriptionsButton.prototype.buildCSSClass = function buildCSSClass() {
111 return 'vjs-descriptions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
114 return DescriptionsButton;
115 }(_textTrackButton2['default']);
118 * `kind` of TextTrack to look for to associate it with this menu.
125 DescriptionsButton.prototype.kind_ = 'descriptions';
128 * The text that should display over the `DescriptionsButton`s controls. Added for localization.
133 DescriptionsButton.prototype.controlText_ = 'Descriptions';
135 _component2['default'].registerComponent('DescriptionsButton', DescriptionsButton);
136 exports['default'] = DescriptionsButton;