mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update guide
This commit is contained in:
parent
7f98cdfec2
commit
9f4127adca
12 changed files with 296 additions and 84 deletions
|
@ -1,8 +1,9 @@
|
|||
define(['browser', 'css!./style'], function (browser) {
|
||||
define(['browser', 'connectionManager', 'playbackManager', 'css!./style'], function (browser, connectionManager, playbackManager) {
|
||||
|
||||
function enableAnimation(elem) {
|
||||
|
||||
if (browser.mobile) {
|
||||
i
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -99,6 +100,8 @@
|
|||
|
||||
function clearBackdrop(clearAll) {
|
||||
|
||||
clearRotation();
|
||||
|
||||
if (currentLoadingBackdrop) {
|
||||
currentLoadingBackdrop.destroy();
|
||||
currentLoadingBackdrop = null;
|
||||
|
@ -107,8 +110,6 @@
|
|||
var elem = getBackdropContainer();
|
||||
elem.innerHTML = '';
|
||||
|
||||
getSkinContainer().removeAttribute('data-backdroptype');
|
||||
|
||||
if (clearAll) {
|
||||
hasExternalBackdrop = false;
|
||||
}
|
||||
|
@ -170,64 +171,146 @@
|
|||
currentLoadingBackdrop = instance;
|
||||
}
|
||||
|
||||
function setBackdrops(items, type) {
|
||||
var windowWidth;
|
||||
function resetWindowSize() {
|
||||
windowWidth = screen.availWidth || window.innerWidth;
|
||||
}
|
||||
window.addEventListener("orientationchange", resetWindowSize);
|
||||
window.addEventListener('resize', resetWindowSize);
|
||||
resetWindowSize();
|
||||
|
||||
var images = items.map(function (i) {
|
||||
function getItemImageUrls(item) {
|
||||
|
||||
if (i.BackdropImageTags && i.BackdropImageTags.length > 0) {
|
||||
return {
|
||||
id: i.Id,
|
||||
tag: i.BackdropImageTags[0],
|
||||
serverId: i.ServerId
|
||||
};
|
||||
}
|
||||
var apiClient = connectionManager.getApiClient(item.ServerId);
|
||||
|
||||
if (i.ParentBackdropItemId && i.ParentBackdropImageTags && i.ParentBackdropImageTags.length) {
|
||||
if (item.BackdropImageTags && item.BackdropImageTags.length > 0) {
|
||||
|
||||
return {
|
||||
id: i.ParentBackdropItemId,
|
||||
tag: i.ParentBackdropImageTags[0],
|
||||
serverId: i.ServerId
|
||||
};
|
||||
}
|
||||
return null;
|
||||
return item.BackdropImageTags.map(function (imgTag, index) {
|
||||
|
||||
}).filter(function (i) {
|
||||
return i != null;
|
||||
});
|
||||
return apiClient.getScaledImageUrl(item.Id, {
|
||||
type: "Backdrop",
|
||||
tag: imgTag,
|
||||
maxWidth: Math.min(windowWidth, 1920),
|
||||
index: index
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
|
||||
|
||||
return item.ParentBackdropImageTags.map(function (imgTag, index) {
|
||||
|
||||
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, {
|
||||
type: "Backdrop",
|
||||
tag: imgTag,
|
||||
maxWidth: Math.min(windowWidth, 1920),
|
||||
index: index
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function getImageUrls(items) {
|
||||
|
||||
var list = [];
|
||||
|
||||
for (var i = 0, length = items.length; i < length; i++) {
|
||||
|
||||
var itemImages = getItemImageUrls(items[i]);
|
||||
|
||||
itemImages.forEach(function (img) {
|
||||
list.push(img);
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
function arraysEqual(a, b) {
|
||||
if (a === b) return true;
|
||||
if (a == null || b == null) return false;
|
||||
if (a.length != b.length) return false;
|
||||
|
||||
// If you don't care about the order of the elements inside
|
||||
// the array, you should sort both arrays here.
|
||||
|
||||
for (var i = 0; i < a.length; ++i) {
|
||||
if (a[i] !== b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var rotationInterval;
|
||||
var currentRotatingImages = [];
|
||||
var currentRotationIndex = -1;
|
||||
function setBackdrops(items, imageSetId) {
|
||||
|
||||
var images = getImageUrls(items);
|
||||
|
||||
imageSetId = imageSetId || new Date().getTime();
|
||||
if (images.length) {
|
||||
|
||||
var index = getRandom(0, images.length - 1);
|
||||
var item = images[index];
|
||||
|
||||
require(['connectionManager'], function (connectionManager) {
|
||||
|
||||
var apiClient = connectionManager.getApiClient(item.serverId);
|
||||
var imgUrl = apiClient.getScaledImageUrl(item.id, {
|
||||
type: "Backdrop",
|
||||
tag: item.tag,
|
||||
maxWidth: Math.min(screen.availWidth || window.innerWidth, 1920)
|
||||
});
|
||||
|
||||
setBackdrop(imgUrl, type);
|
||||
});
|
||||
startRotation(images, imageSetId);
|
||||
|
||||
} else {
|
||||
clearBackdrop();
|
||||
}
|
||||
}
|
||||
|
||||
function setBackdrop(url, type) {
|
||||
function startRotation(images) {
|
||||
|
||||
if (arraysEqual(images, currentRotatingImages)) {
|
||||
return;
|
||||
}
|
||||
|
||||
clearRotation();
|
||||
|
||||
currentRotatingImages = images;
|
||||
currentRotationIndex = -1;
|
||||
|
||||
if (images.length > 1) {
|
||||
rotationInterval = setInterval(onRotationInterval, 20000);
|
||||
}
|
||||
onRotationInterval();
|
||||
}
|
||||
|
||||
function onRotationInterval() {
|
||||
|
||||
if (playbackManager.isPlayingVideo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var newIndex = currentRotationIndex + 1;
|
||||
if (newIndex >= currentRotatingImages.length) {
|
||||
newIndex = 0;
|
||||
}
|
||||
|
||||
currentRotationIndex = newIndex;
|
||||
setBackdropImage(currentRotatingImages[newIndex]);
|
||||
}
|
||||
|
||||
function clearRotation() {
|
||||
var interval = rotationInterval;
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
rotationInterval = null;
|
||||
currentRotatingImages = [];
|
||||
currentRotationIndex = -1;
|
||||
}
|
||||
|
||||
function setBackdrop(url) {
|
||||
|
||||
if (typeof url !== 'string') {
|
||||
url = getImageUrls([url])[0];
|
||||
}
|
||||
|
||||
if (url) {
|
||||
setBackdropImage(url);
|
||||
clearRotation();
|
||||
|
||||
if (type) {
|
||||
getSkinContainer().setAttribute('data-backdroptype', type);
|
||||
} else {
|
||||
getSkinContainer().removeAttribute('data-backdroptype');
|
||||
}
|
||||
setBackdropImage(url);
|
||||
|
||||
} else {
|
||||
clearBackdrop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue