Security update for Core, with self-updated composer
[yaffs-website] / node_modules / video.js / es5 / popup / popup.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 _fn = require('../utils/fn.js');
14
15 var Fn = _interopRequireWildcard(_fn);
16
17 var _events = require('../utils/events.js');
18
19 var Events = _interopRequireWildcard(_events);
20
21 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; } }
22
23 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
24
25 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
26
27 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; }
28
29 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; } /**
30                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 * @file popup.js
31                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
32
33
34 /**
35  * The Popup component is used to build pop up controls.
36  *
37  * @extends Component
38  */
39 var Popup = function (_Component) {
40   _inherits(Popup, _Component);
41
42   function Popup() {
43     _classCallCheck(this, Popup);
44
45     return _possibleConstructorReturn(this, _Component.apply(this, arguments));
46   }
47
48   /**
49    * Add a popup item to the popup
50    *
51    * @param {Object|string} component
52    *        Component or component type to add
53    *
54    */
55   Popup.prototype.addItem = function addItem(component) {
56     this.addChild(component);
57     component.on('click', Fn.bind(this, function () {
58       this.unlockShowing();
59     }));
60   };
61
62   /**
63    * Create the `PopupButton`s DOM element.
64    *
65    * @return {Element}
66    *         The element that gets created.
67    */
68
69
70   Popup.prototype.createEl = function createEl() {
71     var contentElType = this.options_.contentElType || 'ul';
72
73     this.contentEl_ = Dom.createEl(contentElType, {
74       className: 'vjs-menu-content'
75     });
76
77     var el = _Component.prototype.createEl.call(this, 'div', {
78       append: this.contentEl_,
79       className: 'vjs-menu'
80     });
81
82     el.appendChild(this.contentEl_);
83
84     // Prevent clicks from bubbling up. Needed for Popup Buttons,
85     // where a click on the parent is significant
86     Events.on(el, 'click', function (event) {
87       event.preventDefault();
88       event.stopImmediatePropagation();
89     });
90
91     return el;
92   };
93
94   return Popup;
95 }(_component2['default']);
96
97 _component2['default'].registerComponent('Popup', Popup);
98 exports['default'] = Popup;