Version 1
[yaffs-website] / node_modules / video.js / es5 / close-button.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _button = require('./button');
6
7 var _button2 = _interopRequireDefault(_button);
8
9 var _component = require('./component');
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 close-button.js
21                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 */
22
23
24 /**
25  * The `CloseButton` is a `{@link Button}` that fires a `close` event when
26  * it gets clicked.
27  *
28  * @extends Button
29  */
30 var CloseButton = function (_Button) {
31   _inherits(CloseButton, _Button);
32
33   /**
34    * Creates an instance of the this class.
35    *
36    * @param  {Player} player
37    *         The `Player` that this class should be attached to.
38    *
39    * @param  {Object} [options]
40    *         The key/value store of player options.
41    */
42   function CloseButton(player, options) {
43     _classCallCheck(this, CloseButton);
44
45     var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
46
47     _this.controlText(options && options.controlText || _this.localize('Close'));
48     return _this;
49   }
50
51   /**
52    * Builds the default DOM `className`.
53    *
54    * @return {string}
55    *         The DOM `className` for this object.
56    */
57
58
59   CloseButton.prototype.buildCSSClass = function buildCSSClass() {
60     return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
61   };
62
63   /**
64    * This gets called when a `CloseButton` gets clicked. See
65    * {@link ClickableComponent#handleClick} for more information on when this will be
66    * triggered
67    *
68    * @param {EventTarget~Event} event
69    *        The `keydown`, `tap`, or `click` event that caused this function to be
70    *        called.
71    *
72    * @listens tap
73    * @listens click
74    * @fires CloseButton#close
75    */
76
77
78   CloseButton.prototype.handleClick = function handleClick(event) {
79
80     /**
81      * Triggered when the a `CloseButton` is clicked.
82      *
83      * @event CloseButton#close
84      * @type {EventTarget~Event}
85      *
86      * @property {boolean} [bubbles=false]
87      *           set to false so that the close event does not
88      *           bubble up to parents if there is no listener
89      */
90     this.trigger({ type: 'close', bubbles: false });
91   };
92
93   return CloseButton;
94 }(_button2['default']);
95
96 _component2['default'].registerComponent('CloseButton', CloseButton);
97 exports['default'] = CloseButton;