error-display.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. 'use strict';
  2. exports.__esModule = true;
  3. var _component = require('./component');
  4. var _component2 = _interopRequireDefault(_component);
  5. var _modalDialog = require('./modal-dialog');
  6. var _modalDialog2 = _interopRequireDefault(_modalDialog);
  7. var _mergeOptions = require('./utils/merge-options');
  8. var _mergeOptions2 = _interopRequireDefault(_mergeOptions);
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11. 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; }
  12. 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; } /**
  13. * @file error-display.js
  14. */
  15. /**
  16. * A display that indicates an error has occurred. This means that the video
  17. * is unplayable.
  18. *
  19. * @extends ModalDialog
  20. */
  21. var ErrorDisplay = function (_ModalDialog) {
  22. _inherits(ErrorDisplay, _ModalDialog);
  23. /**
  24. * Creates an instance of this class.
  25. *
  26. * @param {Player} player
  27. * The `Player` that this class should be attached to.
  28. *
  29. * @param {Object} [options]
  30. * The key/value store of player options.
  31. */
  32. function ErrorDisplay(player, options) {
  33. _classCallCheck(this, ErrorDisplay);
  34. var _this = _possibleConstructorReturn(this, _ModalDialog.call(this, player, options));
  35. _this.on(player, 'error', _this.open);
  36. return _this;
  37. }
  38. /**
  39. * Builds the default DOM `className`.
  40. *
  41. * @return {string}
  42. * The DOM `className` for this object.
  43. *
  44. * @deprecated Since version 5.
  45. */
  46. ErrorDisplay.prototype.buildCSSClass = function buildCSSClass() {
  47. return 'vjs-error-display ' + _ModalDialog.prototype.buildCSSClass.call(this);
  48. };
  49. /**
  50. * Gets the localized error message based on the `Player`s error.
  51. *
  52. * @return {string}
  53. * The `Player`s error message localized or an empty string.
  54. */
  55. ErrorDisplay.prototype.content = function content() {
  56. var error = this.player().error();
  57. return error ? this.localize(error.message) : '';
  58. };
  59. return ErrorDisplay;
  60. }(_modalDialog2['default']);
  61. /**
  62. * The default options for an `ErrorDisplay`.
  63. *
  64. * @private
  65. */
  66. ErrorDisplay.prototype.options_ = (0, _mergeOptions2['default'])(_modalDialog2['default'].prototype.options_, {
  67. pauseOnOpen: false,
  68. fillAlways: true,
  69. temporary: false,
  70. uncloseable: true
  71. });
  72. _component2['default'].registerComponent('ErrorDisplay', ErrorDisplay);
  73. exports['default'] = ErrorDisplay;