move all user preference controllers to folder

This commit is contained in:
dkanada 2019-10-06 19:56:06 +09:00
parent 0c1c855eb8
commit 27944af119
10 changed files with 37 additions and 67 deletions

View File

@ -2,7 +2,6 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
'use strict'; 'use strict';
function enableAnimation(elem) { function enableAnimation(elem) {
if (browser.slow) { if (browser.slow) {
return false; return false;
} }
@ -11,7 +10,6 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
function enableRotation() { function enableRotation() {
if (browser.tv) { if (browser.tv) {
return false; return false;
} }
@ -25,17 +23,13 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
function Backdrop() { function Backdrop() {
} }
Backdrop.prototype.load = function (url, parent, existingBackdropImage) { Backdrop.prototype.load = function (url, parent, existingBackdropImage) {
var img = new Image(); var img = new Image();
var self = this; var self = this;
img.onload = function () { img.onload = function () {
if (self.isDestroyed) { if (self.isDestroyed) {
return; return;
} }
@ -75,6 +69,7 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
internalBackdrop(true); internalBackdrop(true);
}; };
img.src = url; img.src = url;
}; };
@ -87,14 +82,12 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
}; };
Backdrop.prototype.destroy = function () { Backdrop.prototype.destroy = function () {
this.isDestroyed = true; this.isDestroyed = true;
this.cancelAnimation(); this.cancelAnimation();
}; };
var backdropContainer; var backdropContainer;
function getBackdropContainer() { function getBackdropContainer() {
if (!backdropContainer) { if (!backdropContainer) {
backdropContainer = document.querySelector('.backdropContainer'); backdropContainer = document.querySelector('.backdropContainer');
} }
@ -109,7 +102,6 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
function clearBackdrop(clearAll) { function clearBackdrop(clearAll) {
clearRotation(); clearRotation();
if (currentLoadingBackdrop) { if (currentLoadingBackdrop) {
@ -123,6 +115,7 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
if (clearAll) { if (clearAll) {
hasExternalBackdrop = false; hasExternalBackdrop = false;
} }
internalBackdrop(false); internalBackdrop(false);
} }
@ -133,8 +126,8 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
return backgroundContainer; return backgroundContainer;
} }
function setBackgroundContainerBackgroundEnabled() {
function setBackgroundContainerBackgroundEnabled() {
if (hasInternalBackdrop || hasExternalBackdrop) { if (hasInternalBackdrop || hasExternalBackdrop) {
getBackgroundContainer().classList.add('withBackdrop'); getBackgroundContainer().classList.add('withBackdrop');
} else { } else {
@ -160,7 +153,6 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
var currentLoadingBackdrop; var currentLoadingBackdrop;
function setBackdropImage(url) { function setBackdropImage(url) {
if (currentLoadingBackdrop) { if (currentLoadingBackdrop) {
currentLoadingBackdrop.destroy(); currentLoadingBackdrop.destroy();
currentLoadingBackdrop = null; currentLoadingBackdrop = null;
@ -183,29 +175,23 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
var standardWidths = [480, 720, 1280, 1440, 1920]; var standardWidths = [480, 720, 1280, 1440, 1920];
function getBackdropMaxWidth() { function getBackdropMaxWidth() {
var width = dom.getWindowSize().innerWidth; var width = dom.getWindowSize().innerWidth;
var roundScreenTo = 100;
if (standardWidths.indexOf(width) !== -1) { if (standardWidths.indexOf(width) !== -1) {
return width; return width;
} }
var roundScreenTo = 100;
width = Math.floor(width / roundScreenTo) * roundScreenTo; width = Math.floor(width / roundScreenTo) * roundScreenTo;
return Math.min(width, 1920); return Math.min(width, 1920);
} }
function getItemImageUrls(item, imageOptions) { function getItemImageUrls(item, imageOptions) {
imageOptions = imageOptions || {}; imageOptions = imageOptions || {};
var apiClient = connectionManager.getApiClient(item.ServerId); var apiClient = connectionManager.getApiClient(item.ServerId);
if (item.BackdropImageTags && item.BackdropImageTags.length > 0) { if (item.BackdropImageTags && item.BackdropImageTags.length > 0) {
return item.BackdropImageTags.map(function (imgTag, index) { return item.BackdropImageTags.map(function (imgTag, index) {
return apiClient.getScaledImageUrl(item.BackdropItemId || item.Id, Object.assign(imageOptions, { return apiClient.getScaledImageUrl(item.BackdropItemId || item.Id, Object.assign(imageOptions, {
type: "Backdrop", type: "Backdrop",
tag: imgTag, tag: imgTag,
@ -216,9 +202,7 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) { if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) {
return item.ParentBackdropImageTags.map(function (imgTag, index) { return item.ParentBackdropImageTags.map(function (imgTag, index) {
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, Object.assign(imageOptions, { return apiClient.getScaledImageUrl(item.ParentBackdropItemId, Object.assign(imageOptions, {
type: "Backdrop", type: "Backdrop",
tag: imgTag, tag: imgTag,
@ -232,17 +216,13 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
} }
function getImageUrls(items, imageOptions) { function getImageUrls(items, imageOptions) {
var list = []; var list = [];
var onImg = function (img) { var onImg = function (img) {
list.push(img); list.push(img);
}; };
for (var i = 0, length = items.length; i < length; i++) { for (var i = 0, length = items.length; i < length; i++) {
var itemImages = getItemImageUrls(items[i], imageOptions); var itemImages = getItemImageUrls(items[i], imageOptions);
itemImages.forEach(onImg); itemImages.forEach(onImg);
} }
@ -262,12 +242,12 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
// If you don't care about the order of the elements inside // If you don't care about the order of the elements inside
// the array, you should sort both arrays here. // the array, you should sort both arrays here.
for (var i = 0; i < a.length; ++i) { for (var i = 0; i < a.length; ++i) {
if (a[i] !== b[i]) { if (a[i] !== b[i]) {
return false; return false;
} }
} }
return true; return true;
} }
@ -275,20 +255,16 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
var currentRotatingImages = []; var currentRotatingImages = [];
var currentRotationIndex = -1; var currentRotationIndex = -1;
function setBackdrops(items, imageOptions, enableImageRotation) { function setBackdrops(items, imageOptions, enableImageRotation) {
var images = getImageUrls(items, imageOptions); var images = getImageUrls(items, imageOptions);
if (images.length) { if (images.length) {
startRotation(images, enableImageRotation); startRotation(images, enableImageRotation);
} else { } else {
clearBackdrop(); clearBackdrop();
} }
} }
function startRotation(images, enableImageRotation) { function startRotation(images, enableImageRotation) {
if (arraysEqual(images, currentRotatingImages)) { if (arraysEqual(images, currentRotatingImages)) {
return; return;
} }
@ -301,11 +277,11 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
if (images.length > 1 && enableImageRotation !== false && enableRotation()) { if (images.length > 1 && enableImageRotation !== false && enableRotation()) {
rotationInterval = setInterval(onRotationInterval, 24000); rotationInterval = setInterval(onRotationInterval, 24000);
} }
onRotationInterval(); onRotationInterval();
} }
function onRotationInterval() { function onRotationInterval() {
if (playbackManager.isPlayingLocally(['Video'])) { if (playbackManager.isPlayingLocally(['Video'])) {
return; return;
} }
@ -324,35 +300,29 @@ define(['browser', 'connectionManager', 'playbackManager', 'dom', 'css!./style']
if (interval) { if (interval) {
clearInterval(interval); clearInterval(interval);
} }
rotationInterval = null; rotationInterval = null;
currentRotatingImages = []; currentRotatingImages = [];
currentRotationIndex = -1; currentRotationIndex = -1;
} }
function setBackdrop(url, imageOptions) { function setBackdrop(url, imageOptions) {
if (url && typeof url !== 'string') {
if (url) {
if (typeof url !== 'string') {
url = getImageUrls([url], imageOptions)[0]; url = getImageUrls([url], imageOptions)[0];
} }
}
if (url) { if (url) {
clearRotation(); clearRotation();
setBackdropImage(url); setBackdropImage(url);
} else { } else {
clearBackdrop(); clearBackdrop();
} }
} }
return { return {
setBackdrops: setBackdrops, setBackdrops: setBackdrops,
setBackdrop: setBackdrop, setBackdrop: setBackdrop,
clear: clearBackdrop, clear: clearBackdrop,
externalBackdrop: externalBackdrop externalBackdrop: externalBackdrop
}; };
}); });

View File

@ -14,7 +14,7 @@ define(["apphost", "connectionManager", "listViewStyle", "emby-button"], functio
page.querySelector(".lnkMyProfile").setAttribute("href", "myprofile.html?userId=" + userId); page.querySelector(".lnkMyProfile").setAttribute("href", "myprofile.html?userId=" + userId);
page.querySelector(".lnkDisplayPreferences").setAttribute("href", "mypreferencesdisplay.html?userId=" + userId); page.querySelector(".lnkDisplayPreferences").setAttribute("href", "mypreferencesdisplay.html?userId=" + userId);
page.querySelector(".lnkHomePreferences").setAttribute("href", "mypreferenceshome.html?userId=" + userId); page.querySelector(".lnkHomePreferences").setAttribute("href", "mypreferenceshome.html?userId=" + userId);
page.querySelector(".lnkLanguagePreferences").setAttribute("href", "mypreferenceslanguages.html?userId=" + userId); page.querySelector(".lnkPlaybackPreferences").setAttribute("href", "mypreferencesplayback.html?userId=" + userId);
page.querySelector(".lnkSubtitlePreferences").setAttribute("href", "mypreferencessubtitles.html?userId=" + userId); page.querySelector(".lnkSubtitlePreferences").setAttribute("href", "mypreferencessubtitles.html?userId=" + userId);
if (appHost.supports("multiserver")) { if (appHost.supports("multiserver")) {

View File

@ -30,7 +30,7 @@
</div> </div>
</a> </a>
<a is="emby-linkbutton" data-ripple="false" href="#" class="lnkLanguagePreferences listItem-border"> <a is="emby-linkbutton" data-ripple="false" href="#" class="lnkPlaybackPreferences listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">play_circle_filled</i> <i class="md-icon listItemIcon listItemIcon-transparent">play_circle_filled</i>
<div class="listItemBody"> <div class="listItemBody">

View File

@ -229,41 +229,41 @@ define([
autoFocus: false, autoFocus: false,
transition: "fade" transition: "fade"
}); });
defineRoute({
path: "/mypreferencesdisplay.html",
autoFocus: false,
transition: "fade",
controller: "mypreferencesdisplay"
});
defineRoute({
path: "/mypreferenceshome.html",
autoFocus: false,
transition: "fade",
controller: "mypreferenceshome"
});
defineRoute({
path: "/mypreferencessubtitles.html",
autoFocus: false,
transition: "fade",
controller: "mypreferencessubtitles"
});
defineRoute({
path: "/mypreferenceslanguages.html",
autoFocus: false,
transition: "fade",
controller: "mypreferenceslanguages"
});
defineRoute({ defineRoute({
path: "/mypreferencesmenu.html", path: "/mypreferencesmenu.html",
autoFocus: false, autoFocus: false,
transition: "fade", transition: "fade",
controller: "mypreferencescommon" controller: "user/menu"
}); });
defineRoute({ defineRoute({
path: "/myprofile.html", path: "/myprofile.html",
autoFocus: false, autoFocus: false,
transition: "fade", transition: "fade",
controller: "myprofile" controller: "user/profile"
});
defineRoute({
path: "/mypreferencesdisplay.html",
autoFocus: false,
transition: "fade",
controller: "user/display"
});
defineRoute({
path: "/mypreferenceshome.html",
autoFocus: false,
transition: "fade",
controller: "user/home"
});
defineRoute({
path: "/mypreferencesplayback.html",
autoFocus: false,
transition: "fade",
controller: "user/playback"
});
defineRoute({
path: "/mypreferencessubtitles.html",
autoFocus: false,
transition: "fade",
controller: "user/subtitles"
}); });
defineRoute({ defineRoute({
path: "/notificationsetting.html", path: "/notificationsetting.html",