0

KSPlayer: выбор сезонов из меню

This commit is contained in:
2017-12-15 14:50:15 +03:00
parent c8a8e0a5da
commit 4e49c57904

View File

@@ -9,6 +9,7 @@ const KSPlayer = function(containerId, data) {
let seasonSerials = []; let seasonSerials = [];
const _self = this; const _self = this;
let lastActiveSerialItem; let lastActiveSerialItem;
let lastActiveSeasonItem;
/* --- PRIVATE FUNCTIONS --- */ /* --- PRIVATE FUNCTIONS --- */
@@ -75,6 +76,7 @@ const KSPlayer = function(containerId, data) {
div.id = 'pl-season'; div.id = 'pl-season';
div.className = 'dropdown'; div.className = 'dropdown';
div.style = 'display: inline-block'; div.style = 'display: inline-block';
div.kspSerialMenuElement = undefined;
let button = document.createElement('button'); let button = document.createElement('button');
button.className = 'btn btn-default dropdown-toggle'; button.className = 'btn btn-default dropdown-toggle';
@@ -101,7 +103,23 @@ const KSPlayer = function(containerId, data) {
a.href = '#'; a.href = '#';
a.innerText = item.title; a.innerText = item.title;
a.setAttribute('data-number', idx); a.setAttribute('data-number', idx);
a.onclick = function() { return false; } a.onclick = function() {
text.nodeValue = item.title;
if (lastActiveSeasonItem) {
lastActiveSeasonItem.classList.remove('active');
}
li.classList.add('active');
lastActiveSeasonItem = li;
if (div.kspSerialMenuElement) {
containerElement.removeChild(div.kspSerialMenuElement);
}
containerElement.insertAfter(seasonSerials[idx], div);
div.kspSerialMenuElement = seasonSerials[idx];
return false;
}
seasonSerials.push(createSerialMenuElement(item.serials)); seasonSerials.push(createSerialMenuElement(item.serials));
li.appendChild(a); li.appendChild(a);
@@ -197,6 +215,10 @@ const KSPlayer = function(containerId, data) {
throw `Container "${containerId}" not found!`; throw `Container "${containerId}" not found!`;
} }
containerElement.insertAfter = function(newChild, refChild) {
this.insertBefore(newChild, refChild.nextSibling);
}
let videoElement = createVideoElement(); let videoElement = createVideoElement();
if (data.hasOwnProperty('title')) { if (data.hasOwnProperty('title')) {