mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
First separation commit.
Added LICENSE, README.md, CONTRIBUTORS.md
This commit is contained in:
parent
09513af31b
commit
4678528d00
657 changed files with 422 additions and 0 deletions
18
src/bower_components/emby-webcomponents/images/basicimagefetcher.js
vendored
Normal file
18
src/bower_components/emby-webcomponents/images/basicimagefetcher.js
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
define(["dom"], function(dom) {
|
||||
"use strict";
|
||||
|
||||
function loadImage(elem, url) {
|
||||
return elem ? "IMG" !== elem.tagName ? (elem.style.backgroundImage = "url('" + url + "')", Promise.resolve()) : loadImageIntoImg(elem, url) : Promise.reject("elem cannot be null")
|
||||
}
|
||||
|
||||
function loadImageIntoImg(elem, url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
dom.addEventListener(elem, "load", resolve, {
|
||||
once: !0
|
||||
}), elem.setAttribute("src", url)
|
||||
})
|
||||
}
|
||||
return {
|
||||
loadImage: loadImage
|
||||
}
|
||||
});
|
82
src/bower_components/emby-webcomponents/images/imagehelper.js
vendored
Normal file
82
src/bower_components/emby-webcomponents/images/imagehelper.js
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
define(["lazyLoader", "imageFetcher", "layoutManager", "browser", "appSettings", "require", "css!./style"], function(lazyLoader, imageFetcher, layoutManager, browser, appSettings, require) {
|
||||
"use strict";
|
||||
|
||||
function fillImage(elem, source, enableEffects) {
|
||||
if (!elem) throw new Error("elem cannot be null");
|
||||
source || (source = elem.getAttribute("data-src")), source && fillImageElement(elem, source, enableEffects)
|
||||
}
|
||||
|
||||
function fillImageElement(elem, source, enableEffects) {
|
||||
imageFetcher.loadImage(elem, source).then(function() {
|
||||
enableFade && !1 !== enableEffects && fadeIn(elem), elem.removeAttribute("data-src")
|
||||
})
|
||||
}
|
||||
|
||||
function getVibrantInfoFromElement(elem, url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["vibrant"], function() {
|
||||
if ("IMG" === elem.tagName) return void resolve(getVibrantInfo(elem, url));
|
||||
var img = new Image;
|
||||
img.onload = function() {
|
||||
resolve(getVibrantInfo(img, url))
|
||||
}, img.src = url
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function getSettingsKey(url) {
|
||||
var parts = url.split("://");
|
||||
url = parts[parts.length - 1], url = url.substring(url.indexOf("/") + 1), url = url.split("?")[0];
|
||||
return "vibrant31" + url
|
||||
}
|
||||
|
||||
function getCachedVibrantInfo(url) {
|
||||
return appSettings.get(getSettingsKey(url))
|
||||
}
|
||||
|
||||
function getVibrantInfo(img, url) {
|
||||
var value = getCachedVibrantInfo(url);
|
||||
if (value) return value;
|
||||
var vibrant = new Vibrant(img),
|
||||
swatches = vibrant.swatches();
|
||||
return value = "", value += getSwatchString(swatches.DarkVibrant), appSettings.set(getSettingsKey(url), value), value
|
||||
}
|
||||
|
||||
function getSwatchString(swatch) {
|
||||
return swatch ? swatch.getHex() + "|" + swatch.getBodyTextColor() + "|" + swatch.getTitleTextColor() : "||"
|
||||
}
|
||||
|
||||
function fadeIn(elem) {
|
||||
elem.classList.add("lazy-image-fadein")
|
||||
}
|
||||
|
||||
function lazyChildren(elem) {
|
||||
lazyLoader.lazyChildren(elem, fillImage)
|
||||
}
|
||||
|
||||
function getPrimaryImageAspectRatio(items) {
|
||||
for (var values = [], i = 0, length = items.length; i < length; i++) {
|
||||
var ratio = items[i].PrimaryImageAspectRatio || 0;
|
||||
ratio && (values[values.length] = ratio)
|
||||
}
|
||||
if (!values.length) return null;
|
||||
values.sort(function(a, b) {
|
||||
return a - b
|
||||
});
|
||||
var result, half = Math.floor(values.length / 2);
|
||||
result = values.length % 2 ? values[half] : (values[half - 1] + values[half]) / 2;
|
||||
if (Math.abs(2 / 3 - result) <= .15) return 2 / 3;
|
||||
if (Math.abs(16 / 9 - result) <= .2) return 16 / 9;
|
||||
if (Math.abs(1 - result) <= .15) return 1;
|
||||
return Math.abs(4 / 3 - result) <= .15 ? 4 / 3 : result
|
||||
}
|
||||
|
||||
function fillImages(elems) {
|
||||
for (var i = 0, length = elems.length; i < length; i++) {
|
||||
fillImage(elems[0])
|
||||
}
|
||||
}
|
||||
var self = (window.requestIdleCallback, {}),
|
||||
enableFade = !1;
|
||||
return self.fillImages = fillImages, self.lazyImage = fillImage, self.lazyChildren = lazyChildren, self.getPrimaryImageAspectRatio = getPrimaryImageAspectRatio, self.getCachedVibrantInfo = getCachedVibrantInfo, self.getVibrantInfoFromElement = getVibrantInfoFromElement, self
|
||||
});
|
61
src/bower_components/emby-webcomponents/images/style.css
vendored
Normal file
61
src/bower_components/emby-webcomponents/images/style.css
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
.lazy-image-fadein {
|
||||
-webkit-animation: lazy-image-fadein 330ms ease-in normal both;
|
||||
animation: lazy-image-fadein 330ms ease-in normal both
|
||||
}
|
||||
|
||||
.lazy-image-fadein-fast {
|
||||
-webkit-animation: lazy-image-fadein 160ms ease-in normal both;
|
||||
animation: lazy-image-fadein 160ms ease-in normal both
|
||||
}
|
||||
|
||||
@-webkit-keyframes lazy-image-fadein {
|
||||
from {
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes lazy-image-fadein {
|
||||
from {
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
.lazy-image-fadein {
|
||||
opacity: 0;
|
||||
-webkit-animation-duration: .8s;
|
||||
animation-duration: .8s;
|
||||
-webkit-animation-name: popInAnimation;
|
||||
animation-name: popInAnimation;
|
||||
-webkit-animation-fill-mode: forwards;
|
||||
animation-fill-mode: forwards;
|
||||
-webkit-animation-timing-function: cubic-bezier(0, 0, .5, 1);
|
||||
animation-timing-function: cubic-bezier(0, 0, .5, 1)
|
||||
}
|
||||
|
||||
@-webkit-keyframes popInAnimation {
|
||||
0% {
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes popInAnimation {
|
||||
0% {
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue