Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / popup / popup-button.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _clickableComponent = require('../clickable-component.js');
6
7 var _clickableComponent2 = _interopRequireDefault(_clickableComponent);
8
9 var _component = require('../component.js');
10
11 var _component2 = _interopRequireDefault(_component);
12
13 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
14
15 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
17 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; }
18
19 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; } /**
20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file popup-button.js
21                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
22
23
24 /**
25  * A button class for use with {@link Popup} controls
26  *
27  * @extends ClickableComponent
28  */
29 var PopupButton = function (_ClickableComponent) {
30   _inherits(PopupButton, _ClickableComponent);
31
32   /**
33    * Create an instance of this class.
34    *
35    * @param {Player} player
36    *        The `Player` that this class should be attached to.
37    *
38    * @param {Object} [options]
39    *        The key/value store of player options.
40    */
41   function PopupButton(player) {
42     var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
44     _classCallCheck(this, PopupButton);
45
46     var _this = _possibleConstructorReturn(this, _ClickableComponent.call(this, player, options));
47
48     _this.update();
49     return _this;
50   }
51
52   /**
53    * Update the `Popup` that this button is attached to.
54    */
55
56
57   PopupButton.prototype.update = function update() {
58     var popup = this.createPopup();
59
60     if (this.popup) {
61       this.removeChild(this.popup);
62     }
63
64     this.popup = popup;
65     this.addChild(popup);
66
67     if (this.items && this.items.length === 0) {
68       this.hide();
69     } else if (this.items && this.items.length > 1) {
70       this.show();
71     }
72   };
73
74   /**
75    * Create a `Popup`. - Override with specific functionality for component
76    *
77    * @abstract
78    */
79
80
81   PopupButton.prototype.createPopup = function createPopup() {};
82
83   /**
84    * Create the `PopupButton`s DOM element.
85    *
86    * @return {Element}
87    *         The element that gets created.
88    */
89
90
91   PopupButton.prototype.createEl = function createEl() {
92     return _ClickableComponent.prototype.createEl.call(this, 'div', {
93       className: this.buildCSSClass()
94     });
95   };
96
97   /**
98    * Builds the default DOM `className`.
99    *
100    * @return {string}
101    *         The DOM `className` for this object.
102    */
103
104
105   PopupButton.prototype.buildCSSClass = function buildCSSClass() {
106     var menuButtonClass = 'vjs-menu-button';
107
108     // If the inline option is passed, we want to use different styles altogether.
109     if (this.options_.inline === true) {
110       menuButtonClass += '-inline';
111     } else {
112       menuButtonClass += '-popup';
113     }
114
115     return 'vjs-menu-button ' + menuButtonClass + ' ' + _ClickableComponent.prototype.buildCSSClass.call(this);
116   };
117
118   return PopupButton;
119 }(_clickableComponent2['default']);
120
121 _component2['default'].registerComponent('PopupButton', PopupButton);
122 exports['default'] = PopupButton;