mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
imageoptionseditor
This commit is contained in:
parent
c750ba55b4
commit
0f268a4413
1 changed files with 72 additions and 37 deletions
|
@ -6,33 +6,56 @@ define(["globalize", "dom", "dialogHelper", "emby-checkbox", "emby-select", "emb
|
||||||
Type: type,
|
Type: type,
|
||||||
MinWidth: 0,
|
MinWidth: 0,
|
||||||
Limit: "Primary" === type ? 1 : 0
|
Limit: "Primary" === type ? 1 : 0
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function findImageOptions(imageOptions, type) {
|
function findImageOptions(imageOptions, type) {
|
||||||
return imageOptions.filter(function (i) {
|
return imageOptions.filter(function (i) {
|
||||||
return i.Type == type
|
return i.Type == type;
|
||||||
})[0]
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getImageConfig(options, availableOptions, imageType, itemType) {
|
function getImageConfig(options, availableOptions, imageType, itemType) {
|
||||||
return findImageOptions(options.ImageOptions || [], imageType) || findImageOptions(availableOptions.DefaultImageOptions || [], imageType) || getDefaultImageConfig(itemType, imageType)
|
return findImageOptions(options.ImageOptions || [], imageType) || findImageOptions(availableOptions.DefaultImageOptions || [], imageType) || getDefaultImageConfig(itemType, imageType);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVisibilityOfBackdrops(elem, visible) {
|
function setVisibilityOfBackdrops(elem, visible) {
|
||||||
visible ? (elem.classList.remove("hide"), elem.querySelector("input").setAttribute("required", "required")) : (elem.classList.add("hide"), elem.querySelector("input").setAttribute("required", ""), elem.querySelector("input").removeAttribute("required"))
|
if (visible) {
|
||||||
|
elem.classList.remove("hide");
|
||||||
|
elem.querySelector("input").setAttribute("required", "required");
|
||||||
|
} else {
|
||||||
|
elem.classList.add("hide");
|
||||||
|
elem.querySelector("input").setAttribute("required", "");
|
||||||
|
elem.querySelector("input").removeAttribute("required");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadValues(context, itemType, options, availableOptions) {
|
function loadValues(context, itemType, options, availableOptions) {
|
||||||
var supportedImageTypes = availableOptions.SupportedImageTypes || [];
|
var supportedImageTypes = availableOptions.SupportedImageTypes || [];
|
||||||
setVisibilityOfBackdrops(context.querySelector(".backdropFields"), -1 != supportedImageTypes.indexOf("Backdrop")), setVisibilityOfBackdrops(context.querySelector(".screenshotFields"), -1 != supportedImageTypes.indexOf("Screenshot")), Array.prototype.forEach.call(context.querySelectorAll(".imageType"), function(i) {
|
setVisibilityOfBackdrops(context.querySelector(".backdropFields"), -1 != supportedImageTypes.indexOf("Backdrop"));
|
||||||
var imageType = i.getAttribute("data-imagetype"),
|
setVisibilityOfBackdrops(context.querySelector(".screenshotFields"), -1 != supportedImageTypes.indexOf("Screenshot"));
|
||||||
container = dom.parentWithTag(i, "LABEL"); - 1 == supportedImageTypes.indexOf(imageType) ? container.classList.add("hide") : container.classList.remove("hide"), getImageConfig(options, availableOptions, imageType, itemType).Limit ? i.checked = !0 : i.checked = !1
|
Array.prototype.forEach.call(context.querySelectorAll(".imageType"), function (i) {
|
||||||
|
var imageType = i.getAttribute("data-imagetype");
|
||||||
|
var container = dom.parentWithTag(i, "LABEL");
|
||||||
|
|
||||||
|
if (-1 == supportedImageTypes.indexOf(imageType)) {
|
||||||
|
container.classList.add("hide");
|
||||||
|
} else {
|
||||||
|
container.classList.remove("hide");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getImageConfig(options, availableOptions, imageType, itemType).Limit) {
|
||||||
|
i.checked = true;
|
||||||
|
} else {
|
||||||
|
i.checked = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var backdropConfig = getImageConfig(options, availableOptions, "Backdrop", itemType);
|
var backdropConfig = getImageConfig(options, availableOptions, "Backdrop", itemType);
|
||||||
context.querySelector("#txtMaxBackdrops").value = backdropConfig.Limit, context.querySelector("#txtMinBackdropDownloadWidth").value = backdropConfig.MinWidth;
|
context.querySelector("#txtMaxBackdrops").value = backdropConfig.Limit;
|
||||||
|
context.querySelector("#txtMinBackdropDownloadWidth").value = backdropConfig.MinWidth;
|
||||||
var screenshotConfig = getImageConfig(options, availableOptions, "Screenshot", itemType);
|
var screenshotConfig = getImageConfig(options, availableOptions, "Screenshot", itemType);
|
||||||
context.querySelector("#txtMaxScreenshots").value = screenshotConfig.Limit, context.querySelector("#txtMinScreenshotDownloadWidth").value = screenshotConfig.MinWidth
|
context.querySelector("#txtMaxScreenshots").value = screenshotConfig.Limit;
|
||||||
|
context.querySelector("#txtMinScreenshotDownloadWidth").value = screenshotConfig.MinWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveValues(context, options) {
|
function saveValues(context, options) {
|
||||||
|
@ -41,37 +64,49 @@ define(["globalize", "dom", "dialogHelper", "emby-checkbox", "emby-select", "emb
|
||||||
Type: c.getAttribute("data-imagetype"),
|
Type: c.getAttribute("data-imagetype"),
|
||||||
Limit: c.checked ? 1 : 0,
|
Limit: c.checked ? 1 : 0,
|
||||||
MinWidth: 0
|
MinWidth: 0
|
||||||
}
|
};
|
||||||
}), options.ImageOptions.push({
|
});
|
||||||
|
options.ImageOptions.push({
|
||||||
Type: "Backdrop",
|
Type: "Backdrop",
|
||||||
Limit: context.querySelector("#txtMaxBackdrops").value,
|
Limit: context.querySelector("#txtMaxBackdrops").value,
|
||||||
MinWidth: context.querySelector("#txtMinBackdropDownloadWidth").value
|
MinWidth: context.querySelector("#txtMinBackdropDownloadWidth").value
|
||||||
}), options.ImageOptions.push({
|
});
|
||||||
|
options.ImageOptions.push({
|
||||||
Type: "Screenshot",
|
Type: "Screenshot",
|
||||||
Limit: context.querySelector("#txtMaxScreenshots").value,
|
Limit: context.querySelector("#txtMaxScreenshots").value,
|
||||||
MinWidth: context.querySelector("#txtMinScreenshotDownloadWidth").value
|
MinWidth: context.querySelector("#txtMinScreenshotDownloadWidth").value
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function editor() {
|
function editor() {
|
||||||
this.show = function (itemType, options, availableOptions) {
|
this.show = function (itemType, options, availableOptions) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", "components/imageoptionseditor/imageoptionseditor.template.html", !0), xhr.onload = function(e) {
|
xhr.open("GET", "components/imageoptionseditor/imageoptionseditor.template.html", true);
|
||||||
var template = this.response,
|
|
||||||
dlg = dialogHelper.createDialog({
|
xhr.onload = function (e) {
|
||||||
|
var template = this.response;
|
||||||
|
var dlg = dialogHelper.createDialog({
|
||||||
size: "medium-tall",
|
size: "medium-tall",
|
||||||
removeOnClose: !0,
|
removeOnClose: true,
|
||||||
scrollY: !1
|
scrollY: false
|
||||||
});
|
});
|
||||||
dlg.classList.add("formDialog"), dlg.innerHTML = globalize.translateDocument(template), dlg.addEventListener("close", function() {
|
dlg.classList.add("formDialog");
|
||||||
saveValues(dlg, options)
|
dlg.innerHTML = globalize.translateDocument(template);
|
||||||
}), loadValues(dlg, itemType, options, availableOptions), dialogHelper.open(dlg).then(resolve, resolve), dlg.querySelector(".btnCancel").addEventListener("click", function() {
|
dlg.addEventListener("close", function () {
|
||||||
dialogHelper.close(dlg)
|
saveValues(dlg, options);
|
||||||
})
|
});
|
||||||
}, xhr.send()
|
loadValues(dlg, itemType, options, availableOptions);
|
||||||
})
|
dialogHelper.open(dlg).then(resolve, resolve);
|
||||||
}
|
dlg.querySelector(".btnCancel").addEventListener("click", function () {
|
||||||
}
|
dialogHelper.close(dlg);
|
||||||
return editor
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return editor;
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue