close-button.js 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _button = require('./button');
  4. var _button2 = _interopRequireDefault(_button);
  5. var _component = require('./component');
  6. var _component2 = _interopRequireDefault(_component);
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9. 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; }
  10. 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; } /**
  11. * @file close-button.js
  12. */
  13. /**
  14. * The `CloseButton` is a `{@link Button}` that fires a `close` event when
  15. * it gets clicked.
  16. *
  17. * @extends Button
  18. */
  19. var CloseButton = function (_Button) {
  20. _inherits(CloseButton, _Button);
  21. /**
  22. * Creates an instance of the this class.
  23. *
  24. * @param {Player} player
  25. * The `Player` that this class should be attached to.
  26. *
  27. * @param {Object} [options]
  28. * The key/value store of player options.
  29. */
  30. function CloseButton(player, options) {
  31. _classCallCheck(this, CloseButton);
  32. var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
  33. _this.controlText(options && options.controlText || _this.localize('Close'));
  34. return _this;
  35. }
  36. /**
  37. * Builds the default DOM `className`.
  38. *
  39. * @return {string}
  40. * The DOM `className` for this object.
  41. */
  42. CloseButton.prototype.buildCSSClass = function buildCSSClass() {
  43. return 'vjs-close-button ' + _Button.prototype.buildCSSClass.call(this);
  44. };
  45. /**
  46. * This gets called when a `CloseButton` gets clicked. See
  47. * {@link ClickableComponent#handleClick} for more information on when this will be
  48. * triggered
  49. *
  50. * @param {EventTarget~Event} event
  51. * The `keydown`, `tap`, or `click` event that caused this function to be
  52. * called.
  53. *
  54. * @listens tap
  55. * @listens click
  56. * @fires CloseButton#close
  57. */
  58. CloseButton.prototype.handleClick = function handleClick(event) {
  59. /**
  60. * Triggered when the a `CloseButton` is clicked.
  61. *
  62. * @event CloseButton#close
  63. * @type {EventTarget~Event}
  64. *
  65. * @property {boolean} [bubbles=false]
  66. * set to false so that the close event does not
  67. * bubble up to parents if there is no listener
  68. */
  69. this.trigger({ type: 'close', bubbles: false });
  70. };
  71. return CloseButton;
  72. }(_button2['default']);
  73. _component2['default'].registerComponent('CloseButton', CloseButton);
  74. exports['default'] = CloseButton;