UNPKG

playable

Version:

Video player based on HTML5Video

65 lines 2.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); 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 toggleElementClass_1 = (0, tslib_1.__importDefault)(require("../core/toggleElementClass")); var title_theme_1 = (0, tslib_1.__importDefault)(require("./title.theme")); var title_scss_1 = (0, tslib_1.__importDefault)(require("./title.scss")); var TitleView = /** @class */ (function (_super) { (0, tslib_1.__extends)(TitleView, _super); function TitleView(config) { var _this = this; var callbacks = config.callbacks, theme = config.theme; _this = _super.call(this, theme) || this; _this._callbacks = callbacks; _this._initDOM(); _this._bindEvents(); return _this; } TitleView.prototype._initDOM = function () { this._$rootElement = (0, htmlToElement_1.default)((0, templates_1.titleTemplate)({ styles: this.styleNames, themeStyles: this.themeStyles })); }; TitleView.prototype._bindEvents = function () { this._$rootElement.addEventListener('click', this._callbacks.onClick); }; TitleView.prototype._unbindEvents = function () { this._$rootElement.removeEventListener('click', this._callbacks.onClick); }; TitleView.prototype.setDisplayAsLink = function (flag) { (0, toggleElementClass_1.default)(this._$rootElement, this.styleNames.link, flag); }; TitleView.prototype.setTitle = function (title) { // TODO: mb move this logic to controller? title.isHidden is out of control of this method // TODO: what if we call with empty value `.setTitle('')` and then call `.show()` method? Mb clear value anyway? if (title) { this.show(); this._$rootElement.innerHTML = title; } else { this.hide(); } }; TitleView.prototype.show = function () { this._$rootElement.classList.remove(this.styleNames.hidden); }; TitleView.prototype.hide = function () { this._$rootElement.classList.add(this.styleNames.hidden); }; TitleView.prototype.getElement = function () { return this._$rootElement; }; TitleView.prototype.destroy = function () { this._unbindEvents(); if (this._$rootElement.parentNode) { this._$rootElement.parentNode.removeChild(this._$rootElement); } this._$rootElement = null; }; return TitleView; }(view_1.default)); TitleView.setTheme(title_theme_1.default); TitleView.extendStyleNames(title_scss_1.default); exports.default = TitleView; //# sourceMappingURL=title.view.js.map