playable
Version:
Video player based on HTML5Video
67 lines • 3.09 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 getElementByHook_1 = (0, tslib_1.__importDefault)(require("../../core/getElementByHook"));
var download_theme_1 = (0, tslib_1.__importDefault)(require("./download.theme"));
var download_scss_1 = (0, tslib_1.__importDefault)(require("./download.scss"));
var DownloadView = /** @class */ (function (_super) {
(0, tslib_1.__extends)(DownloadView, _super);
function DownloadView(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.controlTemplate)({
styles: _this.styleNames,
themeStyles: _this.themeStyles,
texts: {
label: _this._textMap.get(constants_1.TextLabel.DOWNLOAD_BUTTON_LABEL),
},
}));
_this._$downloadButton = (0, getElementByHook_1.default)(_this._$rootElement, 'download-button');
_this._tooltipReference = tooltipService.createReference(_this._$downloadButton, {
text: _this._textMap.get(constants_1.TextLabel.DOWNLOAD_BUTTON_TOOLTIP),
});
_this._bindEvents();
return _this;
}
DownloadView.prototype._bindEvents = function () {
this._onButtonClick = this._onButtonClick.bind(this);
this._$downloadButton.addEventListener('click', this._onButtonClick);
};
DownloadView.prototype._unbindEvents = function () {
this._$downloadButton.removeEventListener('click', this._onButtonClick);
};
DownloadView.prototype._onButtonClick = function () {
this._$rootElement.focus();
this._callbacks.onButtonClick();
};
DownloadView.prototype.hide = function () {
this._$rootElement.classList.add(this.styleNames.hidden);
};
DownloadView.prototype.show = function () {
this._$rootElement.classList.remove(this.styleNames.hidden);
};
DownloadView.prototype.getElement = function () {
return this._$rootElement;
};
DownloadView.prototype.destroy = function () {
this._unbindEvents();
this._tooltipReference.destroy();
if (this._$rootElement.parentNode) {
this._$rootElement.parentNode.removeChild(this._$rootElement);
}
this._$downloadButton = null;
this._$rootElement = null;
};
return DownloadView;
}(view_1.default));
DownloadView.setTheme(download_theme_1.default);
DownloadView.extendStyleNames(download_scss_1.default);
exports.default = DownloadView;
//# sourceMappingURL=download.view.js.map