1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge branch 'master' into migrate-to-ES6-55

This commit is contained in:
Cameron 2020-08-08 19:24:44 +01:00 committed by GitHub
commit 9911a43478
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
155 changed files with 6872 additions and 7544 deletions

View file

@ -0,0 +1,8 @@
import * as userSettings from 'userSettings';
import skinManager from 'skinManager';
import connectionManager from 'connectionManager';
import events from 'events';
events.on(connectionManager, 'localusersignedin', function (e, user) {
skinManager.setTheme(userSettings.theme());
});

View file

@ -35,6 +35,7 @@ import appHost from 'apphost';
if (eventListenerCount) {
eventListenerCount--;
}
dom.removeEventListener(scope, 'command', fn, {});
}

View file

@ -1,8 +1,10 @@
define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', 'viewManager', 'libraryBrowser', 'appRouter', 'apphost', 'playbackManager', 'syncPlayManager', 'groupSelectionMenu', 'browser', 'globalize', 'scripts/imagehelper', 'paper-icon-button-light', 'material-icons', 'scrollStyles', 'flexStyles'], function (dom, layoutManager, inputManager, connectionManager, events, viewManager, libraryBrowser, appRouter, appHost, playbackManager, syncPlayManager, groupSelectionMenu, browser, globalize, imageHelper) {
'use strict';
viewManager = viewManager.default || viewManager;
playbackManager = playbackManager.default || playbackManager;
browser = browser.default || browser;
layoutManager = layoutManager.default || layoutManager;
function renderHeader() {
var html = '';
@ -806,6 +808,8 @@ define(['dom', 'layoutManager', 'inputManager', 'connectionManager', 'events', '
navDrawerScrollContainer.addEventListener('click', onMainDrawerClick);
return new Promise(function (resolve, reject) {
require(['navdrawer'], function (navdrawer) {
navdrawer = navdrawer.default || navdrawer;
navDrawerInstance = new navdrawer(getNavDrawerOptions());
if (!layoutManager.tv) {

View file

@ -1,135 +1,138 @@
define(['focusManager', 'dom', 'scrollStyles'], function (focusManager, dom) {
'use strict';
import focusManager from 'focusManager';
import dom from 'dom';
import 'scrollStyles';
function getBoundingClientRect(elem) {
// Support: BlackBerry 5, iOS 3 (original iPhone)
// If we don't have gBCR, just use 0,0 rather than error
if (elem.getBoundingClientRect) {
return elem.getBoundingClientRect();
} else {
return { top: 0, left: 0 };
}
function getBoundingClientRect(elem) {
// Support: BlackBerry 5, iOS 3 (original iPhone)
// If we don't have gBCR, just use 0,0 rather than error
if (elem.getBoundingClientRect) {
return elem.getBoundingClientRect();
} else {
return { top: 0, left: 0 };
}
}
export function getPosition(scrollContainer, item, horizontal) {
const slideeOffset = getBoundingClientRect(scrollContainer);
const itemOffset = getBoundingClientRect(item);
let offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top;
let size = horizontal ? itemOffset.width : itemOffset.height;
if (!size && size !== 0) {
size = item[horizontal ? 'offsetWidth' : 'offsetHeight'];
}
function getPosition(scrollContainer, item, horizontal) {
var slideeOffset = getBoundingClientRect(scrollContainer);
var itemOffset = getBoundingClientRect(item);
const currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop;
var offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top;
var size = horizontal ? itemOffset.width : itemOffset.height;
if (!size && size !== 0) {
size = item[horizontal ? 'offsetWidth' : 'offsetHeight'];
}
offset += currentStart;
var currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop;
const frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
offset += currentStart;
const currentEnd = currentStart + frameSize;
var frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
var currentEnd = currentStart + frameSize;
var isVisible = offset >= currentStart && (offset + size) <= currentEnd;
return {
start: offset,
center: (offset - (frameSize / 2) + (size / 2)),
end: offset - frameSize + size,
size: size,
isVisible: isVisible
};
}
function toCenter(container, elem, horizontal, skipWhenVisible) {
var pos = getPosition(container, elem, horizontal);
if (skipWhenVisible && pos.isVisible) {
return;
}
if (container.scrollTo) {
if (horizontal) {
container.scrollTo(pos.center, 0);
} else {
container.scrollTo(0, pos.center);
}
} else {
if (horizontal) {
container.scrollLeft = Math.round(pos.center);
} else {
container.scrollTop = Math.round(pos.center);
}
}
}
function toStart(container, elem, horizontal, skipWhenVisible) {
var pos = getPosition(container, elem, horizontal);
if (skipWhenVisible && pos.isVisible) {
return;
}
if (container.scrollTo) {
if (horizontal) {
container.scrollTo(pos.start, 0);
} else {
container.scrollTo(0, pos.start);
}
} else {
if (horizontal) {
container.scrollLeft = Math.round(pos.start);
} else {
container.scrollTop = Math.round(pos.start);
}
}
}
function centerOnFocus(e, scrollSlider, horizontal) {
var focused = focusManager.focusableParent(e.target);
if (focused) {
toCenter(scrollSlider, focused, horizontal);
}
}
function centerOnFocusHorizontal(e) {
centerOnFocus(e, this, true);
}
function centerOnFocusVertical(e) {
centerOnFocus(e, this, false);
}
const isVisible = offset >= currentStart && (offset + size) <= currentEnd;
return {
getPosition: getPosition,
centerFocus: {
on: function (element, horizontal) {
if (horizontal) {
dom.addEventListener(element, 'focus', centerOnFocusHorizontal, {
capture: true,
passive: true
});
} else {
dom.addEventListener(element, 'focus', centerOnFocusVertical, {
capture: true,
passive: true
});
}
},
off: function (element, horizontal) {
if (horizontal) {
dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, {
capture: true,
passive: true
});
} else {
dom.removeEventListener(element, 'focus', centerOnFocusVertical, {
capture: true,
passive: true
});
}
}
},
toCenter: toCenter,
toStart: toStart
start: offset,
center: (offset - (frameSize / 2) + (size / 2)),
end: offset - frameSize + size,
size: size,
isVisible: isVisible
};
});
}
export function toCenter(container, elem, horizontal, skipWhenVisible) {
const pos = getPosition(container, elem, horizontal);
if (skipWhenVisible && pos.isVisible) {
return;
}
if (container.scrollTo) {
if (horizontal) {
container.scrollTo(pos.center, 0);
} else {
container.scrollTo(0, pos.center);
}
} else {
if (horizontal) {
container.scrollLeft = Math.round(pos.center);
} else {
container.scrollTop = Math.round(pos.center);
}
}
}
export function toStart(container, elem, horizontal, skipWhenVisible) {
const pos = getPosition(container, elem, horizontal);
if (skipWhenVisible && pos.isVisible) {
return;
}
if (container.scrollTo) {
if (horizontal) {
container.scrollTo(pos.start, 0);
} else {
container.scrollTo(0, pos.start);
}
} else {
if (horizontal) {
container.scrollLeft = Math.round(pos.start);
} else {
container.scrollTop = Math.round(pos.start);
}
}
}
function centerOnFocus(e, scrollSlider, horizontal) {
const focused = focusManager.focusableParent(e.target);
if (focused) {
toCenter(scrollSlider, focused, horizontal);
}
}
function centerOnFocusHorizontal(e) {
centerOnFocus(e, this, true);
}
function centerOnFocusVertical(e) {
centerOnFocus(e, this, false);
}
export const centerFocus = {
on: function (element, horizontal) {
if (horizontal) {
dom.addEventListener(element, 'focus', centerOnFocusHorizontal, {
capture: true,
passive: true
});
} else {
dom.addEventListener(element, 'focus', centerOnFocusVertical, {
capture: true,
passive: true
});
}
},
off: function (element, horizontal) {
if (horizontal) {
dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, {
capture: true,
passive: true
});
} else {
dom.removeEventListener(element, 'focus', centerOnFocusVertical, {
capture: true,
passive: true
});
}
}
};
export default {
getPosition: getPosition,
centerFocus: centerFocus,
toCenter: toCenter,
toStart: toStart
};

View file

@ -1,57 +0,0 @@
define(['searchFields', 'searchResults', 'events'], function (SearchFields, SearchResults, events) {
'use strict';
SearchFields = SearchFields.default || SearchFields;
SearchResults = SearchResults.default || SearchResults;
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({
element: tabContent.querySelector('.searchFields')
});
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);
});
}
function SearchTab(view, tabContent, options) {
var self = this;
options = options || {};
init(this, tabContent, options);
self.preRender = function () {};
self.renderTab = function () {
var searchFields = this.searchFields;
if (searchFields) {
searchFields.focus();
}
};
}
SearchTab.prototype.destroy = function () {
var searchFields = this.searchFields;
if (searchFields) {
searchFields.destroy();
}
this.searchFields = null;
var searchResults = this.searchResults;
if (searchResults) {
searchResults.destroy();
}
this.searchResults = null;
};
return SearchTab;
});

View file

@ -1,213 +1,216 @@
define(['connectionManager', 'playbackManager', 'syncPlayManager', 'events', 'inputManager', 'focusManager', 'appRouter'], function (connectionManager, playbackManager, syncPlayManager, events, inputManager, focusManager, appRouter) {
'use strict';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import syncPlayManager from 'syncPlayManager';
import events from 'events';
import inputManager from 'inputManager';
import focusManager from 'focusManager';
import appRouter from 'appRouter';
playbackManager = playbackManager.default || playbackManager;
const serverNotifications = {};
var serverNotifications = {};
function notifyApp() {
inputManager.notify();
}
function notifyApp() {
inputManager.notify();
}
function displayMessage(cmd) {
var args = cmd.Arguments;
if (args.TimeoutMs) {
require(['toast'], function (toast) {
toast({ title: args.Header, text: args.Text });
});
} else {
require(['alert'], function (alert) {
alert.default({ title: args.Header, text: args.Text });
});
}
}
function displayContent(cmd, apiClient) {
if (!playbackManager.isPlayingLocally(['Video', 'Book'])) {
appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId());
}
}
function playTrailers(apiClient, itemId) {
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
playbackManager.playTrailers(item);
function displayMessage(cmd) {
const args = cmd.Arguments;
if (args.TimeoutMs) {
import('toast').then(({default: toast}) => {
toast({ title: args.Header, text: args.Text });
});
} else {
import('alert').then(({default: alert}) => {
alert({ title: args.Header, text: args.Text });
});
}
}
function processGeneralCommand(cmd, apiClient) {
console.debug('Received command: ' + cmd.Name);
switch (cmd.Name) {
case 'Select':
inputManager.handleCommand('select');
return;
case 'Back':
inputManager.handleCommand('back');
return;
case 'MoveUp':
inputManager.handleCommand('up');
return;
case 'MoveDown':
inputManager.handleCommand('down');
return;
case 'MoveLeft':
inputManager.handleCommand('left');
return;
case 'MoveRight':
inputManager.handleCommand('right');
return;
case 'PageUp':
inputManager.handleCommand('pageup');
return;
case 'PageDown':
inputManager.handleCommand('pagedown');
return;
case 'PlayTrailers':
playTrailers(apiClient, cmd.Arguments.ItemId);
break;
case 'SetRepeatMode':
playbackManager.setRepeatMode(cmd.Arguments.RepeatMode);
break;
case 'SetShuffleQueue':
playbackManager.setQueueShuffleMode(cmd.Arguments.ShuffleMode);
break;
case 'VolumeUp':
inputManager.handleCommand('volumeup');
return;
case 'VolumeDown':
inputManager.handleCommand('volumedown');
return;
case 'ChannelUp':
inputManager.handleCommand('channelup');
return;
case 'ChannelDown':
inputManager.handleCommand('channeldown');
return;
case 'Mute':
inputManager.handleCommand('mute');
return;
case 'Unmute':
inputManager.handleCommand('unmute');
return;
case 'ToggleMute':
inputManager.handleCommand('togglemute');
return;
case 'SetVolume':
notifyApp();
playbackManager.setVolume(cmd.Arguments.Volume);
break;
case 'SetAudioStreamIndex':
notifyApp();
playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
break;
case 'SetSubtitleStreamIndex':
notifyApp();
playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
break;
case 'ToggleFullscreen':
inputManager.handleCommand('togglefullscreen');
return;
case 'GoHome':
inputManager.handleCommand('home');
return;
case 'GoToSettings':
inputManager.handleCommand('settings');
return;
case 'DisplayContent':
displayContent(cmd, apiClient);
break;
case 'GoToSearch':
inputManager.handleCommand('search');
return;
case 'DisplayMessage':
displayMessage(cmd);
break;
case 'ToggleOsd':
// todo
break;
case 'ToggleContextMenu':
// todo
break;
case 'TakeScreenShot':
// todo
break;
case 'SendKey':
// todo
break;
case 'SendString':
// todo
focusManager.sendText(cmd.Arguments.String);
break;
default:
console.debug('processGeneralCommand does not recognize: ' + cmd.Name);
break;
}
notifyApp();
function displayContent(cmd, apiClient) {
if (!playbackManager.isPlayingLocally(['Video', 'Book'])) {
appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId());
}
}
function onMessageReceived(e, msg) {
var apiClient = this;
if (msg.MessageType === 'Play') {
notifyApp();
var serverId = apiClient.serverInfo().Id;
if (msg.Data.PlayCommand === 'PlayNext') {
playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId });
} else if (msg.Data.PlayCommand === 'PlayLast') {
playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId });
} else {
playbackManager.play({
ids: msg.Data.ItemIds,
startPositionTicks: msg.Data.StartPositionTicks,
mediaSourceId: msg.Data.MediaSourceId,
audioStreamIndex: msg.Data.AudioStreamIndex,
subtitleStreamIndex: msg.Data.SubtitleStreamIndex,
startIndex: msg.Data.StartIndex,
serverId: serverId
});
}
} else if (msg.MessageType === 'Playstate') {
if (msg.Data.Command === 'Stop') {
inputManager.handleCommand('stop');
} else if (msg.Data.Command === 'Pause') {
inputManager.handleCommand('pause');
} else if (msg.Data.Command === 'Unpause') {
inputManager.handleCommand('play');
} else if (msg.Data.Command === 'PlayPause') {
inputManager.handleCommand('playpause');
} else if (msg.Data.Command === 'Seek') {
playbackManager.seek(msg.Data.SeekPositionTicks);
} else if (msg.Data.Command === 'NextTrack') {
inputManager.handleCommand('next');
} else if (msg.Data.Command === 'PreviousTrack') {
inputManager.handleCommand('previous');
} else {
notifyApp();
}
} else if (msg.MessageType === 'GeneralCommand') {
var cmd = msg.Data;
processGeneralCommand(cmd, apiClient);
} else if (msg.MessageType === 'UserDataChanged') {
if (msg.Data.UserId === apiClient.getCurrentUserId()) {
for (var i = 0, length = msg.Data.UserDataList.length; i < length; i++) {
events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]);
}
}
} else if (msg.MessageType === 'SyncPlayCommand') {
syncPlayManager.processCommand(msg.Data, apiClient);
} else if (msg.MessageType === 'SyncPlayGroupUpdate') {
syncPlayManager.processGroupUpdate(msg.Data, apiClient);
} else {
events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]);
}
}
function bindEvents(apiClient) {
events.off(apiClient, 'message', onMessageReceived);
events.on(apiClient, 'message', onMessageReceived);
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient);
function playTrailers(apiClient, itemId) {
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
playbackManager.playTrailers(item);
});
return serverNotifications;
}
function processGeneralCommand(cmd, apiClient) {
console.debug('Received command: ' + cmd.Name);
switch (cmd.Name) {
case 'Select':
inputManager.handleCommand('select');
return;
case 'Back':
inputManager.handleCommand('back');
return;
case 'MoveUp':
inputManager.handleCommand('up');
return;
case 'MoveDown':
inputManager.handleCommand('down');
return;
case 'MoveLeft':
inputManager.handleCommand('left');
return;
case 'MoveRight':
inputManager.handleCommand('right');
return;
case 'PageUp':
inputManager.handleCommand('pageup');
return;
case 'PageDown':
inputManager.handleCommand('pagedown');
return;
case 'PlayTrailers':
playTrailers(apiClient, cmd.Arguments.ItemId);
break;
case 'SetRepeatMode':
playbackManager.setRepeatMode(cmd.Arguments.RepeatMode);
break;
case 'SetShuffleQueue':
playbackManager.setQueueShuffleMode(cmd.Arguments.ShuffleMode);
break;
case 'VolumeUp':
inputManager.handleCommand('volumeup');
return;
case 'VolumeDown':
inputManager.handleCommand('volumedown');
return;
case 'ChannelUp':
inputManager.handleCommand('channelup');
return;
case 'ChannelDown':
inputManager.handleCommand('channeldown');
return;
case 'Mute':
inputManager.handleCommand('mute');
return;
case 'Unmute':
inputManager.handleCommand('unmute');
return;
case 'ToggleMute':
inputManager.handleCommand('togglemute');
return;
case 'SetVolume':
notifyApp();
playbackManager.setVolume(cmd.Arguments.Volume);
break;
case 'SetAudioStreamIndex':
notifyApp();
playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index));
break;
case 'SetSubtitleStreamIndex':
notifyApp();
playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index));
break;
case 'ToggleFullscreen':
inputManager.handleCommand('togglefullscreen');
return;
case 'GoHome':
inputManager.handleCommand('home');
return;
case 'GoToSettings':
inputManager.handleCommand('settings');
return;
case 'DisplayContent':
displayContent(cmd, apiClient);
break;
case 'GoToSearch':
inputManager.handleCommand('search');
return;
case 'DisplayMessage':
displayMessage(cmd);
break;
case 'ToggleOsd':
// todo
break;
case 'ToggleContextMenu':
// todo
break;
case 'TakeScreenShot':
// todo
break;
case 'SendKey':
// todo
break;
case 'SendString':
// todo
focusManager.sendText(cmd.Arguments.String);
break;
default:
console.debug('processGeneralCommand does not recognize: ' + cmd.Name);
break;
}
notifyApp();
}
function onMessageReceived(e, msg) {
const apiClient = this;
if (msg.MessageType === 'Play') {
notifyApp();
const serverId = apiClient.serverInfo().Id;
if (msg.Data.PlayCommand === 'PlayNext') {
playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId });
} else if (msg.Data.PlayCommand === 'PlayLast') {
playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId });
} else {
playbackManager.play({
ids: msg.Data.ItemIds,
startPositionTicks: msg.Data.StartPositionTicks,
mediaSourceId: msg.Data.MediaSourceId,
audioStreamIndex: msg.Data.AudioStreamIndex,
subtitleStreamIndex: msg.Data.SubtitleStreamIndex,
startIndex: msg.Data.StartIndex,
serverId: serverId
});
}
} else if (msg.MessageType === 'Playstate') {
if (msg.Data.Command === 'Stop') {
inputManager.handleCommand('stop');
} else if (msg.Data.Command === 'Pause') {
inputManager.handleCommand('pause');
} else if (msg.Data.Command === 'Unpause') {
inputManager.handleCommand('play');
} else if (msg.Data.Command === 'PlayPause') {
inputManager.handleCommand('playpause');
} else if (msg.Data.Command === 'Seek') {
playbackManager.seek(msg.Data.SeekPositionTicks);
} else if (msg.Data.Command === 'NextTrack') {
inputManager.handleCommand('next');
} else if (msg.Data.Command === 'PreviousTrack') {
inputManager.handleCommand('previous');
} else {
notifyApp();
}
} else if (msg.MessageType === 'GeneralCommand') {
const cmd = msg.Data;
processGeneralCommand(cmd, apiClient);
} else if (msg.MessageType === 'UserDataChanged') {
if (msg.Data.UserId === apiClient.getCurrentUserId()) {
for (let i = 0, length = msg.Data.UserDataList.length; i < length; i++) {
events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]);
}
}
} else if (msg.MessageType === 'SyncPlayCommand') {
syncPlayManager.processCommand(msg.Data, apiClient);
} else if (msg.MessageType === 'SyncPlayGroupUpdate') {
syncPlayManager.processGroupUpdate(msg.Data, apiClient);
} else {
events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]);
}
}
function bindEvents(apiClient) {
events.off(apiClient, 'message', onMessageReceived);
events.on(apiClient, 'message', onMessageReceived);
}
connectionManager.getApiClients().forEach(bindEvents);
events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) {
bindEvents(newApiClient);
});
export default serverNotifications;

View file

@ -80,43 +80,6 @@ import events from 'events';
return val ? parseInt(val) : null;
}
export function syncOnlyOnWifi(val) {
if (val !== undefined) {
this.set('syncOnlyOnWifi', val.toString());
}
return this.get('syncOnlyOnWifi') !== 'false';
}
export function syncPath(val) {
if (val !== undefined) {
this.set('syncPath', val);
}
return this.get('syncPath');
}
export function cameraUploadServers(val) {
if (val !== undefined) {
this.set('cameraUploadServers', val.join(','));
}
val = this.get('cameraUploadServers');
if (val) {
return val.split(',');
}
return [];
}
export function runAtStartup(val) {
if (val !== undefined) {
this.set('runatstartup', val.toString());
}
return this.get('runatstartup') === 'true';
}
export function set(name, value, userId) {
const currentValue = this.get(name, userId);
appStorage.setItem(getKey(name, userId), value);
@ -139,10 +102,6 @@ export default {
maxStreamingBitrate: maxStreamingBitrate,
maxStaticMusicBitrate: maxStaticMusicBitrate,
maxChromecastBitrate: maxChromecastBitrate,
syncOnlyOnWifi: syncOnlyOnWifi,
syncPath: syncPath,
cameraUploadServers: cameraUploadServers,
runAtStartup: runAtStartup,
set: set,
get: get
};

View file

@ -15,6 +15,10 @@ function saveServerPreferences(instance) {
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
}
const defaultSubtitleAppearanceSettings = {
verticalPosition: -3
};
export class UserSettings {
constructor() {
}
@ -412,7 +416,7 @@ export class UserSettings {
*/
getSubtitleAppearanceSettings(key) {
key = key || 'localplayersubtitleappearance3';
return JSON.parse(this.get(key, false) || '{}');
return Object.assign(defaultSubtitleAppearanceSettings, JSON.parse(this.get(key, false) || '{}'));
}
/**

View file

@ -18,7 +18,7 @@ function getDefaultConfig() {
});
}
export function enableMultiServer() {
export function getMultiServer() {
return getConfig().then(config => {
return config.multiserver;
}).catch(error => {
@ -26,3 +26,21 @@ export function enableMultiServer() {
return false;
});
}
export function getThemes() {
return getConfig().then(config => {
return config.themes;
}).catch(error => {
console.log('cannot get web config:', error);
return [];
});
}
export function getPlugins() {
return getConfig().then(config => {
return config.plugins;
}).catch(error => {
console.log('cannot get web config:', error);
return [];
});
}

View file

@ -1,23 +1,20 @@
define([], function () {
'use strict';
return {
openUrl: function (url, target) {
if (window.NativeShell) {
window.NativeShell.openUrl(url, target);
} else {
window.open(url, target || '_blank');
}
},
enableFullscreen: function () {
if (window.NativeShell) {
window.NativeShell.enableFullscreen();
}
},
disableFullscreen: function () {
if (window.NativeShell) {
window.NativeShell.disableFullscreen();
}
// TODO: This seems like a good candidate for deprecation
export default {
openUrl: function (url, target) {
if (window.NativeShell) {
window.NativeShell.openUrl(url, target);
} else {
window.open(url, target || '_blank');
}
};
});
},
enableFullscreen: function () {
if (window.NativeShell) {
window.NativeShell.enableFullscreen();
}
},
disableFullscreen: function () {
if (window.NativeShell) {
window.NativeShell.disableFullscreen();
}
}
};

View file

@ -152,13 +152,13 @@ var Dashboard = {
processPluginConfigurationUpdateResult: function () {
require(['loading', 'toast'], function (loading, toast) {
loading.hide();
toast(Globalize.translate('MessageSettingsSaved'));
toast.default(Globalize.translate('MessageSettingsSaved'));
});
},
processServerConfigurationUpdateResult: function (result) {
require(['loading', 'toast'], function (loading, toast) {
loading.hide();
toast(Globalize.translate('MessageSettingsSaved'));
toast.default(Globalize.translate('MessageSettingsSaved'));
});
},
processErrorResponse: function (response) {
@ -180,7 +180,7 @@ var Dashboard = {
alert: function (options) {
if (typeof options == 'string') {
return void require(['toast'], function (toast) {
toast({
toast.default({
text: options
});
});
@ -350,6 +350,7 @@ function initClient() {
}
function getLayoutManager(layoutManager, appHost) {
layoutManager = layoutManager.default || layoutManager;
if (appHost.getDefaultLayout) {
layoutManager.defaultLayout = appHost.getDefaultLayout();
}
@ -477,36 +478,30 @@ function initClient() {
function loadPlugins(appHost, browser, shell) {
console.debug('loading installed plugins');
var list = [
'plugins/playAccessValidation/plugin',
'plugins/experimentalWarnings/plugin',
'plugins/htmlAudioPlayer/plugin',
'plugins/htmlVideoPlayer/plugin',
'plugins/photoPlayer/plugin',
'plugins/bookPlayer/plugin',
'plugins/youtubePlayer/plugin',
'plugins/backdropScreensaver/plugin',
'plugins/logoScreensaver/plugin'
];
if (appHost.supports('remotecontrol')) {
list.push('plugins/sessionPlayer/plugin');
if (browser.chrome || browser.edgeChromium || browser.opera) {
list.push('plugins/chromecastPlayer/plugin');
}
}
if (window.NativeShell) {
list = list.concat(window.NativeShell.getPlugins());
}
return new Promise(function (resolve, reject) {
Promise.all(list.map(loadPlugin)).then(function () {
require(['packageManager'], function (packageManager) {
packageManager.init().then(resolve, reject);
require(['webSettings'], function (webSettings) {
webSettings.getPlugins().then(function (list) {
// these two plugins are dependent on features
if (!appHost.supports('remotecontrol')) {
list.splice(list.indexOf('sessionPlayer'), 1);
if (!browser.chrome && !browser.opera) {
list.splice(list.indexOf('chromecastPlayer', 1));
}
}
// add any native plugins
if (window.NativeShell) {
list = list.concat(window.NativeShell.getPlugins());
}
Promise.all(list.map(loadPlugin)).then(function () {
require(['packageManager'], function (packageManager) {
packageManager.init().then(resolve, reject);
});
}, reject);
});
}, reject);
});
});
}
@ -532,7 +527,7 @@ function initClient() {
window.Emby.Page = appRouter;
require(['emby-button', 'scripts/themeLoader', 'libraryMenu', 'scripts/routes'], function () {
require(['emby-button', 'scripts/autoThemes', 'libraryMenu', 'scripts/routes'], function () {
Emby.Page.start({
click: false,
hashbang: true
@ -621,6 +616,7 @@ function initClient() {
}
var localApiClient;
let promise;
(function () {
var urlArgs = 'v=' + (window.dashboardVersion || new Date().getDate());
@ -653,8 +649,7 @@ function initClient() {
nowPlayingHelper: componentsPath + '/playback/nowplayinghelper',
pluginManager: componentsPath + '/pluginManager',
packageManager: componentsPath + '/packageManager',
screensaverManager: componentsPath + '/screensavermanager',
chromecastHelper: 'plugins/chromecastPlayer/chromecastHelpers'
screensaverManager: componentsPath + '/screensavermanager'
};
requirejs.onError = onRequireJsError;
@ -703,20 +698,12 @@ function initClient() {
onError: onRequireJsError
});
require(['fetch']);
require(['polyfill']);
require(['fast-text-encoding']);
require(['intersection-observer']);
require(['classlist-polyfill']);
// Expose jQuery globally
require(['jQuery'], function(jQuery) {
window.$ = jQuery;
window.jQuery = jQuery;
});
require(['css!assets/css/site']);
require(['jellyfin-noto']);
promise = require(['fetch'])
.then(() => require(['jQuery', 'polyfill', 'fast-text-encoding', 'intersection-observer', 'classlist-polyfill', 'css!assets/css/site', 'jellyfin-noto'], (jQuery) => {
// Expose jQuery globally
window.$ = jQuery;
window.jQuery = jQuery;
}));
// define styles
// TODO determine which of these files can be moved to the components themselves
@ -827,8 +814,8 @@ function initClient() {
define('tvguide', [componentsPath + '/guide/guide'], returnFirstDependency);
define('guide-settings-dialog', [componentsPath + '/guide/guide-settings'], returnFirstDependency);
define('viewManager', [componentsPath + '/viewManager/viewManager'], function (viewManager) {
window.ViewManager = viewManager;
viewManager.dispatchPageEvents(true);
window.ViewManager = viewManager.default;
viewManager.default.dispatchPageEvents(true);
return viewManager;
});
define('slideshow', [componentsPath + '/slideshow/slideshow'], returnFirstDependency);
@ -848,7 +835,7 @@ function initClient() {
define('viewContainer', [componentsPath + '/viewContainer'], returnFirstDependency);
define('dialogHelper', [componentsPath + '/dialogHelper/dialogHelper'], returnFirstDependency);
define('serverNotifications', [scriptsPath + '/serverNotifications'], returnFirstDependency);
define('skinManager', [componentsPath + '/skinManager'], returnFirstDependency);
define('skinManager', [scriptsPath + '/themeManager'], returnFirstDependency);
define('keyboardnavigation', [scriptsPath + '/keyboardNavigation'], returnFirstDependency);
define('mouseManager', [scriptsPath + '/mouseManager'], returnFirstDependency);
define('scrollManager', [componentsPath + '/scrollManager'], returnFirstDependency);
@ -1122,7 +1109,7 @@ function initClient() {
});
})();
return onWebComponentsReady();
promise.then(onWebComponentsReady);
}
initClient();

View file

@ -1,29 +0,0 @@
import * as userSettings from 'userSettings';
import skinManager from 'skinManager';
import connectionManager from 'connectionManager';
import events from 'events';
var currentViewType;
pageClassOn('viewbeforeshow', 'page', function () {
var classList = this.classList;
var viewType = classList.contains('type-interior') || classList.contains('wizardPage') ? 'a' : 'b';
if (viewType !== currentViewType) {
currentViewType = viewType;
var theme;
var context;
if (viewType === 'a') {
theme = userSettings.dashboardTheme();
context = 'serverdashboard';
} else {
theme = userSettings.theme();
}
skinManager.setTheme(theme, context);
}
});
events.on(connectionManager, 'localusersignedin', function (e, user) {
currentViewType = null;
});

View file

@ -0,0 +1,66 @@
import * as webSettings from 'webSettings';
var themeStyleElement;
var currentThemeId;
function unloadTheme() {
var elem = themeStyleElement;
if (elem) {
elem.parentNode.removeChild(elem);
themeStyleElement = null;
currentThemeId = null;
}
}
function getThemes() {
return webSettings.getThemes();
}
function getThemeStylesheetInfo(id) {
return getThemes().then(themes => {
var theme = themes.find(theme => {
return id ? theme.id === id : theme.default;
});
return {
stylesheetPath: 'themes/' + theme.id + '/theme.css',
themeId: theme.id
};
});
}
function setTheme(id) {
return new Promise(function (resolve, reject) {
if (currentThemeId && currentThemeId === id) {
resolve();
return;
}
getThemeStylesheetInfo(id).then(function (info) {
if (currentThemeId && currentThemeId === info.themeId) {
resolve();
return;
}
var linkUrl = info.stylesheetPath;
unloadTheme();
var link = document.createElement('link');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.onload = function () {
resolve();
};
link.setAttribute('href', linkUrl);
document.head.appendChild(link);
themeStyleElement = link;
currentThemeId = info.themeId;
});
});
}
export default {
getThemes: getThemes,
setTheme: setTheme
};