3 exports.__esModule = true;
5 var _slider = require('../../slider/slider.js');
7 var _slider2 = _interopRequireDefault(_slider);
9 var _component = require('../../component.js');
11 var _component2 = _interopRequireDefault(_component);
13 var _fn = require('../../utils/fn.js');
15 var Fn = _interopRequireWildcard(_fn);
17 require('./volume-level.js');
19 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; } }
21 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
23 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25 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; }
27 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; } /**
36 * The bar that contains the volume level and can be clicked on to adjust the level
40 var VolumeBar = function (_Slider) {
41 _inherits(VolumeBar, _Slider);
44 * Creates an instance of this class.
46 * @param {Player} player
47 * The `Player` that this class should be attached to.
49 * @param {Object} [options]
50 * The key/value store of player options.
52 function VolumeBar(player, options) {
53 _classCallCheck(this, VolumeBar);
55 var _this = _possibleConstructorReturn(this, _Slider.call(this, player, options));
57 _this.on(player, 'volumechange', _this.updateARIAAttributes);
58 player.ready(Fn.bind(_this, _this.updateARIAAttributes));
63 * Create the `Component`'s DOM element
66 * The element that was created.
70 VolumeBar.prototype.createEl = function createEl() {
71 return _Slider.prototype.createEl.call(this, 'div', {
72 className: 'vjs-volume-bar vjs-slider-bar'
74 'aria-label': 'volume level'
79 * Handle movement events on the {@link VolumeMenuButton}.
81 * @param {EventTarget~Event} event
82 * The event that caused this function to run.
88 VolumeBar.prototype.handleMouseMove = function handleMouseMove(event) {
90 this.player_.volume(this.calculateDistance(event));
94 * If the player is muted unmute it.
98 VolumeBar.prototype.checkMuted = function checkMuted() {
99 if (this.player_.muted()) {
100 this.player_.muted(false);
105 * Get percent of volume level
108 * Volume level percent as a decimal number.
112 VolumeBar.prototype.getPercent = function getPercent() {
113 if (this.player_.muted()) {
116 return this.player_.volume();
120 * Increase volume level for keyboard users
124 VolumeBar.prototype.stepForward = function stepForward() {
126 this.player_.volume(this.player_.volume() + 0.1);
130 * Decrease volume level for keyboard users
134 VolumeBar.prototype.stepBack = function stepBack() {
136 this.player_.volume(this.player_.volume() - 0.1);
140 * Update ARIA accessibility attributes
142 * @param {EventTarget~Event} [event]
143 * The `volumechange` event that caused this function to run.
145 * @listens Player#volumechange
149 VolumeBar.prototype.updateARIAAttributes = function updateARIAAttributes(event) {
150 // Current value of volume bar as a percentage
151 var volume = (this.player_.volume() * 100).toFixed(2);
153 this.el_.setAttribute('aria-valuenow', volume);
154 this.el_.setAttribute('aria-valuetext', volume + '%');
158 }(_slider2['default']);
161 * Default options for the `VolumeBar`
168 VolumeBar.prototype.options_ = {
169 children: ['volumeLevel'],
170 barName: 'volumeLevel'
174 * Call the update event for this Slider when this event happens on the player.
178 VolumeBar.prototype.playerEvent = 'volumechange';
180 _component2['default'].registerComponent('VolumeBar', VolumeBar);
181 exports['default'] = VolumeBar;