3 exports.__esModule = true;
5 var _component = require('../../component.js');
7 var _component2 = _interopRequireDefault(_component);
9 var _fn = require('../../utils/fn.js');
11 var Fn = _interopRequireWildcard(_fn);
13 var _formatTime = require('../../utils/format-time.js');
15 var _formatTime2 = _interopRequireDefault(_formatTime);
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 play-progress-bar.js
35 var PlayProgressBar = function (_Component) {
36 _inherits(PlayProgressBar, _Component);
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 PlayProgressBar(player, options) {
48 _classCallCheck(this, PlayProgressBar);
50 var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
52 _this.updateDataAttr();
53 _this.on(player, 'timeupdate', _this.updateDataAttr);
54 player.ready(Fn.bind(_this, _this.updateDataAttr));
56 if (options.playerOptions && options.playerOptions.controlBar && options.playerOptions.controlBar.progressControl && options.playerOptions.controlBar.progressControl.keepTooltipsInside) {
57 _this.keepTooltipsInside = options.playerOptions.controlBar.progressControl.keepTooltipsInside;
60 if (_this.keepTooltipsInside) {
61 _this.addClass('vjs-keep-tooltips-inside');
67 * Create the `Component`'s DOM element
70 * The element that was created.
74 PlayProgressBar.prototype.createEl = function createEl() {
75 return _Component.prototype.createEl.call(this, 'div', {
76 className: 'vjs-play-progress vjs-slider-bar',
77 innerHTML: '<span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
82 * Update the data-current-time attribute on the `PlayProgressBar`.
84 * @param {EventTarget~Event} [event]
85 * The `timeupdate` event that caused this to run.
87 * @listens Player#timeupdate
91 PlayProgressBar.prototype.updateDataAttr = function updateDataAttr(event) {
92 var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
94 this.el_.setAttribute('data-current-time', (0, _formatTime2['default'])(time, this.player_.duration()));
97 return PlayProgressBar;
98 }(_component2['default']);
100 _component2['default'].registerComponent('PlayProgressBar', PlayProgressBar);
101 exports['default'] = PlayProgressBar;