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 var _fn = require('../../utils/fn.js');
15 var Fn = _interopRequireWildcard(_fn);
17 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; } }
19 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
21 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23 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; }
25 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; } /**
26 * @file chapters-track-menu-item.js
31 * The chapter track menu item
35 var ChaptersTrackMenuItem = function (_MenuItem) {
36 _inherits(ChaptersTrackMenuItem, _MenuItem);
39 * Creates an instance of this class.
41 * @param {Player} player
42 * The `Player` that this class should be attached to.
44 * @param {Object} [options]
45 * The key/value store of player options.
47 function ChaptersTrackMenuItem(player, options) {
48 _classCallCheck(this, ChaptersTrackMenuItem);
50 var track = options.track;
51 var cue = options.cue;
52 var currentTime = player.currentTime();
54 // Modify options for parent MenuItem class's init.
55 options.selectable = true;
56 options.label = cue.text;
57 options.selected = cue.startTime <= currentTime && currentTime < cue.endTime;
59 var _this = _possibleConstructorReturn(this, _MenuItem.call(this, player, options));
63 track.addEventListener('cuechange', Fn.bind(_this, _this.update));
68 * This gets called when an `ChaptersTrackMenuItem` is "clicked". See
69 * {@link ClickableComponent} for more detailed information on what a click can be.
71 * @param {EventTarget~Event} [event]
72 * The `keydown`, `tap`, or `click` event that caused this function to be
80 ChaptersTrackMenuItem.prototype.handleClick = function handleClick(event) {
81 _MenuItem.prototype.handleClick.call(this);
82 this.player_.currentTime(this.cue.startTime);
83 this.update(this.cue.startTime);
87 * Update chapter menu item
89 * @param {EventTarget~Event} [event]
90 * The `cuechange` event that caused this function to run.
92 * @listens TextTrack#cuechange
96 ChaptersTrackMenuItem.prototype.update = function update(event) {
98 var currentTime = this.player_.currentTime();
100 // vjs.log(currentTime, cue.startTime);
101 this.selected(cue.startTime <= currentTime && currentTime < cue.endTime);
104 return ChaptersTrackMenuItem;
105 }(_menuItem2['default']);
107 _component2['default'].registerComponent('ChaptersTrackMenuItem', ChaptersTrackMenuItem);
108 exports['default'] = ChaptersTrackMenuItem;