UNPKG

playable

Version:

Video player based on HTML5Video

87 lines 3.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var templates_1 = require("./templates"); var htmlToElement_1 = (0, tslib_1.__importDefault)(require("../htmlToElement")); var getElementByHook_1 = (0, tslib_1.__importDefault)(require("../getElementByHook")); var stylable_1 = (0, tslib_1.__importDefault)(require("../stylable")); var tooltip_scss_1 = (0, tslib_1.__importDefault)(require("./tooltip.scss")); var Tooltip = /** @class */ (function (_super) { (0, tslib_1.__extends)(Tooltip, _super); function Tooltip() { var _this = _super.call(this) || this; _this._isHidden = true; _this._initDOM(); return _this; } Tooltip.prototype._initDOM = function () { this._$rootElement = (0, htmlToElement_1.default)((0, templates_1.tooltipTemplate)({ styles: this.styleNames, })); this._$tooltipInner = (0, getElementByHook_1.default)(this._$rootElement, 'tooltip-inner'); }; Tooltip.prototype.getElement = function () { return this._$rootElement; }; Object.defineProperty(Tooltip.prototype, "isHidden", { get: function () { return this._isHidden; }, enumerable: false, configurable: true }); Tooltip.prototype.show = function () { if (!this._isHidden) { return; } this._isHidden = false; this._$rootElement.classList.add(this.styleNames.tooltipVisible); }; Tooltip.prototype.hide = function () { if (this._isHidden) { return; } this._isHidden = true; this._$rootElement.classList.remove(this.styleNames.tooltipVisible); }; Tooltip.prototype.setText = function (text) { this.clearElement(); this._showAsText(); this._$tooltipInner.innerText = text; }; Tooltip.prototype.clearElement = function () { this._$tooltipInner.firstChild && this._$tooltipInner.removeChild(this._$tooltipInner.firstChild); }; Tooltip.prototype.setElement = function (element) { if (element !== this._$tooltipInner.firstChild) { this._showAsElement(); this.clearElement(); if (element) { this._$tooltipInner.appendChild(element); } } }; Tooltip.prototype._showAsText = function () { this._$rootElement.classList.remove(this.styleNames.showAsElement); this._$rootElement.classList.add(this.styleNames.showAsText); }; Tooltip.prototype._showAsElement = function () { this._$rootElement.classList.remove(this.styleNames.showAsText); this._$rootElement.classList.add(this.styleNames.showAsElement); }; Tooltip.prototype.setStyle = function (style) { var _this = this; Object.keys(style).forEach(function (styleKey) { _this._$rootElement.style[styleKey] = style[styleKey]; }); }; Tooltip.prototype.destroy = function () { this._$rootElement = null; this._$tooltipInner = null; }; return Tooltip; }(stylable_1.default)); Tooltip.extendStyleNames(tooltip_scss_1.default); exports.default = Tooltip; //# sourceMappingURL=tooltip.js.map