mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
minor code cleanup
This commit is contained in:
parent
fa27a839f3
commit
e833225ab3
@ -14,30 +14,31 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
type: "error"
|
type: "error"
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
} else {
|
return false;
|
||||||
isCreating = true;
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
var form = this,
|
|
||||||
dlg = $(form).parents(".dialog")[0],
|
|
||||||
name = $("#txtValue", form).val(),
|
|
||||||
type = $("#selectCollectionType", form).val();
|
|
||||||
if (type == "mixed") type = null;
|
|
||||||
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
|
|
||||||
libraryOptions.PathInfos = pathInfos;
|
|
||||||
ApiClient.addVirtualFolder(name, type, currentOptions.refresh, libraryOptions).then(function() {
|
|
||||||
hasChanges = true;
|
|
||||||
isCreating = false;
|
|
||||||
loading.hide();
|
|
||||||
dialogHelper.close(dlg);
|
|
||||||
}, function() {
|
|
||||||
require(["toast"], function(toast) {
|
|
||||||
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
|
|
||||||
})
|
|
||||||
isCreating = false;
|
|
||||||
loading.hide();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isCreating = true;
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
var form = this;
|
||||||
|
var dlg = $(form).parents(".dialog")[0];
|
||||||
|
var name = $("#txtValue", form).val();
|
||||||
|
var type = $("#selectCollectionType", form).val();
|
||||||
|
if (type == "mixed") type = null;
|
||||||
|
var libraryOptions = libraryoptionseditor.getLibraryOptions(dlg.querySelector(".libraryOptions"));
|
||||||
|
libraryOptions.PathInfos = pathInfos;
|
||||||
|
ApiClient.addVirtualFolder(name, type, currentOptions.refresh, libraryOptions).then(function() {
|
||||||
|
hasChanges = true;
|
||||||
|
isCreating = false;
|
||||||
|
loading.hide();
|
||||||
|
dialogHelper.close(dlg);
|
||||||
|
}, function() {
|
||||||
|
require(["toast"], function(toast) {
|
||||||
|
toast(Globalize.translate("ErrorAddingMediaPathToVirtualFolder"))
|
||||||
|
})
|
||||||
|
isCreating = false;
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,13 +50,14 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
|
|
||||||
function initEditor(page, collectionTypeOptions) {
|
function initEditor(page, collectionTypeOptions) {
|
||||||
$("#selectCollectionType", page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val("").on("change", function() {
|
$("#selectCollectionType", page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val("").on("change", function() {
|
||||||
var value = this.value,
|
var value = this.value;
|
||||||
dlg = $(this).parents(".dialog")[0];
|
var dlg = $(this).parents(".dialog")[0];
|
||||||
libraryoptionseditor.setContentType(dlg.querySelector(".libraryOptions"), value == "mixed" ? "" : value);
|
libraryoptionseditor.setContentType(dlg.querySelector(".libraryOptions"), value == "mixed" ? "" : value);
|
||||||
if (value)
|
if (value) {
|
||||||
dlg.querySelector(".libraryOptions").classList.remove("hide");
|
dlg.querySelector(".libraryOptions").classList.remove("hide");
|
||||||
else
|
} else {
|
||||||
dlg.querySelector(".libraryOptions").classList.add("hide");
|
dlg.querySelector(".libraryOptions").classList.add("hide");
|
||||||
|
}
|
||||||
|
|
||||||
if (value != "mixed") {
|
if (value != "mixed") {
|
||||||
var index = this.selectedIndex;
|
var index = this.selectedIndex;
|
||||||
@ -73,7 +75,7 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
|
|
||||||
function onToggleAdvancedChange() {
|
function onToggleAdvancedChange() {
|
||||||
var dlg = dom.parentWithClass(this, "dlg-librarycreator");
|
var dlg = dom.parentWithClass(this, "dlg-librarycreator");
|
||||||
libraryoptionseditor.setAdvancedVisible(dlg.querySelector(".libraryOptions"), this.checked)
|
libraryoptionseditor.setAdvancedVisible(dlg.querySelector(".libraryOptions"), this.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAddButtonClick() {
|
function onAddButtonClick() {
|
||||||
@ -83,7 +85,8 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
picker.show({
|
picker.show({
|
||||||
enableNetworkSharePath: true,
|
enableNetworkSharePath: true,
|
||||||
callback: function(path, networkSharePath) {
|
callback: function(path, networkSharePath) {
|
||||||
path && addMediaLocation(page, path, networkSharePath), picker.close()
|
path && addMediaLocation(page, path, networkSharePath);
|
||||||
|
picker.close();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -95,31 +98,36 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderPaths(page) {
|
function renderPaths(page) {
|
||||||
var foldersHtml = pathInfos.map(getFolderHtml).join(""),
|
var foldersHtml = pathInfos.map(getFolderHtml).join("");
|
||||||
folderList = page.querySelector(".folderList");
|
var folderList = page.querySelector(".folderList");
|
||||||
folderList.innerHTML = foldersHtml, foldersHtml ? folderList.classList.remove("hide") : folderList.classList.add("hide")
|
folderList.innerHTML = foldersHtml;
|
||||||
|
foldersHtml ? folderList.classList.remove("hide") : folderList.classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMediaLocation(page, path, networkSharePath) {
|
function addMediaLocation(page, path, networkSharePath) {
|
||||||
var pathLower = path.toLowerCase();
|
var pathLower = path.toLowerCase();
|
||||||
if (0 == pathInfos.filter(function(p) {
|
var path = pathInfos.filter(function(p) {
|
||||||
return p.Path.toLowerCase() == pathLower
|
return p.Path.toLowerCase() == pathLower;
|
||||||
}).length) {
|
});
|
||||||
|
if (path.length === 0) {
|
||||||
var pathInfo = {
|
var pathInfo = {
|
||||||
Path: path
|
Path: path
|
||||||
};
|
};
|
||||||
networkSharePath && (pathInfo.NetworkPath = networkSharePath), pathInfos.push(pathInfo), renderPaths(page)
|
networkSharePath && (pathInfo.NetworkPath = networkSharePath);
|
||||||
|
pathInfos.push(pathInfo);
|
||||||
|
renderPaths(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRemoveClick(e) {
|
function onRemoveClick(e) {
|
||||||
var button = dom.parentWithClass(e.target, "btnRemovePath"),
|
var button = dom.parentWithClass(e.target, "btnRemovePath");
|
||||||
index = parseInt(button.getAttribute("data-index")),
|
var index = parseInt(button.getAttribute("data-index"));
|
||||||
location = pathInfos[index].Path,
|
var location = pathInfos[index].Path;
|
||||||
locationLower = location.toLowerCase();
|
var locationLower = location.toLowerCase();
|
||||||
pathInfos = pathInfos.filter(function(p) {
|
pathInfos = pathInfos.filter(function(p) {
|
||||||
return p.Path.toLowerCase() != locationLower
|
return p.Path.toLowerCase() != locationLower;
|
||||||
}), renderPaths(dom.parentWithClass(button, "dlg-librarycreator"))
|
});
|
||||||
|
renderPaths(dom.parentWithClass(button, "dlg-librarycreator"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDialogClosed() {
|
function onDialogClosed() {
|
||||||
@ -131,14 +139,17 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
|
|
||||||
function initLibraryOptions(dlg) {
|
function initLibraryOptions(dlg) {
|
||||||
libraryoptionseditor.embed(dlg.querySelector(".libraryOptions")).then(function() {
|
libraryoptionseditor.embed(dlg.querySelector(".libraryOptions")).then(function() {
|
||||||
$("#selectCollectionType", dlg).trigger("change"), onToggleAdvancedChange.call(dlg.querySelector(".chkAdvanced"))
|
$("#selectCollectionType", dlg).trigger("change");
|
||||||
|
onToggleAdvancedChange.call(dlg.querySelector(".chkAdvanced"));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function editor() {
|
function editor() {
|
||||||
this.show = function(options) {
|
this.show = function(options) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
currentOptions = options, currentResolve = resolve, hasChanges = false;
|
currentOptions = options;
|
||||||
|
currentResolve = resolve;
|
||||||
|
hasChanges = false;
|
||||||
var xhr = new XMLHttpRequest;
|
var xhr = new XMLHttpRequest;
|
||||||
xhr.open("GET", "components/medialibrarycreator/medialibrarycreator.template.html", true);
|
xhr.open("GET", "components/medialibrarycreator/medialibrarycreator.template.html", true);
|
||||||
xhr.onload = function(e) {
|
xhr.onload = function(e) {
|
||||||
@ -168,6 +179,13 @@ define(["loading", "dialogHelper", "dom", "jQuery", "components/libraryoptionsed
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var currentResolve, hasChanges, currentOptions, pathInfos = [], isCreating = false;
|
|
||||||
|
var pathInfos = [];
|
||||||
|
var currentResolve;
|
||||||
|
var currentOptions;
|
||||||
|
|
||||||
|
var hasChanges;
|
||||||
|
var isCreating = false;
|
||||||
|
|
||||||
return editor
|
return editor
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
<div class="formDialogHeader">
|
<div class="formDialogHeader">
|
||||||
<button type="button" is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon"></i></button>
|
<button type="button" is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon"></i></button>
|
||||||
<h3 class="formDialogHeaderTitle">
|
<h3 class="formDialogHeaderTitle">${ButtonAddMediaLibrary}</h3>
|
||||||
${ButtonAddMediaLibrary}
|
|
||||||
</h3>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="formDialogContent scrollY" style="padding-top:2em;">
|
<div class="formDialogContent scrollY" style="padding-top:2em;">
|
||||||
<div class="dialogContentInner dialog-content-centered">
|
<div class="dialogContentInner dialog-content-centered">
|
||||||
<form style="margin:auto;">
|
<form style="margin:auto;">
|
||||||
|
|
||||||
<div class="inputContainer" style="text-align:right;">
|
<div class="inputContainer" style="text-align:right;">
|
||||||
<label style="width:auto;">
|
<label style="width:auto;">
|
||||||
<input is="emby-toggle" type="checkbox" class="chkAdvanced noautofocus" />
|
<input is="emby-toggle" type="checkbox" class="chkAdvanced noautofocus" />
|
||||||
@ -21,19 +18,20 @@
|
|||||||
<div class="collectionTypeFieldDescription fieldDescription">
|
<div class="collectionTypeFieldDescription fieldDescription">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inputContainer">
|
<div class="inputContainer">
|
||||||
<input is="emby-input" type="text" id="txtValue" required="required" label="${LabelDisplayName}" />
|
<input is="emby-input" type="text" id="txtValue" required="required" label="${LabelDisplayName}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="display: flex; align-items: center;">
|
<div style="display: flex; align-items: center;">
|
||||||
<h1 style="margin: .5em 0;">${HeadersFolders}</h1>
|
<h1 style="margin: .5em 0;">${HeadersFolders}</h1>
|
||||||
<button is="emby-button" type="button" class="fab btnAddFolder submit" style="margin-left:1em;" title="${ButtonAdd}">
|
<button is="emby-button" type="button" class="fab btnAddFolder submit" style="margin-left:1em;" title="${ButtonAdd}">
|
||||||
<i class="md-icon">add</i>
|
<i class="md-icon">add</i>
|
||||||
</button>
|
</button>
|
||||||
|
<div class="paperList folderList hide" style="margin-bottom:2em;"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="paperList folderList hide" style="margin-bottom:2em;"></div>
|
|
||||||
|
|
||||||
<div class="libraryOptions"></div>
|
<div class="libraryOptions"></div>
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="formDialogFooter">
|
<div class="formDialogFooter">
|
||||||
<button is="emby-button" type="submit" class="raised button-submit block formDialogFooterItem">
|
<button is="emby-button" type="submit" class="raised button-submit block formDialogFooterItem">
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<div class="formDialogContent scrollY" style="padding-top:2em;">
|
<div class="formDialogContent scrollY" style="padding-top:2em;">
|
||||||
<div class="dialogContentInner dialog-content-centered">
|
<div class="dialogContentInner dialog-content-centered">
|
||||||
|
|
||||||
<div class="infoBanner" style="margin-bottom:1.8em;">
|
<div class="infoBanner" style="margin-bottom:1.8em;">
|
||||||
${ChangingMetadataImageSettingsNewContent}
|
${ChangingMetadataImageSettingsNewContent}
|
||||||
</div>
|
</div>
|
||||||
@ -26,6 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="paperList folderList" style="margin-bottom:2em;"></div>
|
<div class="paperList folderList" style="margin-bottom:2em;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="libraryOptions"></div>
|
<div class="libraryOptions"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -157,12 +157,13 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
|
|||||||
Name: globalize.translate("ButtonAddMediaLibrary"),
|
Name: globalize.translate("ButtonAddMediaLibrary"),
|
||||||
icon: "add_circle",
|
icon: "add_circle",
|
||||||
Locations: [],
|
Locations: [],
|
||||||
showType: !1,
|
showType: false,
|
||||||
showLocations: !1,
|
showLocations: false,
|
||||||
showMenu: !1,
|
showMenu: false,
|
||||||
showNameWithIcon: !0
|
showNameWithIcon: true
|
||||||
});
|
});
|
||||||
for (var i = 0, length = virtualFolders.length; i < length; i++) {
|
|
||||||
|
for (var i = 0; i < virtualFolders.length; i++) {
|
||||||
var virtualFolder = virtualFolders[i];
|
var virtualFolder = virtualFolders[i];
|
||||||
html += getVirtualFolderHtml(page, virtualFolder, i)
|
html += getVirtualFolderHtml(page, virtualFolder, i)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user