c0d77c11d3f68006428e28d6e4fa3f96551f0349
[yaffs-website] / control-bar / text-track-controls / captions-button.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _textTrackButton = require('./text-track-button.js');
6
7 var _textTrackButton2 = _interopRequireDefault(_textTrackButton);
8
9 var _component = require('../../component.js');
10
11 var _component2 = _interopRequireDefault(_component);
12
13 var _captionSettingsMenuItem = require('./caption-settings-menu-item.js');
14
15 var _captionSettingsMenuItem2 = _interopRequireDefault(_captionSettingsMenuItem);
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 captions-button.js
25                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
26
27
28 /**
29  * The button component for toggling and selecting captions
30  *
31  * @extends TextTrackButton
32  */
33 var CaptionsButton = function (_TextTrackButton) {
34   _inherits(CaptionsButton, _TextTrackButton);
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    * @param {Component~ReadyCallback} [ready]
46    *        The function to call when this component is ready.
47    */
48   function CaptionsButton(player, options, ready) {
49     _classCallCheck(this, CaptionsButton);
50
51     var _this = _possibleConstructorReturn(this, _TextTrackButton.call(this, player, options, ready));
52
53     _this.el_.setAttribute('aria-label', 'Captions Menu');
54     return _this;
55   }
56
57   /**
58    * Builds the default DOM `className`.
59    *
60    * @return {string}
61    *         The DOM `className` for this object.
62    */
63
64
65   CaptionsButton.prototype.buildCSSClass = function buildCSSClass() {
66     return 'vjs-captions-button ' + _TextTrackButton.prototype.buildCSSClass.call(this);
67   };
68
69   /**
70    * Create caption menu items
71    *
72    * @return {CaptionSettingsMenuItem[]}
73    *         The array of current menu items.
74    */
75
76
77   CaptionsButton.prototype.createItems = function createItems() {
78     var items = [];
79
80     if (!(this.player().tech_ && this.player().tech_.featuresNativeTextTracks)) {
81       items.push(new _captionSettingsMenuItem2['default'](this.player_, { kind: this.kind_ }));
82
83       this.hideThreshold_ += 1;
84     }
85
86     return _TextTrackButton.prototype.createItems.call(this, items);
87   };
88
89   return CaptionsButton;
90 }(_textTrackButton2['default']);
91
92 /**
93  * `kind` of TextTrack to look for to associate it with this menu.
94  *
95  * @type {string}
96  * @private
97  */
98
99
100 CaptionsButton.prototype.kind_ = 'captions';
101
102 /**
103  * The text that should display over the `CaptionsButton`s controls. Added for localization.
104  *
105  * @type {string}
106  * @private
107  */
108 CaptionsButton.prototype.controlText_ = 'Captions';
109
110 _component2['default'].registerComponent('CaptionsButton', CaptionsButton);
111 exports['default'] = CaptionsButton;