mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
cleanup data-require from viewContainer
This commit is contained in:
parent
6502446f88
commit
ce51c8012d
1 changed files with 57 additions and 70 deletions
|
@ -41,98 +41,85 @@ define(["browser", "dom", "layoutManager", "css!components/viewManager/viewConta
|
||||||
var isPluginpage = -1 !== options.url.toLowerCase().indexOf("/configurationpage");
|
var isPluginpage = -1 !== options.url.toLowerCase().indexOf("/configurationpage");
|
||||||
var newViewInfo = normalizeNewView(options, isPluginpage);
|
var newViewInfo = normalizeNewView(options, isPluginpage);
|
||||||
var newView = newViewInfo.elem;
|
var newView = newViewInfo.elem;
|
||||||
var dependencies = "string" == typeof newView ? null : newView.getAttribute("data-require");
|
|
||||||
dependencies = dependencies ? dependencies.split(",") : [];
|
|
||||||
|
|
||||||
if (isPluginpage) {
|
if (isPluginpage) {
|
||||||
dependencies.push("legacy/dashboard");
|
require(["legacy/dashboard"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newViewInfo.hasjQuerySelect) {
|
if (newViewInfo.hasjQuerySelect) {
|
||||||
dependencies.push("legacy/selectmenu");
|
require(["legacy/selectmenu"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newViewInfo.hasjQueryChecked) {
|
if (newViewInfo.hasjQueryChecked) {
|
||||||
dependencies.push("fnchecked");
|
require(["fnchecked"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newViewInfo.hasjQuery) {
|
return new Promise(function (resolve) {
|
||||||
dependencies.push("jQuery");
|
var currentPage = allPages[pageIndex];
|
||||||
}
|
|
||||||
|
|
||||||
if (isPluginpage || newView.classList && newView.classList.contains("type-interior")) {
|
if (currentPage) {
|
||||||
dependencies.push("dashboardcss");
|
triggerDestroy(currentPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
var view = newView;
|
||||||
dependencies.join(",");
|
|
||||||
|
|
||||||
require(dependencies, function () {
|
if ("string" == typeof view) {
|
||||||
var currentPage = allPages[pageIndex];
|
view = document.createElement("div");
|
||||||
|
view.innerHTML = newView;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentPage) {
|
view.classList.add("mainAnimatedPage");
|
||||||
triggerDestroy(currentPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
var view = newView;
|
if (currentPage) {
|
||||||
|
if (newViewInfo.hasScript && window.$) {
|
||||||
if ("string" == typeof view) {
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
view = document.createElement("div");
|
mainAnimatedPages.removeChild(currentPage);
|
||||||
view.innerHTML = newView;
|
|
||||||
}
|
|
||||||
|
|
||||||
view.classList.add("mainAnimatedPage");
|
|
||||||
|
|
||||||
if (currentPage) {
|
|
||||||
if (newViewInfo.hasScript && window.$) {
|
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
|
||||||
mainAnimatedPages.removeChild(currentPage);
|
|
||||||
} else {
|
|
||||||
mainAnimatedPages.replaceChild(view, currentPage);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (newViewInfo.hasScript && window.$) {
|
mainAnimatedPages.replaceChild(view, currentPage);
|
||||||
view = $(view).appendTo(mainAnimatedPages)[0];
|
}
|
||||||
} else {
|
} else {
|
||||||
mainAnimatedPages.appendChild(view);
|
if (newViewInfo.hasScript && window.$) {
|
||||||
}
|
view = $(view).appendTo(mainAnimatedPages)[0];
|
||||||
|
} else {
|
||||||
|
mainAnimatedPages.appendChild(view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.type) {
|
||||||
|
view.setAttribute("data-type", options.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
var properties = [];
|
||||||
|
|
||||||
|
if (options.fullscreen) {
|
||||||
|
properties.push("fullscreen");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties.length) {
|
||||||
|
view.setAttribute("data-properties", properties.join(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
allPages[pageIndex] = view;
|
||||||
|
setControllerClass(view, options).then(function () {
|
||||||
|
if (onBeforeChange) {
|
||||||
|
onBeforeChange(view, false, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.type) {
|
beforeAnimate(allPages, pageIndex, selected);
|
||||||
view.setAttribute("data-type", options.type);
|
selectedPageIndex = pageIndex;
|
||||||
|
currentUrls[pageIndex] = options.url;
|
||||||
|
|
||||||
|
if (!options.cancel && previousAnimatable) {
|
||||||
|
afterAnimate(allPages, pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
var properties = [];
|
if (window.$) {
|
||||||
|
$.mobile = $.mobile || {};
|
||||||
if (options.fullscreen) {
|
$.mobile.activePage = view;
|
||||||
properties.push("fullscreen");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.length) {
|
resolve(view);
|
||||||
view.setAttribute("data-properties", properties.join(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
allPages[pageIndex] = view;
|
|
||||||
setControllerClass(view, options).then(function () {
|
|
||||||
if (onBeforeChange) {
|
|
||||||
onBeforeChange(view, false, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeAnimate(allPages, pageIndex, selected);
|
|
||||||
selectedPageIndex = pageIndex;
|
|
||||||
currentUrls[pageIndex] = options.url;
|
|
||||||
|
|
||||||
if (!options.cancel && previousAnimatable) {
|
|
||||||
afterAnimate(allPages, pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.$) {
|
|
||||||
$.mobile = $.mobile || {};
|
|
||||||
$.mobile.activePage = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve(view);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue