Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / control-bar / progress-control / tooltip-progress-bar.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _component = require('../../component.js');
6
7 var _component2 = _interopRequireDefault(_component);
8
9 var _fn = require('../../utils/fn.js');
10
11 var Fn = _interopRequireWildcard(_fn);
12
13 var _formatTime = require('../../utils/format-time.js');
14
15 var _formatTime2 = _interopRequireDefault(_formatTime);
16
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; } }
18
19 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
20
21 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
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; }
24
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
27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
28
29
30 /**
31  * Shows play progress
32  *
33  * @extends Component
34  */
35 var TooltipProgressBar = function (_Component) {
36   _inherits(TooltipProgressBar, _Component);
37
38   /**
39    * Creates an instance of this class.
40    *
41    * @param {Player} player
42    *        The `Player` that this class should be attached to.
43    *
44    * @param {Object} [options]
45    *        The key/value store of player options.
46    */
47   function TooltipProgressBar(player, options) {
48     _classCallCheck(this, TooltipProgressBar);
49
50     var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
51
52     _this.updateDataAttr();
53     _this.on(player, 'timeupdate', _this.updateDataAttr);
54     player.ready(Fn.bind(_this, _this.updateDataAttr));
55     return _this;
56   }
57
58   /**
59    * Create the `Component`'s DOM element
60    *
61    * @return {Element}
62    *         The element that was created.
63    */
64
65
66   TooltipProgressBar.prototype.createEl = function createEl() {
67     var el = _Component.prototype.createEl.call(this, 'div', {
68       className: 'vjs-tooltip-progress-bar vjs-slider-bar',
69       innerHTML: '<div class="vjs-time-tooltip"></div>\n        <span class="vjs-control-text"><span>' + this.localize('Progress') + '</span>: 0%</span>'
70     });
71
72     this.tooltip = el.querySelector('.vjs-time-tooltip');
73
74     return el;
75   };
76
77   /**
78    * Updatet the data-current-time attribute for TooltipProgressBar
79    *
80    * @param {EventTarget~Event} [event]
81    *        The `timeupdate` event that caused this function to run.
82    *
83    * @listens Player#timeupdate
84    */
85
86
87   TooltipProgressBar.prototype.updateDataAttr = function updateDataAttr(event) {
88     var time = this.player_.scrubbing() ? this.player_.getCache().currentTime : this.player_.currentTime();
89     var formattedTime = (0, _formatTime2['default'])(time, this.player_.duration());
90
91     this.el_.setAttribute('data-current-time', formattedTime);
92     this.tooltip.innerHTML = formattedTime;
93   };
94
95   return TooltipProgressBar;
96 }(_component2['default']);
97
98 _component2['default'].registerComponent('TooltipProgressBar', TooltipProgressBar);
99 exports['default'] = TooltipProgressBar;