UNPKG

playable

Version:

Video player based on HTML5Video

88 lines 2.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var title_view_1 = (0, tslib_1.__importDefault)(require("./title.view")); var player_api_decorator_1 = (0, tslib_1.__importDefault)(require("../../../core/player-api-decorator")); var Title = /** @class */ (function () { function Title(_a) { var theme = _a.theme, config = _a.config; this._theme = theme; this._bindCallbacks(); this._initUI(); this.setTitle(config.title); } Title.prototype.getElement = function () { return this.view.getElement(); }; Title.prototype._bindCallbacks = function () { this._triggerCallback = this._triggerCallback.bind(this); }; Title.prototype._initUI = function () { var config = { theme: this._theme, callbacks: { onClick: this._triggerCallback, }, }; this.view = new Title.View(config); this.view.setTitle(); }; /** * Display title text over the video. If you want to have clickable title, use `setTitleClickCallback` * * @param title - Text for the video title * * @example * player.setTitle('Your awesome video title here'); * * @note * [Live Demo](https://jsfiddle.net/bodia/243k6m0u/) */ Title.prototype.setTitle = function (title) { this.view.setTitle(title); }; /** * Method for attaching callback for click on title * * @param callback - Your function * * @example * const callback = () => { * console.log('Click on title); * } * player.setTitleClickCallback(callback); * */ Title.prototype.setTitleClickCallback = function (callback) { this._callback = callback; this.view.setDisplayAsLink(Boolean(this._callback)); }; Title.prototype._triggerCallback = function () { if (this._callback) { this._callback(); } }; Title.prototype.hide = function () { this.isHidden = true; this.view.hide(); }; Title.prototype.show = function () { this.isHidden = false; this.view.show(); }; Title.prototype.destroy = function () { this.view.destroy(); }; Title.moduleName = 'title'; Title.View = title_view_1.default; Title.dependencies = ['config', 'theme']; (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], Title.prototype, "setTitle", null); (0, tslib_1.__decorate)([ (0, player_api_decorator_1.default)() ], Title.prototype, "setTitleClickCallback", null); return Title; }()); exports.default = Title; //# sourceMappingURL=title.js.map