Merge pull request #506 from grafixeyehero/deminify-2

Deminify
This commit is contained in:
dkanada 2019-10-25 22:22:13 +09:00 committed by GitHub
commit 0d8bc6fb46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1018 additions and 493 deletions

View File

@ -2,7 +2,8 @@ define(["loading"], function(loading) {
"use strict";
function onFinish() {
loading.show(), ApiClient.ajax({
loading.show();
ApiClient.ajax({
url: ApiClient.getUrl("Startup/Complete"),
type: "POST"
}).then(function() {
@ -10,6 +11,7 @@ define(["loading"], function(loading) {
window.location.href = "index.html";
});
}
return function (view, params) {
view.querySelector(".btnWizardNext").addEventListener("click", onFinish);
};

View File

@ -3,29 +3,37 @@ define(["loading", "emby-checkbox", "emby-button", "emby-select"], function(load
function save(page) {
loading.show();
var apiClient = ApiClient,
config = {};
config.EnableRemoteAccess = page.querySelector("#chkRemoteAccess").checked, config.EnableAutomaticPortMapping = page.querySelector("#chkEnableUpnp").checked, apiClient.ajax({
var apiClient = ApiClient;
var config = {};
config.EnableRemoteAccess = page.querySelector("#chkRemoteAccess").checked;
config.EnableAutomaticPortMapping = page.querySelector("#chkEnableUpnp").checked;
apiClient.ajax({
type: "POST",
data: config,
url: apiClient.getUrl("Startup/RemoteAccess")
}).then(function () {
loading.hide(), navigateToNextPage()
})
loading.hide();
navigateToNextPage();
});
}
function navigateToNextPage() {
Dashboard.navigate("wizardfinish.html")
Dashboard.navigate("wizardfinish.html");
}
function onSubmit(e) {
return save(this), e.preventDefault(), !1
save(this);
e.preventDefault();
return false;
}
return function (view, params) {
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader")
}), view.addEventListener("viewhide", function() {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader")
})
}
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit);
view.addEventListener("viewshow", function () {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
});
view.addEventListener("viewhide", function () {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
});
};
});

View File

@ -5,63 +5,80 @@ define(["loading", "emby-checkbox", "emby-button", "emby-select"], function(load
loading.show();
var apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) {
config.PreferredMetadataLanguage = page.querySelector("#selectLanguage").value, config.MetadataCountryCode = page.querySelector("#selectCountry").value, apiClient.ajax({
config.PreferredMetadataLanguage = page.querySelector("#selectLanguage").value;
config.MetadataCountryCode = page.querySelector("#selectCountry").value;
apiClient.ajax({
type: "POST",
data: config,
url: apiClient.getUrl("Startup/Configuration")
}).then(function () {
loading.hide(), navigateToNextPage()
})
})
loading.hide();
navigateToNextPage();
});
});
}
function populateLanguages(select, languages) {
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = languages.length; i < length; i++) {
var culture = languages[i];
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>"
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html
select.innerHTML = html;
}
function populateCountries(select, allCountries) {
var html = "";
html += "<option value=''></option>";
for (var i = 0, length = allCountries.length; i < length; i++) {
var culture = allCountries[i];
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>"
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + "</option>";
}
select.innerHTML = html
select.innerHTML = html;
}
function reloadData(page, config, cultures, countries) {
populateLanguages(page.querySelector("#selectLanguage"), cultures), populateCountries(page.querySelector("#selectCountry"), countries), page.querySelector("#selectLanguage").value = config.PreferredMetadataLanguage, page.querySelector("#selectCountry").value = config.MetadataCountryCode, loading.hide()
populateLanguages(page.querySelector("#selectLanguage"), cultures);
populateCountries(page.querySelector("#selectCountry"), countries);
page.querySelector("#selectLanguage").value = config.PreferredMetadataLanguage;
page.querySelector("#selectCountry").value = config.MetadataCountryCode;
loading.hide();
}
function reload(page) {
loading.show();
var apiClient = ApiClient,
promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")),
promise2 = apiClient.getCultures(),
promise3 = apiClient.getCountries();
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration"));
var promise2 = apiClient.getCultures();
var promise3 = apiClient.getCountries();
Promise.all([promise1, promise2, promise3]).then(function (responses) {
reloadData(page, responses[0], responses[1], responses[2])
})
reloadData(page, responses[0], responses[1], responses[2]);
});
}
function navigateToNextPage() {
Dashboard.navigate("wizardremoteaccess.html")
Dashboard.navigate("wizardremoteaccess.html");
}
function onSubmit(e) {
return save(this), e.preventDefault(), !1
save(this);
e.preventDefault();
return false;
}
return function (view, params) {
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"), reload(this)
}), view.addEventListener("viewhide", function() {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader")
})
}
view.querySelector(".wizardSettingsForm").addEventListener("submit", onSubmit);
view.addEventListener("viewshow", function () {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
reload(this);
});
view.addEventListener("viewhide", function () {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
});
};
});

View File

@ -3,39 +3,46 @@ define(["jQuery", "loading", "emby-button", "emby-select"], function($, loading)
function loadPage(page, config, languageOptions) {
$("#selectLocalizationLanguage", page).html(languageOptions.map(function (l) {
return '<option value="' + l.Value + '">' + l.Name + "</option>"
})).val(config.UICulture), loading.hide()
return '<option value="' + l.Value + '">' + l.Name + "</option>";
})).val(config.UICulture);
loading.hide();
}
function save(page) {
loading.show();
var apiClient = ApiClient;
apiClient.getJSON(apiClient.getUrl("Startup/Configuration")).then(function (config) {
config.UICulture = $("#selectLocalizationLanguage", page).val(), apiClient.ajax({
config.UICulture = $("#selectLocalizationLanguage", page).val();
apiClient.ajax({
type: "POST",
data: config,
url: apiClient.getUrl("Startup/Configuration")
}).then(function () {
Dashboard.navigate("wizarduser.html")
})
})
Dashboard.navigate("wizarduser.html");
});
});
}
function onSubmit() {
return save($(this).parents(".page")), !1
save($(this).parents(".page"));
return false;
}
return function (view, params) {
$(".wizardStartForm", view).on("submit", onSubmit), view.addEventListener("viewshow", function() {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader"), loading.show();
var page = this,
apiClient = ApiClient,
promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration")),
promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options"));
$(".wizardStartForm", view).on("submit", onSubmit);
view.addEventListener("viewshow", function () {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
loading.show();
var page = this;
var apiClient = ApiClient;
var promise1 = apiClient.getJSON(apiClient.getUrl("Startup/Configuration"));
var promise2 = apiClient.getJSON(apiClient.getUrl("Localization/Options"));
Promise.all([promise1, promise2]).then(function (responses) {
loadPage(page, responses[0], responses[1])
})
}), view.addEventListener("viewhide", function() {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader")
})
}
loadPage(page, responses[0], responses[1]);
});
});
view.addEventListener("viewhide", function () {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
});
};
});

View File

@ -30,6 +30,7 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em
function onSubmit(e) {
var form = this;
if (form.querySelector("#txtManualPassword").value != form.querySelector("#txtPasswordConfirm").value) {
require(["toast"], function (toast) {
toast(Globalize.translate("PasswordMatchError"));
@ -37,6 +38,7 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em
} else {
submit(form);
}
e.preventDefault();
return false;
}
@ -49,16 +51,17 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em
page.querySelector("#txtUsername").value = user.Name || "";
page.querySelector("#txtManualPassword").value = user.Password || "";
loading.hide();
})
});
}
return function (view, params) {
view.querySelector(".wizardUserForm").addEventListener("submit", onSubmit);
view.addEventListener("viewshow", function () {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader")
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
});
view.addEventListener("viewhide", function () {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader")
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
});
view.addEventListener("viewshow", onViewShow);
}
};
});

View File

@ -2,21 +2,27 @@ define(["backdrop", "userSettings", "libraryMenu"], function(backdrop, userSetti
"use strict";
function enabled() {
return userSettings.enableBackdrops()
return userSettings.enableBackdrops();
}
function getBackdropItemIds(apiClient, userId, types, parentId) {
var key = "backdrops2_" + userId + (types || "") + (parentId || ""),
data = cache[key];
if (data) return console.log("Found backdrop id list in cache. Key: " + key), data = JSON.parse(data), Promise.resolve(data);
var key = "backdrops2_" + userId + (types || "") + (parentId || "");
var data = cache[key];
if (data) {
console.log("Found backdrop id list in cache. Key: " + key);
data = JSON.parse(data);
return Promise.resolve(data);
}
var options = {
SortBy: "IsFavoriteOrLiked,Random",
Limit: 20,
Recursive: !0,
Recursive: true,
IncludeItemTypes: types,
ImageTypes: "Backdrop",
ParentId: parentId,
EnableTotalRecordCount: !1
EnableTotalRecordCount: false
};
return apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
var images = result.Items.map(function (i) {
@ -24,30 +30,47 @@ define(["backdrop", "userSettings", "libraryMenu"], function(backdrop, userSetti
Id: i.Id,
tag: i.BackdropImageTags[0],
ServerId: i.ServerId
}
};
});
cache[key] = JSON.stringify(images);
return images;
});
return cache[key] = JSON.stringify(images), images
})
}
function showBackdrop(type, parentId) {
var apiClient = window.ApiClient;
apiClient && getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function(images) {
images.length ? backdrop.setBackdrops(images.map(function(i) {
return i.BackdropImageTags = [i.tag], i
})) : backdrop.clear()
})
if (apiClient) {
getBackdropItemIds(apiClient, apiClient.getCurrentUserId(), type, parentId).then(function (images) {
if (images.length) {
backdrop.setBackdrops(images.map(function (i) {
i.BackdropImageTags = [i.tag];
return i;
}));
} else {
backdrop.clear();
}
});
}
}
var cache = {};
pageClassOn("pageshow", "page", function () {
var page = this;
if (!page.classList.contains("selfBackdropPage"))
if (page.classList.contains("backdropPage"))
if (!page.classList.contains("selfBackdropPage")) {
if (page.classList.contains("backdropPage")) {
if (enabled()) {
var type = page.getAttribute("data-backdroptype"),
parentId = page.classList.contains("globalBackdropPage") ? "" : libraryMenu.getTopParentId();
showBackdrop(type, parentId)
} else page.classList.remove("backdropPage"), backdrop.clear();
else backdrop.clear()
})
var type = page.getAttribute("data-backdroptype");
var parentId = page.classList.contains("globalBackdropPage") ? "" : libraryMenu.getTopParentId();
showBackdrop(type, parentId);
} else {
page.classList.remove("backdropPage");
backdrop.clear();
}
} else {
backdrop.clear();
}
}
});
});

View File

@ -3,38 +3,88 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
function renderItems(page, item) {
var sections = [];
item.ArtistCount && sections.push({
if (item.ArtistCount) {
sections.push({
name: Globalize.translate("TabArtists"),
type: "MusicArtist"
}), item.ProgramCount && "Person" == item.Type && sections.push({
});
}
if (item.ProgramCount && "Person" == item.Type) {
sections.push({
name: Globalize.translate("HeaderUpcomingOnTV"),
type: "Program"
}), item.MovieCount && sections.push({
});
}
if (item.MovieCount) {
sections.push({
name: Globalize.translate("TabMovies"),
type: "Movie"
}), item.SeriesCount && sections.push({
});
}
if (item.SeriesCount) {
sections.push({
name: Globalize.translate("TabShows"),
type: "Series"
}), item.EpisodeCount && sections.push({
});
}
if (item.EpisodeCount) {
sections.push({
name: Globalize.translate("TabEpisodes"),
type: "Episode"
}), item.TrailerCount && sections.push({
});
}
if (item.TrailerCount) {
sections.push({
name: Globalize.translate("TabTrailers"),
type: "Trailer"
}), item.AlbumCount && sections.push({
});
}
if (item.AlbumCount) {
sections.push({
name: Globalize.translate("TabAlbums"),
type: "MusicAlbum"
}), item.MusicVideoCount && sections.push({
});
}
if (item.MusicVideoCount) {
sections.push({
name: Globalize.translate("TabMusicVideos"),
type: "MusicVideo"
});
}
var elem = page.querySelector("#childrenContent");
elem.innerHTML = sections.map(function (section) {
var html = "",
sectionClass = "verticalSection";
return "Audio" === section.type && (sectionClass += " verticalSection-extrabottompadding"), html += '<div class="' + sectionClass + '" data-type="' + section.type + '">', html += '<div class="sectionTitleContainer sectionTitleContainer-cards">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">', html += section.name, html += "</h2>", html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + Globalize.translate("ButtonMore") + "</button></a>", html += "</div>", html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right">', html += "</div>", html += "</div>"
var html = "";
var sectionClass = "verticalSection";
if ("Audio" === section.type) {
sectionClass += " verticalSection-extrabottompadding";
}
html += '<div class="' + sectionClass + '" data-type="' + section.type + '">';
html += '<div class="sectionTitleContainer sectionTitleContainer-cards">';
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">';
html += section.name;
html += "</h2>";
html += '<a is="emby-linkbutton" href="#" class="clearLink hide" style="margin-left:1em;vertical-align:middle;"><button is="emby-button" type="button" class="raised more raised-mini noIcon">' + Globalize.translate("ButtonMore") + "</button></a>";
html += "</div>";
html += '<div is="emby-itemscontainer" class="itemsContainer padded-left padded-right">';
html += "</div>";
return html += "</div>";
}).join("");
for (var sectionElems = elem.querySelectorAll(".verticalSection"), i = 0, length = sectionElems.length; i < length; i++) renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type"))
var sectionElems = elem.querySelectorAll(".verticalSection");
for (var i = 0, length = sectionElems.length; i < length; i++) {
renderSection(page, item, sectionElems[i], sectionElems[i].getAttribute("data-type"));
}
}
function renderSection(page, item, element, type) {
@ -50,16 +100,17 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "StartDate"
}, {
shape: "backdrop",
showTitle: !0,
centerText: !0,
overlayMoreButton: !0,
preferThumb: !0,
overlayText: !1,
showAirTime: !0,
showAirDateTime: !0,
showChannelName: !0
showTitle: true,
centerText: true,
overlayMoreButton: true,
preferThumb: true,
overlayText: false,
showAirTime: true,
showAirDateTime: true,
showChannelName: true
});
break;
case "Movie":
loadItems(element, item, type, {
MediaTypes: "",
@ -71,13 +122,14 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "portrait",
showTitle: !0,
centerText: !0,
overlayMoreButton: !0,
overlayText: !1,
showYear: !0
showTitle: true,
centerText: true,
overlayMoreButton: true,
overlayText: false,
showYear: true
});
break;
case "MusicVideo":
loadItems(element, item, type, {
MediaTypes: "",
@ -89,11 +141,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "portrait",
showTitle: !0,
centerText: !0,
overlayPlayButton: !0
showTitle: true,
centerText: true,
overlayPlayButton: true
});
break;
case "Trailer":
loadItems(element, item, type, {
MediaTypes: "",
@ -105,11 +158,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "portrait",
showTitle: !0,
centerText: !0,
overlayPlayButton: !0
showTitle: true,
centerText: true,
overlayPlayButton: true
});
break;
case "Series":
loadItems(element, item, type, {
MediaTypes: "",
@ -121,11 +175,12 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "portrait",
showTitle: !0,
centerText: !0,
overlayMoreButton: !0
showTitle: true,
centerText: true,
overlayMoreButton: true
});
break;
case "MusicAlbum":
loadItems(element, item, type, {
MediaTypes: "",
@ -137,14 +192,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "ProductionYear,Sortname"
}, {
shape: "square",
playFromHere: !0,
showTitle: !0,
showYear: !0,
coverImage: !0,
centerText: !0,
overlayPlayButton: !0
playFromHere: true,
showTitle: true,
showYear: true,
coverImage: true,
centerText: true,
overlayPlayButton: true
});
break;
case "MusicArtist":
loadItems(element, item, type, {
MediaTypes: "",
@ -156,14 +212,15 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "square",
playFromHere: !0,
showTitle: !0,
showParentTitle: !0,
coverImage: !0,
centerText: !0,
overlayPlayButton: !0
playFromHere: true,
showTitle: true,
showParentTitle: true,
coverImage: true,
centerText: true,
overlayPlayButton: true
});
break;
case "Episode":
loadItems(element, item, type, {
MediaTypes: "",
@ -175,12 +232,13 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
SortBy: "SortName"
}, {
shape: "backdrop",
showTitle: !0,
showParentTitle: !0,
centerText: !0,
overlayPlayButton: !0
showTitle: true,
showParentTitle: true,
centerText: true,
overlayPlayButton: true
});
break;
case "Audio":
loadItems(element, item, type, {
MediaTypes: "",
@ -190,57 +248,122 @@ define(["connectionManager", "listView", "cardBuilder", "imageLoader", "libraryB
AlbumArtistIds: "",
SortBy: "AlbumArtist,Album,SortName"
}, {
playFromHere: !0,
playFromHere: true,
action: "playallfromhere",
smallIcon: !0,
artist: !0
})
smallIcon: true,
artist: true
});
}
}
function loadItems(element, item, type, query, listOptions) {
query = getQuery(query, item), getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function(result) {
query = getQuery(query, item);
getItemsFunction(query, item)(query.StartIndex, query.Limit, query.Fields).then(function (result) {
var html = "";
if (query.Limit && result.TotalRecordCount > query.Limit) {
var link = element.querySelector("a");
link.classList.remove("hide"), link.setAttribute("href", getMoreItemsHref(item, type))
} else element.querySelector("a").classList.add("hide");
link.classList.remove("hide");
link.setAttribute("href", getMoreItemsHref(item, type));
} else {
element.querySelector("a").classList.add("hide");
}
listOptions.items = result.Items;
var itemsContainer = element.querySelector(".itemsContainer");
"Audio" == type ? (html = listView.getListViewHtml(listOptions), itemsContainer.classList.remove("vertical-wrap"), itemsContainer.classList.add("vertical-list")) : (html = cardBuilder.getCardsHtml(listOptions), itemsContainer.classList.add("vertical-wrap"), itemsContainer.classList.remove("vertical-list")), itemsContainer.innerHTML = html, imageLoader.lazyChildren(itemsContainer)
})
if ("Audio" == type) {
html = listView.getListViewHtml(listOptions);
itemsContainer.classList.remove("vertical-wrap");
itemsContainer.classList.add("vertical-list");
} else {
html = cardBuilder.getCardsHtml(listOptions);
itemsContainer.classList.add("vertical-wrap");
itemsContainer.classList.remove("vertical-list");
}
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
});
}
function getMoreItemsHref(item, type) {
return "Genre" == item.Type ? "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId : "MusicGenre" == item.Type ? "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId : "Studio" == item.Type ? "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId : "MusicArtist" == item.Type ? "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId : "Person" == item.Type ? "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId : "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId
if ("Genre" == item.Type) {
return "list.html?type=" + type + "&genreId=" + item.Id + "&serverId=" + item.ServerId;
}
if ("MusicGenre" == item.Type) {
return "list.html?type=" + type + "&musicGenreId=" + item.Id + "&serverId=" + item.ServerId;
}
if ("Studio" == item.Type) {
return "list.html?type=" + type + "&studioId=" + item.Id + "&serverId=" + item.ServerId;
}
if ("MusicArtist" == item.Type) {
return "list.html?type=" + type + "&artistId=" + item.Id + "&serverId=" + item.ServerId;
}
if ("Person" == item.Type) {
return "list.html?type=" + type + "&personId=" + item.Id + "&serverId=" + item.ServerId;
}
return "list.html?type=" + type + "&parentId=" + item.Id + "&serverId=" + item.ServerId;
}
function addCurrentItemToQuery(query, item) {
"Person" == item.Type ? query.PersonIds = item.Id : "Genre" == item.Type ? query.GenreIds = item.Id : "MusicGenre" == item.Type ? query.GenreIds = item.Id : "Studio" == item.Type ? query.StudioIds = item.Id : "MusicArtist" == item.Type && (connectionManager.getApiClient(item.ServerId).isMinServerVersion("3.4.1.18") ? query.AlbumArtistIds = item.Id : query.ArtistIds = item.Id)
if (item.Type == "Person") {
query.PersonIds = item.Id;
} else if (item.Type == "Genre") {
query.Genres = item.Name;
} else if (item.Type == "MusicGenre") {
query.Genres = item.Name;
} else if (item.Type == "GameGenre") {
query.Genres = item.Name;
} else if (item.Type == "Studio") {
query.StudioIds = item.Id;
} else if (item.Type == "MusicArtist") {
query.AlbumArtistIds = item.Id;
}
}
function getQuery(options, item) {
var query = {
SortOrder: "Ascending",
IncludeItemTypes: "",
Recursive: !0,
Recursive: true,
Fields: "AudioInfo,SeriesInfo,ParentId,PrimaryImageAspectRatio,BasicSyncInfo",
Limit: 100,
StartIndex: 0,
CollapseBoxSetItems: !1
CollapseBoxSetItems: false
};
return query = Object.assign(query, options || {}), addCurrentItemToQuery(query, item), query
query = Object.assign(query, options || {});
addCurrentItemToQuery(query, item);
return query;
}
function getItemsFunction(options, item) {
var query = getQuery(options, item);
return function (index, limit, fields) {
query.StartIndex = index, query.Limit = limit, fields && (query.Fields += "," + fields);
query.StartIndex = index;
query.Limit = limit;
if (fields) {
query.Fields += "," + fields;
}
var apiClient = connectionManager.getApiClient(item.ServerId);
return "MusicArtist" === query.IncludeItemTypes ? (query.IncludeItemTypes = null, apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query)) : apiClient.getItems(apiClient.getCurrentUserId(), query)
if ("MusicArtist" === query.IncludeItemTypes) {
query.IncludeItemTypes = null;
return apiClient.getAlbumArtists(apiClient.getCurrentUserId(), query);
}
return apiClient.getItems(apiClient.getCurrentUserId(), query);
};
}
window.ItemsByName = {
renderItems: renderItems
}
};
});

View File

@ -1,33 +1,56 @@
define(["userSettings"], function (userSettings) {
"use strict";
var libraryBrowser = {
getSavedQueryKey: function (modifier) {
return window.location.href.split("#")[0] + (modifier || "")
return window.location.href.split("#")[0] + (modifier || "");
},
loadSavedQueryValues: function (key, query) {
var values = userSettings.get(key);
return values ? (values = JSON.parse(values), Object.assign(query, values)) : query
if (values) {
values = JSON.parse(values);
return Object.assign(query, values);
}
return query;
},
saveQueryValues: function (key, query) {
var values = {};
query.SortBy && (values.SortBy = query.SortBy), query.SortOrder && (values.SortOrder = query.SortOrder), userSettings.set(key, JSON.stringify(values))
if (query.SortBy) {
values.SortBy = query.SortBy;
}
if (query.SortOrder) {
values.SortOrder = query.SortOrder;
}
userSettings.set(key, JSON.stringify(values));
},
saveViewSetting: function (key, value) {
userSettings.set(key + "-_view", value)
userSettings.set(key + "-_view", value);
},
getSavedView: function (key) {
return userSettings.get(key + "-_view")
return userSettings.get(key + "-_view");
},
showLayoutMenu: function (button, currentLayout, views) {
var dispatchEvent = !0;
views || (dispatchEvent = !1, views = button.getAttribute("data-layouts"), views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"]);
var dispatchEvent = true;
if (!views) {
dispatchEvent = false;
views = button.getAttribute("data-layouts");
views = views ? views.split(",") : ["List", "Poster", "PosterCard", "Thumb", "ThumbCard"];
}
var menuItems = views.map(function (v) {
return {
name: Globalize.translate("Option" + v),
id: v,
selected: currentLayout == v
}
};
});
require(["actionsheet"], function (actionsheet) {
actionsheet.show({
items: menuItems,
@ -37,65 +60,139 @@ define(["userSettings"], function(userSettings) {
detail: {
viewStyle: id
},
bubbles: !0,
cancelable: !1
})), dispatchEvent || window.$ && $(button).trigger("layoutchange", [id])
bubbles: true,
cancelable: false
}));
if (!dispatchEvent) {
if (window.$) {
$(button).trigger("layoutchange", [id]);
}
})
})
}
}
});
});
},
getQueryPagingHtml: function (options) {
var startIndex = options.startIndex,
limit = options.limit,
totalRecordCount = options.totalRecordCount,
html = "",
recordsEnd = Math.min(startIndex + limit, totalRecordCount),
showControls = limit < totalRecordCount;
var startIndex = options.startIndex;
var limit = options.limit;
var totalRecordCount = options.totalRecordCount;
var html = "";
var recordsEnd = Math.min(startIndex + limit, totalRecordCount);
var showControls = limit < totalRecordCount;
if (html += '<div class="listPaging">', showControls) {
html += '<span style="vertical-align:middle;">';
html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount, html += "</span>"
html += (totalRecordCount ? startIndex + 1 : 0) + "-" + recordsEnd + " of " + totalRecordCount;
html += "</span>";
}
return (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) && (html += '<div style="display:inline-block;">', showControls && (html += '<button is="paper-icon-button-light" class="btnPreviousPage autoSize" ' + (startIndex ? "" : "disabled") + '><i class="md-icon">&#xE5C4;</i></button>', html += '<button is="paper-icon-button-light" class="btnNextPage autoSize" ' + (startIndex + limit >= totalRecordCount ? "disabled" : "") + '><i class="md-icon">&#xE5C8;</i></button>'), options.addLayoutButton && (html += '<button is="paper-icon-button-light" title="' + Globalize.translate("ButtonSelectView") + '" class="btnChangeLayout autoSize" data-layouts="' + (options.layouts || "") + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || "") + '\');"><i class="md-icon">&#xE42A;</i></button>'), options.sortButton && (html += '<button is="paper-icon-button-light" class="btnSort autoSize" title="' + Globalize.translate("ButtonSort") + '"><i class="md-icon">&#xE053;</i></button>'), options.filterButton && (html += '<button is="paper-icon-button-light" class="btnFilter autoSize" title="' + Globalize.translate("ButtonFilter") + '"><i class="md-icon">&#xE152;</i></button>'), html += "</div>"), html += "</div>"
if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) {
html += '<div style="display:inline-block;">';
if (showControls) {
html += '<button is="paper-icon-button-light" class="btnPreviousPage autoSize" ' + (startIndex ? "" : "disabled") + '><i class="md-icon">&#xE5C4;</i></button>';
html += '<button is="paper-icon-button-light" class="btnNextPage autoSize" ' + (startIndex + limit >= totalRecordCount ? "disabled" : "") + '><i class="md-icon">&#xE5C8;</i></button>';
}
if (options.addLayoutButton) {
html += '<button is="paper-icon-button-light" title="' + Globalize.translate("ButtonSelectView") + '" class="btnChangeLayout autoSize" data-layouts="' + (options.layouts || "") + '" onclick="LibraryBrowser.showLayoutMenu(this, \'' + (options.currentLayout || "") + '\');"><i class="md-icon">&#xE42A;</i></button>';
}
if (options.sortButton) {
html += '<button is="paper-icon-button-light" class="btnSort autoSize" title="' + Globalize.translate("ButtonSort") + '"><i class="md-icon">&#xE053;</i></button>';
}
if (options.filterButton) {
html += '<button is="paper-icon-button-light" class="btnFilter autoSize" title="' + Globalize.translate("ButtonFilter") + '"><i class="md-icon">&#xE152;</i></button>';
}
html += "</div>";
}
return html += "</div>";
},
showSortMenu: function (options) {
require(["dialogHelper", "emby-radio"], function (dialogHelper) {
function onSortByChange() {
var newValue = this.value;
if (this.checked) {
var changed = options.query.SortBy != newValue;
options.query.SortBy = newValue.replace("_", ","), options.query.StartIndex = 0, options.callback && changed && options.callback()
options.query.SortBy = newValue.replace("_", ",");
options.query.StartIndex = 0;
if (options.callback && changed) {
options.callback();
}
}
}
function onSortOrderChange() {
var newValue = this.value;
if (this.checked) {
var changed = options.query.SortOrder != newValue;
options.query.SortOrder = newValue, options.query.StartIndex = 0, options.callback && changed && options.callback()
options.query.SortOrder = newValue;
options.query.StartIndex = 0;
if (options.callback && changed) {
options.callback();
}
}
}
var dlg = dialogHelper.createDialog({
removeOnClose: !0,
modal: !1,
removeOnClose: true,
modal: false,
entryAnimationDuration: 160,
exitAnimationDuration: 200
});
dlg.classList.add("ui-body-a"), dlg.classList.add("background-theme-a"), dlg.classList.add("formDialog");
dlg.classList.add("ui-body-a");
dlg.classList.add("background-theme-a");
dlg.classList.add("formDialog");
var html = "";
html += '<div style="margin:0;padding:1.25em 1.5em 1.5em;">', html += '<h2 style="margin:0 0 .5em;">', html += Globalize.translate("HeaderSortBy"), html += "</h2>";
var i, length, isChecked;
for (html += "<div>", i = 0, length = options.items.length; i < length; i++) {
var option = options.items[i],
radioValue = option.id.replace(",", "_");
isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : "", html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortBy" data-id="' + option.id + '" value="' + radioValue + '" class="menuSortBy" ' + isChecked + " /><span>" + option.name + "</span></label>"
html += '<div style="margin:0;padding:1.25em 1.5em 1.5em;">';
html += '<h2 style="margin:0 0 .5em;">';
html += Globalize.translate("HeaderSortBy");
html += "</h2>";
var i, length;
var isChecked;
html += '<div>';
for (i = 0, length = options.items.length; i < length; i++) {
var option = options.items[i];
var radioValue = option.id.replace(",", "_");
isChecked = (options.query.SortBy || "").replace(",", "_") == radioValue ? " checked" : "";
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortBy" data-id="' + option.id + '" value="' + radioValue + '" class="menuSortBy" ' + isChecked + " /><span>" + option.name + "</span></label>";
}
html += "</div>", html += '<h2 style="margin: 1em 0 .5em;">', html += Globalize.translate("HeaderSortOrder"), html += "</h2>", html += "<div>", isChecked = "Ascending" == options.query.SortOrder ? " checked" : "", html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Ascending" class="menuSortOrder" ' + isChecked + " /><span>" + Globalize.translate("OptionAscending") + "</span></label>", isChecked = "Descending" == options.query.SortOrder ? " checked" : "", html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Descending" class="menuSortOrder" ' + isChecked + " /><span>" + Globalize.translate("OptionDescending") + "</span></label>", html += "</div>", html += "</div>", dlg.innerHTML = html, dialogHelper.open(dlg);
html += "</div>";
html += '<h2 style="margin: 1em 0 .5em;">';
html += Globalize.translate("HeaderSortOrder");
html += "</h2>";
html += "<div>";
isChecked = "Ascending" == options.query.SortOrder ? " checked" : "";
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Ascending" class="menuSortOrder" ' + isChecked + " /><span>" + Globalize.translate("OptionAscending") + "</span></label>";
isChecked = "Descending" == options.query.SortOrder ? " checked" : "";
html += '<label class="radio-label-block"><input type="radio" is="emby-radio" name="SortOrder" value="Descending" class="menuSortOrder" ' + isChecked + " /><span>" + Globalize.translate("OptionDescending") + "</span></label>";
html += "</div>";
html += "</div>";
dlg.innerHTML = html;
dialogHelper.open(dlg);
var sortBys = dlg.querySelectorAll(".menuSortBy");
for (i = 0, length = sortBys.length; i < length; i++) sortBys[i].addEventListener("change", onSortByChange);
for (i = 0, length = sortBys.length; i < length; i++) {
sortBys[i].addEventListener("change", onSortByChange);
}
var sortOrders = dlg.querySelectorAll(".menuSortOrder");
for (i = 0, length = sortOrders.length; i < length; i++) sortOrders[i].addEventListener("change", onSortOrderChange)
})
for (i = 0, length = sortOrders.length; i < length; i++) {
sortOrders[i].addEventListener("change", onSortOrderChange);
}
});
}
};
return window.LibraryBrowser = libraryBrowser, libraryBrowser
window.LibraryBrowser = libraryBrowser;
return libraryBrowser;
});

View File

@ -105,6 +105,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
function bindMenuEvents() {
mainDrawerButton = document.querySelector(".mainDrawerButton");
if (mainDrawerButton) {
mainDrawerButton.addEventListener("click", toggleMainDrawer);
}
@ -198,18 +199,21 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
html += '<h3 class="sidebarHeader">';
html += globalize.translate("HeaderUser");
html += "</h3>";
if (appHost.supports("multiserver")) {
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><i class="md-icon navMenuOptionIcon">wifi</i><span class="navMenuOptionText">' + globalize.translate("ButtonSelectServer") + "</span></a>";
}
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder btnLogout" data-itemid="logout" href="#"><i class="md-icon navMenuOptionIcon">exit_to_app</i><span class="navMenuOptionText">' + globalize.translate("ButtonSignOut") + "</span></a>";
html += "</div>";
}
// add buttons to navigation drawer
navDrawerScrollContainer.innerHTML = html;
// bind logout button click to method
var btnLogout = navDrawerScrollContainer.querySelector(".btnLogout");
if (btnLogout) {
btnLogout.addEventListener("click", onLogoutClick);
}
@ -250,6 +254,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
pageUrls = pageUrls.split("|");
selected = pageUrls.filter(isUrlInCurrentView).length > 0;
}
if (selected) {
link.classList.add("navMenuOption-selected");
var title = "";
@ -377,6 +382,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
function addPluginPagesToMainMenu(links, pluginItems, section) {
for (var i = 0, length = pluginItems.length; i < length; i++) {
var pluginItem = pluginItems[i];
if (pluginItem.EnableInMainMenu && pluginItem.MenuSection === section) {
links.push({
name: pluginItem.DisplayName,
@ -416,15 +422,14 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
return getToolsMenuLinks(apiClient).then(function (items) {
var item;
var menuHtml = "";
menuHtml += '<div class="drawerContent">';
for (var i = 0; i < items.length; i++) {
item = items[i];
if (item.href) {
menuHtml += getToolsLinkHtml(item);
}
else if (item.name) {
} else if (item.name) {
menuHtml += '<h3 class="sidebarHeader">';
menuHtml += item.name;
menuHtml += "</h3>";
@ -460,8 +465,8 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
for (var i = 0, length = items.length; i < length; i++) {
var view = items[i];
list.push(view);
if ("livetv" == view.CollectionType) {
view.ImageTags = {};
view.icon = "live_tv";
@ -484,8 +489,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
if (elem) {
if (show) {
elem.classList.remove("hide");
}
else {
} else {
elem.classList.add("hide");
}
}
@ -503,15 +507,13 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
// FIXME: Potentially the same as above
if (user.Policy.EnableContentDownloading) {
showBySelector(".lnkSyncToOtherDevices", true);
}
else {
} else {
showBySelector(".lnkSyncToOtherDevices", false);
}
if (user.Policy.EnableContentDownloading && appHost.supports("sync")) {
showBySelector(".libraryMenuDownloads", true);
}
else {
} else {
showBySelector(".libraryMenuDownloads", false);
}
@ -529,9 +531,11 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
html += items.map(function (i) {
var icon = i.icon || imageHelper.getLibraryIcon(i.CollectionType);
var itemId = i.Id;
if (i.onclick) {
i.onclick;
}
return '<a is="emby-linkbutton" data-itemid="' + itemId + '" class="lnkMediaFolder navMenuOption" href="' + getItemHref(i, i.CollectionType) + '"><i class="md-icon navMenuOptionIcon">' + icon + '</i><span class="sectionName navMenuOptionText">' + i.Name + "</span></a>";
}).join("");
libraryMenuOptions.innerHTML = html;
@ -592,23 +596,17 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
if (isChannelsPage && "channels" === itemId) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else if (isLiveTvPage && "livetv" === itemId) {
} else if (isLiveTvPage && "livetv" === itemId) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else if (isEditorPage && "editor" === itemId) {
} else if (isEditorPage && "editor" === itemId) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else if (isMySyncPage && "manageoffline" === itemId && -1 != window.location.href.toString().indexOf("mode=download")) {
} else if (isMySyncPage && "manageoffline" === itemId && -1 != window.location.href.toString().indexOf("mode=download")) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else if (isMySyncPage && "syncotherdevices" === itemId && -1 == window.location.href.toString().indexOf("mode=download")) {
} else if (isMySyncPage && "syncotherdevices" === itemId && -1 == window.location.href.toString().indexOf("mode=download")) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else if (id && itemId == id) {
} else if (id && itemId == id) {
lnkMediaFolder.classList.add("navMenuOption-selected");
}
else {
} else {
lnkMediaFolder.classList.remove("navMenuOption-selected");
}
}
@ -667,8 +665,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
if (title) {
LibraryMenu.setTitle(title);
}
else if (page.classList.contains("standalonePage")) {
} else if (page.classList.contains("standalonePage")) {
LibraryMenu.setDefaultTitle();
}
}
@ -697,6 +694,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
function refreshLibraryDrawer(user) {
loadNavDrawer();
currentDrawerType = "library";
if (user) {
Promise.resolve(user);
} else {
@ -729,9 +727,11 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
return new Promise(function (resolve, reject) {
require(["navdrawer"], function (navdrawer) {
navDrawerInstance = new navdrawer(getNavDrawerOptions());
if (!layoutManager.tv) {
navDrawerElement.classList.remove("hide");
}
resolve(navDrawerInstance);
});
});

View File

@ -2,56 +2,94 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutM
"use strict";
function enableScrollX() {
return !layoutManager.desktop
return !layoutManager.desktop;
}
function getBackdropShape() {
return enableScrollX() ? "overflowBackdrop" : "backdrop"
return enableScrollX() ? "overflowBackdrop" : "backdrop";
}
function getTimersHtml(timers, options) {
options = options || {};
var i, length, items = timers.map(function(t) {
return t.Type = "Timer", t
}),
groups = [],
currentGroupName = "",
currentGroup = [];
var i;
var length;
var items = timers.map(function (t) {
t.Type = "Timer";
return t;
});
var groups = [];
var currentGroupName = "";
var currentGroup = [];
for (i = 0, length = items.length; i < length; i++) {
var item = items[i],
dateText = "";
if (!1 !== options.indexByDate && item.StartDate) try {
var premiereDate = datetime.parseISO8601Date(item.StartDate, !0);
var item = items[i];
var dateText = "";
if (options.indexByDate !== false && item.StartDate) {
try {
var premiereDate = datetime.parseISO8601Date(item.StartDate, true);
dateText = datetime.toLocaleDateString(premiereDate, {
weekday: "long",
month: "short",
day: "numeric"
})
} catch (err) {}
dateText != currentGroupName ? (currentGroup.length && groups.push({
name: currentGroupName,
items: currentGroup
}), currentGroupName = dateText, currentGroup = [item]) : currentGroup.push(item)
});
} catch (err) {
console.log("Error parsing premiereDate:" + item.StartDate + "; error: " + err);
}
currentGroup.length && groups.push({
}
if (dateText != currentGroupName) {
if (currentGroup.length) {
groups.push({
name: currentGroupName,
items: currentGroup
});
}
currentGroupName = dateText;
currentGroup = [item];
} else {
currentGroup.push(item);
}
}
if (currentGroup.length) {
groups.push({
name: currentGroupName,
items: currentGroup
});
}
var html = "";
for (i = 0, length = groups.length; i < length; i++) {
var group = groups[i],
supportsImageAnalysis = appHost.supports("imageanalysis"),
cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
if (cardLayout = !0, group.name && (html += '<div class="verticalSection">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + "</h2>"), enableScrollX()) {
var group = groups[i];
var supportsImageAnalysis = appHost.supports("imageanalysis");
var cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
cardLayout = true;
if (group.name) {
html += '<div class="verticalSection">';
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + "</h2>";
}
if (enableScrollX()) {
var scrollXClass = "scrollX hiddenScrollX";
layoutManager.tv && (scrollXClass += " smoothScrollX"), html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">'
} else html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
if (layoutManager.tv) {
scrollXClass += " smoothScrollX";
}
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
} else {
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
}
html += cardBuilder.getCardsHtml({
items: group.items,
shape: cardLayout ? getBackdropShape() : enableScrollX() ? "autoOverflow" : "autoVertical",
showParentTitleOrTitle: !0,
showAirTime: !0,
showAirEndTime: !0,
showParentTitleOrTitle: true,
showAirTime: true,
showAirEndTime: true,
showChannelName: !cardLayout,
cardLayout: cardLayout,
centerText: !cardLayout,
@ -59,15 +97,22 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutM
cardFooterAside: "none",
preferThumb: !!cardLayout || "auto",
defaultShape: cardLayout ? null : "portrait",
coverImage: !0,
allowBottomPadding: !1,
overlayText: !1,
coverImage: true,
allowBottomPadding: false,
overlayText: false,
showChannelLogo: cardLayout
}), html += "</div>", group.name && (html += "</div>")
});
html += "</div>";
if (group.name) {
html += "</div>";
}
return Promise.resolve(html)
}
return Promise.resolve(html);
}
window.LiveTvHelpers = {
getTimersHtml: getTimersHtml
}
};
});

View File

@ -8,32 +8,43 @@ define(["listView"], function(listView) {
EnableImageTypes: "Primary,Backdrop,Banner,Thumb",
UserId: ApiClient.getCurrentUserId()
};
return ApiClient.getJSON(ApiClient.getUrl("Playlists/" + itemId + "/Items", query))
}
return ApiClient.getJSON(ApiClient.getUrl("Playlists/" + itemId + "/Items", query));
};
}
function getItemsHtmlFn(itemId) {
return function (items) {
return listView.getListViewHtml({
items: items,
showIndex: !1,
showRemoveFromPlaylist: !0,
playFromHere: !0,
showIndex: false,
showRemoveFromPlaylist: true,
playFromHere: true,
action: "playallfromhere",
smallIcon: !0,
dragHandle: !0,
smallIcon: true,
dragHandle: true,
playlistId: itemId
})
}
});
};
}
function init(page, item) {
var elem = page.querySelector("#childrenContent .itemsContainer");
elem.classList.add("vertical-list"), elem.classList.remove("vertical-wrap"), elem.enableDragReordering(!0), elem.fetchData = getFetchPlaylistItemsFn(item.Id), elem.getItemsHtml = getItemsHtmlFn(item.Id)
elem.classList.add("vertical-list");
elem.classList.remove("vertical-wrap");
elem.enableDragReordering(true);
elem.fetchData = getFetchPlaylistItemsFn(item.Id);
elem.getItemsHtml = getItemsHtmlFn(item.Id);
}
window.PlaylistViewer = {
render: function (page, item) {
page.playlistInit || (page.playlistInit = !0, init(page, item)), page.querySelector("#childrenContent").classList.add("verticalSection-extrabottompadding"), page.querySelector("#childrenContent .itemsContainer").refreshItems()
if (!page.playlistInit) {
page.playlistInit = true;
init(page, item);
}
page.querySelector("#childrenContent").classList.add("verticalSection-extrabottompadding");
page.querySelector("#childrenContent .itemsContainer").refreshItems();
}
};
});

View File

@ -1,124 +1,186 @@
define(["loading", "listView", "cardBuilder", "libraryMenu", "libraryBrowser", "apphost", "imageLoader", "emby-itemscontainer"], function (loading, listView, cardBuilder, libraryMenu, libraryBrowser, appHost, imageLoader) {
"use strict";
return function (view, params) {
function getPageData(context) {
var key = getSavedQueryKey(context),
pageData = data[key];
return pageData || (pageData = data[key] = {
var key = getSavedQueryKey(context);
var pageData = data[key];
if (!pageData) {
pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "Playlist",
Recursive: !0,
Recursive: true,
Fields: "PrimaryImageAspectRatio,SortName,CumulativeRunTimeTicks,CanDelete",
StartIndex: 0,
Limit: 100
},
view: libraryBrowser.getSavedView(key) || "Poster"
}, pageData.query.ParentId = libraryMenu.getTopParentId(), libraryBrowser.loadSavedQueryValues(key, pageData.query)), pageData
};
pageData.query.ParentId = libraryMenu.getTopParentId();
libraryBrowser.loadSavedQueryValues(key, pageData.query);
}
return pageData;
}
function getQuery(context) {
return getPageData(context).query
return getPageData(context).query;
}
function getSavedQueryKey(context) {
return context.savedQueryKey || (context.savedQueryKey = libraryBrowser.getSavedQueryKey()), context.savedQueryKey
if (!context.savedQueryKey) {
context.savedQueryKey = libraryBrowser.getSavedQueryKey();
}
return context.savedQueryKey;
}
function showLoadingMessage() {
loading.show()
loading.show();
}
function hideLoadingMessage() {
loading.hide()
loading.hide();
}
function onViewStyleChange() {
var viewStyle = getPageData(view).view,
itemsContainer = view.querySelector(".itemsContainer");
"List" == viewStyle ? (itemsContainer.classList.add("vertical-list"), itemsContainer.classList.remove("vertical-wrap")) : (itemsContainer.classList.remove("vertical-list"), itemsContainer.classList.add("vertical-wrap")), itemsContainer.innerHTML = ""
var viewStyle = getPageData(view).view;
var itemsContainer = view.querySelector(".itemsContainer");
if ("List" == viewStyle) {
itemsContainer.classList.add("vertical-list");
itemsContainer.classList.remove("vertical-wrap");
} else {
itemsContainer.classList.remove("vertical-list");
itemsContainer.classList.add("vertical-wrap");
}
itemsContainer.innerHTML = "";
}
function reloadItems() {
showLoadingMessage();
var query = getQuery(view),
promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query),
promise2 = Dashboard.getCurrentUser();
var query = getQuery(view);
var promise1 = ApiClient.getItems(Dashboard.getCurrentUserId(), query);
var promise2 = Dashboard.getCurrentUser();
Promise.all([promise1, promise2]).then(function (responses) {
var result = responses[0];
responses[1];
window.scrollTo(0, 0);
var html = "",
viewStyle = getPageData(view).view;
var html = "";
var viewStyle = getPageData(view).view;
view.querySelector(".listTopPaging").innerHTML = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
viewButton: !1,
showLimit: !1,
updatePageSizeSetting: !1,
addLayoutButton: !0,
viewButton: false,
showLimit: false,
updatePageSizeSetting: false,
addLayoutButton: true,
layouts: "List,Poster,PosterCard,Thumb,ThumbCard",
currentLayout: viewStyle
}), result.TotalRecordCount ? (html = "List" == viewStyle ? listView.getListViewHtml({
});
if (result.TotalRecordCount) {
if (viewStyle == "List") {
html = listView.getListViewHtml({
items: result.Items,
sortBy: query.SortBy
}) : "PosterCard" == viewStyle ? cardBuilder.getCardsHtml({
});
} else if (viewStyle == "PosterCard") {
html = cardBuilder.getCardsHtml({
items: result.Items,
shape: "square",
coverImage: !0,
showTitle: !0,
cardLayout: !0
}) : "Thumb" == viewStyle ? cardBuilder.getCardsHtml({
coverImage: true,
showTitle: true,
cardLayout: true
});
} else if (viewStyle == "Thumb") {
html = cardBuilder.getCardsHtml({
items: result.Items,
shape: "backdrop",
showTitle: !0,
centerText: !0,
preferThumb: !0,
overlayPlayButton: !0
}) : "ThumbCard" == viewStyle ? cardBuilder.getCardsHtml({
showTitle: true,
centerText: true,
preferThumb: true,
overlayPlayButton: true
});
} else if (viewStyle == "ThumbCard") {
html = cardBuilder.getCardsHtml({
items: result.Items,
shape: "backdrop",
showTitle: !0,
preferThumb: !0,
cardLayout: !0
}) : cardBuilder.getCardsHtml({
showTitle: true,
preferThumb: true,
cardLayout: true
});
} else {
html = cardBuilder.getCardsHtml({
items: result.Items,
shape: "square",
showTitle: !0,
coverImage: !0,
centerText: !0,
overlayPlayButton: !0
}), view.querySelector(".noItemsMessage").classList.add("hide")) : view.querySelector(".noItemsMessage").classList.remove("hide");
var elem = view.querySelector(".itemsContainer");
elem.innerHTML = html, imageLoader.lazyChildren(elem);
var btnNextPage = view.querySelector(".btnNextPage");
btnNextPage && btnNextPage.addEventListener("click", function() {
query.StartIndex += query.Limit, reloadItems()
showTitle: true,
coverImage: true,
centerText: true,
overlayPlayButton: true
});
var btnPreviousPage = view.querySelector(".btnPreviousPage");
btnPreviousPage && btnPreviousPage.addEventListener("click", function() {
query.StartIndex -= query.Limit, reloadItems()
});
var btnChangeLayout = view.querySelector(".btnChangeLayout");
btnChangeLayout && btnChangeLayout.addEventListener("layoutchange", function(e) {
var layout = e.detail.viewStyle;
getPageData(view).view = layout, libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout), onViewStyleChange(), reloadItems()
}), libraryBrowser.saveQueryValues(getSavedQueryKey(view), query), hideLoadingMessage()
})
}
view.querySelector(".noItemsMessage").classList.add("hide");
} else {
view.querySelector(".noItemsMessage").classList.remove("hide");
}
var elem = view.querySelector(".itemsContainer");
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
var btnNextPage = view.querySelector(".btnNextPage");
if (btnNextPage) {
btnNextPage.addEventListener("click", function () {
query.StartIndex += query.Limit;
reloadItems();
});
}
var btnPreviousPage = view.querySelector(".btnPreviousPage");
if (btnPreviousPage) {
btnPreviousPage.addEventListener("click", function () {
query.StartIndex -= query.Limit;
reloadItems();
});
}
var btnChangeLayout = view.querySelector(".btnChangeLayout");
if (btnChangeLayout) {
btnChangeLayout.addEventListener("layoutchange", function (e) {
var layout = e.detail.viewStyle;
getPageData(view).view = layout;
libraryBrowser.saveViewSetting(getSavedQueryKey(view), layout);
onViewStyleChange();
reloadItems();
});
}
libraryBrowser.saveQueryValues(getSavedQueryKey(view), query);
hideLoadingMessage();
});
}
var data = {};
view.addEventListener("viewbeforeshow", function () {
reloadItems()
}), view.querySelector(".btnNewPlaylist").addEventListener("click", function() {
reloadItems();
});
view.querySelector(".btnNewPlaylist").addEventListener("click", function () {
require(["playlistEditor"], function (playlistEditor) {
var serverId = ApiClient.serverInfo().Id;
(new playlistEditor).show({
new playlistEditor().show({
items: [],
serverId: serverId
})
})
}), onViewStyleChange()
}
});
});
});
onViewStyleChange();
};
});

View File

@ -2,29 +2,53 @@ define(["searchFields", "searchResults", "events"], function(SearchFields, Searc
"use strict";
function init(instance, tabContent, options) {
tabContent.innerHTML = '<div class="padded-left padded-right searchFields"></div><div class="searchResults padded-top" style="padding-top:1.5em;"></div>', instance.searchFields = new SearchFields({
tabContent.innerHTML = '<div class="padded-left padded-right searchFields"></div><div class="searchResults padded-top" style="padding-top:1.5em;"></div>';
instance.searchFields = new SearchFields({
element: tabContent.querySelector(".searchFields")
}), instance.searchResults = new SearchResults({
});
instance.searchResults = new SearchResults({
element: tabContent.querySelector(".searchResults"),
serverId: ApiClient.serverId(),
parentId: options.parentId,
collectionType: options.collectionType
}), events.on(instance.searchFields, "search", function(e, value) {
instance.searchResults.search(value)
})
});
events.on(instance.searchFields, "search", function (e, value) {
instance.searchResults.search(value);
});
}
function SearchTab(view, tabContent, options) {
var self = this;
options = options || {}, init(this, tabContent, options), self.preRender = function() {}, self.renderTab = function() {
options = options || {};
init(this, tabContent, options);
self.preRender = function () {};
self.renderTab = function () {
var searchFields = this.searchFields;
searchFields && searchFields.focus()
if (searchFields) {
searchFields.focus();
}
};
}
return SearchTab.prototype.destroy = function() {
SearchTab.prototype.destroy = function () {
var searchFields = this.searchFields;
searchFields && searchFields.destroy(), this.searchFields = null;
if (searchFields) {
searchFields.destroy();
}
this.searchFields = null;
var searchResults = this.searchResults;
searchResults && searchResults.destroy(), this.searchResults = null
}, SearchTab
if (searchResults) {
searchResults.destroy();
}
this.searchResults = null;
};
return SearchTab;
});

View File

@ -1,48 +1,119 @@
define(["events", "userSettings", "serverNotifications", "connectionManager", "emby-button"], function (events, userSettings, serverNotifications, connectionManager) {
"use strict";
return function (options) {
function pollTasks() {
connectionManager.getApiClient(serverId).getScheduledTasks({
IsEnabled: !0
}).then(updateTasks)
IsEnabled: true
}).then(updateTasks);
}
function updateTasks(tasks) {
var task = tasks.filter(function (t) {
return t.Key == options.taskKey
return t.Key == options.taskKey;
})[0];
if (options.panel && (task ? options.panel.classList.remove("hide") : options.panel.classList.add("hide")), task) {
"Idle" == task.State ? button.removeAttribute("disabled") : button.setAttribute("disabled", "disabled"), button.setAttribute("data-taskid", task.Id);
if (options.panel) {
if (task) {
options.panel.classList.remove('hide');
} else {
options.panel.classList.add('hide');
}
}
if (!task) {
return;
}
if (task.State == 'Idle') {
button.removeAttribute("disabled");
} else {
button.setAttribute("disabled", "disabled");
}
button.setAttribute("data-taskid", task.Id);
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
if (options.progressElem && (options.progressElem.value = progress, "Running" == task.State ? options.progressElem.classList.remove("hide") : options.progressElem.classList.add("hide")), options.lastResultElem) {
var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : "";
"Failed" == lastResult ? options.lastResultElem.html('<span style="color:#FF0000;">(' + Globalize.translate("LabelFailed") + ")</span>") : "Cancelled" == lastResult ? options.lastResultElem.html('<span style="color:#0026FF;">(' + Globalize.translate("LabelCancelled") + ")</span>") : "Aborted" == lastResult ? options.lastResultElem.html('<span style="color:#FF0000;">' + Globalize.translate("LabelAbortedByServerShutdown") + "</span>") : options.lastResultElem.html(lastResult)
if (options.progressElem) {
options.progressElem.value = progress;
if (task.State == 'Running') {
options.progressElem.classList.remove('hide');
} else {
options.progressElem.classList.add('hide');
}
}
if (options.lastResultElem) {
var lastResult = task.LastExecutionResult ? task.LastExecutionResult.Status : '';
if (lastResult == "Failed") {
options.lastResultElem.html('<span style="color:#FF0000;">(' + Globalize.translate('LabelFailed') + ')</span>');
} else if (lastResult == "Cancelled") {
options.lastResultElem.html('<span style="color:#0026FF;">(' + Globalize.translate('LabelCancelled') + ')</span>');
} else if (lastResult == "Aborted") {
options.lastResultElem.html('<span style="color:#FF0000;">' + Globalize.translate('LabelAbortedByServerShutdown') + '</span>');
} else {
options.lastResultElem.html(lastResult);
}
}
}
function onScheduledTaskMessageConfirmed(id) {
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks)
connectionManager.getApiClient(serverId).startScheduledTask(id).then(pollTasks);
}
function onButtonClick() {
onScheduledTaskMessageConfirmed(this.getAttribute("data-taskid"))
onScheduledTaskMessageConfirmed(this.getAttribute("data-taskid"));
}
function onScheduledTasksUpdate(e, apiClient, info) {
apiClient.serverId() === serverId && updateTasks(info)
if (apiClient.serverId() === serverId) {
updateTasks(info);
}
}
var pollInterval;
var button = options.button;
var serverId = ApiClient.serverId();
function onPollIntervalFired() {
connectionManager.getApiClient(serverId).isMessageChannelOpen() || pollTasks()
if (!connectionManager.getApiClient(serverId).isMessageChannelOpen()) {
pollTasks();
}
var pollInterval, button = options.button,
serverId = ApiClient.serverId();
options.panel && options.panel.classList.add("hide"), "off" == options.mode ? (button.removeEventListener("click", onButtonClick), events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate), function() {
connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop"), pollInterval && clearInterval(pollInterval)
}()) : (button.addEventListener("click", onButtonClick), pollTasks(), function() {
}
function startInterval() {
var apiClient = connectionManager.getApiClient(serverId);
pollInterval && clearInterval(pollInterval), apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000"), pollInterval = setInterval(onPollIntervalFired, 1e4)
}(), events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate))
if (pollInterval) {
clearInterval(pollInterval);
}
apiClient.sendMessage("ScheduledTasksInfoStart", "1000,1000");
pollInterval = setInterval(onPollIntervalFired, 5000);
}
function stopInterval() {
connectionManager.getApiClient(serverId).sendMessage("ScheduledTasksInfoStop");
if (pollInterval) {
clearInterval(pollInterval);
}
}
if (options.panel) {
options.panel.classList.add("hide");
}
if (options.mode == 'off') {
button.removeEventListener("click", onButtonClick);
events.off(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate);
stopInterval();
} else {
button.addEventListener("click", onButtonClick);
pollTasks();
startInterval();
events.on(serverNotifications, "ScheduledTasksInfo", onScheduledTasksUpdate);
}
};
});

View File

@ -1,15 +1,27 @@
define(["userSettings", "skinManager", "connectionManager", "events"], function (userSettings, skinManager, connectionManager, events) {
"use strict";
var currentViewType;
pageClassOn("viewbeforeshow", "page", function () {
var classList = this.classList,
viewType = classList.contains("type-interior") || classList.contains("wizardPage") ? "a" : "b";
var classList = this.classList;
var viewType = classList.contains("type-interior") || classList.contains("wizardPage") ? "a" : "b";
if (viewType !== currentViewType) {
currentViewType = viewType;
var theme, context;
"a" === viewType ? (theme = userSettings.dashboardTheme(), context = "serverdashboard") : theme = userSettings.theme(), skinManager.setTheme(theme, context)
var theme;
var context;
if ("a" === viewType) {
theme = userSettings.dashboardTheme();
context = "serverdashboard";
} else {
theme = userSettings.theme();
}
skinManager.setTheme(theme, context);
}
}), events.on(connectionManager, "localusersignedin", function(e, user) {
currentViewType = null
})
});
events.on(connectionManager, "localusersignedin", function (e, user) {
currentViewType = null;
});
});

View File

@ -2,19 +2,29 @@ define(["jQuery", "loading", "libraryMenu"], function($, loading, libraryMenu) {
"use strict";
function loadUser(page, user) {
libraryMenu.setTitle(user.Name), "Guest" == user.ConnectLinkType ? $(".connectMessage", page).show() : $(".connectMessage", page).hide(), loading.hide()
libraryMenu.setTitle(user.Name);
if ("Guest" == user.ConnectLinkType) {
$(".connectMessage", page).show();
} else {
$(".connectMessage", page).hide();
}
loading.hide();
}
function loadData(page) {
loading.show();
var userId = getParameterByName("userId");
ApiClient.getUser(userId).then(function (user) {
loadUser(page, user)
})
}
$(document).on("pageinit", "#userPasswordPage", function() {
$(".adminUpdatePasswordForm").off("submit", UpdatePasswordPage.onSubmit).on("submit", UpdatePasswordPage.onSubmit), $(".adminLocalAccessForm").off("submit", UpdatePasswordPage.onLocalAccessSubmit).on("submit", UpdatePasswordPage.onLocalAccessSubmit)
}).on("pagebeforeshow", "#userPasswordPage", function() {
loadData(this)
})
loadUser(page, user);
});
}
$(document).on("pageinit", "#userPasswordPage", function () {
$(".adminUpdatePasswordForm").off("submit", UpdatePasswordPage.onSubmit).on("submit", UpdatePasswordPage.onSubmit);
$(".adminLocalAccessForm").off("submit", UpdatePasswordPage.onLocalAccessSubmit).on("submit", UpdatePasswordPage.onLocalAccessSubmit);
}).on("pagebeforeshow", "#userPasswordPage", function () {
loadData(this);
});
});

View File

@ -2,16 +2,26 @@ define(["dom", "emby-button"], function(dom) {
"use strict";
function onSubmit(e) {
return dom.parentWithClass(this, "page").querySelector(".chkAccept").checked ? Dashboard.navigate("wizardfinish.html") : Dashboard.alert({
if (dom.parentWithClass(this, "page").querySelector(".chkAccept").checked) {
Dashboard.navigate("wizardfinish.html");
} else {
Dashboard.alert({
message: Globalize.translate("MessagePleaseAcceptTermsOfServiceBeforeContinuing"),
title: ""
}), e.preventDefault(), !1
}
return function(view, params) {
view.querySelector(".wizardAgreementForm").addEventListener("submit", onSubmit), view.addEventListener("viewshow", function() {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader")
}), view.addEventListener("viewhide", function() {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader")
})
}
});
}
e.preventDefault();
return false;
}
return function (view, params) {
view.querySelector(".wizardAgreementForm").addEventListener("submit", onSubmit);
view.addEventListener("viewshow", function () {
document.querySelector(".skinHeader").classList.add("noHomeButtonHeader");
});
view.addEventListener("viewhide", function () {
document.querySelector(".skinHeader").classList.remove("noHomeButtonHeader");
});
};
});