Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / control-bar / audio-track-controls / audio-track-button.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _trackButton = require('../track-button.js');
6
7 var _trackButton2 = _interopRequireDefault(_trackButton);
8
9 var _component = require('../../component.js');
10
11 var _component2 = _interopRequireDefault(_component);
12
13 var _audioTrackMenuItem = require('./audio-track-menu-item.js');
14
15 var _audioTrackMenuItem2 = _interopRequireDefault(_audioTrackMenuItem);
16
17 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
18
19 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20
21 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; }
22
23 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; } /**
24                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file audio-track-button.js
25                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
26
27
28 /**
29  * The base class for buttons that toggle specific {@link AudioTrack} types.
30  *
31  * @extends TrackButton
32  */
33 var AudioTrackButton = function (_TrackButton) {
34   _inherits(AudioTrackButton, _TrackButton);
35
36   /**
37    * Creates an instance of this class.
38    *
39    * @param {Player} player
40    *        The `Player` that this class should be attached to.
41    *
42    * @param {Object} [options={}]
43    *        The key/value store of player options.
44    */
45   function AudioTrackButton(player) {
46     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
47
48     _classCallCheck(this, AudioTrackButton);
49
50     options.tracks = player.audioTracks && player.audioTracks();
51
52     var _this = _possibleConstructorReturn(this, _TrackButton.call(this, player, options));
53
54     _this.el_.setAttribute('aria-label', 'Audio Menu');
55     return _this;
56   }
57
58   /**
59    * Builds the default DOM `className`.
60    *
61    * @return {string}
62    *         The DOM `className` for this object.
63    */
64
65
66   AudioTrackButton.prototype.buildCSSClass = function buildCSSClass() {
67     return 'vjs-audio-button ' + _TrackButton.prototype.buildCSSClass.call(this);
68   };
69
70   /**
71    * Create a menu item for each audio track
72    *
73    * @param {AudioTrackMenuItem[]} [items=[]]
74    *        An array of existing menu items to use.
75    *
76    * @return {AudioTrackMenuItem[]}
77    *         An array of menu items
78    */
79
80
81   AudioTrackButton.prototype.createItems = function createItems() {
82     var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
83
84     // if there's only one audio track, there no point in showing it
85     this.hideThreshold_ = 1;
86
87     var tracks = this.player_.audioTracks && this.player_.audioTracks();
88
89     if (!tracks) {
90       return items;
91     }
92
93     for (var i = 0; i < tracks.length; i++) {
94       var track = tracks[i];
95
96       items.push(new _audioTrackMenuItem2['default'](this.player_, {
97         track: track,
98         // MenuItem is selectable
99         selectable: true
100       }));
101     }
102
103     return items;
104   };
105
106   return AudioTrackButton;
107 }(_trackButton2['default']);
108
109 /**
110  * The text that should display over the `AudioTrackButton`s controls. Added for localization.
111  *
112  * @type {string}
113  * @private
114  */
115
116
117 AudioTrackButton.prototype.controlText_ = 'Audio Track';
118 _component2['default'].registerComponent('AudioTrackButton', AudioTrackButton);
119 exports['default'] = AudioTrackButton;