Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / control-bar / live-display.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _component = require('../component');
6
7 var _component2 = _interopRequireDefault(_component);
8
9 var _dom = require('../utils/dom.js');
10
11 var Dom = _interopRequireWildcard(_dom);
12
13 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; } }
14
15 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
16
17 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
19 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; }
20
21 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; } /**
22                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file live-display.js
23                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
24
25
26 // TODO - Future make it click to snap to live
27
28 /**
29  * Displays the live indicator when duration is Infinity.
30  *
31  * @extends Component
32  */
33 var LiveDisplay = function (_Component) {
34   _inherits(LiveDisplay, _Component);
35
36   /**
37    * Creates an instance of this class.
38    *
39    * @param {Player} player
40    *        The `Player` that this class should be attached to.
41    *
42    * @param {Object} [options]
43    *        The key/value store of player options.
44    */
45   function LiveDisplay(player, options) {
46     _classCallCheck(this, LiveDisplay);
47
48     var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
49
50     _this.updateShowing();
51     _this.on(_this.player(), 'durationchange', _this.updateShowing);
52     return _this;
53   }
54
55   /**
56    * Create the `Component`'s DOM element
57    *
58    * @return {Element}
59    *         The element that was created.
60    */
61
62
63   LiveDisplay.prototype.createEl = function createEl() {
64     var el = _Component.prototype.createEl.call(this, 'div', {
65       className: 'vjs-live-control vjs-control'
66     });
67
68     this.contentEl_ = Dom.createEl('div', {
69       className: 'vjs-live-display',
70       innerHTML: '<span class="vjs-control-text">' + this.localize('Stream Type') + '</span>' + this.localize('LIVE')
71     }, {
72       'aria-live': 'off'
73     });
74
75     el.appendChild(this.contentEl_);
76     return el;
77   };
78
79   /**
80    * Check the duration to see if the LiveDisplay should be showing or not. Then show/hide
81    * it accordingly
82    *
83    * @param {EventTarget~Event} [event]
84    *        The {@link Player#durationchange} event that caused this function to run.
85    *
86    * @listens Player#durationchange
87    */
88
89
90   LiveDisplay.prototype.updateShowing = function updateShowing(event) {
91     if (this.player().duration() === Infinity) {
92       this.show();
93     } else {
94       this.hide();
95     }
96   };
97
98   return LiveDisplay;
99 }(_component2['default']);
100
101 _component2['default'].registerComponent('LiveDisplay', LiveDisplay);
102 exports['default'] = LiveDisplay;