playable
Version:
Video player based on HTML5Video
117 lines • 4.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var constants_1 = require("../../../../constants");
var view_1 = (0, tslib_1.__importDefault)(require("../../core/view"));
var templates_1 = require("./templates");
var htmlToElement_1 = (0, tslib_1.__importDefault)(require("../../core/htmlToElement"));
var logo_theme_1 = (0, tslib_1.__importDefault)(require("./logo.theme"));
var logo_scss_1 = (0, tslib_1.__importDefault)(require("./logo.scss"));
var LogoView = /** @class */ (function (_super) {
(0, tslib_1.__extends)(LogoView, _super);
function LogoView(config) {
var _this = this;
var callbacks = config.callbacks, textMap = config.textMap, tooltipService = config.tooltipService, theme = config.theme;
_this = _super.call(this, theme) || this;
_this._callbacks = callbacks;
_this._textMap = textMap;
_this._$rootElement = (0, htmlToElement_1.default)((0, templates_1.logoTemplate)({
styles: _this.styleNames,
texts: {
label: _this._textMap.get(constants_1.TextLabel.LOGO_LABEL),
},
}));
_this._$logoImage = (0, htmlToElement_1.default)((0, templates_1.logoImageTemplate)({
styles: _this.styleNames,
texts: {
label: _this._textMap.get(constants_1.TextLabel.LOGO_LABEL),
},
}));
_this._$logoInput = (0, htmlToElement_1.default)((0, templates_1.logoInputTemplate)({
styles: _this.styleNames,
texts: {
label: _this._textMap.get(constants_1.TextLabel.LOGO_LABEL),
},
}));
_this._$logoButton = (0, htmlToElement_1.default)((0, templates_1.logoButtonTemplate)({
styles: _this.styleNames,
themeStyles: _this.themeStyles,
texts: {
label: _this._textMap.get(constants_1.TextLabel.LOGO_LABEL),
},
}));
_this._tooltipReference = tooltipService.createReference(_this._$rootElement, {
text: _this._textMap.get(constants_1.TextLabel.LOGO_TOOLTIP),
});
_this.setLogo(config.logo);
_this._bindCallbacks();
_this._bindEvents();
_this.showAsButton();
return _this;
}
LogoView.prototype.setLogo = function (url) {
if (url) {
this._$logoImage.setAttribute('src', url);
this._$logoInput.setAttribute('src', url);
}
else {
this._$logoImage.removeAttribute('src');
this._$logoInput.removeAttribute('src');
}
};
LogoView.prototype.showAsImage = function () {
this._setChild(this._$logoImage);
this._tooltipReference.disable();
};
LogoView.prototype.showAsButton = function () {
this._setChild(this._$logoButton);
this._tooltipReference.enable();
};
LogoView.prototype.showAsInput = function () {
this._setChild(this._$logoInput);
this._tooltipReference.enable();
};
LogoView.prototype._setChild = function (childNode) {
this._$rootElement.firstChild &&
this._$rootElement.removeChild(this._$rootElement.firstChild);
this._$rootElement.appendChild(childNode);
};
LogoView.prototype._bindCallbacks = function () {
this._onClick = this._onClick.bind(this);
};
LogoView.prototype._bindEvents = function () {
this._$rootElement.addEventListener('click', this._onClick);
};
LogoView.prototype._unbindEvents = function () {
this._$rootElement.removeEventListener('click', this._onClick);
};
LogoView.prototype._onClick = function () {
this._$rootElement.focus();
this._callbacks.onLogoClick();
};
LogoView.prototype.show = function () {
this._$rootElement.classList.remove(this.styleNames.hidden);
};
LogoView.prototype.hide = function () {
this._$rootElement.classList.remove(this.styleNames.hidden);
};
LogoView.prototype.getElement = function () {
return this._$rootElement;
};
LogoView.prototype.destroy = function () {
this._unbindEvents();
this._tooltipReference.destroy();
if (this._$rootElement.parentNode) {
this._$rootElement.parentNode.removeChild(this._$rootElement);
}
this._$rootElement = null;
this._$logoImage = null;
this._$logoInput = null;
this._$logoButton = null;
};
return LogoView;
}(view_1.default));
LogoView.setTheme(logo_theme_1.default);
LogoView.extendStyleNames(logo_scss_1.default);
exports.default = LogoView;
//# sourceMappingURL=logo.view.js.map