UNPKG

playable

Version:

Video player based on HTML5Video

89 lines 3.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var player_api_decorator_1 = (0, tslib_1.__importDefault)(require("../../../../core/player-api-decorator")); var constants_1 = require("../../../../constants"); var keyboard_interceptor_1 = (0, tslib_1.__importStar)(require("../../../../utils/keyboard-interceptor")); var download_view_1 = (0, tslib_1.__importDefault)(require("./download.view")); var DownloadButton = /** @class */ (function () { function DownloadButton(_a) { var eventEmitter = _a.eventEmitter, textMap = _a.textMap, tooltipService = _a.tooltipService, theme = _a.theme; this._eventEmitter = eventEmitter; this._textMap = textMap; this._theme = theme; this._tooltipService = tooltipService; this._bindCallbacks(); this._initUI(); this._initInterceptor(); } DownloadButton.prototype.getElement = function () { return this.view.getElement(); }; DownloadButton.prototype._bindCallbacks = function () { this._triggerCallback = this._triggerCallback.bind(this); }; DownloadButton.prototype._initUI = function () { var config = { callbacks: { onButtonClick: this._triggerCallback, }, textMap: this._textMap, tooltipService: this._tooltipService, theme: this._theme, }; this.view = new DownloadButton.View(config); }; DownloadButton.prototype._initInterceptor = function () { var _a; var _this = this; this._interceptor = new keyboard_interceptor_1.default(this.getElement(), (_a = {}, _a[keyboard_interceptor_1.KEYCODES.SPACE_BAR] = function (e) { e.stopPropagation(); _this._eventEmitter.emitAsync(constants_1.UIEvent.KEYBOARD_KEYDOWN_INTERCEPTED); _this._triggerCallback(); }, _a[keyboard_interceptor_1.KEYCODES.ENTER] = function (e) { e.stopPropagation(); _this._eventEmitter.emitAsync(constants_1.UIEvent.KEYBOARD_KEYDOWN_INTERCEPTED); _this._triggerCallback(); }, _a)); }; DownloadButton.prototype._destroyInterceptor = function () { this._interceptor.destroy(); }; DownloadButton.prototype._triggerCallback = function () { if (this._callback) { this._callback(); } }; /** * If download button presented, set callback on click * @example * player.setDownloadClickCallback(() => console.log('handle download logic')); */ DownloadButton.prototype.setDownloadClickCallback = function (callback) { this._callback = callback; }; DownloadButton.prototype.hide = function () { this.isHidden = true; this.view.hide(); }; DownloadButton.prototype.show = function () { this.isHidden = false; this.view.show(); }; DownloadButton.prototype.destroy = function () { this._destroyInterceptor(); this.view.destroy(); }; DownloadButton.moduleName = 'downloadButton'; DownloadButton.View = download_view_1.default; DownloadButton.dependencies = ['eventEmitter', 'textMap', 'tooltipService', 'theme']; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], DownloadButton.prototype, "setDownloadClickCallback", null); return DownloadButton; }()); exports.default = DownloadButton; //# sourceMappingURL=download.js.map