playable
Version:
Video player based on HTML5Video
53 lines • 2.36 kB
JavaScript
;
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 getElementByHook_1 = (0, tslib_1.__importDefault)(require("../core/getElementByHook"));
var htmlToElement_1 = (0, tslib_1.__importDefault)(require("../core/htmlToElement"));
var loading_cover_scss_1 = (0, tslib_1.__importDefault)(require("./loading-cover.scss"));
var LoadingCoverView = /** @class */ (function (_super) {
(0, tslib_1.__extends)(LoadingCoverView, _super);
function LoadingCoverView() {
var _this = _super.call(this) || this;
_this._initDOM();
return _this;
}
LoadingCoverView.prototype.getElement = function () {
return this._$rootElement;
};
LoadingCoverView.prototype._initDOM = function () {
this._$rootElement = (0, htmlToElement_1.default)((0, templates_1.loadingCoverTemplate)({
styles: this.styleNames,
}));
this._$image = (0, getElementByHook_1.default)(this._$rootElement, 'loading-cover-image');
};
LoadingCoverView.prototype.hide = function () {
this._$rootElement.classList.add(this.styleNames.hidden);
};
LoadingCoverView.prototype.show = function () {
this._$rootElement.classList.remove(this.styleNames.hidden);
};
LoadingCoverView.prototype.setCover = function (url) {
var _this = this;
if (url && typeof url === 'string') {
this._$image.classList.add(this.styleNames.hidden);
var onImageLoad_1 = function () {
_this._$image.classList.remove(_this.styleNames.hidden);
_this._$image.removeEventListener('load', onImageLoad_1);
};
this._$image.addEventListener('load', onImageLoad_1);
this._$image.setAttribute('src', url);
}
};
LoadingCoverView.prototype.destroy = function () {
if (this._$rootElement.parentNode) {
this._$rootElement.parentNode.removeChild(this._$rootElement);
}
this._$rootElement = null;
};
return LoadingCoverView;
}(view_1.default));
LoadingCoverView.extendStyleNames(loading_cover_scss_1.default);
exports.default = LoadingCoverView;
//# sourceMappingURL=loading-cover.view.js.map