Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / control-bar / time-controls / remaining-time-display.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 _dom = require('../../utils/dom.js');
10
11 var Dom = _interopRequireWildcard(_dom);
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 remaining-time-display.js
27                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
28
29
30 /**
31  * Displays the time left in the video
32  *
33  * @extends Component
34  */
35 var RemainingTimeDisplay = function (_Component) {
36   _inherits(RemainingTimeDisplay, _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 RemainingTimeDisplay(player, options) {
48     _classCallCheck(this, RemainingTimeDisplay);
49
50     var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
51
52     _this.on(player, 'timeupdate', _this.updateContent);
53     _this.on(player, 'durationchange', _this.updateContent);
54     return _this;
55   }
56
57   /**
58    * Create the `Component`'s DOM element
59    *
60    * @return {Element}
61    *         The element that was created.
62    */
63
64
65   RemainingTimeDisplay.prototype.createEl = function createEl() {
66     var el = _Component.prototype.createEl.call(this, 'div', {
67       className: 'vjs-remaining-time vjs-time-control vjs-control'
68     });
69
70     this.contentEl_ = Dom.createEl('div', {
71       className: 'vjs-remaining-time-display',
72       // label the remaining time for screen reader users
73       innerHTML: '<span class="vjs-control-text">' + this.localize('Remaining Time') + '</span> -0:00'
74     }, {
75       // tell screen readers not to automatically read the time as it changes
76       'aria-live': 'off'
77     });
78
79     el.appendChild(this.contentEl_);
80     return el;
81   };
82
83   /**
84    * Update remaining time display.
85    *
86    * @param {EventTarget~Event} [event]
87    *        The `timeupdate` or `durationchange` event that caused this to run.
88    *
89    * @listens Player#timeupdate
90    * @listens Player#durationchange
91    */
92
93
94   RemainingTimeDisplay.prototype.updateContent = function updateContent(event) {
95     if (this.player_.duration()) {
96       var localizedText = this.localize('Remaining Time');
97       var formattedTime = (0, _formatTime2['default'])(this.player_.remainingTime());
98
99       if (formattedTime !== this.formattedTime_) {
100         this.formattedTime_ = formattedTime;
101         this.contentEl_.innerHTML = '<span class="vjs-control-text">' + localizedText + '</span> -' + formattedTime;
102       }
103     }
104
105     // Allows for smooth scrubbing, when player can't keep up.
106     // var time = (this.player_.scrubbing()) ? this.player_.getCache().currentTime : this.player_.currentTime();
107     // this.contentEl_.innerHTML = vjs.formatTime(time, this.player_.duration());
108   };
109
110   return RemainingTimeDisplay;
111 }(_component2['default']);
112
113 _component2['default'].registerComponent('RemainingTimeDisplay', RemainingTimeDisplay);
114 exports['default'] = RemainingTimeDisplay;