3 exports.__esModule = true;
5 var _menuItem = require('../../menu/menu-item.js');
7 var _menuItem2 = _interopRequireDefault(_menuItem);
9 var _component = require('../../component.js');
11 var _component2 = _interopRequireDefault(_component);
13 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
15 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17 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; }
19 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; } /**
20 * @file playback-rate-menu-item.js
25 * The specific menu item type for selecting a playback rate.
29 var PlaybackRateMenuItem = function (_MenuItem) {
30 _inherits(PlaybackRateMenuItem, _MenuItem);
33 * Creates an instance of this class.
35 * @param {Player} player
36 * The `Player` that this class should be attached to.
38 * @param {Object} [options]
39 * The key/value store of player options.
41 function PlaybackRateMenuItem(player, options) {
42 _classCallCheck(this, PlaybackRateMenuItem);
44 var label = options.rate;
45 var rate = parseFloat(label, 10);
47 // Modify options for parent MenuItem class's init.
48 options.label = label;
49 options.selected = rate === 1;
50 options.selectable = true;
52 var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
57 _this.on(player, 'ratechange', _this.update);
62 * This gets called when an `PlaybackRateMenuItem` is "clicked". See
63 * {@link ClickableComponent} for more detailed information on what a click can be.
65 * @param {EventTarget~Event} [event]
66 * The `keydown`, `tap`, or `click` event that caused this function to be
74 PlaybackRateMenuItem.prototype.handleClick = function handleClick(event) {
75 _MenuItem.prototype.handleClick.call(this);
76 this.player().playbackRate(this.rate);
80 * Update the PlaybackRateMenuItem when the playbackrate changes.
82 * @param {EventTarget~Event} [event]
83 * The `ratechange` event that caused this function to run.
85 * @listens Player#ratechange
89 PlaybackRateMenuItem.prototype.update = function update(event) {
90 this.selected(this.player().playbackRate() === this.rate);
93 return PlaybackRateMenuItem;
94 }(_menuItem2['default']);
97 * The text that should display over the `PlaybackRateMenuItem`s controls. Added for localization.
104 PlaybackRateMenuItem.prototype.contentElType = 'button';
106 _component2['default'].registerComponent('PlaybackRateMenuItem', PlaybackRateMenuItem);
107 exports['default'] = PlaybackRateMenuItem;