playable
Version:
Video player based on HTML5Video
120 lines • 4.26 kB
JavaScript
"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 keyboard_interceptor_1 = (0, tslib_1.__importStar)(require("../../../../utils/keyboard-interceptor"));
var constants_1 = require("../../../../constants");
var logo_view_1 = (0, tslib_1.__importDefault)(require("./logo.view"));
var Logo = /** @class */ (function () {
function Logo(_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();
}
Logo.prototype.getElement = function () {
return this.view.getElement();
};
Logo.prototype._bindCallbacks = function () {
this._triggerCallback = this._triggerCallback.bind(this);
};
Logo.prototype._initUI = function () {
var config = {
theme: this._theme,
callbacks: {
onLogoClick: this._triggerCallback,
},
textMap: this._textMap,
tooltipService: this._tooltipService,
};
this.view = new Logo.View(config);
};
Logo.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));
};
Logo.prototype._destroyInterceptor = function () {
this._interceptor.destroy();
};
Logo.prototype._triggerCallback = function () {
if (this._callback) {
this._callback();
}
};
/**
* Method for setting source of image, that would be used as logo
* @param src - Source of logo
* @example
* player.setLogo('https://example.com/logo.png');
*
*/
Logo.prototype.setLogo = function (src) {
this._logoSrc = src;
this.view.setLogo(this._logoSrc);
this._setProperDisplayState();
};
/**
* Method for attaching callback for click on logo
*
* @param callback - Your function
*
* @example
* const callback = () => {
* console.log('Click on title);
* }
* player.setLogoClickCallback(callback);
*
*/
Logo.prototype.setLogoClickCallback = function (callback) {
this._callback = callback;
this._setProperDisplayState();
};
Logo.prototype._setProperDisplayState = function () {
if (this._callback) {
this._logoSrc ? this.view.showAsInput() : this.view.showAsButton();
}
else {
this._logoSrc ? this.view.showAsImage() : this.view.showAsButton();
}
};
Logo.prototype.hide = function () {
this.isHidden = true;
this.view.hide();
};
Logo.prototype.show = function () {
this.isHidden = false;
this.view.show();
};
Logo.prototype.destroy = function () {
this._destroyInterceptor();
this.view.destroy();
};
Logo.moduleName = 'logo';
Logo.View = logo_view_1.default;
Logo.dependencies = ['eventEmitter', 'textMap', 'tooltipService', 'theme'];
(0, tslib_1.__decorate)([
(0, player_api_decorator_1.default)()
], Logo.prototype, "setLogo", null);
(0, tslib_1.__decorate)([
(0, player_api_decorator_1.default)()
], Logo.prototype, "setLogoClickCallback", null);
return Logo;
}());
exports.default = Logo;
//# sourceMappingURL=logo.js.map