112309222454e9b2838500d4085db5319b987fc6
[yaffs-website] / node_modules / video.js / es5 / control-bar / volume-control / volume-control.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _component = require('../../component.js');
6
7 var _component2 = _interopRequireDefault(_component);
8
9 require('./volume-bar.js');
10
11 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
12
13 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
15 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; }
16
17 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; } /**
18                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file volume-control.js
19                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
20
21
22 // Required children
23
24
25 /**
26  * The component for controlling the volume level
27  *
28  * @extends Component
29  */
30 var VolumeControl = function (_Component) {
31   _inherits(VolumeControl, _Component);
32
33   /**
34    * Creates an instance of this class.
35    *
36    * @param {Player} player
37    *        The `Player` that this class should be attached to.
38    *
39    * @param {Object} [options={}]
40    *        The key/value store of player options.
41    */
42   function VolumeControl(player, options) {
43     _classCallCheck(this, VolumeControl);
44
45     // hide volume controls when they're not supported by the current tech
46     var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
47
48     if (player.tech_ && player.tech_.featuresVolumeControl === false) {
49       _this.addClass('vjs-hidden');
50     }
51     _this.on(player, 'loadstart', function () {
52       if (player.tech_.featuresVolumeControl === false) {
53         this.addClass('vjs-hidden');
54       } else {
55         this.removeClass('vjs-hidden');
56       }
57     });
58     return _this;
59   }
60
61   /**
62    * Create the `Component`'s DOM element
63    *
64    * @return {Element}
65    *         The element that was created.
66    */
67
68
69   VolumeControl.prototype.createEl = function createEl() {
70     return _Component.prototype.createEl.call(this, 'div', {
71       className: 'vjs-volume-control vjs-control'
72     });
73   };
74
75   return VolumeControl;
76 }(_component2['default']);
77
78 /**
79  * Default options for the `VolumeControl`
80  *
81  * @type {Object}
82  * @private
83  */
84
85
86 VolumeControl.prototype.options_ = {
87   children: ['volumeBar']
88 };
89
90 _component2['default'].registerComponent('VolumeControl', VolumeControl);
91 exports['default'] = VolumeControl;