mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
deuglification
This commit is contained in:
parent
c93cd26774
commit
dee0e6a5c7
3 changed files with 1240 additions and 487 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,129 +1,155 @@
|
||||||
define(["layoutManager", "userSettings", "inputManager", "loading", "globalize", "libraryBrowser", "mainTabsManager", "cardBuilder", "apphost", "imageLoader", "scrollStyles", "emby-itemscontainer", "emby-tabs", "emby-button"], function(layoutManager, userSettings, inputManager, loading, globalize, libraryBrowser, mainTabsManager, cardBuilder, appHost, imageLoader) {
|
define(["layoutManager", "userSettings", "inputManager", "loading", "globalize", "libraryBrowser", "mainTabsManager", "cardBuilder", "apphost", "imageLoader", "scrollStyles", "emby-itemscontainer", "emby-tabs", "emby-button"], function (layoutManager, userSettings, inputManager, loading, globalize, libraryBrowser, mainTabsManager, cardBuilder, appHost, imageLoader) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function enableScrollX() {
|
function enableScrollX() {
|
||||||
return !layoutManager.desktop
|
return !layoutManager.desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBackdropShape() {
|
function getBackdropShape() {
|
||||||
return enableScrollX() ? "overflowBackdrop" : "backdrop"
|
if (enableScrollX()) {
|
||||||
|
return "overflowBackdrop";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "backdrop";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPortraitShape() {
|
function getPortraitShape() {
|
||||||
return enableScrollX() ? "overflowPortrait" : "portrait"
|
if (enableScrollX()) {
|
||||||
|
return "overflowPortrait";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "portrait";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLimit() {
|
function getLimit() {
|
||||||
return enableScrollX() ? 12 : 9
|
if (enableScrollX()) {
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadRecommendedPrograms(page) {
|
function loadRecommendedPrograms(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var limit = getLimit();
|
var limit = getLimit();
|
||||||
enableScrollX() && (limit *= 2), ApiClient.getLiveTvRecommendedPrograms({
|
|
||||||
|
if (enableScrollX()) {
|
||||||
|
limit *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApiClient.getLiveTvRecommendedPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
IsAiring: !0,
|
IsAiring: true,
|
||||||
limit: limit,
|
limit: limit,
|
||||||
ImageTypeLimit: 1,
|
ImageTypeLimit: 1,
|
||||||
EnableImageTypes: "Primary,Thumb,Backdrop",
|
EnableImageTypes: "Primary,Thumb,Backdrop",
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo,PrimaryImageAspectRatio"
|
Fields: "ChannelInfo,PrimaryImageAspectRatio"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "activeProgramItems", "play", {
|
renderItems(page, result.Items, "activeProgramItems", "play", {
|
||||||
showAirDateTime: !1,
|
showAirDateTime: false,
|
||||||
showAirEndTime: !0
|
showAirEndTime: true
|
||||||
}), loading.hide()
|
});
|
||||||
})
|
loading.hide();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function reload(page, enableFullRender) {
|
function reload(page, enableFullRender) {
|
||||||
enableFullRender && (loadRecommendedPrograms(page), ApiClient.getLiveTvPrograms({
|
if (enableFullRender) {
|
||||||
|
loadRecommendedPrograms(page);
|
||||||
|
ApiClient.getLiveTvPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
HasAired: !1,
|
HasAired: false,
|
||||||
limit: getLimit(),
|
limit: getLimit(),
|
||||||
IsMovie: !1,
|
IsMovie: false,
|
||||||
IsSports: !1,
|
IsSports: false,
|
||||||
IsKids: !1,
|
IsKids: false,
|
||||||
IsNews: !1,
|
IsNews: false,
|
||||||
IsSeries: !0,
|
IsSeries: true,
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
||||||
EnableImageTypes: "Primary,Thumb"
|
EnableImageTypes: "Primary,Thumb"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "upcomingEpisodeItems")
|
renderItems(page, result.Items, "upcomingEpisodeItems");
|
||||||
}), ApiClient.getLiveTvPrograms({
|
});
|
||||||
|
ApiClient.getLiveTvPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
HasAired: !1,
|
HasAired: false,
|
||||||
limit: getLimit(),
|
limit: getLimit(),
|
||||||
IsMovie: !0,
|
IsMovie: true,
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo",
|
Fields: "ChannelInfo",
|
||||||
EnableImageTypes: "Primary,Thumb"
|
EnableImageTypes: "Primary,Thumb"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "upcomingTvMovieItems", null, {
|
renderItems(page, result.Items, "upcomingTvMovieItems", null, {
|
||||||
shape: getPortraitShape(),
|
shape: getPortraitShape(),
|
||||||
preferThumb: null,
|
preferThumb: null,
|
||||||
showParentTitle: !1
|
showParentTitle: false
|
||||||
})
|
});
|
||||||
}), ApiClient.getLiveTvPrograms({
|
});
|
||||||
|
ApiClient.getLiveTvPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
HasAired: !1,
|
HasAired: false,
|
||||||
limit: getLimit(),
|
limit: getLimit(),
|
||||||
IsSports: !0,
|
IsSports: true,
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
||||||
EnableImageTypes: "Primary,Thumb"
|
EnableImageTypes: "Primary,Thumb"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "upcomingSportsItems")
|
renderItems(page, result.Items, "upcomingSportsItems");
|
||||||
}), ApiClient.getLiveTvPrograms({
|
});
|
||||||
|
ApiClient.getLiveTvPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
HasAired: !1,
|
HasAired: false,
|
||||||
limit: getLimit(),
|
limit: getLimit(),
|
||||||
IsKids: !0,
|
IsKids: true,
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
||||||
EnableImageTypes: "Primary,Thumb"
|
EnableImageTypes: "Primary,Thumb"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "upcomingKidsItems")
|
renderItems(page, result.Items, "upcomingKidsItems");
|
||||||
}), ApiClient.getLiveTvPrograms({
|
});
|
||||||
|
ApiClient.getLiveTvPrograms({
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
HasAired: !1,
|
HasAired: false,
|
||||||
limit: getLimit(),
|
limit: getLimit(),
|
||||||
IsNews: !0,
|
IsNews: true,
|
||||||
EnableTotalRecordCount: !1,
|
EnableTotalRecordCount: false,
|
||||||
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
Fields: "ChannelInfo,PrimaryImageAspectRatio",
|
||||||
EnableImageTypes: "Primary,Thumb"
|
EnableImageTypes: "Primary,Thumb"
|
||||||
}).then(function(result) {
|
}).then(function (result) {
|
||||||
renderItems(page, result.Items, "upcomingNewsItems", null, {
|
renderItems(page, result.Items, "upcomingNewsItems", null, {
|
||||||
showParentTitleOrTitle: !0,
|
showParentTitleOrTitle: true,
|
||||||
showTitle: !1,
|
showTitle: false,
|
||||||
showParentTitle: !1
|
showParentTitle: false
|
||||||
})
|
});
|
||||||
}))
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderItems(page, items, sectionClass, overlayButton, cardOptions) {
|
function renderItems(page, items, sectionClass, overlayButton, cardOptions) {
|
||||||
var html = cardBuilder.getCardsHtml(Object.assign({
|
var html = cardBuilder.getCardsHtml(Object.assign({
|
||||||
items: items,
|
items: items,
|
||||||
preferThumb: "auto",
|
preferThumb: "auto",
|
||||||
inheritThumb: !1,
|
inheritThumb: false,
|
||||||
shape: enableScrollX() ? "autooverflow" : "auto",
|
shape: enableScrollX() ? "autooverflow" : "auto",
|
||||||
defaultShape: getBackdropShape(),
|
defaultShape: getBackdropShape(),
|
||||||
showParentTitle: !0,
|
showParentTitle: true,
|
||||||
showTitle: !0,
|
showTitle: true,
|
||||||
centerText: !0,
|
centerText: true,
|
||||||
coverImage: !0,
|
coverImage: true,
|
||||||
overlayText: !1,
|
overlayText: false,
|
||||||
lazy: !0,
|
lazy: true,
|
||||||
overlayPlayButton: "play" === overlayButton,
|
overlayPlayButton: "play" === overlayButton,
|
||||||
overlayMoreButton: "more" === overlayButton,
|
overlayMoreButton: "more" === overlayButton,
|
||||||
overlayInfoButton: "info" === overlayButton,
|
overlayInfoButton: "info" === overlayButton,
|
||||||
allowBottomPadding: !enableScrollX(),
|
allowBottomPadding: !enableScrollX(),
|
||||||
showAirTime: !0,
|
showAirTime: true,
|
||||||
showAirDateTime: !0
|
showAirDateTime: true
|
||||||
}, cardOptions || {})),
|
}, cardOptions || {}));
|
||||||
elem = page.querySelector("." + sectionClass);
|
var elem = page.querySelector("." + sectionClass);
|
||||||
elem.innerHTML = html, imageLoader.lazyChildren(elem)
|
elem.innerHTML = html;
|
||||||
|
imageLoader.lazyChildren(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabs() {
|
function getTabs() {
|
||||||
|
@ -142,119 +168,227 @@ define(["layoutManager", "userSettings", "inputManager", "loading", "globalize",
|
||||||
}, {
|
}, {
|
||||||
name: globalize.translate("ButtonSearch"),
|
name: globalize.translate("ButtonSearch"),
|
||||||
cssClass: "searchTabButton"
|
cssClass: "searchTabButton"
|
||||||
}]
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setScrollClasses(elem, scrollX) {
|
function setScrollClasses(elem, scrollX) {
|
||||||
scrollX ? (elem.classList.add("hiddenScrollX"), layoutManager.tv && elem.classList.add("smoothScrollX"), elem.classList.add("scrollX"), elem.classList.remove("vertical-wrap")) : (elem.classList.remove("hiddenScrollX"), elem.classList.remove("smoothScrollX"), elem.classList.remove("scrollX"), elem.classList.add("vertical-wrap"))
|
if (scrollX) {
|
||||||
|
elem.classList.add("hiddenScrollX");
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
elem.classList.add("smoothScrollX");
|
||||||
|
}
|
||||||
|
|
||||||
|
elem.classList.add("scrollX");
|
||||||
|
elem.classList.remove("vertical-wrap");
|
||||||
|
} else {
|
||||||
|
elem.classList.remove("hiddenScrollX");
|
||||||
|
elem.classList.remove("smoothScrollX");
|
||||||
|
elem.classList.remove("scrollX");
|
||||||
|
elem.classList.add("vertical-wrap");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultTabIndex(folderId) {
|
function getDefaultTabIndex(folderId) {
|
||||||
switch (userSettings.get("landing-" + folderId)) {
|
switch (userSettings.get("landing-" + folderId)) {
|
||||||
case "guide":
|
case "guide":
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return function(view, params) {
|
|
||||||
|
return function (view, params) {
|
||||||
function enableFullRender() {
|
function enableFullRender() {
|
||||||
return (new Date).getTime() - lastFullRender > 3e5
|
return new Date().getTime() - lastFullRender > 3e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBeforeTabChange(e) {
|
function onBeforeTabChange(e__q) {
|
||||||
preLoadTab(view, parseInt(e.detail.selectedTabIndex))
|
preLoadTab(view, parseInt(e__q.detail.selectedTabIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTabChange(e) {
|
function onTabChange(e__w) {
|
||||||
var previousTabController = tabControllers[parseInt(e.detail.previousIndex)];
|
var previousTabController = tabControllers[parseInt(e__w.detail.previousIndex)];
|
||||||
previousTabController && previousTabController.onHide && previousTabController.onHide(), loadTab(view, parseInt(e.detail.selectedTabIndex))
|
|
||||||
|
if (previousTabController && previousTabController.onHide) {
|
||||||
|
previousTabController.onHide();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadTab(view, parseInt(e__w.detail.selectedTabIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabContainers() {
|
function getTabContainers() {
|
||||||
return view.querySelectorAll(".pageTabContent")
|
return view.querySelectorAll(".pageTabContent");
|
||||||
}
|
}
|
||||||
|
|
||||||
function initTabs() {
|
function initTabs() {
|
||||||
mainTabsManager.setTabs(view, currentTabIndex, getTabs, getTabContainers, onBeforeTabChange, onTabChange)
|
mainTabsManager.setTabs(view, currentTabIndex, getTabs, getTabContainers, onBeforeTabChange, onTabChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabController(page, index, callback) {
|
function getTabController(page, index, callback) {
|
||||||
var depends = [];
|
var depends = [];
|
||||||
|
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
depends.push("scripts/livetvguide");
|
depends.push("scripts/livetvguide");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
depends.push("scripts/livetvchannels");
|
depends.push("scripts/livetvchannels");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
depends.push("scripts/livetvrecordings");
|
depends.push("scripts/livetvrecordings");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
depends.push("scripts/livetvschedule");
|
depends.push("scripts/livetvschedule");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
depends.push("scripts/livetvseriestimers");
|
depends.push("scripts/livetvseriestimers");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
depends.push("scripts/searchtab")
|
depends.push("scripts/searchtab");
|
||||||
}
|
}
|
||||||
require(depends, function(controllerFactory) {
|
|
||||||
|
require(depends, function (controllerFactory) {
|
||||||
var tabContent;
|
var tabContent;
|
||||||
0 == index && (tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']"), self.tabContent = tabContent);
|
|
||||||
|
if (0 == index) {
|
||||||
|
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
||||||
|
self.tabContent = tabContent;
|
||||||
|
}
|
||||||
|
|
||||||
var controller = tabControllers[index];
|
var controller = tabControllers[index];
|
||||||
controller || (tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']"), controller = 0 === index ? self : 6 === index ? new controllerFactory(view, tabContent, {
|
|
||||||
|
if (!controller) {
|
||||||
|
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
|
||||||
|
controller = 0 === index ? self : 6 === index ? new controllerFactory(view, tabContent, {
|
||||||
collectionType: "livetv"
|
collectionType: "livetv"
|
||||||
}) : new controllerFactory(view, params, tabContent), tabControllers[index] = controller, controller.initTab && controller.initTab()), callback(controller)
|
}) : new controllerFactory(view, params, tabContent);
|
||||||
})
|
tabControllers[index] = controller;
|
||||||
|
|
||||||
|
if (controller.initTab) {
|
||||||
|
controller.initTab();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(controller);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function preLoadTab(page, index) {
|
function preLoadTab(page, index) {
|
||||||
getTabController(page, index, function(controller) {
|
getTabController(page, index, function (controller) {
|
||||||
-1 == renderedTabs.indexOf(index) && controller.preRender && controller.preRender()
|
if (-1 == renderedTabs.indexOf(index) && controller.preRender) {
|
||||||
})
|
controller.preRender();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTab(page, index) {
|
function loadTab(page, index) {
|
||||||
currentTabIndex = index, getTabController(page, index, function(controller) {
|
currentTabIndex = index;
|
||||||
initialTabIndex = null, 1 === index ? document.body.classList.add("autoScrollY") : document.body.classList.remove("autoScrollY"), -1 == renderedTabs.indexOf(index) ? (1 === index && renderedTabs.push(index), controller.renderTab()) : controller.onShow && controller.onShow(), currentTabController = controller
|
getTabController(page, index, function (controller) {
|
||||||
})
|
initialTabIndex = null;
|
||||||
|
|
||||||
|
if (1 === index) {
|
||||||
|
document.body.classList.add("autoScrollY");
|
||||||
|
} else {
|
||||||
|
document.body.classList.remove("autoScrollY");
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputCommand(e) {
|
if (-1 == renderedTabs.indexOf(index)) {
|
||||||
switch (e.detail.command) {
|
if (1 === index) {
|
||||||
|
renderedTabs.push(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.renderTab();
|
||||||
|
} else {
|
||||||
|
if (controller.onShow) {
|
||||||
|
controller.onShow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentTabController = controller;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onInputCommand(e__e) {
|
||||||
|
switch (e__e.detail.command) {
|
||||||
case "search":
|
case "search":
|
||||||
e.preventDefault(), Dashboard.navigate("search.html?collectionType=livetv")
|
e__e.preventDefault();
|
||||||
|
Dashboard.navigate("search.html?collectionType=livetv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var isViewRestored, self = this,
|
|
||||||
currentTabIndex = parseInt(params.tab || getDefaultTabIndex("livetv")),
|
var isViewRestored;
|
||||||
initialTabIndex = currentTabIndex,
|
var self = this;
|
||||||
lastFullRender = 0;
|
var currentTabIndex = parseInt(params.tab || getDefaultTabIndex("livetv"));
|
||||||
[].forEach.call(view.querySelectorAll(".sectionTitleTextButton-programs"), function(link) {
|
var initialTabIndex = currentTabIndex;
|
||||||
|
var lastFullRender = 0;
|
||||||
|
[].forEach.call(view.querySelectorAll(".sectionTitleTextButton-programs"), function (link) {
|
||||||
var href = link.href;
|
var href = link.href;
|
||||||
href && (link.href = href + "&serverId=" + ApiClient.serverId())
|
|
||||||
}), self.initTab = function() {
|
if (href) {
|
||||||
for (var tabContent = view.querySelector(".pageTabContent[data-index='0']"), containers = tabContent.querySelectorAll(".itemsContainer"), i = 0, length = containers.length; i < length; i++) setScrollClasses(containers[i], enableScrollX())
|
link.href = href + "&serverId=" + ApiClient.serverId();
|
||||||
}, self.renderTab = function() {
|
|
||||||
var tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
|
||||||
enableFullRender() ? (reload(tabContent, !0), lastFullRender = (new Date).getTime()) : reload(tabContent)
|
|
||||||
};
|
|
||||||
var currentTabController, tabControllers = [],
|
|
||||||
renderedTabs = [];
|
|
||||||
view.addEventListener("viewbeforeshow", function(e) {
|
|
||||||
isViewRestored = e.detail.isRestored, initTabs()
|
|
||||||
}), view.addEventListener("viewshow", function(e) {
|
|
||||||
isViewRestored = e.detail.isRestored, isViewRestored || mainTabsManager.selectedTabIndex(initialTabIndex), inputManager.on(window, onInputCommand)
|
|
||||||
}), view.addEventListener("viewbeforehide", function(e) {
|
|
||||||
currentTabController && currentTabController.onHide && currentTabController.onHide(), document.body.classList.remove("autoScrollY"), inputManager.off(window, onInputCommand)
|
|
||||||
}), view.addEventListener("viewdestroy", function(e) {
|
|
||||||
tabControllers.forEach(function(t) {
|
|
||||||
t.destroy && t.destroy()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
self.initTab = function () {
|
||||||
|
var tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
||||||
|
var containers = tabContent.querySelectorAll(".itemsContainer");
|
||||||
|
|
||||||
|
for (var i__r = 0, length = containers.length; i__r < length; i__r++) {
|
||||||
|
setScrollClasses(containers[i__r], enableScrollX());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.renderTab = function () {
|
||||||
|
var tabContent = view.querySelector(".pageTabContent[data-index='0']");
|
||||||
|
|
||||||
|
if (enableFullRender()) {
|
||||||
|
reload(tabContent, true);
|
||||||
|
lastFullRender = new Date().getTime();
|
||||||
|
} else {
|
||||||
|
reload(tabContent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var currentTabController;
|
||||||
|
var tabControllers = [];
|
||||||
|
var renderedTabs = [];
|
||||||
|
view.addEventListener("viewbeforeshow", function (e__t) {
|
||||||
|
isViewRestored = e__t.detail.isRestored;
|
||||||
|
initTabs();
|
||||||
|
});
|
||||||
|
view.addEventListener("viewshow", function (e__y) {
|
||||||
|
isViewRestored = e__y.detail.isRestored;
|
||||||
|
|
||||||
|
if (!isViewRestored) {
|
||||||
|
mainTabsManager.selectedTabIndex(initialTabIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
inputManager.on(window, onInputCommand);
|
||||||
|
});
|
||||||
|
view.addEventListener("viewbeforehide", function (e__u) {
|
||||||
|
if (currentTabController && currentTabController.onHide) {
|
||||||
|
currentTabController.onHide();
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.classList.remove("autoScrollY");
|
||||||
|
inputManager.off(window, onInputCommand);
|
||||||
|
});
|
||||||
|
view.addEventListener("viewdestroy", function (e__i) {
|
||||||
|
tabControllers.forEach(function (t__o) {
|
||||||
|
if (t__o.destroy) {
|
||||||
|
t__o.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
|
@ -1,78 +1,212 @@
|
||||||
define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", "emby-checkbox", "emby-select"], function(loading, libraryMenu, globalize) {
|
define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", "emby-checkbox", "emby-select"], function (loading, libraryMenu, globalize) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function reloadList(page) {
|
function reloadList(page) {
|
||||||
loading.show(), query.IsAppStoreSafe = !0;
|
loading.show();
|
||||||
var promise1 = ApiClient.getAvailablePlugins(query),
|
query.IsAppStoreSafe = true;
|
||||||
promise2 = ApiClient.getInstalledPlugins();
|
var promise1 = ApiClient.getAvailablePlugins(query);
|
||||||
Promise.all([promise1, promise2]).then(function(responses) {
|
var promise2 = ApiClient.getInstalledPlugins();
|
||||||
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
populateList({
|
populateList({
|
||||||
catalogElement: page.querySelector("#pluginTiles"),
|
catalogElement: page.querySelector("#pluginTiles"),
|
||||||
noItemsElement: page.querySelector("#noPlugins"),
|
noItemsElement: page.querySelector("#noPlugins"),
|
||||||
availablePlugins: responses[0],
|
availablePlugins: responses[0],
|
||||||
installedPlugins: responses[1]
|
installedPlugins: responses[1]
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateList(options) {
|
function populateList(options) {
|
||||||
populateListInternal(options)
|
populateListInternal(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeaderText(category) {
|
function getHeaderText(category) {
|
||||||
category.replace(" ", "").replace(" ", "");
|
category.replace(" ", "").replace(" ", "");
|
||||||
return "Channel" === category ? category = "Channels" : "Theme" === category ? category = "Themes" : "LiveTV" === category ? category = "HeaderLiveTV" : "ScreenSaver" === category && (category = "HeaderScreenSavers"), globalize.translate(category)
|
|
||||||
|
if ("Channel" === category) {
|
||||||
|
category = "Channels";
|
||||||
|
} else {
|
||||||
|
if ("Theme" === category) {
|
||||||
|
category = "Themes";
|
||||||
|
} else {
|
||||||
|
if ("LiveTV" === category) {
|
||||||
|
category = "HeaderLiveTV";
|
||||||
|
} else {
|
||||||
|
if ("ScreenSaver" === category) {
|
||||||
|
category = "HeaderScreenSavers";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return globalize.translate(category);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserInstalledPlugin(plugin) {
|
function isUserInstalledPlugin(plugin) {
|
||||||
return -1 === ["02528C96-F727-44D7-BE87-9EEF040758C3", "0277E613-3EC0-4360-A3DE-F8AF0AABB5E9", "4DCB591C-0FA2-4C5D-A7E5-DABE37164C8B"].indexOf(plugin.guid)
|
return -1 === ["02528C96-F727-44D7-BE87-9EEF040758C3", "0277E613-3EC0-4360-A3DE-F8AF0AABB5E9", "4DCB591C-0FA2-4C5D-A7E5-DABE37164C8B"].indexOf(plugin.guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function populateListInternal(options) {
|
function populateListInternal(options) {
|
||||||
var availablePlugins = options.availablePlugins,
|
var availablePlugins = options.availablePlugins;
|
||||||
installedPlugins = options.installedPlugins,
|
var installedPlugins = options.installedPlugins;
|
||||||
allPlugins = availablePlugins.filter(function(p) {
|
var allPlugins = availablePlugins.filter(function (p__w) {
|
||||||
return p.category = p.category || "General", p.categoryDisplayName = getHeaderText(p.category), (!options.categories || -1 != options.categories.indexOf(p.category)) && ((!options.targetSystem || p.targetSystem == options.targetSystem) && "UserInstalled" == p.type)
|
p__w.category = p__w.category || "General";
|
||||||
|
p__w.categoryDisplayName = getHeaderText(p__w.category);
|
||||||
|
|
||||||
|
if (!options.categories || -1 != options.categories.indexOf(p__w.category)) {
|
||||||
|
if (!options.targetSystem || p__w.targetSystem == options.targetSystem) {
|
||||||
|
return "UserInstalled" == p__w.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
availablePlugins = allPlugins.sort(function(a, b) {
|
availablePlugins = allPlugins.sort(function (a__e, b__r) {
|
||||||
var aName = a.category,
|
var aName = a__e.category;
|
||||||
bName = b.category;
|
var bName = b__r.category;
|
||||||
return aName > bName ? 1 : bName > aName ? -1 : (aName = a.name, bName = b.name, aName > bName ? 1 : bName > aName ? -1 : 0)
|
|
||||||
|
if (aName > bName) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bName > aName) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
aName = a__e.name;
|
||||||
|
bName = b__r.name;
|
||||||
|
|
||||||
|
if (aName > bName) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bName > aName) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
var i, length, plugin, currentCategory, html = "";
|
var i__q;
|
||||||
|
var length;
|
||||||
|
var plugin;
|
||||||
|
var currentCategory;
|
||||||
|
var html = "";
|
||||||
|
|
||||||
if (!options.categories) {
|
if (!options.categories) {
|
||||||
currentCategory = globalize.translate("HeaderTopPlugins"), html += '<div class="verticalSection">', html += '<h2 class="sectionTitle sectionTitle-cards">' + currentCategory + "</h2>";
|
currentCategory = globalize.translate("HeaderTopPlugins");
|
||||||
var topPlugins = allPlugins.slice(0).sort(function(a, b) {
|
html += '<div class="verticalSection">';
|
||||||
if (a.installs > b.installs) return -1;
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + currentCategory + "</h2>";
|
||||||
if (b.installs > a.installs) return 1;
|
var topPlugins = allPlugins.slice(0).sort(function (a__t, b__y) {
|
||||||
var aName = a.name,
|
if (a__t.installs > b__y.installs) {
|
||||||
bName = b.name;
|
return -1;
|
||||||
return aName > bName ? 1 : bName > aName ? -1 : 0
|
}
|
||||||
|
|
||||||
|
if (b__y.installs > a__t.installs) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var aName = a__t.name;
|
||||||
|
var bName = b__y.name;
|
||||||
|
|
||||||
|
if (aName > bName) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bName > aName) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}).filter(isUserInstalledPlugin);
|
}).filter(isUserInstalledPlugin);
|
||||||
html += '<div class="itemsContainer vertical-wrap">';
|
html += '<div class="itemsContainer vertical-wrap">';
|
||||||
var limit = screen.availWidth >= 1920 ? 15 : 12;
|
var limit = screen.availWidth >= 1920 ? 15 : 12;
|
||||||
for (i = 0, length = Math.min(topPlugins.length, limit); i < length; i++) html += getPluginHtml(topPlugins[i], options, installedPlugins);
|
|
||||||
html += "</div>", html += "</div>"
|
for (i__q = 0, length = Math.min(topPlugins.length, limit); i__q < length; i__q++) {
|
||||||
|
html += getPluginHtml(topPlugins[i__q], options, installedPlugins);
|
||||||
}
|
}
|
||||||
var hasOpenTag = !1;
|
|
||||||
for (currentCategory = null, !1 === options.showCategory && (html += '<div class="itemsContainer vertical-wrap">', hasOpenTag = !0), i = 0, length = availablePlugins.length; i < length; i++) {
|
html += "</div>";
|
||||||
plugin = availablePlugins[i];
|
html += "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasOpenTag = false;
|
||||||
|
|
||||||
|
for (currentCategory = null, false === options.showCategory && (html += '<div class="itemsContainer vertical-wrap">', hasOpenTag = true), i__q = 0, length = availablePlugins.length; i__q < length; i__q++) {
|
||||||
|
plugin = availablePlugins[i__q];
|
||||||
var category = plugin.categoryDisplayName;
|
var category = plugin.categoryDisplayName;
|
||||||
category != currentCategory && (!1 !== options.showCategory && (currentCategory && (hasOpenTag = !1, html += "</div>", html += "</div>"), html += '<div class="verticalSection">', html += '<h2 class="sectionTitle sectionTitle-cards">' + category + "</h2>", html += '<div class="itemsContainer vertical-wrap">', hasOpenTag = !0), currentCategory = category), html += getPluginHtml(plugin, options, installedPlugins)
|
|
||||||
|
if (category != currentCategory) {
|
||||||
|
if (false !== options.showCategory) {
|
||||||
|
if (currentCategory) {
|
||||||
|
hasOpenTag = false;
|
||||||
|
html += "</div>";
|
||||||
|
html += "</div>";
|
||||||
}
|
}
|
||||||
hasOpenTag && (html += "</div>", html += "</div>"), !availablePlugins.length && options.noItemsElement && options.noItemsElement.classList.add("hide"), options.catalogElement.innerHTML = html, loading.hide()
|
|
||||||
|
html += '<div class="verticalSection">';
|
||||||
|
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + "</h2>";
|
||||||
|
html += '<div class="itemsContainer vertical-wrap">';
|
||||||
|
hasOpenTag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentCategory = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
html += getPluginHtml(plugin, options, installedPlugins);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasOpenTag) {
|
||||||
|
html += "</div>";
|
||||||
|
html += "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!availablePlugins.length && options.noItemsElement) {
|
||||||
|
options.noItemsElement.classList.add("hide");
|
||||||
|
}
|
||||||
|
|
||||||
|
options.catalogElement.innerHTML = html;
|
||||||
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPluginHtml(plugin, options, installedPlugins) {
|
function getPluginHtml(plugin, options, installedPlugins) {
|
||||||
var html = "",
|
var html = "";
|
||||||
href = plugin.externalUrl ? plugin.externalUrl : "addplugin.html?name=" + encodeURIComponent(plugin.name) + "&guid=" + plugin.guid;
|
var href = plugin.externalUrl ? plugin.externalUrl : "addplugin.html?name=" + encodeURIComponent(plugin.name) + "&guid=" + plugin.guid;
|
||||||
options.context && (href += "&context=" + options.context);
|
|
||||||
|
if (options.context) {
|
||||||
|
href += "&context=" + options.context;
|
||||||
|
}
|
||||||
|
|
||||||
var target = plugin.externalUrl ? ' target="_blank"' : "";
|
var target = plugin.externalUrl ? ' target="_blank"' : "";
|
||||||
html += "<div class='card backdropCard'>", html += '<div class="cardBox visualCardBox">', html += '<div class="cardScalable visualCardBox-cardScalable">', html += '<div class="cardPadder cardPadder-backdrop"></div>', html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + ">", plugin.thumbImage ? (html += '<div class="cardImage coveredImage" style="background-image:url(\'' + plugin.thumbImage + "');\">", html += "</div>") : html += '<i class="cardImageIcon md-icon"></i>', html += "</a>", html += "</div>", html += '<div class="cardFooter">', html += "<div class='cardText'>", html += plugin.name, html += "</div>";
|
html += "<div class='card backdropCard'>";
|
||||||
var installedPlugin = plugin.isApp ? null : installedPlugins.filter(function(ip) {
|
html += '<div class="cardBox visualCardBox">';
|
||||||
return ip.Id == plugin.guid
|
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||||
|
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||||
|
html += '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + href + '"' + target + ">";
|
||||||
|
|
||||||
|
if (plugin.thumbImage) {
|
||||||
|
html += '<div class="cardImage coveredImage" style="background-image:url(\'' + plugin.thumbImage + "');\">";
|
||||||
|
html += "</div>";
|
||||||
|
} else {
|
||||||
|
html += '<i class="cardImageIcon md-icon"></i>';
|
||||||
|
}
|
||||||
|
|
||||||
|
html += "</a>";
|
||||||
|
html += "</div>";
|
||||||
|
html += '<div class="cardFooter">';
|
||||||
|
html += "<div class='cardText'>";
|
||||||
|
html += plugin.name;
|
||||||
|
html += "</div>";
|
||||||
|
var installedPlugin = plugin.isApp ? null : installedPlugins.filter(function (ip) {
|
||||||
|
return ip.Id == plugin.guid;
|
||||||
})[0];
|
})[0];
|
||||||
return html += "<div class='cardText cardText-secondary'>", html += installedPlugin ? globalize.translate("LabelVersionInstalled").replace("{0}", installedPlugin.Version) : " ", html += "</div>", html += "</div>", html += "</div>", html += "</div>"
|
html += "<div class='cardText cardText-secondary'>";
|
||||||
|
html += installedPlugin ? globalize.translate("LabelVersionInstalled").replace("{0}", installedPlugin.Version) : " ";
|
||||||
|
html += "</div>";
|
||||||
|
html += "</div>";
|
||||||
|
html += "</div>";
|
||||||
|
return html += "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTabs() {
|
function getTabs() {
|
||||||
|
@ -82,20 +216,24 @@ define(["loading", "libraryMenu", "globalize", "cardStyle", "emby-linkbutton", "
|
||||||
}, {
|
}, {
|
||||||
href: "plugincatalog.html",
|
href: "plugincatalog.html",
|
||||||
name: globalize.translate("TabCatalog")
|
name: globalize.translate("TabCatalog")
|
||||||
}]
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = {
|
var query = {
|
||||||
TargetSystems: "Server",
|
TargetSystems: "Server",
|
||||||
IsAdult: !1
|
IsAdult: false
|
||||||
};
|
};
|
||||||
return window.PluginCatalog = {
|
window.PluginCatalog = {
|
||||||
renderCatalog: populateList
|
renderCatalog: populateList
|
||||||
},
|
};
|
||||||
function(view, params) {
|
return function (view, params) {
|
||||||
view.querySelector("#selectSystem").addEventListener("change", function() {
|
view.querySelector("#selectSystem").addEventListener("change", function () {
|
||||||
query.TargetSystems = this.value, reloadList(view)
|
query.TargetSystems = this.value;
|
||||||
}), view.addEventListener("viewshow", function() {
|
reloadList(view);
|
||||||
libraryMenu.setTabs("plugins", 1, getTabs), reloadList(this)
|
});
|
||||||
})
|
view.addEventListener("viewshow", function () {
|
||||||
}
|
libraryMenu.setTabs("plugins", 1, getTabs);
|
||||||
|
reloadList(this);
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
Loading…
Add table
Add a link
Reference in a new issue