1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update components

This commit is contained in:
Luke Pulverenti 2016-03-04 22:39:49 -05:00
parent 7dbb1f7535
commit b447272b19
26 changed files with 478 additions and 107 deletions

View file

@ -1,13 +1,23 @@
define(['cryptojs-md5'], function () {
function setImageIntoElement(elem, url) {
function loadImage(elem, url) {
if (elem.tagName !== "IMG") {
elem.style.backgroundImage = "url('" + url + "')";
return new Promise(function (resolve, reject) {
var tmp = new Image();
tmp.onload = function () {
elem.style.backgroundImage = "url('" + url + "')";
resolve(elem);
};
tmp.src = url;
});
} else {
elem.setAttribute("src", url);
return Promise.resolve(elem);
}
}
@ -151,12 +161,10 @@ define(['cryptojs-md5'], function () {
return getImageUrl(url).then(function (localUrl) {
setImageIntoElement(elem, localUrl);
return elem;
return loadImage(elem, localUrl);
}, function () {
setImageIntoElement(elem, url);
return elem;
return loadImage(elem, url);
});
}
};