0

KSPlayer: Убираем всё лишнее

This commit is contained in:
2017-12-15 14:56:13 +03:00
parent 40b8e28fd4
commit 09a9b97774

View File

@@ -45,7 +45,7 @@ const KSPlayer = function(containerId, data) {
a.innerText = item.title;
a.onclick = function() {
text.nodeValue = item.title;
_self.setTitle(item.title);
setTitle(item.title);
if (lastActiveSerialItem) {
lastActiveSerialItem.classList.remove('active');
@@ -207,6 +207,23 @@ const KSPlayer = function(containerId, data) {
videoElement.src = source;
}
function setTitle(text) {
if (text) {
if (!titleElement) initTitleElement();
titleElement.innerText = text;
if (!isShowTitle) {
containerElement.insertBefore(titleElement, videoElement);
isShowTitle = true;
}
} else {
if (isShowTitle && titleElement) {
containerElement.removeChild(titleElement);
isShowTitle = false;
}
}
}
/* --- CONSTRUCTOR --------- */
const containerElement = document.getElementById(containerId);
@@ -237,27 +254,4 @@ const KSPlayer = function(containerId, data) {
}
containerElement.appendChild(videoElement);
/* --- FUNCTIONS ----------- */
this.getType = function() {
return videoType;
}
this.setTitle = function(text) {
if (text) {
if (!titleElement) initTitleElement();
titleElement.innerText = text;
if (!isShowTitle) {
containerElement.insertBefore(titleElement, videoElement);
isShowTitle = true;
}
} else {
if (isShowTitle && titleElement) {
containerElement.removeChild(titleElement);
isShowTitle = false;
}
}
}
}