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

@ -2,4 +2,3 @@ node_modules
dist
.idea
.vscode
src/libraries

View File

@ -35,6 +35,7 @@
- [Thibault Nocchi](https://github.com/ThibaultNocchi)
- [MrTimscampi](https://github.com/MrTimscampi)
- [Sarab Singh](https://github.com/sarab97)
- [GuilhermeHideki](https://github.com/GuilhermeHideki)
- [Andrei Oanca](https://github.com/OancaAndrei)
- [Cromefire_](https://github.com/cromefire)

View File

@ -5,7 +5,7 @@
"repository": "https://github.com/jellyfin/jellyfin-web",
"license": "GPL-2.0-or-later",
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/core": "^7.11.1",
"@babel/eslint-parser": "^7.11.0",
"@babel/eslint-plugin": "^7.11.0",
"@babel/plugin-proposal-class-properties": "^7.10.1",
@ -17,7 +17,7 @@
"babel-loader": "^8.0.6",
"browser-sync": "^2.26.12",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "^4.2.0",
"css-loader": "^4.2.1",
"cssnano": "^4.1.10",
"del": "^5.1.0",
"eslint": "^7.6.0",
@ -38,7 +38,7 @@
"gulp-postcss": "^8.0.0",
"gulp-sass": "^4.0.2",
"gulp-sourcemaps": "^2.6.5",
"gulp-terser": "^1.2.1",
"gulp-terser": "^1.3.2",
"html-webpack-plugin": "^4.3.0",
"lazypipe": "^1.0.2",
"node-sass": "^4.13.1",
@ -63,7 +63,7 @@
"fast-text-encoding": "^1.0.3",
"flv.js": "^1.5.0",
"headroom.js": "^0.11.0",
"hls.js": "^0.14.7",
"hls.js": "^0.14.8",
"howler": "^2.2.0",
"intersection-observer": "^0.11.0",
"jellyfin-apiclient": "^1.4.1",
@ -80,7 +80,7 @@
"sortablejs": "^1.10.2",
"swiper": "^5.4.5",
"webcomponents.js": "^0.7.24",
"whatwg-fetch": "^3.2.0"
"whatwg-fetch": "^3.4.0"
},
"babel": {
"presets": [
@ -110,6 +110,7 @@
"src/components/favoriteitems.js",
"src/components/fetchhelper.js",
"src/components/filterdialog/filterdialog.js",
"src/components/focusManager.js",
"src/components/groupedcards.js",
"src/components/homeScreenSettings/homeScreenSettings.js",
"src/components/homesections/homesections.js",
@ -124,6 +125,8 @@
"src/components/itemHelper.js",
"src/components/itemidentifier/itemidentifier.js",
"src/components/itemMediaInfo/itemMediaInfo.js",
"src/components/itemsrefresher.js",
"src/components/layoutManager.js",
"src/components/lazyLoader/lazyLoaderIntersectionObserver.js",
"src/components/libraryoptionseditor/libraryoptionseditor.js",
"src/components/listview/listview.js",
@ -152,21 +155,35 @@
"src/components/playlisteditor/playlisteditor.js",
"src/components/playmenu.js",
"src/components/prompt/prompt.js",
"src/components/recordingcreator/seriesrecordingeditor.js",
"src/components/recordingcreator/recordinghelper.js",
"src/components/refreshdialog/refreshdialog.js",
"src/components/sanatizefilename.js",
"src/components/scrollManager.js",
"src/components/slideshow/slideshow.js",
"src/components/sortmenu/sortmenu.js",
"src/plugins/htmlVideoPlayer/plugin.js",
"src/plugins/logoScreensaver/plugin.js",
"src/plugins/playAccessValidation/plugin.js",
"src/components/search/searchfields.js",
"src/components/search/searchresults.js",
"src/components/settingshelper.js",
"src/components/shortcuts.js",
"src/components/subtitleeditor/subtitleeditor.js",
"src/components/subtitlesync/subtitlesync.js",
"src/components/subtitlesettings/subtitleappearancehelper.js",
"src/components/subtitlesettings/subtitlesettings.js",
"src/components/syncPlay/groupSelectionMenu.js",
"src/components/syncPlay/playbackPermissionManager.js",
"src/components/syncPlay/syncPlayManager.js",
"src/components/syncPlay/timeSyncManager.js",
"src/components/viewManager/viewManager.js",
"src/components/tvproviders/schedulesdirect.js",
"src/components/tvproviders/xmltv.js",
"src/components/toast/toast.js",
"src/components/upnextdialog/upnextdialog.js",
"src/components/viewContainer.js",
"src/components/castSenderApi.js",
"src/controllers/session/addServer/index.js",
"src/controllers/session/forgotPassword/index.js",
"src/controllers/session/redeemPassword/index.js",
@ -193,7 +210,12 @@
"src/controllers/dashboard/metadataImages.js",
"src/controllers/dashboard/metadatanfo.js",
"src/controllers/dashboard/networking.js",
"src/controllers/dashboard/notifications/notification.js",
"src/controllers/dashboard/notifications/notifications.js",
"src/controllers/dashboard/playback.js",
"src/controllers/dashboard/plugins/add/index.js",
"src/controllers/dashboard/plugins/installed/index.js",
"src/controllers/dashboard/plugins/available/index.js",
"src/controllers/dashboard/plugins/repositories/index.js",
"src/controllers/dashboard/scheduledtasks/scheduledtask.js",
"src/controllers/dashboard/scheduledtasks/scheduledtasks.js",
@ -205,6 +227,17 @@
"src/controllers/dashboard/users/userparentalcontrol.js",
"src/controllers/dashboard/users/userpasswordpage.js",
"src/controllers/dashboard/users/userprofilespage.js",
"src/controllers/list.js",
"src/controllers/edititemmetadata.js",
"src/controllers/favorites.js",
"src/controllers/hometab.js",
"src/controllers/movies/moviecollections.js",
"src/controllers/movies/moviegenres.js",
"src/controllers/movies/movies.js",
"src/controllers/movies/moviesrecommended.js",
"src/controllers/movies/movietrailers.js",
"src/controllers/playback/nowplaying.js",
"src/controllers/playback/videoosd.js",
"src/controllers/itemDetails/index.js",
"src/controllers/playback/queue/index.js",
"src/controllers/playback/video/index.js",
@ -212,7 +245,12 @@
"src/controllers/livetv/livetvguide.js",
"src/controllers/livetvtuner.js",
"src/controllers/livetvstatus.js",
"src/controllers/livetvguideprovider.js",
"src/controllers/livetvsettings.js",
"src/controllers/livetv/livetvrecordings.js",
"src/controllers/livetv/livetvschedule.js",
"src/controllers/livetv/livetvseriestimers.js",
"src/controllers/livetv/livetvchannels.js",
"src/controllers/shows/episodes.js",
"src/controllers/shows/tvgenres.js",
"src/controllers/shows/tvlatest.js",
@ -251,6 +289,9 @@
"src/elements/emby-tabs/emby-tabs.js",
"src/elements/emby-textarea/emby-textarea.js",
"src/elements/emby-toggle/emby-toggle.js",
"src/libraries/screensavermanager.js",
"src/libraries/navdrawer/navdrawer.js",
"src/libraries/scroller.js",
"src/plugins/backdropScreensaver/plugin.js",
"src/plugins/bookPlayer/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js",
@ -269,16 +310,21 @@
"src/scripts/globalize.js",
"src/scripts/imagehelper.js",
"src/scripts/inputManager.js",
"src/scripts/autoThemes.js",
"src/scripts/themeManager.js",
"src/scripts/keyboardNavigation.js",
"src/scripts/libraryBrowser.js",
"src/scripts/livetvcomponents.js",
"src/scripts/mouseManager.js",
"src/scripts/multiDownload.js",
"src/scripts/playlists.js",
"src/scripts/scrollHelper.js",
"src/scripts/serverNotifications.js",
"src/scripts/routes.js",
"src/scripts/settings/appSettings.js",
"src/scripts/settings/userSettings.js",
"src/scripts/settings/webSettings.js",
"src/scripts/shell.js",
"src/scripts/taskbutton.js",
"src/scripts/themeLoader.js",
"src/scripts/touchHelper.js"
@ -308,6 +354,7 @@
"Firefox ESR"
],
"scripts": {
"start": "yarn serve",
"serve": "gulp serve --development",
"prepare": "gulp --production",
"build:development": "gulp --development",

33
scripts/duplicates.py Normal file
View File

@ -0,0 +1,33 @@
import sys
import os
import json
# load every string in the source language
# print all duplicate values to a file
cwd = os.getcwd()
source = cwd + '/../src/strings/en-us.json'
reverse = {}
duplicates = {}
with open(source) as en:
strings = json.load(en)
for key, value in strings.items():
if value not in reverse:
reverse[value] = [key]
else:
reverse[value].append(key)
for key, value in reverse.items():
if len(value) > 1:
duplicates[key] = value
print('LENGTH: ' + str(len(duplicates)))
with open('duplicates.txt', 'w') as out:
for item in duplicates:
out.write(json.dumps(item) + ': ')
out.write(json.dumps(duplicates[item]) + '\n')
out.close()
print('DONE')

View File

@ -11,7 +11,7 @@ langlst = os.listdir(langdir)
keys = []
with open('scout.txt', 'r') as f:
with open('unused.txt', 'r') as f:
for line in f:
keys.append(line.strip('\n'))

View File

@ -236,12 +236,6 @@
text-align: center;
}
.layout-desktop .searchTabButton,
.layout-mobile .searchTabButton,
.layout-tv .headerSearchButton {
display: none !important;
}
.mainDrawer-scrollContainer {
padding-bottom: 10vh;
}

View File

@ -1,6 +1,7 @@
define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdrop', 'browser', 'page', 'appSettings', 'apphost', 'connectionManager'], function (loading, globalize, events, viewManager, skinManager, backdrop, browser, page, appSettings, appHost, connectionManager) {
'use strict';
viewManager = viewManager.default || viewManager;
browser = browser.default || browser;
loading = loading.default || loading;
@ -37,7 +38,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
switch (result.State) {
case 'SignedIn':
loading.hide();
skinManager.loadUserSkin();
Emby.Page.goHome();
break;
case 'ServerSignIn':
result.ApiClient.getPublicUsers().then(function (users) {
@ -150,7 +151,6 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
if (typeof route.path === 'string') {
loadContentUrl(ctx, next, route, currentRequest);
} else {
// ? TODO
next();
}
};
@ -288,12 +288,9 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
connectionManager.connect({
enableAutoLogin: appSettings.enableAutoLogin()
}).then(function (result) {
firstConnectionResult = result;
options = options || {};
page({
click: options.click !== false,
hashbang: options.hashbang !== false
@ -345,7 +342,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
if (route.isDefaultRoute) {
console.debug('appRouter - loading skin home page');
loadUserSkinWithOptions(ctx);
Emby.Page.goHome();
return;
} else if (route.roles) {
validateRoles(apiClient, route.roles).then(function () {
@ -359,15 +356,6 @@ define(['loading', 'globalize', 'events', 'viewManager', 'skinManager', 'backdro
callback();
}
function loadUserSkinWithOptions(ctx) {
require(['queryString'], function (queryString) {
var params = queryString.parse(ctx.querystring);
skinManager.loadUserSkin({
start: params.start
});
});
}
function validateRoles(apiClient, roles) {
return Promise.all(roles.split(',').map(function (role) {
return validateRole(apiClient, role);

View File

@ -279,7 +279,7 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
features.push('targetblank');
features.push('screensaver');
webSettings.enableMultiServer().then(enabled => {
webSettings.getMultiServer().then(enabled => {
if (enabled) features.push('multiserver');
});
@ -409,13 +409,6 @@ define(['appSettings', 'browser', 'events', 'htmlMediaHelper', 'webSettings', 'g
getPushTokenInfo: function () {
return {};
},
setThemeColor: function (color) {
var metaThemeColor = document.querySelector('meta[name=theme-color]');
if (metaThemeColor) {
metaThemeColor.setAttribute('content', color);
}
},
setUserScalable: function (scalable) {
if (!browser.tv) {
var att = scalable ? 'width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes' : 'width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no';

View File

@ -1,34 +1,28 @@
define([], function() {
'use strict';
if (window.appMode === 'cordova' || window.appMode === 'android') {
return {
load: function () {
window.chrome = window.chrome || {};
class CastSenderApi {
load() {
if (window.appMode === 'cordova' || window.appMode === 'android') {
window.chrome = window.chrome || {};
return Promise.resolve();
} else {
let ccLoaded = false;
if (ccLoaded) {
return Promise.resolve();
}
};
} else {
var ccLoaded = false;
return {
load: function () {
if (ccLoaded) {
return Promise.resolve();
}
return new Promise(function (resolve, reject) {
var fileref = document.createElement('script');
fileref.setAttribute('type', 'text/javascript');
return new Promise(function (resolve) {
const fileref = document.createElement('script');
fileref.setAttribute('type', 'text/javascript');
fileref.onload = function () {
ccLoaded = true;
resolve();
};
fileref.onload = function () {
ccLoaded = true;
resolve();
};
fileref.setAttribute('src', 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js');
document.querySelector('head').appendChild(fileref);
});
}
};
fileref.setAttribute('src', 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js');
document.querySelector('head').appendChild(fileref);
});
}
}
});
}
export default CastSenderApi;

View File

@ -200,7 +200,7 @@ import 'flexStyles';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(scrollHelper => {
import('scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -354,7 +354,7 @@ import 'scrollStyles';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(scrollHelper => {
import('scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,6 +1,5 @@
import browser from 'browser';
import layoutManager from 'layoutManager';
import appSettings from 'appSettings';
import pluginManager from 'pluginManager';
import appHost from 'apphost';
import focusManager from 'focusManager';
@ -16,17 +15,22 @@ import 'emby-button';
/* eslint-disable indent */
function fillThemes(select, isDashboard) {
select.innerHTML = skinManager.getThemes().map(t => {
let value = t.id;
if (t.isDefault && !isDashboard) {
value = '';
} else if (t.isDefaultServerDashboard && isDashboard) {
value = '';
}
function fillThemes(context, userSettings) {
const select = context.querySelector('#selectTheme');
return `<option value="${value}">${t.name}</option>`;
}).join('');
skinManager.getThemes().then(themes => {
select.innerHTML = themes.map(t => {
return `<option value="${t.id}">${t.name}</option>`;
}).join('');
// get default theme
var defaultTheme = themes.find(theme => {
return theme.default;
});
// set the current theme
select.value = userSettings.theme() || defaultTheme.id;
});
}
function loadScreensavers(context, userSettings) {
@ -46,6 +50,7 @@ import 'emby-button';
selectScreensaver.innerHTML = options.map(o => {
return `<option value="${o.value}">${o.name}</option>`;
}).join('');
selectScreensaver.value = userSettings.screensaver();
if (!selectScreensaver.value) {
@ -54,57 +59,6 @@ import 'emby-button';
}
}
function loadSoundEffects(context, userSettings) {
const selectSoundEffects = context.querySelector('.selectSoundEffects');
const options = pluginManager.ofType('soundeffects').map(plugin => {
return {
name: plugin.name,
value: plugin.id
};
});
options.unshift({
name: globalize.translate('None'),
value: 'none'
});
selectSoundEffects.innerHTML = options.map(o => {
return `<option value="${o.value}">${o.name}</option>`;
}).join('');
selectSoundEffects.value = userSettings.soundEffects();
if (!selectSoundEffects.value) {
// TODO: set the default instead of none
selectSoundEffects.value = 'none';
}
}
function loadSkins(context, userSettings) {
const selectSkin = context.querySelector('.selectSkin');
const options = pluginManager.ofType('skin').map(plugin => {
return {
name: plugin.name,
value: plugin.id
};
});
selectSkin.innerHTML = options.map(o => {
return `<option value="${o.value}">${o.name}</option>`;
}).join('');
selectSkin.value = userSettings.skin();
if (!selectSkin.value && options.length) {
selectSkin.value = options[0].value;
}
if (options.length > 1 && appHost.supports('skins')) {
context.querySelector('.selectSkinContainer').classList.remove('hide');
} else {
context.querySelector('.selectSkinContainer').classList.add('hide');
}
}
function showOrHideMissingEpisodesField(context) {
if (browser.tizen || browser.web0s) {
context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
@ -115,12 +69,6 @@ import 'emby-button';
}
function loadForm(context, user, userSettings) {
if (user.Policy.IsAdministrator) {
context.querySelector('.selectDashboardThemeContainer').classList.remove('hide');
} else {
context.querySelector('.selectDashboardThemeContainer').classList.add('hide');
}
if (appHost.supports('displaylanguage')) {
context.querySelector('.languageSection').classList.remove('hide');
} else {
@ -139,18 +87,6 @@ import 'emby-button';
context.querySelector('.learnHowToContributeContainer').classList.add('hide');
}
if (appHost.supports('runatstartup')) {
context.querySelector('.fldAutorun').classList.remove('hide');
} else {
context.querySelector('.fldAutorun').classList.add('hide');
}
if (appHost.supports('soundeffects')) {
context.querySelector('.fldSoundEffects').classList.remove('hide');
} else {
context.querySelector('.fldSoundEffects').classList.add('hide');
}
if (appHost.supports('screensaver')) {
context.querySelector('.selectScreensaverContainer').classList.remove('hide');
} else {
@ -173,16 +109,8 @@ import 'emby-button';
context.querySelector('.fldThemeVideo').classList.add('hide');
}
context.querySelector('.chkRunAtStartup').checked = appSettings.runAtStartup();
const selectTheme = context.querySelector('#selectTheme');
const selectDashboardTheme = context.querySelector('#selectDashboardTheme');
fillThemes(selectTheme);
fillThemes(selectDashboardTheme, true);
fillThemes(context, userSettings);
loadScreensavers(context, userSettings);
loadSoundEffects(context, userSettings);
loadSkins(context, userSettings);
context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
@ -198,9 +126,6 @@ import 'emby-button';
context.querySelector('#txtLibraryPageSize').value = userSettings.libraryPageSize();
selectDashboardTheme.value = userSettings.dashboardTheme() || '';
selectTheme.value = userSettings.theme() || '';
context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
showOrHideMissingEpisodesField(context);
@ -209,8 +134,6 @@ import 'emby-button';
}
function saveUser(context, user, userSettingsInstance, apiClient) {
appSettings.runAtStartup(context.querySelector('.chkRunAtStartup').checked);
user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
if (appHost.supports('displaylanguage')) {
@ -221,15 +144,11 @@ import 'emby-button';
userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
userSettingsInstance.theme(context.querySelector('#selectTheme').value);
userSettingsInstance.soundEffects(context.querySelector('.selectSoundEffects').value);
userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);
userSettingsInstance.skin(context.querySelector('.selectSkin').value);
userSettingsInstance.enableFastFadein(context.querySelector('#chkFadein').checked);
userSettingsInstance.enableBlurhash(context.querySelector('#chkBlurhash').checked);
userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);

View File

@ -1,5 +1,4 @@
<form style="margin: 0 auto;">
<h2 class="sectionTitle">
${Display}
</h2>
@ -123,26 +122,14 @@
<div class="fieldDescription">${LabelPleaseRestart}</div>
</div>
<div class="selectContainer hide selectSkinContainer">
<select is="emby-select" class="selectSkin" label="${LabelSkin}"></select>
</div>
<div class="selectContainer">
<select id="selectTheme" is="emby-select" label="${LabelTheme}"></select>
</div>
<div class="selectContainer selectDashboardThemeContainer hide">
<select id="selectDashboardTheme" is="emby-select" label="${LabelDashboardTheme}"></select>
</div>
<div class="selectContainer hide selectScreensaverContainer">
<select is="emby-select" class="selectScreensaver" label="${LabelScreensaver}"></select>
</div>
<div class="selectContainer fldSoundEffects hide">
<select is="emby-select" class="selectSoundEffects" label="${LabelSoundEffects}"></select>
</div>
<div class="inputContainer inputContainer-withDescription">
<input is="emby-input" type="number" id="txtLibraryPageSize" pattern="[0-9]*" required="required" min="0" max="1000" step="1" label="${LabelLibraryPageSize}" />
<div class="fieldDescription">${LabelLibraryPageSizeHelp}</div>
@ -196,13 +183,6 @@
<div class="fieldDescription checkboxFieldDescription">${EnableThemeVideosHelp}</div>
</div>
<div class="checkboxContainer hide fldAutorun">
<label>
<input type="checkbox" is="emby-checkbox" class="chkRunAtStartup" />
<span>${RunAtStartup}</span>
</label>
</div>
<div class="checkboxContainer checkboxContainer-withDescription fldDisplayMissingEpisodes hide">
<label>
<input type="checkbox" is="emby-checkbox" class="chkDisplayMissingEpisodes" />

View File

@ -1,5 +1,8 @@
define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', 'inputManager', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, appHost, inputManager, layoutManager, connectionManager, appRouter, globalize, userSettings) {
'use strict';
focusManager = focusManager.default || focusManager;
layoutManager = layoutManager.default || layoutManager;
function onSubmit(e) {
e.preventDefault();
@ -150,6 +153,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost',
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
scrollHelper = scrollHelper.default || scrollHelper;
var fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,5 +1,7 @@
define(['dom', 'scrollManager'], function (dom, scrollManager) {
'use strict';
/* eslint-disable indent */
import dom from 'dom';
import scrollManager from 'scrollManager';
var scopes = [];
function pushScope(elem) {
@ -472,37 +474,38 @@ define(['dom', 'scrollManager'], function (dom, scrollManager) {
}
}
return {
autoFocus: autoFocus,
focus: focus,
focusableParent: focusableParent,
getFocusableElements: getFocusableElements,
moveLeft: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 0, container, focusableElements);
},
moveRight: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 1, container, focusableElements);
},
moveUp: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 2, container, focusableElements);
},
moveDown: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 3, container, focusableElements);
},
sendText: sendText,
isCurrentlyFocusable: isCurrentlyFocusable,
pushScope: pushScope,
popScope: popScope,
focusFirst: focusFirst,
focusLast: focusLast,
moveFocus: moveFocus
};
});
/* eslint-enable indent */
export default {
autoFocus: autoFocus,
focus: focus,
focusableParent: focusableParent,
getFocusableElements: getFocusableElements,
moveLeft: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 0, container, focusableElements);
},
moveRight: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 1, container, focusableElements);
},
moveUp: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 2, container, focusableElements);
},
moveDown: function (sourceElement, options) {
var container = options ? options.container : null;
var focusableElements = options ? options.focusableElements : null;
nav(sourceElement, 3, container, focusableElements);
},
sendText: sendText,
isCurrentlyFocusable: isCurrentlyFocusable,
pushScope: pushScope,
popScope: popScope,
focusFirst: focusFirst,
focusLast: focusLast,
moveFocus: moveFocus
};

View File

@ -1,6 +1,9 @@
define(['dialogHelper', 'globalize', 'userSettings', 'layoutManager', 'connectionManager', 'require', 'loading', 'scrollHelper', 'emby-checkbox', 'emby-radio', 'css!./../formdialog', 'material-icons'], function (dialogHelper, globalize, userSettings, layoutManager, connectionManager, require, loading, scrollHelper) {
'use strict';
layoutManager = layoutManager.default || layoutManager;
scrollHelper = scrollHelper.default || scrollHelper;
function saveCategories(context, options) {
var categories = [];

View File

@ -4,6 +4,10 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager',
playbackManager = playbackManager.default || playbackManager;
browser = browser.default || browser;
loading = loading.default || loading;
layoutManager = layoutManager.default || layoutManager;
focusManager = focusManager.default || focusManager;
scrollHelper = scrollHelper.default || scrollHelper;
serverNotifications = serverNotifications.default || serverNotifications;
function showViewSettings(instance) {
require(['guide-settings-dialog'], function (guideSettingsDialog) {

View File

@ -59,8 +59,8 @@ import 'css!./imageeditor';
currentItem = item;
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
const btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
for (let i = 0, length = btnBrowseAllImages.length; i < length; i++) {
var btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
for (var i = 0, length = btnBrowseAllImages.length; i < length; i++) {
if (providers.length) {
btnBrowseAllImages[i].classList.remove('hide');
} else {

View File

@ -1,130 +1,130 @@
define(['playbackManager', 'serverNotifications', 'events'], function (playbackManager, serverNotifications, events) {
'use strict';
import playbackManager from 'playbackManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
playbackManager = playbackManager.default || playbackManager;
function onUserDataChanged(e, apiClient, userData) {
const instance = this;
function onUserDataChanged(e, apiClient, userData) {
var instance = this;
var eventsToMonitor = getEventsToMonitor(instance);
// TODO: Check user data change reason?
if (eventsToMonitor.indexOf('markfavorite') !== -1) {
instance.notifyRefreshNeeded();
} else if (eventsToMonitor.indexOf('markplayed') !== -1) {
instance.notifyRefreshNeeded();
}
}
function getEventsToMonitor(instance) {
var options = instance.options;
var monitor = options ? options.monitorEvents : null;
if (monitor) {
return monitor.split(',');
}
return [];
}
function onTimerCreated(e, apiClient, data) {
var instance = this;
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onSeriesTimerCreated(e, apiClient, data) {
var instance = this;
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onTimerCancelled(e, apiClient, data) {
var instance = this;
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onSeriesTimerCancelled(e, apiClient, data) {
var instance = this;
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onLibraryChanged(e, apiClient, data) {
var instance = this;
var eventsToMonitor = getEventsToMonitor(instance);
if (eventsToMonitor.indexOf('seriestimers') !== -1 || eventsToMonitor.indexOf('timers') !== -1) {
// yes this is an assumption
return;
}
var itemsAdded = data.ItemsAdded || [];
var itemsRemoved = data.ItemsRemoved || [];
if (!itemsAdded.length && !itemsRemoved.length) {
return;
}
var options = instance.options || {};
var parentId = options.parentId;
if (parentId) {
var foldersAddedTo = data.FoldersAddedTo || [];
var foldersRemovedFrom = data.FoldersRemovedFrom || [];
var collectionFolders = data.CollectionFolders || [];
if (foldersAddedTo.indexOf(parentId) === -1 && foldersRemovedFrom.indexOf(parentId) === -1 && collectionFolders.indexOf(parentId) === -1) {
return;
}
}
const eventsToMonitor = getEventsToMonitor(instance);
// TODO: Check user data change reason?
if (eventsToMonitor.indexOf('markfavorite') !== -1) {
instance.notifyRefreshNeeded();
} else if (eventsToMonitor.indexOf('markplayed') !== -1) {
instance.notifyRefreshNeeded();
}
}
function onPlaybackStopped(e, stopInfo) {
var instance = this;
function getEventsToMonitor(instance) {
const options = instance.options;
const monitor = options ? options.monitorEvents : null;
if (monitor) {
return monitor.split(',');
}
var state = stopInfo.state;
return [];
}
var eventsToMonitor = getEventsToMonitor(instance);
if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') {
if (eventsToMonitor.indexOf('videoplayback') !== -1) {
instance.notifyRefreshNeeded(true);
return;
}
} else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') {
if (eventsToMonitor.indexOf('audioplayback') !== -1) {
instance.notifyRefreshNeeded(true);
return;
}
function onTimerCreated(e, apiClient, data) {
const instance = this;
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onSeriesTimerCreated(e, apiClient, data) {
const instance = this;
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onTimerCancelled(e, apiClient, data) {
const instance = this;
if (getEventsToMonitor(instance).indexOf('timers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onSeriesTimerCancelled(e, apiClient, data) {
const instance = this;
if (getEventsToMonitor(instance).indexOf('seriestimers') !== -1) {
instance.notifyRefreshNeeded();
return;
}
}
function onLibraryChanged(e, apiClient, data) {
const instance = this;
const eventsToMonitor = getEventsToMonitor(instance);
if (eventsToMonitor.indexOf('seriestimers') !== -1 || eventsToMonitor.indexOf('timers') !== -1) {
// yes this is an assumption
return;
}
const itemsAdded = data.ItemsAdded || [];
const itemsRemoved = data.ItemsRemoved || [];
if (!itemsAdded.length && !itemsRemoved.length) {
return;
}
const options = instance.options || {};
const parentId = options.parentId;
if (parentId) {
const foldersAddedTo = data.FoldersAddedTo || [];
const foldersRemovedFrom = data.FoldersRemovedFrom || [];
const collectionFolders = data.CollectionFolders || [];
if (foldersAddedTo.indexOf(parentId) === -1 && foldersRemovedFrom.indexOf(parentId) === -1 && collectionFolders.indexOf(parentId) === -1) {
return;
}
}
function addNotificationEvent(instance, name, handler, owner) {
var localHandler = handler.bind(instance);
instance.notifyRefreshNeeded();
}
function onPlaybackStopped(e, stopInfo) {
const instance = this;
const state = stopInfo.state;
const eventsToMonitor = getEventsToMonitor(instance);
if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') {
if (eventsToMonitor.indexOf('videoplayback') !== -1) {
instance.notifyRefreshNeeded(true);
return;
}
} else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') {
if (eventsToMonitor.indexOf('audioplayback') !== -1) {
instance.notifyRefreshNeeded(true);
return;
}
}
}
function addNotificationEvent(instance, name, handler, owner) {
const localHandler = handler.bind(instance);
owner = owner || serverNotifications;
events.on(owner, name, localHandler);
instance['event_' + name] = localHandler;
}
function removeNotificationEvent(instance, name, owner) {
const handler = instance['event_' + name];
if (handler) {
owner = owner || serverNotifications;
events.on(owner, name, localHandler);
instance['event_' + name] = localHandler;
events.off(owner, name, handler);
instance['event_' + name] = null;
}
}
function removeNotificationEvent(instance, name, owner) {
var handler = instance['event_' + name];
if (handler) {
owner = owner || serverNotifications;
events.off(owner, name, handler);
instance['event_' + name] = null;
}
}
function ItemsRefresher(options) {
class ItemsRefresher {
constructor(options) {
this.options = options || {};
addNotificationEvent(this, 'UserDataChanged', onUserDataChanged);
@ -136,18 +136,18 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
addNotificationEvent(this, 'playbackstop', onPlaybackStopped, playbackManager);
}
ItemsRefresher.prototype.pause = function () {
pause() {
clearRefreshInterval(this, true);
this.paused = true;
};
}
ItemsRefresher.prototype.resume = function (options) {
resume(options) {
this.paused = false;
var refreshIntervalEndTime = this.refreshIntervalEndTime;
const refreshIntervalEndTime = this.refreshIntervalEndTime;
if (refreshIntervalEndTime) {
var remainingMs = refreshIntervalEndTime - new Date().getTime();
const remainingMs = refreshIntervalEndTime - new Date().getTime();
if (remainingMs > 0 && !this.needsRefresh) {
resetRefreshInterval(this, remainingMs);
} else {
@ -161,9 +161,9 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
}
return Promise.resolve();
};
}
ItemsRefresher.prototype.refreshItems = function () {
refreshItems() {
if (!this.fetchData) {
return Promise.resolve();
}
@ -176,15 +176,15 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
this.needsRefresh = false;
return this.fetchData().then(onDataFetched.bind(this));
};
}
ItemsRefresher.prototype.notifyRefreshNeeded = function (isInForeground) {
notifyRefreshNeeded(isInForeground) {
if (this.paused) {
this.needsRefresh = true;
return;
}
var timeout = this.refreshTimeout;
const timeout = this.refreshTimeout;
if (timeout) {
clearTimeout(timeout);
}
@ -194,44 +194,9 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
} else {
this.refreshTimeout = setTimeout(this.refreshItems.bind(this), 10000);
}
};
function clearRefreshInterval(instance, isPausing) {
if (instance.refreshInterval) {
clearInterval(instance.refreshInterval);
instance.refreshInterval = null;
if (!isPausing) {
instance.refreshIntervalEndTime = null;
}
}
}
function resetRefreshInterval(instance, intervalMs) {
clearRefreshInterval(instance);
if (!intervalMs) {
var options = instance.options;
if (options) {
intervalMs = options.refreshIntervalMs;
}
}
if (intervalMs) {
instance.refreshInterval = setInterval(instance.notifyRefreshNeeded.bind(instance), intervalMs);
instance.refreshIntervalEndTime = new Date().getTime() + intervalMs;
}
}
function onDataFetched(result) {
resetRefreshInterval(this);
if (this.afterRefresh) {
this.afterRefresh(result);
}
}
ItemsRefresher.prototype.destroy = function () {
destroy() {
clearRefreshInterval(this);
removeNotificationEvent(this, 'UserDataChanged');
@ -244,7 +209,42 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackM
this.fetchData = null;
this.options = null;
};
}
}
return ItemsRefresher;
});
function clearRefreshInterval(instance, isPausing) {
if (instance.refreshInterval) {
clearInterval(instance.refreshInterval);
instance.refreshInterval = null;
if (!isPausing) {
instance.refreshIntervalEndTime = null;
}
}
}
function resetRefreshInterval(instance, intervalMs) {
clearRefreshInterval(instance);
if (!intervalMs) {
const options = instance.options;
if (options) {
intervalMs = options.refreshIntervalMs;
}
}
if (intervalMs) {
instance.refreshInterval = setInterval(instance.notifyRefreshNeeded.bind(instance), intervalMs);
instance.refreshIntervalEndTime = new Date().getTime() + intervalMs;
}
}
function onDataFetched(result) {
resetRefreshInterval(this);
if (this.afterRefresh) {
this.afterRefresh(result);
}
}
export default ItemsRefresher;

View File

@ -1,23 +1,19 @@
define(['browser', 'appSettings', 'events'], function (browser, appSettings, events) {
'use strict';
import browser from 'browser';
import appSettings from 'appSettings';
import events from 'events';
browser = browser.default || browser;
function setLayout(instance, layout, selectedLayout) {
if (layout === selectedLayout) {
instance[layout] = true;
document.documentElement.classList.add('layout-' + layout);
} else {
instance[layout] = false;
document.documentElement.classList.remove('layout-' + layout);
}
function setLayout(instance, layout, selectedLayout) {
if (layout === selectedLayout) {
instance[layout] = true;
document.documentElement.classList.add('layout-' + layout);
} else {
instance[layout] = false;
document.documentElement.classList.remove('layout-' + layout);
}
}
function LayoutManager() {
}
LayoutManager.prototype.setLayout = function (layout, save) {
class LayoutManager {
setLayout(layout, save) {
if (!layout || layout === 'auto') {
this.autoLayout();
@ -35,13 +31,13 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
}
events.trigger(this, 'modechange');
};
}
LayoutManager.prototype.getSavedLayout = function (layout) {
getSavedLayout(layout) {
return appSettings.get('layout');
};
}
LayoutManager.prototype.autoLayout = function () {
autoLayout() {
// Take a guess at initial layout. The consuming app can override
if (browser.mobile) {
this.setLayout('mobile', false);
@ -50,16 +46,16 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
} else {
this.setLayout(this.defaultLayout || 'tv', false);
}
};
}
LayoutManager.prototype.init = function () {
var saved = this.getSavedLayout();
init() {
const saved = this.getSavedLayout();
if (saved) {
this.setLayout(saved, false);
} else {
this.autoLayout();
}
};
}
}
return new LayoutManager();
});
export default new LayoutManager();

View File

@ -2,6 +2,7 @@ define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'requir
'use strict';
playbackManager = playbackManager.default || playbackManager;
serverNotifications = serverNotifications.default || serverNotifications;
function onOneDocumentClick() {
document.removeEventListener('click', onOneDocumentClick);

View File

@ -210,7 +210,7 @@ import 'emby-button';
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(scrollHelper => {
import('scrollHelper').then((scrollHelper) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,6 +1,8 @@
define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields'], function (globalize, connectionManager, require, loading, appHost, dom, recordingHelper, events) {
'use strict';
recordingHelper = recordingHelper.default || recordingHelper;
function onRecordingButtonClick(e) {
var item = this.item;

View File

@ -1,6 +1,9 @@
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'datetime', 'imageLoader', 'recordingFields', 'events', 'emby-checkbox', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, datetime, imageLoader, recordingFields, events) {
'use strict';
layoutManager = layoutManager.default || layoutManager;
scrollHelper = scrollHelper.default || scrollHelper;
var currentDialog;
var closeAction;
var currentRecordingFields;

View File

@ -1,7 +1,9 @@
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) {
'use strict';
scrollHelper = scrollHelper.default || scrollHelper;
loading = loading.default || loading;
layoutManager = layoutManager.default || layoutManager;
var currentDialog;
var recordingDeleted = false;
@ -12,6 +14,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
function deleteTimer(apiClient, timerId) {
return new Promise(function (resolve, reject) {
require(['recordingHelper'], function (recordingHelper) {
recordingHelper = recordingHelper.default || recordingHelper;
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
});
});

View File

@ -1,6 +1,8 @@
define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) {
'use strict';
serverNotifications = serverNotifications.default || serverNotifications;
recordingHelper = recordingHelper.default || recordingHelper;
loading = loading.default || loading;
function loadData(parent, program, apiClient) {

View File

@ -1,194 +1,195 @@
define(['globalize', 'loading', 'connectionManager'], function (globalize, loading, connectionManager) {
'use strict';
import globalize from 'globalize';
import loading from 'loading';
import connectionManager from 'connectionManager';
loading = loading.default || loading;
/*eslint prefer-const: "error"*/
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
loading.show();
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
loading.show();
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
if (item.IsSeries) {
// create series
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
loading.hide();
sendToast(globalize.translate('SeriesRecordingScheduled'));
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
if (item.IsSeries) {
// create series
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
loading.hide();
sendToast(globalize.translate('SeriesRecordingScheduled'));
});
});
} else {
// cancel
if (confirmTimerCancellation) {
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
}
return cancelTimer(apiClient.serverId(), timerId, true);
}
});
}
function cancelTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
import('confirm').then(({ default: confirm }) => {
confirm.default({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
}).then(function () {
loading.show();
const apiClient = connectionManager.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
});
});
}
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
import('confirm').then(({ default: confirm }) => {
confirm.default({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
}).then(function () {
loading.show();
const apiClient = connectionManager.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
import('toast').then(({default: toast}) => {
toast(globalize.translate('SeriesCancelled'));
});
loading.hide();
resolve();
}, reject);
}, reject);
});
});
}
function cancelTimer(apiClient, timerId, hideLoading) {
loading.show();
return apiClient.cancelLiveTvTimer(timerId).then(function () {
if (hideLoading !== false) {
loading.hide();
sendToast(globalize.translate('RecordingCancelled'));
}
});
}
function createRecording(apiClient, programId, isSeries) {
loading.show();
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
const promise = isSeries ?
apiClient.createLiveTvSeriesTimer(item) :
apiClient.createLiveTvTimer(item);
return promise.then(function () {
loading.hide();
sendToast(globalize.translate('RecordingScheduled'));
});
});
}
function sendToast(msg) {
import('toast').then(({ default: toast }) => {
toast(msg);
});
}
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
return new Promise(function (resolve, reject) {
import('dialog').then(({ default: dialog }) => {
const items = [];
items.push({
name: globalize.translate('HeaderKeepRecording'),
id: 'cancel',
type: 'submit'
});
if (timerStatus === 'InProgress') {
items.push({
name: globalize.translate('HeaderStopRecording'),
id: 'canceltimer',
type: 'cancel'
});
} else {
// cancel
if (confirmTimerCancellation) {
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
}
return cancelTimer(apiClient.serverId(), timerId, true);
items.push({
name: globalize.translate('HeaderCancelRecording'),
id: 'canceltimer',
type: 'cancel'
});
}
});
}
function cancelTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
require(['confirm'], function (confirm) {
confirm.default({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelRecording'),
cancelText: globalize.translate('HeaderKeepRecording')
}).then(function () {
loading.show();
var apiClient = connectionManager.getApiClient(serverId);
cancelTimer(apiClient, timerId, true).then(resolve, reject);
}, reject);
items.push({
name: globalize.translate('HeaderCancelSeries'),
id: 'cancelseriestimer',
type: 'cancel'
});
});
}
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
return new Promise(function (resolve, reject) {
require(['confirm'], function (confirm) {
confirm.default({
dialog({
text: globalize.translate('MessageConfirmRecordingCancellation'),
primary: 'delete',
confirmText: globalize.translate('HeaderCancelSeries'),
cancelText: globalize.translate('HeaderKeepSeries')
text: globalize.translate('MessageConfirmRecordingCancellation'),
buttons: items
}).then(function () {
}).then(function (result) {
const apiClient = connectionManager.getApiClient(serverId);
if (result === 'canceltimer') {
loading.show();
var apiClient = connectionManager.getApiClient(serverId);
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
require(['toast'], function (toast) {
cancelTimer(apiClient, timerId, true).then(resolve, reject);
} else if (result === 'cancelseriestimer') {
loading.show();
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
import('toast').then(({ default: toast }) => {
toast(globalize.translate('SeriesCancelled'));
});
loading.hide();
resolve();
}, reject);
}, reject);
});
});
}
function cancelTimer(apiClient, timerId, hideLoading) {
loading.show();
return apiClient.cancelLiveTvTimer(timerId).then(function () {
if (hideLoading !== false) {
loading.hide();
sendToast(globalize.translate('RecordingCancelled'));
}
});
}
function createRecording(apiClient, programId, isSeries) {
loading.show();
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
var promise = isSeries ?
apiClient.createLiveTvSeriesTimer(item) :
apiClient.createLiveTvTimer(item);
return promise.then(function () {
loading.hide();
sendToast(globalize.translate('RecordingScheduled'));
});
});
}
function sendToast(msg) {
require(['toast'], function (toast) {
toast(msg);
});
}
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
return new Promise(function (resolve, reject) {
require(['dialog'], function (dialog) {
var items = [];
items.push({
name: globalize.translate('HeaderKeepRecording'),
id: 'cancel',
type: 'submit'
});
if (timerStatus === 'InProgress') {
items.push({
name: globalize.translate('HeaderStopRecording'),
id: 'canceltimer',
type: 'cancel'
});
} else {
items.push({
name: globalize.translate('HeaderCancelRecording'),
id: 'canceltimer',
type: 'cancel'
});
resolve();
}
items.push({
name: globalize.translate('HeaderCancelSeries'),
id: 'cancelseriestimer',
type: 'cancel'
});
dialog({
text: globalize.translate('MessageConfirmRecordingCancellation'),
buttons: items
}).then(function (result) {
var apiClient = connectionManager.getApiClient(serverId);
if (result === 'canceltimer') {
loading.show();
cancelTimer(apiClient, timerId, true).then(resolve, reject);
} else if (result === 'cancelseriestimer') {
loading.show();
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
require(['toast'], function (toast) {
toast(globalize.translate('SeriesCancelled'));
});
loading.hide();
resolve();
}, reject);
} else {
resolve();
}
}, reject);
});
}, reject);
});
}
});
}
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
var apiClient = connectionManager.getApiClient(serverId);
var hasTimer = timerId && timerStatus !== 'Cancelled';
if (seriesTimerId && hasTimer) {
// cancel
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
} else if (hasTimer && programId) {
// change to series recording, if possible
// otherwise cancel individual recording
return changeRecordingToSeries(apiClient, timerId, programId, true);
} else if (programId) {
// schedule recording
return createRecording(apiClient, programId);
} else {
return Promise.reject();
}
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
const apiClient = connectionManager.getApiClient(serverId);
const hasTimer = timerId && timerStatus !== 'Cancelled';
if (seriesTimerId && hasTimer) {
// cancel
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
} else if (hasTimer && programId) {
// change to series recording, if possible
// otherwise cancel individual recording
return changeRecordingToSeries(apiClient, timerId, programId, true);
} else if (programId) {
// schedule recording
return createRecording(apiClient, programId);
} else {
return Promise.reject();
}
}
export default {
cancelTimer: cancelTimer,
createRecording: createRecording,
changeRecordingToSeries: changeRecordingToSeries,
toggleRecording: toggleRecording,
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
};
return {
cancelTimer: cancelTimer,
createRecording: createRecording,
changeRecordingToSeries: changeRecordingToSeries,
toggleRecording: toggleRecording,
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
};
});

View File

@ -1,143 +1,200 @@
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'datetime', 'scrollStyles', 'emby-button', 'emby-checkbox', 'emby-input', 'emby-select', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader, datetime) {
'use strict';
import dialogHelper from 'dialogHelper';
import globalize from 'globalize';
import layoutManager from 'layoutManager';
import connectionManager from 'connectionManager';
import loading from 'loading';
import scrollHelper from 'scrollHelper';
import datetime from 'datetime';
import 'scrollStyles';
import 'emby-button';
import 'emby-checkbox';
import 'emby-input';
import 'emby-select';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'css!./recordingcreator';
import 'material-icons';
import 'flexStyles';
loading = loading.default || loading;
/*eslint prefer-const: "error"*/
var currentDialog;
var recordingUpdated = false;
var recordingDeleted = false;
var currentItemId;
var currentServerId;
let currentDialog;
let recordingUpdated = false;
let recordingDeleted = false;
let currentItemId;
let currentServerId;
function deleteTimer(apiClient, timerId) {
return new Promise(function (resolve, reject) {
require(['recordingHelper'], function (recordingHelper) {
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
});
function deleteTimer(apiClient, timerId) {
return new Promise(function (resolve, reject) {
import('recordingHelper').then(({ default: recordingHelper }) => {
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
});
});
}
function renderTimer(context, item) {
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
if (item.ChannelName || item.ChannelNumber) {
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
} else {
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
}
function renderTimer(context, item, apiClient) {
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
loading.hide();
}
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
function closeDialog(isDeleted) {
recordingUpdated = true;
recordingDeleted = isDeleted;
if (item.ChannelName || item.ChannelNumber) {
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
} else {
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
}
dialogHelper.close(currentDialog);
}
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
function onSubmit(e) {
const form = this;
const apiClient = connectionManager.getApiClient(currentServerId);
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
apiClient.updateLiveTvSeriesTimer(item);
});
e.preventDefault();
// Disable default form submission
return false;
}
function init(context) {
fillKeepUpTo(context);
context.querySelector('.btnCancel').addEventListener('click', function () {
closeDialog(false);
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
const apiClient = connectionManager.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
});
});
context.querySelector('form').addEventListener('submit', onSubmit);
}
function reload(context, id) {
const apiClient = connectionManager.getApiClient(currentServerId);
loading.show();
if (typeof id === 'string') {
currentItemId = id;
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
renderTimer(context, result);
loading.hide();
});
} else if (id) {
currentItemId = id.Id;
renderTimer(context, id);
loading.hide();
}
}
function closeDialog(isDeleted) {
recordingUpdated = true;
recordingDeleted = isDeleted;
function fillKeepUpTo(context) {
let html = '';
dialogHelper.close(currentDialog);
}
for (let i = 0; i <= 50; i++) {
let text;
function onSubmit(e) {
var form = this;
var apiClient = connectionManager.getApiClient(currentServerId);
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
apiClient.updateLiveTvSeriesTimer(item);
});
e.preventDefault();
// Disable default form submission
return false;
}
function init(context) {
fillKeepUpTo(context);
context.querySelector('.btnCancel').addEventListener('click', function () {
closeDialog(false);
});
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
var apiClient = connectionManager.getApiClient(currentServerId);
deleteTimer(apiClient, currentItemId).then(function () {
closeDialog(true);
});
});
context.querySelector('form').addEventListener('submit', onSubmit);
}
function reload(context, id) {
var apiClient = connectionManager.getApiClient(currentServerId);
loading.show();
if (typeof id === 'string') {
currentItemId = id;
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
renderTimer(context, result, apiClient);
loading.hide();
});
} else if (id) {
currentItemId = id.Id;
renderTimer(context, id, apiClient);
loading.hide();
}
}
function fillKeepUpTo(context) {
var html = '';
for (var i = 0; i <= 50; i++) {
var text;
if (i === 0) {
text = globalize.translate('AsManyAsPossible');
} else if (i === 1) {
text = globalize.translate('ValueOneEpisode');
} else {
text = globalize.translate('ValueEpisodeCount', i);
}
html += '<option value="' + i + '">' + text + '</option>';
if (i === 0) {
text = globalize.translate('AsManyAsPossible');
} else if (i === 1) {
text = globalize.translate('ValueOneEpisode');
} else {
text = globalize.translate('ValueEpisodeCount', i);
}
context.querySelector('.selectKeepUpTo').innerHTML = html;
html += '<option value="' + i + '">' + text + '</option>';
}
function onFieldChange(e) {
this.querySelector('.btnSubmit').click();
}
context.querySelector('.selectKeepUpTo').innerHTML = html;
}
function embed(itemId, serverId, options) {
function onFieldChange() {
this.querySelector('.btnSubmit').click();
}
function embed(itemId, serverId, options) {
recordingUpdated = false;
recordingDeleted = false;
currentServerId = serverId;
loading.show();
options = options || {};
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
} else {
dialogOptions.size = 'small';
}
const dlg = options.context;
dlg.classList.add('hide');
dlg.innerHTML = globalize.translateHtml(template, 'core');
dlg.querySelector('.formDialogHeader').classList.add('hide');
dlg.querySelector('.formDialogFooter').classList.add('hide');
dlg.querySelector('.formDialogContent').className = '';
dlg.querySelector('.dialogContentInner').className = '';
dlg.classList.remove('hide');
dlg.removeEventListener('change', onFieldChange);
dlg.addEventListener('change', onFieldChange);
currentDialog = dlg;
init(dlg);
reload(dlg, itemId);
});
}
function showEditor(itemId, serverId, options) {
return new Promise(function (resolve, reject) {
recordingUpdated = false;
recordingDeleted = false;
currentServerId = serverId;
loading.show();
options = options || {};
require(['text!./seriesrecordingeditor.template.html'], function (template) {
var dialogOptions = {
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
};
@ -148,101 +205,58 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
dialogOptions.size = 'small';
}
var dlg = options.context;
const dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('hide');
dlg.innerHTML = globalize.translateHtml(template, 'core');
dlg.classList.add('formDialog');
dlg.classList.add('recordingDialog');
dlg.querySelector('.formDialogHeader').classList.add('hide');
dlg.querySelector('.formDialogFooter').classList.add('hide');
dlg.querySelector('.formDialogContent').className = '';
dlg.querySelector('.dialogContentInner').className = '';
dlg.classList.remove('hide');
if (!layoutManager.tv) {
dlg.style['min-width'] = '20%';
}
dlg.removeEventListener('change', onFieldChange);
dlg.addEventListener('change', onFieldChange);
let html = '';
html += globalize.translateHtml(template, 'core');
dlg.innerHTML = html;
if (options.enableCancel === false) {
dlg.querySelector('.formDialogFooter').classList.add('hide');
}
currentDialog = dlg;
dlg.addEventListener('closing', function () {
if (!recordingDeleted) {
this.querySelector('.btnSubmit').click();
}
});
dlg.addEventListener('close', function () {
if (recordingUpdated) {
resolve({
updated: true,
deleted: recordingDeleted
});
} else {
reject();
}
});
if (layoutManager.tv) {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
}
init(dlg);
reload(dlg, itemId);
dialogHelper.open(dlg);
});
}
});
}
function showEditor(itemId, serverId, options) {
return new Promise(function (resolve, reject) {
recordingUpdated = false;
recordingDeleted = false;
currentServerId = serverId;
loading.show();
options = options || {};
require(['text!./seriesrecordingeditor.template.html'], function (template) {
var dialogOptions = {
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
} else {
dialogOptions.size = 'small';
}
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
dlg.classList.add('recordingDialog');
if (!layoutManager.tv) {
dlg.style['min-width'] = '20%';
}
var html = '';
html += globalize.translateHtml(template, 'core');
dlg.innerHTML = html;
if (options.enableCancel === false) {
dlg.querySelector('.formDialogFooter').classList.add('hide');
}
currentDialog = dlg;
dlg.addEventListener('closing', function () {
if (!recordingDeleted) {
this.querySelector('.btnSubmit').click();
}
});
dlg.addEventListener('close', function () {
if (recordingUpdated) {
resolve({
updated: true,
deleted: recordingDeleted
});
} else {
reject();
}
});
if (layoutManager.tv) {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
}
init(dlg);
reload(dlg, itemId);
dialogHelper.open(dlg);
});
});
}
return {
show: showEditor,
embed: embed
};
});
export default {
show: showEditor,
embed: embed
};

View File

@ -2,6 +2,7 @@ define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'imageL
'use strict';
playbackManager = playbackManager.default || playbackManager;
layoutManager = layoutManager.default || layoutManager;
var showMuteButton = true;
var showVolumeSlider = true;

View File

@ -1,186 +0,0 @@
define(['apphost', 'userSettings', 'browser', 'events', 'backdrop', 'globalize', 'require', 'appSettings'], function (appHost, userSettings, browser, events, backdrop, globalize, require, appSettings) {
'use strict';
browser = browser.default || browser;
var themeStyleElement;
var currentThemeId;
function unloadTheme() {
var elem = themeStyleElement;
if (elem) {
elem.parentNode.removeChild(elem);
themeStyleElement = null;
currentThemeId = null;
}
}
function loadUserSkin(options) {
options = options || {};
if (options.start) {
Emby.Page.invokeShortcut(options.start);
} else {
Emby.Page.goHome();
}
}
function getThemes() {
return [{
name: 'Apple TV',
id: 'appletv'
}, {
name: 'Blue Radiance',
id: 'blueradiance'
}, {
name: 'Dark',
id: 'dark',
isDefault: true,
isDefaultServerDashboard: true
}, {
name: 'Light',
id: 'light'
}, {
name: 'Purple Haze',
id: 'purplehaze'
}, {
name: 'Windows Media Center',
id: 'wmc'
}];
}
var skinManager = {
getThemes: getThemes,
loadUserSkin: loadUserSkin
};
function getThemeStylesheetInfo(id, isDefaultProperty) {
var themes = skinManager.getThemes();
var defaultTheme;
var selectedTheme;
for (var i = 0, length = themes.length; i < length; i++) {
var theme = themes[i];
if (theme[isDefaultProperty]) {
defaultTheme = theme;
}
if (id === theme.id) {
selectedTheme = theme;
}
}
selectedTheme = selectedTheme || defaultTheme;
return {
stylesheetPath: require.toUrl('themes/' + selectedTheme.id + '/theme.css'),
themeId: selectedTheme.id
};
}
var themeResources = {};
var lastSound = 0;
var currentSound;
function loadThemeResources(id) {
lastSound = 0;
if (currentSound) {
currentSound.stop();
currentSound = null;
}
backdrop.clearBackdrop();
}
function onThemeLoaded() {
document.documentElement.classList.remove('preload');
try {
var color = getComputedStyle(document.querySelector('.skinHeader')).getPropertyValue('background-color');
if (color) {
appHost.setThemeColor(color);
}
} catch (err) {
console.error('error setting theme color: ' + err);
}
}
skinManager.setTheme = function (id, context) {
return new Promise(function (resolve, reject) {
if (currentThemeId && currentThemeId === id) {
resolve();
return;
}
var isDefaultProperty = context === 'serverdashboard' ? 'isDefaultServerDashboard' : 'isDefault';
var info = getThemeStylesheetInfo(id, isDefaultProperty);
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 () {
onThemeLoaded();
resolve();
};
link.setAttribute('href', linkUrl);
document.head.appendChild(link);
themeStyleElement = link;
currentThemeId = info.themeId;
loadThemeResources(info.themeId);
onViewBeforeShow({});
});
};
function onViewBeforeShow(e) {
if (e.detail && e.detail.type === 'video-osd') {
// This removes the space that the scrollbar takes while playing a video
document.body.classList.remove('force-scroll');
return;
}
if (themeResources.backdrop) {
backdrop.setBackdrop(themeResources.backdrop);
}
if (!browser.mobile && userSettings.enableThemeSongs()) {
if (lastSound === 0) {
if (themeResources.themeSong) {
playSound(themeResources.themeSong);
}
} else if ((new Date().getTime() - lastSound) > 30000) {
if (themeResources.effect) {
playSound(themeResources.effect);
}
}
}
// This keeps the scrollbar always present in all pages, so we avoid clipping while switching between pages
// that need the scrollbar and pages that don't.
document.body.classList.add('force-scroll');
}
document.addEventListener('viewshow', onViewBeforeShow);
function playSound(path, volume) {
lastSound = new Date().getTime();
require(['howler'], function (howler) {
/* globals Howl */
try {
var sound = new Howl({
src: [path],
volume: volume || 0.1
});
sound.play();
currentSound = sound;
} catch (err) {
console.error('error playing sound: ' + err);
}
});
}
return skinManager;
});

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +1,51 @@
define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutManager', 'connectionManager', 'globalize', 'userSettings', 'emby-select', 'paper-icon-button-light', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dom, focusManager, dialogHelper, loading, layoutManager, connectionManager, globalize, userSettings) {
'use strict';
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import * as userSettings from 'userSettings';
import 'emby-select';
import 'paper-icon-button-light';
import 'material-icons';
import 'css!./../formdialog';
import 'emby-button';
import 'flexStyles';
function onSubmit(e) {
e.preventDefault();
return false;
}
function onSubmit(e) {
e.preventDefault();
return false;
}
function initEditor(context, settings) {
context.querySelector('form').addEventListener('submit', onSubmit);
function initEditor(context, settings) {
context.querySelector('form').addEventListener('submit', onSubmit);
context.querySelector('.selectSortOrder').value = settings.sortOrder;
context.querySelector('.selectSortBy').value = settings.sortBy;
}
context.querySelector('.selectSortOrder').value = settings.sortOrder;
context.querySelector('.selectSortBy').value = settings.sortBy;
}
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
var fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
const fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
function fillSortBy(context, options) {
var selectSortBy = context.querySelector('.selectSortBy');
function fillSortBy(context, options) {
const selectSortBy = context.querySelector('.selectSortBy');
selectSortBy.innerHTML = options.map(function (o) {
return '<option value="' + o.value + '">' + o.name + '</option>';
}).join('');
}
selectSortBy.innerHTML = options.map(function (o) {
return '<option value="' + o.value + '">' + o.name + '</option>';
}).join('');
}
function saveValues(context, settings, settingsKey) {
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
}
function saveValues(context, settingsKey) {
userSettings.setFilter(settingsKey + '-sortorder', context.querySelector('.selectSortOrder').value);
userSettings.setFilter(settingsKey + '-sortby', context.querySelector('.selectSortBy').value);
}
function SortMenu() {
}
SortMenu.prototype.show = function (options) {
class SortMenu {
show(options) {
return new Promise(function (resolve, reject) {
require(['text!./sortmenu.template.html'], function (template) {
var dialogOptions = {
import('text!./sortmenu.template.html').then(({default: template}) => {
const dialogOptions = {
removeOnClose: true,
scrollY: false
};
@ -51,11 +56,11 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
dialogOptions.size = 'small';
}
var dlg = dialogHelper.createDialog(dialogOptions);
const dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
var html = '';
let html = '';
html += '<div class="formDialogHeader">';
html += '<button is="paper-icon-button-light" class="btnCancel hide-mouse-idle-tv" tabindex="-1"><span class="material-icons arrow_back"></span></button>';
@ -78,7 +83,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
}
var submitted;
let submitted;
dlg.querySelector('form').addEventListener('change', function () {
submitted = true;
@ -90,7 +95,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
}
if (submitted) {
saveValues(dlg, options.settings, options.settingsKey);
saveValues(dlg, options.settingsKey);
resolve();
return;
}
@ -99,7 +104,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana
});
});
});
};
}
}
return SortMenu;
});
export default SortMenu;

View File

@ -1,426 +1,437 @@
define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings', 'connectionManager', 'loading', 'focusManager', 'dom', 'apphost', 'emby-select', 'listViewStyle', 'paper-icon-button-light', 'css!./../formdialog', 'material-icons', 'css!./subtitleeditor', 'emby-button', 'flexStyles'], function (dialogHelper, require, layoutManager, globalize, userSettings, connectionManager, loading, focusManager, dom, appHost) {
'use strict';
import dialogHelper from 'dialogHelper';
import layoutManager from 'layoutManager';
import globalize from 'globalize';
import * as userSettings from 'userSettings';
import connectionManager from 'connectionManager';
import loading from 'loading';
import focusManager from 'focusManager';
import dom from 'dom';
import 'emby-select';
import 'listViewStyle';
import 'paper-icon-button-light';
import 'css!./../formdialog';
import 'material-icons';
import 'css!./subtitleeditor';
import 'emby-button';
import 'flexStyles';
loading = loading.default || loading;
let currentItem;
let hasChanges;
var currentItem;
var hasChanges;
function downloadRemoteSubtitles(context, id) {
let url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
function downloadRemoteSubtitles(context, id) {
var url = 'Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + id;
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({
type: 'POST',
url: apiClient.getUrl(url)
type: 'POST',
url: apiClient.getUrl(url)
}).then(function () {
hasChanges = true;
import('toast').then(({default: toast}) => {
toast(globalize.translate('MessageDownloadQueued'));
});
focusManager.autoFocus(context);
});
}
function deleteLocalSubtitle(context, index) {
let msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
import('confirm').then(({default: confirm}) => {
confirm({
title: globalize.translate('ConfirmDeletion'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
}).then(function () {
hasChanges = true;
loading.show();
require(['toast'], function (toast) {
toast(globalize.translate('MessageDownloadQueued'));
});
let itemId = currentItem.Id;
let url = 'Videos/' + itemId + '/Subtitles/' + index;
focusManager.autoFocus(context);
});
}
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
function deleteLocalSubtitle(context, index) {
var msg = globalize.translate('MessageAreYouSureDeleteSubtitles');
apiClient.ajax({
require(['confirm'], function (confirm) {
confirm.default({
title: globalize.translate('ConfirmDeletion'),
text: msg,
confirmText: globalize.translate('Delete'),
primary: 'delete'
type: 'DELETE',
url: apiClient.getUrl(url)
}).then(function () {
loading.show();
var itemId = currentItem.Id;
var url = 'Videos/' + itemId + '/Subtitles/' + index;
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
apiClient.ajax({
type: 'DELETE',
url: apiClient.getUrl(url)
}).then(function () {
hasChanges = true;
reload(context, apiClient, itemId);
});
hasChanges = true;
reload(context, apiClient, itemId);
});
});
}
});
}
function fillSubtitleList(context, item) {
var streams = item.MediaStreams || [];
function fillSubtitleList(context, item) {
let streams = item.MediaStreams || [];
var subs = streams.filter(function (s) {
return s.Type === 'Subtitle';
});
let subs = streams.filter(function (s) {
return s.Type === 'Subtitle';
});
var html = '';
let html = '';
if (subs.length) {
html += '<h2>' + globalize.translate('MySubtitles') + '</h2>';
if (subs.length) {
html += '<h2>' + globalize.translate('MySubtitles') + '</h2>';
html += '<div>';
html += '<div>';
html += subs.map(function (s) {
var itemHtml = '';
html += subs.map(function (s) {
let itemHtml = '';
var tagName = layoutManager.tv ? 'button' : 'div';
var className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border';
let tagName = layoutManager.tv ? 'button' : 'div';
let className = layoutManager.tv && s.Path ? 'listItem listItem-border btnDelete' : 'listItem listItem-border';
if (layoutManager.tv) {
className += ' listItem-focusscale listItem-button';
}
className += ' listItem-noborder';
itemHtml += '<' + tagName + ' class="' + className + '" data-index="' + s.Index + '">';
itemHtml += '<span class="listItemIcon material-icons closed_caption"></span>';
itemHtml += '<div class="listItemBody two-line">';
itemHtml += '<div>';
itemHtml += s.DisplayTitle || '';
itemHtml += '</div>';
if (s.Path) {
itemHtml += '<div class="secondary listItemBodyText">' + (s.Path) + '</div>';
}
itemHtml += '</a>';
itemHtml += '</div>';
if (!layoutManager.tv) {
if (s.Path) {
itemHtml += '<button is="paper-icon-button-light" data-index="' + s.Index + '" title="' + globalize.translate('Delete') + '" class="btnDelete listItemButton"><span class="material-icons delete"></span></button>';
}
}
itemHtml += '</' + tagName + '>';
return itemHtml;
}).join('');
html += '</div>';
}
var elem = context.querySelector('.subtitleList');
if (subs.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
elem.innerHTML = html;
}
function fillLanguages(context, apiClient, languages) {
var selectLanguage = context.querySelector('#selectLanguage');
selectLanguage.innerHTML = languages.map(function (l) {
return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>';
});
var lastLanguage = userSettings.get('subtitleeditor-language');
if (lastLanguage) {
selectLanguage.value = lastLanguage;
} else {
apiClient.getCurrentUser().then(function (user) {
var lang = user.Configuration.SubtitleLanguagePreference;
if (lang) {
selectLanguage.value = lang;
}
});
}
}
function renderSearchResults(context, results) {
var lastProvider = '';
var html = '';
if (!results.length) {
context.querySelector('.noSearchResults').classList.remove('hide');
context.querySelector('.subtitleResults').innerHTML = '';
loading.hide();
return;
}
context.querySelector('.noSearchResults').classList.add('hide');
for (var i = 0, length = results.length; i < length; i++) {
var result = results[i];
var provider = result.ProviderName;
if (provider !== lastProvider) {
if (i > 0) {
html += '</div>';
}
html += '<h2>' + provider + '</h2>';
html += '<div>';
lastProvider = provider;
}
var tagName = layoutManager.tv ? 'button' : 'div';
var className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border';
if (layoutManager.tv) {
className += ' listItem-focusscale listItem-button';
}
html += '<' + tagName + ' class="' + className + '" data-subid="' + result.Id + '">';
className += ' listItem-noborder';
html += '<span class="listItemIcon material-icons closed_caption"></span>';
itemHtml += '<' + tagName + ' class="' + className + '" data-index="' + s.Index + '">';
var bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
itemHtml += '<span class="listItemIcon material-icons closed_caption"></span>';
html += '<div class="listItemBody ' + bodyClass + '">';
itemHtml += '<div class="listItemBody two-line">';
html += '<div>' + (result.Name) + '</div>';
html += '<div class="secondary listItemBodyText">';
itemHtml += '<div>';
itemHtml += s.DisplayTitle || '';
itemHtml += '</div>';
if (result.Format) {
html += '<span style="margin-right:1em;">' + globalize.translate('FormatValue', result.Format) + '</span>';
if (s.Path) {
itemHtml += '<div class="secondary listItemBodyText">' + (s.Path) + '</div>';
}
if (result.DownloadCount != null) {
html += '<span>' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
}
html += '</div>';
if (result.Comment) {
html += '<div class="secondary listItemBodyText">' + (result.Comment) + '</div>';
}
if (result.IsHashMatch) {
html += '<div class="secondary listItemBodyText"><div class="inline-flex align-items-center justify-content-center" style="background:#3388cc;color:#fff;padding: .3em 1em;border-radius:1000em;">' + globalize.translate('PerfectMatch') + '</div></div>';
}
html += '</div>';
itemHtml += '</a>';
itemHtml += '</div>';
if (!layoutManager.tv) {
html += '<button type="button" is="paper-icon-button-light" data-subid="' + result.Id + '" class="btnDownload listItemButton"><span class="material-icons file_download"></span></button>';
if (s.Path) {
itemHtml += '<button is="paper-icon-button-light" data-index="' + s.Index + '" title="' + globalize.translate('Delete') + '" class="btnDelete listItemButton"><span class="material-icons delete"></span></button>';
}
}
html += '</' + tagName + '>';
itemHtml += '</' + tagName + '>';
return itemHtml;
}).join('');
html += '</div>';
}
let elem = context.querySelector('.subtitleList');
if (subs.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
elem.innerHTML = html;
}
function fillLanguages(context, apiClient, languages) {
let selectLanguage = context.querySelector('#selectLanguage');
selectLanguage.innerHTML = languages.map(function (l) {
return '<option value="' + l.ThreeLetterISOLanguageName + '">' + l.DisplayName + '</option>';
});
let lastLanguage = userSettings.get('subtitleeditor-language');
if (lastLanguage) {
selectLanguage.value = lastLanguage;
} else {
apiClient.getCurrentUser().then(function (user) {
let lang = user.Configuration.SubtitleLanguagePreference;
if (lang) {
selectLanguage.value = lang;
}
});
}
}
function renderSearchResults(context, results) {
let lastProvider = '';
let html = '';
if (!results.length) {
context.querySelector('.noSearchResults').classList.remove('hide');
context.querySelector('.subtitleResults').innerHTML = '';
loading.hide();
return;
}
context.querySelector('.noSearchResults').classList.add('hide');
for (let i = 0, length = results.length; i < length; i++) {
let result = results[i];
let provider = result.ProviderName;
if (provider !== lastProvider) {
if (i > 0) {
html += '</div>';
}
html += '<h2>' + provider + '</h2>';
html += '<div>';
lastProvider = provider;
}
if (results.length) {
html += '</div>';
let tagName = layoutManager.tv ? 'button' : 'div';
let className = layoutManager.tv ? 'listItem listItem-border btnOptions' : 'listItem listItem-border';
if (layoutManager.tv) {
className += ' listItem-focusscale listItem-button';
}
var elem = context.querySelector('.subtitleResults');
elem.innerHTML = html;
html += '<' + tagName + ' class="' + className + '" data-subid="' + result.Id + '">';
html += '<span class="listItemIcon material-icons closed_caption"></span>';
let bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
html += '<div class="listItemBody ' + bodyClass + '">';
html += '<div>' + (result.Name) + '</div>';
html += '<div class="secondary listItemBodyText">';
if (result.Format) {
html += '<span style="margin-right:1em;">' + globalize.translate('FormatValue', result.Format) + '</span>';
}
if (result.DownloadCount != null) {
html += '<span>' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
}
html += '</div>';
if (result.Comment) {
html += '<div class="secondary listItemBodyText">' + (result.Comment) + '</div>';
}
if (result.IsHashMatch) {
html += '<div class="secondary listItemBodyText"><div class="inline-flex align-items-center justify-content-center" style="background:#3388cc;color:#fff;padding: .3em 1em;border-radius:1000em;">' + globalize.translate('PerfectMatch') + '</div></div>';
}
html += '</div>';
if (!layoutManager.tv) {
html += '<button type="button" is="paper-icon-button-light" data-subid="' + result.Id + '" class="btnDownload listItemButton"><span class="material-icons file_download"></span></button>';
}
html += '</' + tagName + '>';
}
if (results.length) {
html += '</div>';
}
let elem = context.querySelector('.subtitleResults');
elem.innerHTML = html;
loading.hide();
}
function searchForSubtitles(context, language) {
userSettings.set('subtitleeditor-language', language);
loading.show();
let apiClient = connectionManager.getApiClient(currentItem.ServerId);
let url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
apiClient.getJSON(url).then(function (results) {
renderSearchResults(context, results);
});
}
function reload(context, apiClient, itemId) {
context.querySelector('.noSearchResults').classList.add('hide');
function onGetItem(item) {
currentItem = item;
fillSubtitleList(context, item);
let file = item.Path || '';
let index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
if (index > -1) {
file = file.substring(index + 1);
}
if (file) {
context.querySelector('.pathValue').innerHTML = file;
context.querySelector('.originalFile').classList.remove('hide');
} else {
context.querySelector('.pathValue').innerHTML = '';
context.querySelector('.originalFile').classList.add('hide');
}
loading.hide();
}
function searchForSubtitles(context, language) {
userSettings.set('subtitleeditor-language', language);
if (typeof itemId === 'string') {
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(onGetItem);
} else {
onGetItem(itemId);
}
}
loading.show();
function onSearchSubmit(e) {
let form = this;
var apiClient = connectionManager.getApiClient(currentItem.ServerId);
var url = apiClient.getUrl('Items/' + currentItem.Id + '/RemoteSearch/Subtitles/' + language);
let lang = form.querySelector('#selectLanguage', form).value;
apiClient.getJSON(url).then(function (results) {
renderSearchResults(context, results);
});
searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang);
e.preventDefault();
return false;
}
function onSubtitleListClick(e) {
let btnDelete = dom.parentWithClass(e.target, 'btnDelete');
if (btnDelete) {
let index = btnDelete.getAttribute('data-index');
let context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog');
deleteLocalSubtitle(context, index);
}
}
function onSubtitleResultsClick(e) {
let subtitleId;
let context;
let btnOptions = dom.parentWithClass(e.target, 'btnOptions');
if (btnOptions) {
subtitleId = btnOptions.getAttribute('data-subid');
context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog');
showDownloadOptions(btnOptions, context, subtitleId);
}
function reload(context, apiClient, itemId) {
context.querySelector('.noSearchResults').classList.add('hide');
let btnDownload = dom.parentWithClass(e.target, 'btnDownload');
if (btnDownload) {
subtitleId = btnDownload.getAttribute('data-subid');
context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog');
downloadRemoteSubtitles(context, subtitleId);
}
}
function onGetItem(item) {
currentItem = item;
function showDownloadOptions(button, context, subtitleId) {
let items = [];
fillSubtitleList(context, item);
var file = item.Path || '';
var index = Math.max(file.lastIndexOf('/'), file.lastIndexOf('\\'));
if (index > -1) {
file = file.substring(index + 1);
items.push({
name: globalize.translate('Download'),
id: 'download'
});
import('actionsheet').then(({default: actionsheet}) => {
actionsheet.show({
items: items,
positionTo: button
}).then(function (id) {
switch (id) {
case 'download':
downloadRemoteSubtitles(context, subtitleId);
break;
default:
break;
}
});
});
}
if (file) {
context.querySelector('.pathValue').innerHTML = file;
context.querySelector('.originalFile').classList.remove('hide');
} else {
context.querySelector('.pathValue').innerHTML = '';
context.querySelector('.originalFile').classList.add('hide');
}
function centerFocus(elem, horiz, on) {
import('scrollHelper').then(({default: scrollHelper}) => {
let fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
loading.hide();
}
function showEditorInternal(itemId, serverId, template) {
hasChanges = false;
if (typeof itemId === 'string') {
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(onGetItem);
let apiClient = connectionManager.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
let dialogOptions = {
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
} else {
onGetItem(itemId);
}
}
function onSearchSubmit(e) {
var form = this;
var lang = form.querySelector('#selectLanguage', form).value;
searchForSubtitles(dom.parentWithClass(form, 'formDialogContent'), lang);
e.preventDefault();
return false;
}
function onSubtitleListClick(e) {
var btnDelete = dom.parentWithClass(e.target, 'btnDelete');
if (btnDelete) {
var index = btnDelete.getAttribute('data-index');
var context = dom.parentWithClass(btnDelete, 'subtitleEditorDialog');
deleteLocalSubtitle(context, index);
}
}
function onSubtitleResultsClick(e) {
var subtitleId;
var context;
var btnOptions = dom.parentWithClass(e.target, 'btnOptions');
if (btnOptions) {
subtitleId = btnOptions.getAttribute('data-subid');
context = dom.parentWithClass(btnOptions, 'subtitleEditorDialog');
showDownloadOptions(btnOptions, context, subtitleId);
dialogOptions.size = 'small';
}
var btnDownload = dom.parentWithClass(e.target, 'btnDownload');
if (btnDownload) {
subtitleId = btnDownload.getAttribute('data-subid');
context = dom.parentWithClass(btnDownload, 'subtitleEditorDialog');
downloadRemoteSubtitles(context, subtitleId);
let dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
dlg.classList.add('subtitleEditorDialog');
dlg.innerHTML = globalize.translateHtml(template, 'core');
dlg.querySelector('.originalSubtitleFileLabel').innerHTML = globalize.translate('File');
dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit);
let btnSubmit = dlg.querySelector('.btnSubmit');
if (layoutManager.tv) {
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
dlg.querySelector('.btnSearchSubtitles').classList.add('hide');
} else {
btnSubmit.classList.add('hide');
}
}
function showDownloadOptions(button, context, subtitleId) {
var items = [];
let editorContent = dlg.querySelector('.formDialogContent');
items.push({
name: globalize.translate('Download'),
id: 'download'
dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick);
dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick);
apiClient.getCultures().then(function (languages) {
fillLanguages(editorContent, apiClient, languages);
});
require(['actionsheet'], function (actionsheet) {
actionsheet.show({
items: items,
positionTo: button
}).then(function (id) {
switch (id) {
case 'download':
downloadRemoteSubtitles(context, subtitleId);
break;
default:
break;
}
});
dlg.querySelector('.btnCancel').addEventListener('click', function () {
dialogHelper.close(dlg);
});
}
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
var fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});
}
function showEditorInternal(itemId, serverId, template) {
hasChanges = false;
var apiClient = connectionManager.getApiClient(serverId);
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
var dialogOptions = {
removeOnClose: true,
scrollY: false
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
} else {
dialogOptions.size = 'small';
}
var dlg = dialogHelper.createDialog(dialogOptions);
dlg.classList.add('formDialog');
dlg.classList.add('subtitleEditorDialog');
dlg.innerHTML = globalize.translateHtml(template, 'core');
dlg.querySelector('.originalSubtitleFileLabel').innerHTML = globalize.translate('File');
dlg.querySelector('.subtitleSearchForm').addEventListener('submit', onSearchSubmit);
var btnSubmit = dlg.querySelector('.btnSubmit');
if (layoutManager.tv) {
centerFocus(dlg.querySelector('.formDialogContent'), false, true);
dlg.querySelector('.btnSearchSubtitles').classList.add('hide');
} else {
btnSubmit.classList.add('hide');
}
var editorContent = dlg.querySelector('.formDialogContent');
dlg.querySelector('.subtitleList').addEventListener('click', onSubtitleListClick);
dlg.querySelector('.subtitleResults').addEventListener('click', onSubtitleResultsClick);
apiClient.getCultures().then(function (languages) {
fillLanguages(editorContent, apiClient, languages);
});
dlg.querySelector('.btnCancel').addEventListener('click', function () {
dialogHelper.close(dlg);
});
return new Promise(function (resolve, reject) {
dlg.addEventListener('close', function () {
if (layoutManager.tv) {
centerFocus(dlg.querySelector('.formDialogContent'), false, false);
}
if (hasChanges) {
resolve();
} else {
reject();
}
});
dialogHelper.open(dlg);
reload(editorContent, apiClient, item);
});
});
}
function showEditor(itemId, serverId) {
loading.show();
return new Promise(function (resolve, reject) {
require(['text!./subtitleeditor.template.html'], function (template) {
showEditorInternal(itemId, serverId, template).then(resolve, reject);
});
});
}
dlg.addEventListener('close', function () {
if (layoutManager.tv) {
centerFocus(dlg.querySelector('.formDialogContent'), false, false);
}
return {
show: showEditor
};
});
if (hasChanges) {
resolve();
} else {
reject();
}
});
dialogHelper.open(dlg);
reload(editorContent, apiClient, item);
});
});
}
function showEditor(itemId, serverId) {
loading.show();
return new Promise(function (resolve, reject) {
import('text!./subtitleeditor.template.html').then(({default: template}) => {
showEditorInternal(itemId, serverId, template).then(resolve, reject);
});
});
}
export default {
show: showEditor
};

View File

@ -3,52 +3,29 @@
* @module components/subtitleSettings/subtitleAppearanceHelper
*/
function getTextStyles(settings, isCue) {
function getTextStyles(settings, preview) {
let list = [];
if (isCue) {
switch (settings.textSize || '') {
case 'smaller':
list.push({ name: 'font-size', value: '.5em' });
break;
case 'small':
list.push({ name: 'font-size', value: '.7em' });
break;
case 'large':
list.push({ name: 'font-size', value: '1.3em' });
break;
case 'larger':
list.push({ name: 'font-size', value: '1.72em' });
break;
case 'extralarge':
list.push({ name: 'font-size', value: '2em' });
break;
default:
case 'medium':
break;
}
} else {
switch (settings.textSize || '') {
case 'smaller':
list.push({ name: 'font-size', value: '.8em' });
break;
case 'small':
list.push({ name: 'font-size', value: 'inherit' });
break;
case 'larger':
list.push({ name: 'font-size', value: '2em' });
break;
case 'extralarge':
list.push({ name: 'font-size', value: '2.2em' });
break;
case 'large':
list.push({ name: 'font-size', value: '1.72em' });
break;
default:
case 'medium':
list.push({ name: 'font-size', value: '1.36em' });
break;
}
switch (settings.textSize || '') {
case 'smaller':
list.push({ name: 'font-size', value: '.8em' });
break;
case 'small':
list.push({ name: 'font-size', value: 'inherit' });
break;
case 'larger':
list.push({ name: 'font-size', value: '2em' });
break;
case 'extralarge':
list.push({ name: 'font-size', value: '2.2em' });
break;
case 'large':
list.push({ name: 'font-size', value: '1.72em' });
break;
default:
case 'medium':
list.push({ name: 'font-size', value: '1.36em' });
break;
}
switch (settings.dropShadow || '') {
@ -111,13 +88,43 @@ function getTextStyles(settings, isCue) {
break;
}
if (!preview) {
const pos = parseInt(settings.verticalPosition, 10);
const lineHeight = 1.35; // FIXME: It is better to read this value from element
const line = Math.abs(pos * lineHeight);
if (pos < 0) {
list.push({ name: 'min-height', value: `${line}em` });
list.push({ name: 'margin-top', value: '' });
} else {
list.push({ name: 'min-height', value: '' });
list.push({ name: 'margin-top', value: `${line}em` });
}
}
return list;
}
export function getStyles(settings, isCue) {
function getWindowStyles(settings, preview) {
const list = [];
if (!preview) {
const pos = parseInt(settings.verticalPosition, 10);
if (pos < 0) {
list.push({ name: 'top', value: '' });
list.push({ name: 'bottom', value: '0' });
} else {
list.push({ name: 'top', value: '0' });
list.push({ name: 'bottom', value: '' });
}
}
return list;
}
export function getStyles(settings, preview) {
return {
text: getTextStyles(settings, isCue),
window: []
text: getTextStyles(settings, preview),
window: getWindowStyles(settings, preview)
};
}
@ -130,7 +137,7 @@ function applyStyleList(styles, elem) {
}
export function applyStyles(elements, appearanceSettings) {
let styles = getStyles(appearanceSettings);
let styles = getStyles(appearanceSettings, !!elements.preview);
if (elements.text) {
applyStyleList(styles.text, elements.text);

View File

@ -0,0 +1,26 @@
.subtitleappearance-fullpreview {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1000;
pointer-events: none;
transition: 0.2s;
}
.subtitleappearance-fullpreview-hide {
opacity: 0;
}
.subtitleappearance-fullpreview-window {
position: absolute;
width: 100%;
font-size: 170%;
text-align: center;
}
.subtitleappearance-fullpreview-text {
display: inline-block;
max-width: 70%;
}

View File

@ -2,6 +2,7 @@ import globalize from 'globalize';
import appHost from 'apphost';
import appSettings from 'appSettings';
import focusManager from 'focusManager';
import layoutManager from 'layoutManager';
import loading from 'loading';
import connectionManager from 'connectionManager';
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
@ -10,9 +11,11 @@ import dom from 'dom';
import events from 'events';
import 'listViewStyle';
import 'emby-select';
import 'emby-slider';
import 'emby-input';
import 'emby-checkbox';
import 'flexStyles';
import 'css!./subtitlesettings';
/**
* Subtitle settings.
@ -27,6 +30,7 @@ function getSubtitleAppearanceObject(context) {
appearanceSettings.font = context.querySelector('#selectFont').value;
appearanceSettings.textBackground = context.querySelector('#inputTextBackground').value;
appearanceSettings.textColor = context.querySelector('#inputTextColor').value;
appearanceSettings.verticalPosition = context.querySelector('#sliderVerticalPosition').value;
return appearanceSettings;
}
@ -51,6 +55,7 @@ function loadForm(context, user, userSettings, appearanceSettings, apiClient) {
context.querySelector('#inputTextBackground').value = appearanceSettings.textBackground || 'transparent';
context.querySelector('#inputTextColor').value = appearanceSettings.textColor || '#ffffff';
context.querySelector('#selectFont').value = appearanceSettings.font || '';
context.querySelector('#sliderVerticalPosition').value = appearanceSettings.verticalPosition;
context.querySelector('#selectSubtitleBurnIn').value = appSettings.get('subtitleburnin') || '';
@ -112,10 +117,45 @@ function onAppearanceFieldChange(e) {
let elements = {
window: view.querySelector('.subtitleappearance-preview-window'),
text: view.querySelector('.subtitleappearance-preview-text')
text: view.querySelector('.subtitleappearance-preview-text'),
preview: true
};
subtitleAppearanceHelper.applyStyles(elements, appearanceSettings);
subtitleAppearanceHelper.applyStyles({
window: view.querySelector('.subtitleappearance-fullpreview-window'),
text: view.querySelector('.subtitleappearance-fullpreview-text')
}, appearanceSettings);
}
const subtitlePreviewDelay = 1000;
let subtitlePreviewTimer;
function showSubtitlePreview(persistent) {
clearTimeout(subtitlePreviewTimer);
this._fullPreview.classList.remove('subtitleappearance-fullpreview-hide');
if (persistent) {
this._refFullPreview++;
}
if (this._refFullPreview === 0) {
subtitlePreviewTimer = setTimeout(hideSubtitlePreview.bind(this), subtitlePreviewDelay);
}
}
function hideSubtitlePreview(persistent) {
clearTimeout(subtitlePreviewTimer);
if (persistent) {
this._refFullPreview--;
}
if (this._refFullPreview === 0) {
this._fullPreview.classList.add('subtitleappearance-fullpreview-hide');
}
}
function embed(options, self) {
@ -138,6 +178,36 @@ function embed(options, self) {
if (appHost.supports('subtitleappearancesettings')) {
options.element.querySelector('.subtitleAppearanceSection').classList.remove('hide');
self._fullPreview = options.element.querySelector('.subtitleappearance-fullpreview');
self._refFullPreview = 0;
const sliderVerticalPosition = options.element.querySelector('#sliderVerticalPosition');
sliderVerticalPosition.addEventListener('input', onAppearanceFieldChange);
sliderVerticalPosition.addEventListener('input', () => showSubtitlePreview.call(self));
const eventPrefix = window.PointerEvent ? 'pointer' : 'mouse';
sliderVerticalPosition.addEventListener(`${eventPrefix}enter`, () => showSubtitlePreview.call(self, true));
sliderVerticalPosition.addEventListener(`${eventPrefix}leave`, () => hideSubtitlePreview.call(self, true));
if (layoutManager.tv) {
sliderVerticalPosition.addEventListener('focus', () => showSubtitlePreview.call(self, true));
sliderVerticalPosition.addEventListener('blur', () => hideSubtitlePreview.call(self, true));
// Give CustomElements time to attach
setTimeout(() => {
sliderVerticalPosition.classList.add('focusable');
sliderVerticalPosition.enableKeyboardDragging();
}, 0);
}
options.element.querySelector('.chkPreview').addEventListener('change', (e) => {
if (e.target.checked) {
showSubtitlePreview.call(self, true);
} else {
hideSubtitlePreview.call(self, true);
}
});
}
self.loadData();

View File

@ -38,6 +38,16 @@
${HeaderSubtitleAppearance}
</h2>
<div class="subtitleappearance-fullpreview subtitleappearance-fullpreview-hide">
<div class="subtitleappearance-fullpreview-window">
<div class="subtitleappearance-fullpreview-text">
${HeaderSubtitleAppearance}
<br>
${TheseSettingsAffectSubtitlesOnThisDevice}
</div>
</div>
</div>
<div style="margin: 2em 0 2em;">
<div class="subtitleappearance-preview flex align-items-center justify-content-center" style="margin:2em 0;padding:1.6em;color:black;background:linear-gradient(140deg,#aa5cc3,#00a4dc);">
<div class="subtitleappearance-preview-window flex align-items-center justify-content-center" style="width: 90%; padding: .25em;">
@ -89,6 +99,20 @@
<option value="">${DropShadow}</option>
</select>
</div>
<div class="sliderContainer-settings">
<div class="sliderContainer">
<input is="emby-slider" id="sliderVerticalPosition" label="${LabelSubtitleVerticalPosition}" type="range" min="-16" max="16" />
</div>
<div class="fieldDescription">${SubtitleVerticalPositionHelp}</div>
</div>
<div class="checkboxContainer">
<label>
<input is="emby-checkbox" type="checkbox" class="chkPreview" />
<span>${Preview}</span>
</label>
</div>
</div>
<button is="emby-button" type="submit" class="raised button-submit block btnSave hide">

View File

@ -1,147 +1,148 @@
define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html', 'css!./subtitlesync'], function (playbackManager, layoutManager, template, css) {
'use strict';
import playbackManager from 'playbackManager';
import layoutManager from 'layoutManager';
import template from 'text!./subtitlesync.template.html';
import 'css!./subtitlesync';
playbackManager = playbackManager.default || playbackManager;
let player;
let subtitleSyncSlider;
let subtitleSyncTextField;
let subtitleSyncCloseButton;
let subtitleSyncContainer;
var player;
var subtitleSyncSlider;
var subtitleSyncTextField;
var subtitleSyncCloseButton;
var subtitleSyncContainer;
function init(instance) {
const parent = document.createElement('div');
document.body.appendChild(parent);
parent.innerHTML = template;
function init(instance) {
var parent = document.createElement('div');
document.body.appendChild(parent);
parent.innerHTML = template;
subtitleSyncSlider = parent.querySelector('.subtitleSyncSlider');
subtitleSyncTextField = parent.querySelector('.subtitleSyncTextField');
subtitleSyncCloseButton = parent.querySelector('.subtitleSync-closeButton');
subtitleSyncContainer = parent.querySelector('.subtitleSyncContainer');
subtitleSyncSlider = parent.querySelector('.subtitleSyncSlider');
subtitleSyncTextField = parent.querySelector('.subtitleSyncTextField');
subtitleSyncCloseButton = parent.querySelector('.subtitleSync-closeButton');
subtitleSyncContainer = parent.querySelector('.subtitleSyncContainer');
if (layoutManager.tv) {
subtitleSyncSlider.classList.add('focusable');
// HACK: Delay to give time for registered element attach (Firefox)
setTimeout(function () {
subtitleSyncSlider.enableKeyboardDragging();
}, 0);
}
if (layoutManager.tv) {
subtitleSyncSlider.classList.add('focusable');
// HACK: Delay to give time for registered element attach (Firefox)
setTimeout(function () {
subtitleSyncSlider.enableKeyboardDragging();
}, 0);
}
subtitleSyncContainer.classList.add('hide');
subtitleSyncContainer.classList.add('hide');
subtitleSyncTextField.updateOffset = function (offset) {
this.textContent = offset + 's';
};
subtitleSyncTextField.updateOffset = function(offset) {
this.textContent = offset + 's';
};
subtitleSyncTextField.addEventListener('click', function () {
// keep focus to prevent fade with osd
this.hasFocus = true;
});
subtitleSyncTextField.addEventListener('click', function () {
subtitleSyncTextField.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
// if input key is enter search for float pattern
let inputOffset = /[-+]?\d+\.?\d*/g.exec(this.textContent);
if (inputOffset) {
inputOffset = inputOffset[0];
// replace current text by considered offset
this.textContent = inputOffset + 's';
inputOffset = parseFloat(inputOffset);
// set new offset
playbackManager.setSubtitleOffset(inputOffset, player);
// synchronize with slider value
subtitleSyncSlider.updateOffset(
getPercentageFromOffset(inputOffset));
} else {
this.textContent = (playbackManager.getPlayerSubtitleOffset(player) || 0) + 's';
}
this.hasFocus = false;
event.preventDefault();
} else {
// keep focus to prevent fade with osd
this.hasFocus = true;
});
subtitleSyncTextField.addEventListener('keydown', function(event) {
if (event.key === 'Enter') {
// if input key is enter search for float pattern
var inputOffset = /[-+]?\d+\.?\d*/g.exec(this.textContent);
if (inputOffset) {
inputOffset = inputOffset[0];
// replace current text by considered offset
this.textContent = inputOffset + 's';
inputOffset = parseFloat(inputOffset);
// set new offset
playbackManager.setSubtitleOffset(inputOffset, player);
// synchronize with slider value
subtitleSyncSlider.updateOffset(
getPercentageFromOffset(inputOffset));
} else {
this.textContent = (playbackManager.getPlayerSubtitleOffset(player) || 0) + 's';
}
this.hasFocus = false;
if (event.key.match(/[+-\d.s]/) === null) {
event.preventDefault();
} else {
// keep focus to prevent fade with osd
this.hasFocus = true;
if (event.key.match(/[+-\d.s]/) === null) {
event.preventDefault();
}
}
}
// FIXME: TV layout will require special handling for navigation keys. But now field is not focusable
event.stopPropagation();
});
// FIXME: TV layout will require special handling for navigation keys. But now field is not focusable
event.stopPropagation();
});
subtitleSyncTextField.blur = function() {
// prevent textfield to blur while element has focus
if (!this.hasFocus && this.prototype) {
this.prototype.blur();
}
};
subtitleSyncTextField.blur = function () {
// prevent textfield to blur while element has focus
if (!this.hasFocus && this.prototype) {
this.prototype.blur();
}
};
subtitleSyncSlider.updateOffset = function(percent) {
// default value is 0s = 50%
this.value = percent === undefined ? 50 : percent;
};
subtitleSyncSlider.updateOffset = function (percent) {
// default value is 0s = 50%
this.value = percent === undefined ? 50 : percent;
};
subtitleSyncSlider.addEventListener('change', function () {
// set new offset
playbackManager.setSubtitleOffset(getOffsetFromPercentage(this.value), player);
// synchronize with textField value
subtitleSyncTextField.updateOffset(
getOffsetFromPercentage(this.value));
});
subtitleSyncSlider.addEventListener('change', function () {
// set new offset
playbackManager.setSubtitleOffset(getOffsetFromPercentage(this.value), player);
// synchronize with textField value
subtitleSyncTextField.updateOffset(
getOffsetFromPercentage(this.value));
});
subtitleSyncSlider.getBubbleHtml = function (value) {
var newOffset = getOffsetFromPercentage(value);
return '<h1 class="sliderBubbleText">' +
subtitleSyncSlider.getBubbleHtml = function (value) {
const newOffset = getOffsetFromPercentage(value);
return '<h1 class="sliderBubbleText">' +
(newOffset > 0 ? '+' : '') + parseFloat(newOffset) + 's' +
'</h1>';
};
};
subtitleSyncCloseButton.addEventListener('click', function() {
playbackManager.disableShowingSubtitleOffset(player);
SubtitleSync.prototype.toggle('forceToHide');
});
subtitleSyncCloseButton.addEventListener('click', function () {
playbackManager.disableShowingSubtitleOffset(player);
SubtitleSync.prototype.toggle('forceToHide');
});
instance.element = parent;
}
instance.element = parent;
}
function getOffsetFromPercentage(value) {
// convert percent to fraction
var offset = (value - 50) / 50;
// multiply by offset min/max range value (-x to +x) :
offset *= 30;
return offset.toFixed(1);
}
function getOffsetFromPercentage(value) {
// convert percent to fraction
let offset = (value - 50) / 50;
// multiply by offset min/max range value (-x to +x) :
offset *= 30;
return offset.toFixed(1);
}
function getPercentageFromOffset(value) {
// divide by offset min/max range value (-x to +x) :
var percentValue = value / 30;
// convert fraction to percent
percentValue *= 50;
percentValue += 50;
return Math.min(100, Math.max(0, percentValue.toFixed()));
}
function getPercentageFromOffset(value) {
// divide by offset min/max range value (-x to +x) :
let percentValue = value / 30;
// convert fraction to percent
percentValue *= 50;
percentValue += 50;
return Math.min(100, Math.max(0, percentValue.toFixed()));
}
function SubtitleSync(currentPlayer) {
class SubtitleSync {
constructor(currentPlayer) {
player = currentPlayer;
init(this);
}
SubtitleSync.prototype.destroy = function() {
destroy() {
SubtitleSync.prototype.toggle('forceToHide');
if (player) {
playbackManager.disableShowingSubtitleOffset(player);
playbackManager.setSubtitleOffset(0, player);
}
var elem = this.element;
const elem = this.element;
if (elem) {
elem.parentNode.removeChild(elem);
this.element = null;
}
};
}
SubtitleSync.prototype.toggle = function(action) {
toggle(action) {
if (player && playbackManager.supportSubtitleOffset(player)) {
/* eslint-disable no-fallthrough */
switch (action) {
@ -170,7 +171,7 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
}
/* eslint-enable no-fallthrough */
}
};
}
}
return SubtitleSync;
});
export default SubtitleSync;

View File

@ -1,6 +1,8 @@
define(['backdrop', 'mainTabsManager', 'layoutManager', 'emby-tabs'], function (backdrop, mainTabsManager, layoutManager) {
'use strict';
layoutManager = layoutManager.default || layoutManager;
function onViewDestroy(e) {
var tabControllers = this.tabControllers;

View File

@ -1,36 +1,34 @@
define(['css!./toast'], function () {
'use strict';
import 'css!./toast';
function remove(elem) {
setTimeout(function () {
elem.parentNode.removeChild(elem);
}, 300);
function remove(elem) {
setTimeout(function () {
elem.parentNode.removeChild(elem);
}, 300);
}
function animateRemove(elem) {
setTimeout(function () {
elem.classList.remove('toastVisible');
remove(elem);
}, 3300);
}
export default function (options) {
if (typeof options === 'string') {
options = {
text: options
};
}
function animateRemove(elem) {
setTimeout(function () {
elem.classList.remove('toastVisible');
remove(elem);
}, 3300);
}
const elem = document.createElement('div');
elem.classList.add('toast');
elem.innerHTML = options.text;
return function (options) {
if (typeof options === 'string') {
options = {
text: options
};
}
document.body.appendChild(elem);
var elem = document.createElement('div');
elem.classList.add('toast');
elem.innerHTML = options.text;
setTimeout(function () {
elem.classList.add('toastVisible');
document.body.appendChild(elem);
setTimeout(function () {
elem.classList.add('toastVisible');
animateRemove(elem);
}, 300);
};
});
animateRemove(elem);
}, 300);
}

View File

@ -3,6 +3,9 @@ define(['dialogHelper', 'dom', 'layoutManager', 'connectionManager', 'globalize'
browser = browser.default || browser;
loading = loading.default || loading;
layoutManager = layoutManager.default || layoutManager;
focusManager = focusManager.default || focusManager;
scrollHelper = scrollHelper.default || scrollHelper;
var enableFocusTransform = !browser.slow && !browser.edge;

View File

@ -1,299 +1,304 @@
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'listViewStyle', 'emby-input', 'emby-select', 'emby-button', 'flexStyles'], function ($, loading, globalize) {
'use strict';
import $ from 'jQuery';
import loading from 'loading';
import globalize from 'globalize';
import 'emby-checkbox';
import 'emby-input';
import 'listViewStyle';
import 'paper-icon-button-light';
import 'emby-select';
import 'emby-button';
import 'flexStyles';
loading = loading.default || loading;
export default function (page, providerId, options) {
function reload() {
loading.show();
ApiClient.getNamedConfiguration('livetv').then(function (config) {
const info = config.ListingProviders.filter(function (i) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId;
$('#selectListing', page).val(info.ListingsId || '');
page.querySelector('.txtUser').value = info.Username || '';
page.querySelector('.txtPass').value = '';
page.querySelector('.txtZipCode').value = info.ZipCode || '';
return function (page, providerId, options) {
function reload() {
loading.show();
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId;
$('#selectListing', page).val(info.ListingsId || '');
page.querySelector('.txtUser').value = info.Username || '';
page.querySelector('.txtPass').value = '';
page.querySelector('.txtZipCode').value = info.ZipCode || '';
if (info.Username && info.Password) {
page.querySelector('.listingsSection').classList.remove('hide');
} else {
page.querySelector('.listingsSection').classList.add('hide');
}
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
if (info.EnableAllTuners) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
setCountry(info);
refreshTunerDevices(page, info, config.TunerHosts);
});
}
function setCountry(info) {
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
var i;
var length;
var countryList = [];
for (var region in result) {
var countries = result[region];
if (countries.length && region !== 'ZZZ') {
for (i = 0, length = countries.length; i < length; i++) {
countryList.push({
name: countries[i].fullName,
value: countries[i].shortName
});
}
}
}
countryList.sort(function (a, b) {
if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
return 0;
});
$('#selectCountry', page).html(countryList.map(function (c) {
return '<option value="' + c.value + '">' + c.name + '</option>';
}).join('')).val(info.Country || '');
$(page.querySelector('.txtZipCode')).trigger('change');
}, function () { // ApiClient.getJSON() error handler
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
});
});
loading.hide();
}
function sha256(str) {
if (!self.TextEncoder) {
return Promise.resolve('');
if (info.Username && info.Password) {
page.querySelector('.listingsSection').classList.remove('hide');
} else {
page.querySelector('.listingsSection').classList.add('hide');
}
var buffer = new TextEncoder('utf-8').encode(str);
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
return hex(hash);
});
}
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
function hex(buffer) {
var hexCodes = [];
var view = new DataView(buffer);
for (var i = 0; i < view.byteLength; i += 4) {
var value = view.getUint32(i);
var stringValue = value.toString(16);
var paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
hexCodes.push(paddedValue);
if (info.EnableAllTuners) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
return hexCodes.join('');
}
setCountry(info);
refreshTunerDevices(page, info, config.TunerHosts);
});
}
function submitLoginForm() {
loading.show();
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
var info = {
Type: 'SchedulesDirect',
Username: page.querySelector('.txtUser').value,
EnableAllTuners: true,
Password: passwordHash,
Pw: page.querySelector('.txtPass').value
};
var id = providerId;
function setCountry(info) {
ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/SchedulesDirect/Countries')).then(function (result) {
let i;
let length;
const countryList = [];
if (id) {
info.Id = id;
for (const region in result) {
const countries = result[region];
if (countries.length && region !== 'ZZZ') {
for (i = 0, length = countries.length; i < length; i++) {
countryList.push({
name: countries[i].fullName,
value: countries[i].shortName
});
}
}
}
countryList.sort(function (a, b) {
if (a.name > b.name) {
return 1;
}
ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateLogin: true
}),
data: JSON.stringify(info),
contentType: 'application/json',
dataType: 'json'
}).then(function (result) {
Dashboard.processServerConfigurationUpdateResult();
providerId = result.Id;
reload();
}, function () {
Dashboard.alert({ // ApiClient.ajax() error handler
message: globalize.translate('ErrorSavingTvProvider')
});
});
if (a.name < b.name) {
return -1;
}
return 0;
});
$('#selectCountry', page).html(countryList.map(function (c) {
return '<option value="' + c.value + '">' + c.name + '</option>';
}).join('')).val(info.Country || '');
$(page.querySelector('.txtZipCode')).trigger('change');
}, function () { // ApiClient.getJSON() error handler
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
});
});
loading.hide();
}
function sha256(str) {
if (!self.TextEncoder) {
return Promise.resolve('');
}
function submitListingsForm() {
var selectedListingsId = $('#selectListing', page).val();
const buffer = new TextEncoder('utf-8').encode(str);
return crypto.subtle.digest('SHA-256', buffer).then(function (hash) {
return hex(hash);
});
}
if (!selectedListingsId) {
return void Dashboard.alert({
message: globalize.translate('ErrorPleaseSelectLineup')
});
}
function hex(buffer) {
const hexCodes = [];
const view = new DataView(buffer);
loading.show();
var id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (i) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector('.txtZipCode').value;
info.Country = $('#selectCountry', page).val();
info.ListingsId = selectedListingsId;
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
return i.checked;
}).map(function (i) {
return i.getAttribute('data-id');
});
ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateListings: true
}),
data: JSON.stringify(info),
contentType: 'application/json'
}).then(function (result) {
loading.hide();
if (options.showConfirmation) {
Dashboard.processServerConfigurationUpdateResult();
}
Events.trigger(self, 'submitted');
}, function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('ErrorAddingListingsToSchedulesDirect')
});
});
});
for (let i = 0; i < view.byteLength; i += 4) {
const value = view.getUint32(i);
const stringValue = value.toString(16);
const paddedValue = ('00000000' + stringValue).slice(-'00000000'.length);
hexCodes.push(paddedValue);
}
function refreshListings(value) {
if (!value) {
return void $('#selectListing', page).html('');
return hexCodes.join('');
}
function submitLoginForm() {
loading.show();
sha256(page.querySelector('.txtPass').value).then(function (passwordHash) {
const info = {
Type: 'SchedulesDirect',
Username: page.querySelector('.txtUser').value,
EnableAllTuners: true,
Password: passwordHash,
Pw: page.querySelector('.txtPass').value
};
const id = providerId;
if (id) {
info.Id = id;
}
loading.show();
ApiClient.ajax({
type: 'GET',
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
Id: providerId,
Location: value,
Country: $('#selectCountry', page).val()
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateLogin: true
}),
data: JSON.stringify(info),
contentType: 'application/json',
dataType: 'json'
}).then(function (result) {
$('#selectListing', page).html(result.map(function (o) {
return '<option value="' + o.Id + '">' + o.Name + '</option>';
}));
if (listingsId) {
$('#selectListing', page).val(listingsId);
}
loading.hide();
}, function (result) {
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
Dashboard.processServerConfigurationUpdateResult();
providerId = result.Id;
reload();
}, function () {
Dashboard.alert({ // ApiClient.ajax() error handler
message: globalize.translate('ErrorSavingTvProvider')
});
refreshListings('');
});
});
}
function submitListingsForm() {
const selectedListingsId = $('#selectListing', page).val();
if (!selectedListingsId) {
return void Dashboard.alert({
message: globalize.translate('ErrorPleaseSelectLineup')
});
}
loading.show();
const id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
const info = config.ListingProviders.filter(function (i) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector('.txtZipCode').value;
info.Country = $('#selectCountry', page).val();
info.ListingsId = selectedListingsId;
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
return i.checked;
}).map(function (i) {
return i.getAttribute('data-id');
});
ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateListings: true
}),
data: JSON.stringify(info),
contentType: 'application/json'
}).then(function (result) {
loading.hide();
});
}
function getTunerName(providerId) {
switch (providerId = providerId.toLowerCase()) {
case 'm3u':
return 'M3U Playlist';
case 'hdhomerun':
return 'HDHomerun';
case 'satip':
return 'DVB';
default:
return 'Unknown';
}
}
function refreshTunerDevices(page, providerInfo, devices) {
var html = '';
for (var i = 0, length = devices.length; i < length; i++) {
var device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
html += device.FriendlyName || getTunerName(device.Type);
html += '</div>';
html += '<div class="listItemBodyText secondary">';
html += device.Url;
html += '</div>';
html += '</div>';
html += '</div>';
}
page.querySelector('.tunerList').innerHTML = html;
}
var listingsId;
var self = this;
self.submit = function () {
page.querySelector('.btnSubmitListingsContainer').click();
};
self.init = function () {
options = options || {};
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
var hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
var hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('.formLogin', page).on('submit', function () {
submitLoginForm();
return false;
});
$('.formListings', page).on('submit', function () {
submitListingsForm();
return false;
});
$('.txtZipCode', page).on('change', function () {
refreshListings(this.value);
});
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {
if (e.target.checked) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
if (options.showConfirmation) {
Dashboard.processServerConfigurationUpdateResult();
}
Events.trigger(self, 'submitted');
}, function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('ErrorAddingListingsToSchedulesDirect')
});
});
$('.createAccountHelp', page).html(globalize.translate('MessageCreateAccountAt', '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
reload();
};
});
}
function refreshListings(value) {
if (!value) {
return void $('#selectListing', page).html('');
}
loading.show();
ApiClient.ajax({
type: 'GET',
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
Id: providerId,
Location: value,
Country: $('#selectCountry', page).val()
}),
dataType: 'json'
}).then(function (result) {
$('#selectListing', page).html(result.map(function (o) {
return '<option value="' + o.Id + '">' + o.Name + '</option>';
}));
if (listingsId) {
$('#selectListing', page).val(listingsId);
}
loading.hide();
}, function (result) {
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
});
refreshListings('');
loading.hide();
});
}
function getTunerName(providerId) {
switch (providerId = providerId.toLowerCase()) {
case 'm3u':
return 'M3U Playlist';
case 'hdhomerun':
return 'HDHomerun';
case 'satip':
return 'DVB';
default:
return 'Unknown';
}
}
function refreshTunerDevices(page, providerInfo, devices) {
let html = '';
for (let i = 0, length = devices.length; i < length; i++) {
const device = devices[i];
html += '<div class="listItem">';
const enabledTuners = providerInfo.EnabledTuners || [];
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
const checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="checkboxContainer listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" data-id="' + device.Id + '" class="chkTuner" ' + checkedAttribute + '/><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
html += device.FriendlyName || getTunerName(device.Type);
html += '</div>';
html += '<div class="listItemBodyText secondary">';
html += device.Url;
html += '</div>';
html += '</div>';
html += '</div>';
}
page.querySelector('.tunerList').innerHTML = html;
}
let listingsId;
const self = this;
self.submit = function () {
page.querySelector('.btnSubmitListingsContainer').click();
};
});
self.init = function () {
options = options || {};
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
const hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('.formLogin', page).on('submit', function () {
submitLoginForm();
return false;
});
$('.formListings', page).on('submit', function () {
submitListingsForm();
return false;
});
$('.txtZipCode', page).on('change', function () {
refreshListings(this.value);
});
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {
if (e.target.checked) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
});
$('.createAccountHelp', page).html(globalize.translate('MessageCreateAccountAt', '<a is="emby-linkbutton" class="button-link" href="http://www.schedulesdirect.org" target="_blank">http://www.schedulesdirect.org</a>'));
reload();
};
}

View File

@ -1,191 +1,193 @@
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-input', 'listViewStyle', 'paper-icon-button-light'], function ($, loading, globalize) {
'use strict';
import $ from 'jQuery';
import loading from 'loading';
import globalize from 'globalize';
import 'emby-checkbox';
import 'emby-input';
import 'listViewStyle';
import 'paper-icon-button-light';
loading = loading.default || loading;
export default function (page, providerId, options) {
function getListingProvider(config, id) {
if (config && id) {
const result = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0];
return function (page, providerId, options) {
function getListingProvider(config, id) {
if (config && id) {
var result = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0];
if (result) {
return Promise.resolve(result);
}
return getListingProvider();
if (result) {
return Promise.resolve(result);
}
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/Default'));
return getListingProvider();
}
function reload() {
loading.show();
ApiClient.getNamedConfiguration('livetv').then(function (config) {
getListingProvider(config, providerId).then(function (info) {
page.querySelector('.txtPath').value = info.Path || '';
page.querySelector('.txtKids').value = (info.KidsCategories || []).join('|');
page.querySelector('.txtNews').value = (info.NewsCategories || []).join('|');
page.querySelector('.txtSports').value = (info.SportsCategories || []).join('|');
page.querySelector('.txtMovies').value = (info.MovieCategories || []).join('|');
page.querySelector('.txtMoviePrefix').value = info.MoviePrefix || '';
page.querySelector('.txtUserAgent').value = info.UserAgent || '';
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
return ApiClient.getJSON(ApiClient.getUrl('LiveTv/ListingProviders/Default'));
}
if (page.querySelector('.chkAllTuners').checked) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
function reload() {
loading.show();
ApiClient.getNamedConfiguration('livetv').then(function (config) {
getListingProvider(config, providerId).then(function (info) {
page.querySelector('.txtPath').value = info.Path || '';
page.querySelector('.txtKids').value = (info.KidsCategories || []).join('|');
page.querySelector('.txtNews').value = (info.NewsCategories || []).join('|');
page.querySelector('.txtSports').value = (info.SportsCategories || []).join('|');
page.querySelector('.txtMovies').value = (info.MovieCategories || []).join('|');
page.querySelector('.txtMoviePrefix').value = info.MoviePrefix || '';
page.querySelector('.txtUserAgent').value = info.UserAgent || '';
page.querySelector('.chkAllTuners').checked = info.EnableAllTuners;
refreshTunerDevices(page, info, config.TunerHosts);
loading.hide();
});
});
}
function getCategories(txtInput) {
var value = txtInput.value;
if (value) {
return value.split('|');
}
return [];
}
function submitListingsForm() {
loading.show();
var id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
var info = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0] || {};
info.Type = 'xmltv';
info.Path = page.querySelector('.txtPath').value;
info.MoviePrefix = page.querySelector('.txtMoviePrefix').value || null;
info.UserAgent = page.querySelector('.txtUserAgent').value || null;
info.MovieCategories = getCategories(page.querySelector('.txtMovies'));
info.KidsCategories = getCategories(page.querySelector('.txtKids'));
info.NewsCategories = getCategories(page.querySelector('.txtNews'));
info.SportsCategories = getCategories(page.querySelector('.txtSports'));
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (tuner) {
return tuner.checked;
}).map(function (tuner) {
return tuner.getAttribute('data-id');
});
ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateListings: true
}),
data: JSON.stringify(info),
contentType: 'application/json'
}).then(function (result) {
loading.hide();
if (options.showConfirmation !== false) {
Dashboard.processServerConfigurationUpdateResult();
}
Events.trigger(self, 'submitted');
}, function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('ErrorAddingXmlTvFile')
});
});
});
}
function getTunerName(providerId) {
switch (providerId = providerId.toLowerCase()) {
case 'm3u':
return 'M3U Playlist';
case 'hdhomerun':
return 'HDHomerun';
case 'satip':
return 'DVB';
default:
return 'Unknown';
}
}
function refreshTunerDevices(page, providerInfo, devices) {
var html = '';
for (var i = 0, length = devices.length; i < length; i++) {
var device = devices[i];
html += '<div class="listItem">';
var enabledTuners = providerInfo.EnabledTuners || [];
var isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
var checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
html += device.FriendlyName || getTunerName(device.Type);
html += '</div>';
html += '<div class="listItemBodyText secondary">';
html += device.Url;
html += '</div>';
html += '</div>';
html += '</div>';
}
page.querySelector('.tunerList').innerHTML = html;
}
function onSelectPathClick(e) {
var page = $(e.target).parents('.xmltvForm')[0];
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser.default();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
var txtPath = page.querySelector('.txtPath');
txtPath.value = path;
txtPath.focus();
}
picker.close();
}
});
});
}
var self = this;
self.submit = function () {
page.querySelector('.btnSubmitListings').click();
};
self.init = function () {
options = options || {};
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
var hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
var hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('form', page).on('submit', function () {
submitListingsForm();
return false;
});
page.querySelector('#btnSelectPath').addEventListener('click', onSelectPathClick);
page.querySelector('.chkAllTuners').addEventListener('change', function (evt) {
if (evt.target.checked) {
if (page.querySelector('.chkAllTuners').checked) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
refreshTunerDevices(page, info, config.TunerHosts);
loading.hide();
});
reload();
};
});
}
function getCategories(txtInput) {
const value = txtInput.value;
if (value) {
return value.split('|');
}
return [];
}
function submitListingsForm() {
loading.show();
const id = providerId;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
const info = config.ListingProviders.filter(function (provider) {
return provider.Id === id;
})[0] || {};
info.Type = 'xmltv';
info.Path = page.querySelector('.txtPath').value;
info.MoviePrefix = page.querySelector('.txtMoviePrefix').value || null;
info.UserAgent = page.querySelector('.txtUserAgent').value || null;
info.MovieCategories = getCategories(page.querySelector('.txtMovies'));
info.KidsCategories = getCategories(page.querySelector('.txtKids'));
info.NewsCategories = getCategories(page.querySelector('.txtNews'));
info.SportsCategories = getCategories(page.querySelector('.txtSports'));
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (tuner) {
return tuner.checked;
}).map(function (tuner) {
return tuner.getAttribute('data-id');
});
ApiClient.ajax({
type: 'POST',
url: ApiClient.getUrl('LiveTv/ListingProviders', {
ValidateListings: true
}),
data: JSON.stringify(info),
contentType: 'application/json'
}).then(function (result) {
loading.hide();
if (options.showConfirmation !== false) {
Dashboard.processServerConfigurationUpdateResult();
}
Events.trigger(self, 'submitted');
}, function () {
loading.hide();
Dashboard.alert({
message: globalize.translate('ErrorAddingXmlTvFile')
});
});
});
}
function getTunerName(providerId) {
switch (providerId = providerId.toLowerCase()) {
case 'm3u':
return 'M3U Playlist';
case 'hdhomerun':
return 'HDHomerun';
case 'satip':
return 'DVB';
default:
return 'Unknown';
}
}
function refreshTunerDevices(page, providerInfo, devices) {
let html = '';
for (let i = 0, length = devices.length; i < length; i++) {
const device = devices[i];
html += '<div class="listItem">';
const enabledTuners = providerInfo.EnabledTuners || [];
const isChecked = providerInfo.EnableAllTuners || enabledTuners.indexOf(device.Id) !== -1;
const checkedAttribute = isChecked ? ' checked' : '';
html += '<label class="listItemCheckboxContainer"><input type="checkbox" is="emby-checkbox" class="chkTuner" data-id="' + device.Id + '" ' + checkedAttribute + '><span></span></label>';
html += '<div class="listItemBody two-line">';
html += '<div class="listItemBodyText">';
html += device.FriendlyName || getTunerName(device.Type);
html += '</div>';
html += '<div class="listItemBodyText secondary">';
html += device.Url;
html += '</div>';
html += '</div>';
html += '</div>';
}
page.querySelector('.tunerList').innerHTML = html;
}
function onSelectPathClick(e) {
const page = $(e.target).parents('.xmltvForm')[0];
import('directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
const txtPath = page.querySelector('.txtPath');
txtPath.value = path;
txtPath.focus();
}
picker.close();
}
});
});
}
const self = this;
self.submit = function () {
page.querySelector('.btnSubmitListings').click();
};
});
self.init = function () {
options = options || {};
// Only hide the buttons if explicitly set to false; default to showing if undefined or null
// FIXME: rename this option to clarify logic
const hideCancelButton = options.showCancelButton === false;
page.querySelector('.btnCancel').classList.toggle('hide', hideCancelButton);
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('form', page).on('submit', function () {
submitListingsForm();
return false;
});
page.querySelector('#btnSelectPath').addEventListener('click', onSelectPathClick);
page.querySelector('.chkAllTuners').addEventListener('change', function (evt) {
if (evt.target.checked) {
page.querySelector('.selectTunersSection').classList.add('hide');
} else {
page.querySelector('.selectTunersSection').classList.remove('hide');
}
});
reload();
};
}

View File

@ -1,9 +1,19 @@
define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'layoutManager', 'focusManager', 'globalize', 'itemHelper', 'css!./upnextdialog', 'emby-button', 'flexStyles'], function (dom, playbackManager, connectionManager, events, mediaInfo, layoutManager, focusManager, globalize, itemHelper) {
'use strict';
import dom from 'dom';
import playbackManager from 'playbackManager';
import connectionManager from 'connectionManager';
import events from 'events';
import mediaInfo from 'mediaInfo';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import globalize from 'globalize';
import itemHelper from 'itemHelper';
import 'css!./upnextdialog';
import 'emby-button';
import 'flexStyles';
playbackManager = playbackManager.default || playbackManager;
/* eslint-disable indent */
var transitionEndEventName = dom.whichTransitionEvent();
const transitionEndEventName = dom.whichTransitionEvent();
function seriesImageUrl(item, options) {
if (item.Type !== 'Episode') {
@ -58,7 +68,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
function setPoster(osdPoster, item, secondaryItem) {
if (item) {
var imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
let imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
seriesImageUrl(item, { type: 'Thumb' }) ||
imageUrl(item, { type: 'Primary' });
@ -78,7 +88,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function getHtml() {
var html = '';
let html = '';
html += '<div class="upNextDialog-poster">';
html += '</div>';
@ -114,17 +124,17 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function setNextVideoText() {
var instance = this;
const instance = this;
var elem = instance.options.parent;
const elem = instance.options.parent;
var secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
const secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
console.debug('up next seconds remaining: ' + secondsRemaining);
var timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
const timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
var nextVideoText = instance.itemType === 'Episode' ?
const nextVideoText = instance.itemType === 'Episode' ?
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
@ -132,9 +142,9 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function fillItem(item) {
var instance = this;
const instance = this;
var elem = instance.options.parent;
const elem = instance.options.parent;
setPoster(elem.querySelector('.upNextDialog-poster'), item);
@ -143,7 +153,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
elem.querySelector('.upNextDialog-mediainfo').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(item, {
});
var title = itemHelper.getDisplayName(item);
let title = itemHelper.getDisplayName(item);
if (item.SeriesName) {
title = item.SeriesName + ' - ' + title;
}
@ -163,10 +173,10 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function onStartNowClick() {
var options = this.options;
const options = this.options;
if (options) {
var player = options.player;
const player = options.player;
this.hide();
@ -188,7 +198,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function clearHideAnimationEventListeners(instance, elem) {
var fn = instance._onHideAnimationComplete;
const fn = instance._onHideAnimationComplete;
if (fn) {
dom.removeEventListener(elem, transitionEndEventName, fn, {
@ -198,8 +208,8 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function onHideAnimationComplete(e) {
var instance = this;
var elem = e.target;
const instance = this;
const elem = e.target;
elem.classList.add('hide');
@ -208,14 +218,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function hideComingUpNext() {
var instance = this;
const instance = this;
clearCountdownTextTimeout(this);
if (!instance.options) {
return;
}
var elem = instance.options.parent;
const elem = instance.options.parent;
if (!elem) {
return;
@ -232,7 +242,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
elem.classList.add('upNextDialog-hidden');
var fn = onHideAnimationComplete.bind(instance);
const fn = onHideAnimationComplete.bind(instance);
instance._onHideAnimationComplete = fn;
dom.addEventListener(elem, transitionEndEventName, fn, {
@ -241,12 +251,12 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function getTimeRemainingMs(instance) {
var options = instance.options;
const options = instance.options;
if (options) {
var runtimeTicks = playbackManager.duration(options.player);
const runtimeTicks = playbackManager.duration(options.player);
if (runtimeTicks) {
var timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
const timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
return Math.round(timeRemainingTicks / 10000);
}
@ -256,7 +266,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
function startComingUpNextHideTimer(instance) {
var timeRemainingMs = getTimeRemainingMs(instance);
const timeRemainingMs = getTimeRemainingMs(instance);
if (timeRemainingMs <= 0) {
return;
@ -268,14 +278,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
}
function UpNextDialog(options) {
class UpNextDialog {
constructor(options) {
this.options = options;
init(this, options);
}
UpNextDialog.prototype.show = function () {
var elem = this.options.parent;
show() {
const elem = this.options.parent;
clearHideAnimationEventListeners(this, elem);
@ -293,18 +303,18 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
}
startComingUpNextHideTimer(this);
};
UpNextDialog.prototype.hide = function () {
}
hide() {
hideComingUpNext.call(this);
};
UpNextDialog.prototype.destroy = function () {
}
destroy() {
hideComingUpNext.call(this);
this.options = null;
this.itemType = null;
};
}
}
return UpNextDialog;
});
export default UpNextDialog;
/* eslint-enable indent */

View File

@ -1,134 +1,134 @@
define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], function (viewContainer, focusManager, queryString, layoutManager) {
'use strict';
import viewContainer from 'viewContainer';
import focusManager from 'focusManager';
import queryString from 'queryString';
import layoutManager from 'layoutManager';
var currentView;
var dispatchPageEvents;
let currentView;
let dispatchPageEvents;
viewContainer.setOnBeforeChange(function (newView, isRestored, options) {
var lastView = currentView;
if (lastView) {
var beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true);
viewContainer.setOnBeforeChange(function (newView, isRestored, options) {
const lastView = currentView;
if (lastView) {
const beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true);
if (!beforeHideResult) {
// todo: cancel
}
}
var eventDetail = getViewEventDetail(newView, options, isRestored);
if (!newView.initComplete) {
newView.initComplete = true;
if (typeof options.controllerFactory === 'function') {
new options.controllerFactory(newView, eventDetail.detail.params);
} else if (options.controllerFactory && typeof options.controllerFactory.default === 'function') {
new options.controllerFactory.default(newView, eventDetail.detail.params);
}
if (!options.controllerFactory || dispatchPageEvents) {
dispatchViewEvent(newView, eventDetail, 'viewinit');
}
}
dispatchViewEvent(newView, eventDetail, 'viewbeforeshow');
});
function onViewChange(view, options, isRestore) {
var lastView = currentView;
if (lastView) {
dispatchViewEvent(lastView, null, 'viewhide');
}
currentView = view;
var eventDetail = getViewEventDetail(view, options, isRestore);
if (!isRestore) {
if (options.autoFocus !== false) {
focusManager.autoFocus(view);
}
} else if (!layoutManager.mobile) {
if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) {
focusManager.focus(view.activeElement);
} else {
focusManager.autoFocus(view);
}
}
view.dispatchEvent(new CustomEvent('viewshow', eventDetail));
if (dispatchPageEvents) {
view.dispatchEvent(new CustomEvent('pageshow', eventDetail));
if (!beforeHideResult) {
// todo: cancel
}
}
function getProperties(view) {
var props = view.getAttribute('data-properties');
const eventDetail = getViewEventDetail(newView, options, isRestored);
if (props) {
return props.split(',');
if (!newView.initComplete) {
newView.initComplete = true;
if (typeof options.controllerFactory === 'function') {
new options.controllerFactory(newView, eventDetail.detail.params);
} else if (options.controllerFactory && typeof options.controllerFactory.default === 'function') {
new options.controllerFactory.default(newView, eventDetail.detail.params);
}
return [];
if (!options.controllerFactory || dispatchPageEvents) {
dispatchViewEvent(newView, eventDetail, 'viewinit');
}
}
function dispatchViewEvent(view, eventInfo, eventName, isCancellable) {
if (!eventInfo) {
eventInfo = {
detail: {
type: view.getAttribute('data-type'),
properties: getProperties(view)
},
bubbles: true,
cancelable: isCancellable
};
}
dispatchViewEvent(newView, eventDetail, 'viewbeforeshow');
});
eventInfo.cancelable = isCancellable || false;
var eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo));
if (dispatchPageEvents) {
eventInfo.cancelable = false;
view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo));
}
return eventResult;
function onViewChange(view, options, isRestore) {
const lastView = currentView;
if (lastView) {
dispatchViewEvent(lastView, null, 'viewhide');
}
function getViewEventDetail(view, options, isRestore) {
var url = options.url;
var index = url.indexOf('?');
var params = index === -1 ? {} : queryString.parse(url.substring(index + 1));
currentView = view;
return {
const eventDetail = getViewEventDetail(view, options, isRestore);
if (!isRestore) {
if (options.autoFocus !== false) {
focusManager.autoFocus(view);
}
} else if (!layoutManager.mobile) {
if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) {
focusManager.focus(view.activeElement);
} else {
focusManager.autoFocus(view);
}
}
view.dispatchEvent(new CustomEvent('viewshow', eventDetail));
if (dispatchPageEvents) {
view.dispatchEvent(new CustomEvent('pageshow', eventDetail));
}
}
function getProperties(view) {
const props = view.getAttribute('data-properties');
if (props) {
return props.split(',');
}
return [];
}
function dispatchViewEvent(view, eventInfo, eventName, isCancellable) {
if (!eventInfo) {
eventInfo = {
detail: {
type: view.getAttribute('data-type'),
properties: getProperties(view),
params: params,
isRestored: isRestore,
state: options.state,
// The route options
options: options.options || {}
properties: getProperties(view)
},
bubbles: true,
cancelable: false
cancelable: isCancellable
};
}
function resetCachedViews() {
// Reset all cached views whenever the skin changes
viewContainer.reset();
eventInfo.cancelable = isCancellable || false;
const eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo));
if (dispatchPageEvents) {
eventInfo.cancelable = false;
view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo));
}
document.addEventListener('skinunload', resetCachedViews);
return eventResult;
}
function ViewManager() {
}
function getViewEventDetail(view, options, isRestore) {
const url = options.url;
const index = url.indexOf('?');
const params = index === -1 ? {} : queryString.parse(url.substring(index + 1));
ViewManager.prototype.loadView = function (options) {
var lastView = currentView;
return {
detail: {
type: view.getAttribute('data-type'),
properties: getProperties(view),
params: params,
isRestored: isRestore,
state: options.state,
// The route options
options: options.options || {}
},
bubbles: true,
cancelable: false
};
}
function resetCachedViews() {
// Reset all cached views whenever the skin changes
viewContainer.reset();
}
document.addEventListener('skinunload', resetCachedViews);
class ViewManager {
loadView(options) {
const lastView = currentView;
// Record the element that has focus
if (lastView) {
@ -142,9 +142,9 @@ define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], functi
viewContainer.loadView(options).then(function (view) {
onViewChange(view, options);
});
};
}
ViewManager.prototype.tryRestoreView = function (options, onViewChanging) {
tryRestoreView(options, onViewChanging) {
if (options.cancel) {
return Promise.reject({ cancelled: true });
}
@ -158,15 +158,15 @@ define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], functi
onViewChanging();
onViewChange(view, options, true);
});
};
}
ViewManager.prototype.currentView = function () {
currentView() {
return currentView;
};
}
ViewManager.prototype.dispatchPageEvents = function (value) {
dispatchPageEvents(value) {
dispatchPageEvents = value;
};
}
}
return new ViewManager();
});
export default new ViewManager();

View File

@ -1,6 +1,8 @@
define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'connectionManager', 'appRouter', 'globalize', 'userSettings', 'emby-checkbox', 'emby-input', 'paper-icon-button-light', 'emby-select', 'material-icons', 'css!./../formdialog', 'emby-button', 'flexStyles'], function (require, dialogHelper, loading, appHost, layoutManager, connectionManager, appRouter, globalize, userSettings) {
'use strict';
layoutManager = layoutManager.default || layoutManager;
function onSubmit(e) {
e.preventDefault();
return false;
@ -29,6 +31,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne
function centerFocus(elem, horiz, on) {
require(['scrollHelper'], function (scrollHelper) {
scrollHelper = scrollHelper.default || scrollHelper;
var fn = on ? 'on' : 'off';
scrollHelper.centerFocus[fn](elem, horiz);
});

View File

@ -1,3 +1,38 @@
{
"multiserver": false
"multiserver": false,
"themes": [
{
"name": "Apple TV",
"id": "appletv"
}, {
"name": "Blue Radiance",
"id": "blueradiance"
}, {
"name": "Dark",
"id": "dark",
"default": true
}, {
"name": "Light",
"id": "light"
}, {
"name": "Purple Haze",
"id": "purplehaze"
}, {
"name": "WMC",
"id": "wmc"
}
],
"plugins": [
"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",
"plugins/sessionPlayer/plugin",
"plugins/chromecastPlayer/plugin"
]
}

View File

@ -1,119 +1,118 @@
define(['jQuery', 'emby-checkbox'], function ($) {
'use strict';
import $ from 'jQuery';
import 'emby-checkbox';
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
var html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
html += items.map(function (u) {
var isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1;
var checkedHtml = isChecked ? ' checked="checked"' : '';
return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>';
}).join('');
html += '</div>';
elem.html(html).trigger('create');
}
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
let html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
html += items.map(function (u) {
const isChecked = isEnabledList ? currentList.indexOf(u.Id) != -1 : currentList.indexOf(u.Id) == -1;
const checkedHtml = isChecked ? ' checked="checked"' : '';
return '<label><input is="emby-checkbox" class="' + cssClass + '" type="checkbox" data-itemid="' + u.Id + '"' + checkedHtml + '/><span>' + u.Name + '</span></label>';
}).join('');
html += '</div>';
elem.html(html).trigger('create');
}
function reload(page) {
var type = getParameterByName('type');
var promise1 = ApiClient.getUsers();
var promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
var promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
var promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services'));
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
var users = responses[0];
var notificationOptions = responses[1];
var types = responses[2];
var services = responses[3];
var notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type;
})[0];
var typeInfo = types.filter(function (n) {
return n.Type == type;
})[0] || {};
function reload(page) {
const type = getParameterByName('type');
const promise1 = ApiClient.getUsers();
const promise2 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
const promise3 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
const promise4 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Services'));
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
const users = responses[0];
const notificationOptions = responses[1];
const types = responses[2];
const services = responses[3];
let notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type;
})[0];
const typeInfo = types.filter(function (n) {
return n.Type == type;
})[0] || {};
if (typeInfo.IsBasedOnUserEvent) {
$('.monitorUsers', page).show();
} else {
$('.monitorUsers', page).hide();
}
if (typeInfo.IsBasedOnUserEvent) {
$('.monitorUsers', page).show();
} else {
$('.monitorUsers', page).hide();
}
$('.notificationType', page).html(typeInfo.Name || 'Unknown Notification');
$('.notificationType', page).html(typeInfo.Name || 'Unknown Notification');
if (!notificationConfig) {
notificationConfig = {
DisabledMonitorUsers: [],
SendToUsers: [],
DisabledServices: [],
SendToUserMode: 'Admins'
};
}
if (!notificationConfig) {
notificationConfig = {
DisabledMonitorUsers: [],
SendToUsers: [],
DisabledServices: [],
SendToUserMode: 'Admins'
};
}
fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers);
fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.SendToUsers, true);
fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices);
$('#chkEnabled', page).prop('checked', notificationConfig.Enabled || false);
$('#selectUsers', page).val(notificationConfig.SendToUserMode).trigger('change');
});
}
function save(page) {
var type = getParameterByName('type');
var promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
// TODO: Check if this promise is really needed, as it's unused.
var promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
Promise.all([promise1, promise2]).then(function (responses) {
var notificationOptions = responses[0];
var notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type;
})[0];
if (!notificationConfig) {
notificationConfig = {
Type: type
};
notificationOptions.Options.push(notificationConfig);
}
notificationConfig.Enabled = $('#chkEnabled', page).is(':checked');
notificationConfig.SendToUserMode = $('#selectUsers', page).val();
notificationConfig.DisabledMonitorUsers = $('.chkMonitor', page).get().filter(function (c) {
return !c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
notificationConfig.SendToUsers = $('.chkSendTo', page).get().filter(function (c) {
return c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
notificationConfig.DisabledServices = $('.chkService', page).get().filter(function (c) {
return !c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).then(function (r) {
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('notificationsettings.html');
});
});
}
function onSubmit() {
save($(this).parents('.page'));
return false;
}
var notificationsConfigurationKey = 'notifications';
$(document).on('pageinit', '#notificationSettingPage', function () {
var page = this;
$('#selectUsers', page).on('change', function () {
if (this.value == 'Custom') {
$('.selectCustomUsers', page).show();
} else {
$('.selectCustomUsers', page).hide();
}
});
$('.notificationSettingForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#notificationSettingPage', function () {
reload(this);
fillItems($('.monitorUsersList', page), users, 'chkMonitor', 'chkMonitor', notificationConfig.DisabledMonitorUsers);
fillItems($('.sendToUsersList', page), users, 'chkSendTo', 'chkSendTo', notificationConfig.SendToUsers, true);
fillItems($('.servicesList', page), services, 'chkService', 'chkService', notificationConfig.DisabledServices);
$('#chkEnabled', page).prop('checked', notificationConfig.Enabled || false);
$('#selectUsers', page).val(notificationConfig.SendToUserMode).trigger('change');
});
}
function save(page) {
const type = getParameterByName('type');
const promise1 = ApiClient.getNamedConfiguration(notificationsConfigurationKey);
// TODO: Check if this promise is really needed, as it's unused.
const promise2 = ApiClient.getJSON(ApiClient.getUrl('Notifications/Types'));
Promise.all([promise1, promise2]).then(function (responses) {
const notificationOptions = responses[0];
let notificationConfig = notificationOptions.Options.filter(function (n) {
return n.Type == type;
})[0];
if (!notificationConfig) {
notificationConfig = {
Type: type
};
notificationOptions.Options.push(notificationConfig);
}
notificationConfig.Enabled = $('#chkEnabled', page).is(':checked');
notificationConfig.SendToUserMode = $('#selectUsers', page).val();
notificationConfig.DisabledMonitorUsers = $('.chkMonitor', page).get().filter(function (c) {
return !c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
notificationConfig.SendToUsers = $('.chkSendTo', page).get().filter(function (c) {
return c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
notificationConfig.DisabledServices = $('.chkService', page).get().filter(function (c) {
return !c.checked;
}).map(function (c) {
return c.getAttribute('data-itemid');
});
ApiClient.updateNamedConfiguration(notificationsConfigurationKey, notificationOptions).then(function (r) {
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('notificationsettings.html');
});
});
}
function onSubmit() {
save($(this).parents('.page'));
return false;
}
const notificationsConfigurationKey = 'notifications';
$(document).on('pageinit', '#notificationSettingPage', function () {
const page = this;
$('#selectUsers', page).on('change', function () {
if (this.value == 'Custom') {
$('.selectCustomUsers', page).show();
} else {
$('.selectCustomUsers', page).hide();
}
});
$('.notificationSettingForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshow', '#notificationSettingPage', function () {
reload(this);
});

View File

@ -1,62 +1,61 @@
define(['loading', 'libraryMenu', 'globalize', 'listViewStyle', 'emby-button'], function(loading, libraryMenu, globalize) {
'use strict';
import loading from 'loading';
import globalize from 'globalize';
import 'listViewStyle';
import 'emby-button';
loading = loading.default || loading;
function reload(page) {
loading.show();
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function(list) {
var html = '';
var lastCategory = '';
var showHelp = true;
html += list.map(function(notification) {
var itemHtml = '';
if (notification.Category !== lastCategory) {
lastCategory = notification.Category;
if (lastCategory) {
itemHtml += '</div>';
itemHtml += '</div>';
}
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
itemHtml += '<h2 class="sectionTitle">';
itemHtml += notification.Category;
itemHtml += '</h2>';
if (showHelp) {
showHelp = false;
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/notifications.html">';
itemHtml += globalize.translate('Help');
itemHtml += '</a>';
}
function reload(page) {
loading.show();
ApiClient.getJSON(ApiClient.getUrl('Notifications/Types')).then(function (list) {
let html = '';
let lastCategory = '';
let showHelp = true;
html += list.map(function (notification) {
let itemHtml = '';
if (notification.Category !== lastCategory) {
lastCategory = notification.Category;
if (lastCategory) {
itemHtml += '</div>';
itemHtml += '</div>';
itemHtml += '<div class="paperList">';
}
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + notification.Type + '">';
if (notification.Enabled) {
itemHtml += '<span class="listItemIcon material-icons notifications_active"></span>';
} else {
itemHtml += '<span class="listItemIcon material-icons notifications_off" style="background-color:#999;"></span>';
itemHtml += '<div class="verticalSection verticalSection-extrabottompadding">';
itemHtml += '<div class="sectionTitleContainer" style="margin-bottom:1em;">';
itemHtml += '<h2 class="sectionTitle">';
itemHtml += notification.Category;
itemHtml += '</h2>';
if (showHelp) {
showHelp = false;
itemHtml += '<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://docs.jellyfin.org/general/server/notifications.html">';
itemHtml += globalize.translate('Help');
itemHtml += '</a>';
}
itemHtml += '<div class="listItemBody">';
itemHtml += '<div class="listItemBodyText">' + notification.Name + '</div>';
itemHtml += '</div>';
itemHtml += '<button type="button" is="paper-icon-button-light"><span class="material-icons mode_edit"></span></button>';
itemHtml += '</a>';
return itemHtml;
}).join('');
if (list.length) {
html += '</div>';
html += '</div>';
itemHtml += '<div class="paperList">';
}
page.querySelector('.notificationList').innerHTML = html;
loading.hide();
});
}
itemHtml += '<a class="listItem listItem-border" is="emby-linkbutton" data-ripple="false" href="notificationsetting.html?type=' + notification.Type + '">';
if (notification.Enabled) {
itemHtml += '<span class="listItemIcon material-icons notifications_active"></span>';
} else {
itemHtml += '<span class="listItemIcon material-icons notifications_off" style="background-color:#999;"></span>';
}
itemHtml += '<div class="listItemBody">';
itemHtml += '<div class="listItemBodyText">' + notification.Name + '</div>';
itemHtml += '</div>';
itemHtml += '<button type="button" is="paper-icon-button-light"><span class="material-icons mode_edit"></span></button>';
itemHtml += '</a>';
return itemHtml;
}).join('');
return function(view, params) {
view.addEventListener('viewshow', function() {
reload(view);
});
};
});
if (list.length) {
html += '</div>';
html += '</div>';
}
page.querySelector('.notificationList').innerHTML = html;
loading.hide();
});
}
export default function (view, params) {
view.addEventListener('viewshow', function () {
reload(view);
});
}

View File

@ -1,143 +1,146 @@
define(['jQuery', 'loading', 'libraryMenu', 'globalize', 'connectionManager', 'emby-button'], function ($, loading, libraryMenu, globalize, connectionManager) {
'use strict';
import $ from 'jQuery';
import loading from 'loading';
import globalize from 'globalize';
import 'emby-button';
loading = loading.default || loading;
function populateHistory(packageInfo, page) {
let html = '';
const length = Math.min(packageInfo.versions.length, 10);
function populateHistory(packageInfo, page) {
var html = '';
var length = Math.min(packageInfo.versions.length, 10);
for (var i = 0; i < length; i++) {
var version = packageInfo.versions[i];
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
}
$('#revisionHistory', page).html(html);
for (let i = 0; i < length; i++) {
let version = packageInfo.versions[i];
html += '<h2 style="margin:.5em 0;">' + version.version + '</h2>';
html += '<div style="margin-bottom:1.5em;">' + version.changelog + '</div>';
}
function populateVersions(packageInfo, page, installedPlugin) {
var html = '';
$('#revisionHistory', page).html(html);
}
for (var i = 0; i < packageInfo.versions.length; i++) {
var version = packageInfo.versions[i];
html += '<option value="' + version.version + '">' + version.version + '</option>';
}
function populateVersions(packageInfo, page, installedPlugin) {
let html = '';
var selectmenu = $('#selectVersion', page).html(html);
if (!installedPlugin) {
$('#pCurrentVersion', page).hide().html('');
}
var packageVersion = packageInfo.versions[0];
if (packageVersion) {
selectmenu.val(packageVersion.version);
}
for (let i = 0; i < packageInfo.versions.length; i++) {
const version = packageInfo.versions[i];
html += '<option value="' + version.version + '">' + version.version + '</option>';
}
function renderPackage(pkg, installedPlugins, page) {
var installedPlugin = installedPlugins.filter(function (ip) {
return ip.Name == pkg.name;
})[0];
const selectmenu = $('#selectVersion', page).html(html);
populateVersions(pkg, page, installedPlugin);
populateHistory(pkg, page);
$('.pluginName', page).html(pkg.name);
$('#btnInstallDiv', page).removeClass('hide');
$('#pSelectVersion', page).removeClass('hide');
if (pkg.overview) {
$('#overview', page).show().html(pkg.overview);
} else {
$('#overview', page).hide();
}
$('#description', page).html(pkg.description);
$('#developer', page).html(pkg.owner);
if (installedPlugin) {
var currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
$('#pCurrentVersion', page).show().html(currentVersionText);
} else {
$('#pCurrentVersion', page).hide().html('');
}
loading.hide();
if (!installedPlugin) {
$('#pCurrentVersion', page).hide().html('');
}
function alertText(options) {
require(['alert'], function ({default: alert}) {
alert(options);
});
const packageVersion = packageInfo.versions[0];
if (packageVersion) {
selectmenu.val(packageVersion.version);
}
}
function renderPackage(pkg, installedPlugins, page) {
const installedPlugin = installedPlugins.filter(function (ip) {
return ip.Name == pkg.name;
})[0];
populateVersions(pkg, page, installedPlugin);
populateHistory(pkg, page);
$('.pluginName', page).html(pkg.name);
$('#btnInstallDiv', page).removeClass('hide');
$('#pSelectVersion', page).removeClass('hide');
if (pkg.overview) {
$('#overview', page).show().html(pkg.overview);
} else {
$('#overview', page).hide();
}
function performInstallation(page, name, guid, version) {
var developer = $('#developer', page).html().toLowerCase();
$('#description', page).html(pkg.description);
$('#developer', page).html(pkg.owner);
var alertCallback = function () {
loading.show();
page.querySelector('#btnInstall').disabled = true;
ApiClient.installPlugin(name, guid, version).then(function () {
loading.hide();
alertText(globalize.translate('MessagePluginInstalled'));
});
};
if (installedPlugin) {
const currentVersionText = globalize.translate('MessageYouHaveVersionInstalled', '<strong>' + installedPlugin.Version + '</strong>');
$('#pCurrentVersion', page).show().html(currentVersionText);
} else {
$('#pCurrentVersion', page).hide().html('');
}
if (developer !== 'jellyfin') {
loading.hide();
}
function alertText(options) {
import('alert').then(({default: alert}) => {
alert(options);
});
}
function performInstallation(page, name, guid, version) {
const developer = $('#developer', page).html().toLowerCase();
const alertCallback = function () {
loading.show();
page.querySelector('#btnInstall').disabled = true;
ApiClient.installPlugin(name, guid, version).then(() => {
loading.hide();
var msg = globalize.translate('MessagePluginInstallDisclaimer');
msg += '<br/>';
msg += '<br/>';
msg += globalize.translate('PleaseConfirmPluginInstallation');
require(['confirm'], function (confirm) {
confirm.default(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
alertCallback();
}, function () {
console.debug('plugin not installed');
});
});
} else {
alertCallback();
}
}
return function (view, params) {
$('.addPluginForm', view).on('submit', function () {
loading.show();
var page = $(this).parents('#addPluginPage')[0];
var name = params.name;
var guid = params.guid;
ApiClient.getInstalledPlugins().then(function (plugins) {
var installedPlugin = plugins.filter(function (plugin) {
return plugin.Name == name;
})[0];
var version = $('#selectVersion', page).val();
if (installedPlugin && installedPlugin.Version === version) {
loading.hide();
Dashboard.alert({
message: globalize.translate('MessageAlreadyInstalled'),
title: globalize.translate('HeaderPluginInstallation')
});
} else {
performInstallation(page, name, guid, version);
}
});
return false;
});
view.addEventListener('viewshow', function () {
var page = this;
loading.show();
var name = params.name;
var guid = params.guid;
var promise1 = ApiClient.getPackageInfo(name, guid);
var promise2 = ApiClient.getInstalledPlugins();
Promise.all([promise1, promise2]).then(function (responses) {
renderPackage(responses[0], responses[1], page);
});
alertText(globalize.translate('MessagePluginInstalled'));
}).catch(() => {
alertText(globalize.translate('MessagePluginInstallError'));
});
};
});
if (developer !== 'jellyfin') {
loading.hide();
let msg = globalize.translate('MessagePluginInstallDisclaimer');
msg += '<br/>';
msg += '<br/>';
msg += globalize.translate('PleaseConfirmPluginInstallation');
import('confirm').then(({default: confirm}) => {
confirm(msg, globalize.translate('HeaderConfirmPluginInstallation')).then(function () {
alertCallback();
}).catch(() => {
console.debug('plugin not installed');
});
});
} else {
alertCallback();
}
}
export default function(view, params) {
$('.addPluginForm', view).on('submit', function () {
loading.show();
const page = $(this).parents('#addPluginPage')[0];
const name = params.name;
const guid = params.guid;
ApiClient.getInstalledPlugins().then(function (plugins) {
const installedPlugin = plugins.filter(function (plugin) {
return plugin.Name == name;
})[0];
const version = $('#selectVersion', page).val();
if (installedPlugin && installedPlugin.Version === version) {
loading.hide();
Dashboard.alert({
message: globalize.translate('MessageAlreadyInstalled'),
title: globalize.translate('HeaderPluginInstallation')
});
} else {
performInstallation(page, name, guid, version);
}
}).catch(() => {
alertText(globalize.translate('MessageGetInstalledPluginsError'));
});
return false;
});
view.addEventListener('viewshow', function () {
const page = this;
loading.show();
const name = params.name;
const guid = params.guid;
const promise1 = ApiClient.getPackageInfo(name, guid);
const promise2 = ApiClient.getInstalledPlugins();
Promise.all([promise1, promise2]).then(function (responses) {
renderPackage(responses[0], responses[1], page);
});
});
}

View File

@ -1,143 +1,142 @@
define(['loading', 'libraryMenu', 'globalize', 'cardStyle', 'emby-button', 'emby-checkbox', 'emby-select'], function (loading, libraryMenu, globalize) {
'use strict';
import loading from 'loading';
import libraryMenu from 'libraryMenu';
import globalize from 'globalize';
import 'cardStyle';
import 'emby-button';
import 'emby-checkbox';
import 'emby-select';
loading = loading.default || loading;
function reloadList(page) {
loading.show();
var promise1 = ApiClient.getAvailablePlugins();
var promise2 = ApiClient.getInstalledPlugins();
Promise.all([promise1, promise2]).then(function (responses) {
populateList({
catalogElement: page.querySelector('#pluginTiles'),
noItemsElement: page.querySelector('#noPlugins'),
availablePlugins: responses[0],
installedPlugins: responses[1]
});
function reloadList(page) {
loading.show();
const promise1 = ApiClient.getAvailablePlugins();
const promise2 = ApiClient.getInstalledPlugins();
Promise.all([promise1, promise2]).then(function (responses) {
populateList({
catalogElement: page.querySelector('#pluginTiles'),
noItemsElement: page.querySelector('#noPlugins'),
availablePlugins: responses[0],
installedPlugins: responses[1]
});
});
}
function getHeaderText(category) {
category = category.replace(' ', '');
// TODO: Replace with switch
if (category === 'Channel') {
category = 'Channels';
} else if (category === 'Theme') {
category = 'Themes';
} else if (category === 'LiveTV') {
category = 'HeaderLiveTV';
} else if (category === 'ScreenSaver') {
category = 'HeaderScreenSavers';
}
function getHeaderText(category) {
category = category.replace(' ', '');
if (category === 'Channel') {
category = 'Channels';
} else if (category === 'Theme') {
category = 'Themes';
} else if (category === 'LiveTV') {
category = 'HeaderLiveTV';
} else if (category === 'ScreenSaver') {
category = 'HeaderScreenSavers';
return globalize.translate(category);
}
function populateList(options) {
const availablePlugins = options.availablePlugins;
const installedPlugins = options.installedPlugins;
availablePlugins.forEach(function (plugin, index, array) {
plugin.category = plugin.category || 'General';
plugin.categoryDisplayName = getHeaderText(plugin.category);
array[index] = plugin;
});
availablePlugins.sort(function (a, b) {
if (a.category > b.category) {
return 1;
} else if (b.category > a.category) {
return -1;
}
if (a.name > b.name) {
return 1;
} else if (b.name > a.name) {
return -1;
}
return 0;
});
return globalize.translate(category);
}
let currentCategory = null;
let html = '';
function populateList(options) {
var availablePlugins = options.availablePlugins;
var installedPlugins = options.installedPlugins;
availablePlugins.forEach(function (plugin, index, array) {
plugin.category = plugin.category || 'General';
plugin.categoryDisplayName = getHeaderText(plugin.category);
array[index] = plugin;
});
availablePlugins.sort(function (a, b) {
if (a.category > b.category) {
return 1;
} else if (b.category > a.category) {
return -1;
for (let i = 0; i < availablePlugins.length; i++) {
const plugin = availablePlugins[i];
const category = plugin.categoryDisplayName;
if (category != currentCategory) {
if (currentCategory) {
html += '</div>';
html += '</div>';
}
if (a.name > b.name) {
return 1;
} else if (b.name > a.name) {
return -1;
}
return 0;
});
var currentCategory = null;
var html = '';
for (var i = 0; i < availablePlugins.length; i++) {
var plugin = availablePlugins[i];
var category = plugin.categoryDisplayName;
if (category != currentCategory) {
if (currentCategory) {
html += '</div>';
html += '</div>';
}
html += '<div class="verticalSection">';
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
html += '<div class="itemsContainer vertical-wrap">';
currentCategory = category;
}
html += getPluginHtml(plugin, options, installedPlugins);
html += '<div class="verticalSection">';
html += '<h2 class="sectionTitle sectionTitle-cards">' + category + '</h2>';
html += '<div class="itemsContainer vertical-wrap">';
currentCategory = category;
}
html += '</div>';
html += '</div>';
html += getPluginHtml(plugin, options, installedPlugins);
}
html += '</div>';
html += '</div>';
if (!availablePlugins.length && options.noItemsElement) {
options.noItemsElement.classList.remove('hide');
}
options.catalogElement.innerHTML = html;
loading.hide();
if (!availablePlugins.length && options.noItemsElement) {
options.noItemsElement.classList.remove('hide');
}
function getPluginHtml(plugin, options, installedPlugins) {
var html = '';
var href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
options.catalogElement.innerHTML = html;
loading.hide();
}
if (options.context) {
href += '&context=' + options.context;
}
function getPluginHtml(plugin, options, installedPlugins) {
let html = '';
let href = plugin.externalUrl ? plugin.externalUrl : 'addplugin.html?name=' + encodeURIComponent(plugin.name) + '&guid=' + plugin.guid;
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 + '>';
html += '<span class="cardImageIcon material-icons folder"></span>';
html += '</a>';
html += '</div>';
html += '<div class="cardFooter">';
html += "<div class='cardText'>";
html += plugin.name;
html += '</div>';
var installedPlugin = installedPlugins.filter(function (ip) {
return ip.Id == plugin.guid;
})[0];
html += "<div class='cardText cardText-secondary'>";
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : '&nbsp;';
html += '</div>';
html += '</div>';
html += '</div>';
return html += '</div>';
if (options.context) {
href += '&context=' + options.context;
}
function getTabs() {
return [{
href: 'installedplugins.html',
name: globalize.translate('TabMyPlugins')
}, {
href: 'availableplugins.html',
name: globalize.translate('TabCatalog')
}, {
href: 'repositories.html',
name: globalize.translate('TabRepositories')
}];
}
const 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 + '>';
html += '<span class="cardImageIcon material-icons folder"></span>';
html += '</a>';
html += '</div>';
html += '<div class="cardFooter">';
html += "<div class='cardText'>";
html += plugin.name;
html += '</div>';
const installedPlugin = installedPlugins.filter(function (ip) {
return ip.Id == plugin.guid;
})[0];
html += "<div class='cardText cardText-secondary'>";
html += installedPlugin ? globalize.translate('LabelVersionInstalled', installedPlugin.Version) : '&nbsp;';
html += '</div>';
html += '</div>';
html += '</div>';
return html += '</div>';
}
window.PluginCatalog = {
renderCatalog: populateList
};
function getTabs() {
return [{
href: 'installedplugins.html',
name: globalize.translate('TabMyPlugins')
}, {
href: 'availableplugins.html',
name: globalize.translate('TabCatalog')
}, {
href: 'repositories.html',
name: globalize.translate('TabRepositories')
}];
}
return function (view, params) {
view.addEventListener('viewshow', function () {
libraryMenu.setTabs('plugins', 1, getTabs);
reloadList(this);
});
};
});
export default function (view) {
view.addEventListener('viewshow', function () {
libraryMenu.setTabs('plugins', 1, getTabs);
reloadList(this);
});
}

View File

@ -1,192 +1,193 @@
define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button'], function (loading, libraryMenu, dom, globalize) {
'use strict';
import loading from 'loading';
import libraryMenu from 'libraryMenu';
import dom from 'dom';
import globalize from 'globalize';
import 'cardStyle';
import 'emby-button';
loading = loading.default || loading;
function deletePlugin(page, uniqueid, name) {
const msg = globalize.translate('UninstallPluginConfirmation', name);
function deletePlugin(page, uniqueid, name) {
var msg = globalize.translate('UninstallPluginConfirmation', name);
require(['confirm'], function (confirm) {
confirm.default({
title: globalize.translate('HeaderUninstallPlugin'),
text: msg,
primary: 'delete',
confirmText: globalize.translate('HeaderUninstallPlugin')
}).then(function () {
loading.show();
ApiClient.uninstallPlugin(uniqueid).then(function () {
reloadList(page);
});
import('confirm').then(({default: confirm}) => {
confirm.default({
title: globalize.translate('HeaderUninstallPlugin'),
text: msg,
primary: 'delete',
confirmText: globalize.translate('HeaderUninstallPlugin')
}).then(function () {
loading.show();
ApiClient.uninstallPlugin(uniqueid).then(function () {
reloadList(page);
});
});
}
});
}
function showNoConfigurationMessage() {
Dashboard.alert({
message: globalize.translate('MessageNoPluginConfiguration')
});
}
function showNoConfigurationMessage() {
Dashboard.alert({
message: globalize.translate('MessageNoPluginConfiguration')
});
}
function showConnectMessage() {
Dashboard.alert({
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
});
}
function showConnectMessage() {
Dashboard.alert({
message: globalize.translate('MessagePluginConfigurationRequiresLocalAccess')
});
}
function getPluginCardHtml(plugin, pluginConfigurationPages) {
var configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
return pluginConfigurationPage.PluginId == plugin.Id;
})[0];
var configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
var html = '';
html += "<div data-id='" + plugin.Id + "' data-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
html += '<div class="cardBox visualCardBox">';
html += '<div class="cardScalable">';
html += '<div class="cardPadder cardPadder-backdrop"></div>';
html += configPageUrl ? '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + configPageUrl + '">' : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
html += '<span class="cardImageIcon material-icons folder"></span>';
html += configPageUrl ? '</a>' : '</div>';
function getPluginCardHtml(plugin, pluginConfigurationPages) {
const configPage = pluginConfigurationPages.filter(function (pluginConfigurationPage) {
return pluginConfigurationPage.PluginId == plugin.Id;
})[0];
const configPageUrl = configPage ? Dashboard.getConfigurationPageUrl(configPage.Name) : null;
let html = '';
html += "<div data-id='" + plugin.Id + "' data-name='" + plugin.Name + "' data-removable='" + plugin.CanUninstall + "' class='card backdropCard'>";
html += '<div class="cardBox visualCardBox">';
html += '<div class="cardScalable">';
html += '<div class="cardPadder cardPadder-backdrop"></div>';
html += configPageUrl ? '<a class="cardContent cardImageContainer" is="emby-linkbutton" href="' + configPageUrl + '">' : '<div class="cardContent noConfigPluginCard noHoverEffect cardImageContainer emby-button">';
html += '<span class="cardImageIcon material-icons folder"></span>';
html += configPageUrl ? '</a>' : '</div>';
html += '</div>';
html += '<div class="cardFooter">';
if (configPage || plugin.CanUninstall) {
html += '<div style="text-align:right; float:right;padding-top:5px;">';
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
html += '</div>';
html += '<div class="cardFooter">';
}
if (configPage || plugin.CanUninstall) {
html += '<div style="text-align:right; float:right;padding-top:5px;">';
html += '<button type="button" is="paper-icon-button-light" class="btnCardMenu autoSize"><span class="material-icons more_vert"></span></button>';
html += '</div>';
html += "<div class='cardText'>";
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
html += '</div>';
html += "<div class='cardText cardText-secondary'>";
html += plugin.Version;
html += '</div>';
html += '</div>';
html += '</div>';
html += '</div>';
return html;
}
function renderPlugins(page, plugins) {
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
populateList(page, plugins, configPages);
});
}
function populateList(page, plugins, pluginConfigurationPages) {
plugins = plugins.sort(function (plugin1, plugin2) {
if (plugin1.Name > plugin2.Name) {
return 1;
}
html += "<div class='cardText'>";
html += configPage && configPage.DisplayName ? configPage.DisplayName : plugin.Name;
html += '</div>';
html += "<div class='cardText cardText-secondary'>";
html += plugin.Version;
html += '</div>';
html += '</div>';
html += '</div>';
html += '</div>';
return html;
}
function renderPlugins(page, plugins) {
ApiClient.getJSON(ApiClient.getUrl('web/configurationpages') + '?pageType=PluginConfiguration').then(function (configPages) {
populateList(page, plugins, configPages);
});
}
function populateList(page, plugins, pluginConfigurationPages) {
plugins = plugins.sort(function (plugin1, plugin2) {
if (plugin1.Name > plugin2.Name) {
return 1;
}
return -1;
});
var html = plugins.map(function (p) {
return getPluginCardHtml(p, pluginConfigurationPages);
}).join('');
var installedPluginsElement = page.querySelector('.installedPlugins');
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
if (plugins.length) {
installedPluginsElement.classList.add('itemsContainer');
installedPluginsElement.classList.add('vertical-wrap');
} else {
html += '<div class="centerMessage">';
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
html += globalize.translate('MessageBrowsePluginCatalog');
html += '</a></p>';
html += '</div>';
}
installedPluginsElement.innerHTML = html;
loading.hide();
}
function showPluginMenu(page, elem) {
var card = dom.parentWithClass(elem, 'card');
var id = card.getAttribute('data-id');
var name = card.getAttribute('data-name');
var removable = card.getAttribute('data-removable');
var configHref = card.querySelector('.cardContent').getAttribute('href');
var menuItems = [];
if (configHref) {
menuItems.push({
name: globalize.translate('ButtonSettings'),
id: 'open',
icon: 'mode_edit'
});
}
if (removable === 'true') {
menuItems.push({
name: globalize.translate('ButtonUninstall'),
id: 'delete',
icon: 'delete'
});
}
require(['actionsheet'], function (actionsheet) {
actionsheet.show({
items: menuItems,
positionTo: elem,
callback: function (resultId) {
switch (resultId) {
case 'open':
Dashboard.navigate(configHref);
break;
case 'delete':
deletePlugin(page, id, name);
break;
}
}
});
});
}
function reloadList(page) {
loading.show();
ApiClient.getInstalledPlugins().then(function (plugins) {
renderPlugins(page, plugins);
});
}
function getTabs() {
return [{
href: 'installedplugins.html',
name: globalize.translate('TabMyPlugins')
}, {
href: 'availableplugins.html',
name: globalize.translate('TabCatalog')
}, {
href: 'repositories.html',
name: globalize.translate('TabRepositories')
}];
}
function onInstalledPluginsClick(e) {
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
showNoConfigurationMessage();
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
showConnectMessage();
} else {
var btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
if (btnCardMenu) {
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
}
}
}
pageIdOn('pageshow', 'pluginsPage', function () {
libraryMenu.setTabs('plugins', 0, getTabs);
reloadList(this);
return -1;
});
window.PluginsPage = {
renderPlugins: renderPlugins
};
let html = plugins.map(function (p) {
return getPluginCardHtml(p, pluginConfigurationPages);
}).join('');
const installedPluginsElement = page.querySelector('.installedPlugins');
installedPluginsElement.removeEventListener('click', onInstalledPluginsClick);
installedPluginsElement.addEventListener('click', onInstalledPluginsClick);
if (plugins.length) {
installedPluginsElement.classList.add('itemsContainer');
installedPluginsElement.classList.add('vertical-wrap');
} else {
html += '<div class="centerMessage">';
html += '<h1>' + globalize.translate('MessageNoPluginsInstalled') + '</h1>';
html += '<p><a is="emby-linkbutton" class="button-link" href="availableplugins.html">';
html += globalize.translate('MessageBrowsePluginCatalog');
html += '</a></p>';
html += '</div>';
}
installedPluginsElement.innerHTML = html;
loading.hide();
}
function showPluginMenu(page, elem) {
const card = dom.parentWithClass(elem, 'card');
const id = card.getAttribute('data-id');
const name = card.getAttribute('data-name');
const removable = card.getAttribute('data-removable');
const configHref = card.querySelector('.cardContent').getAttribute('href');
const menuItems = [];
if (configHref) {
menuItems.push({
name: globalize.translate('ButtonSettings'),
id: 'open',
icon: 'mode_edit'
});
}
if (removable === 'true') {
menuItems.push({
name: globalize.translate('ButtonUninstall'),
id: 'delete',
icon: 'delete'
});
}
import('actionsheet').then(({default: actionsheet}) => {
actionsheet.show({
items: menuItems,
positionTo: elem,
callback: function (resultId) {
switch (resultId) {
case 'open':
Dashboard.navigate(configHref);
break;
case 'delete':
deletePlugin(page, id, name);
break;
}
}
});
});
}
function reloadList(page) {
loading.show();
ApiClient.getInstalledPlugins().then(function (plugins) {
renderPlugins(page, plugins);
});
}
function getTabs() {
return [{
href: 'installedplugins.html',
name: globalize.translate('TabMyPlugins')
}, {
href: 'availableplugins.html',
name: globalize.translate('TabCatalog')
}, {
href: 'repositories.html',
name: globalize.translate('TabRepositories')
}];
}
function onInstalledPluginsClick(e) {
if (dom.parentWithClass(e.target, 'noConfigPluginCard')) {
showNoConfigurationMessage();
} else if (dom.parentWithClass(e.target, 'connectModePluginCard')) {
showConnectMessage();
} else {
const btnCardMenu = dom.parentWithClass(e.target, 'btnCardMenu');
if (btnCardMenu) {
showPluginMenu(dom.parentWithClass(btnCardMenu, 'page'), btnCardMenu);
}
}
}
pageIdOn('pageshow', 'pluginsPage', function () {
libraryMenu.setTabs('plugins', 0, getTabs);
reloadList(this);
});
window.PluginsPage = {
renderPlugins: renderPlugins
};

View File

@ -1,33 +1,30 @@
define(['loading', 'scripts/editorsidebar'], function (loading) {
'use strict';
import loading from 'loading';
import 'scripts/editorsidebar';
loading = loading.default || loading;
function reload(context, itemId) {
loading.show();
function reload(context, itemId) {
loading.show();
if (itemId) {
require(['metadataEditor'], function ({default: metadataEditor}) {
metadataEditor.embed(context.querySelector('.editPageInnerContent'), itemId, ApiClient.serverInfo().Id);
});
} else {
context.querySelector('.editPageInnerContent').innerHTML = '';
loading.hide();
}
if (itemId) {
import('metadataEditor').then(({ default: metadataEditor }) => {
metadataEditor.embed(context.querySelector('.editPageInnerContent'), itemId, ApiClient.serverInfo().Id);
});
} else {
context.querySelector('.editPageInnerContent').innerHTML = '';
loading.hide();
}
}
return function (view, params) {
view.addEventListener('viewshow', function () {
reload(this, MetadataEditor.getCurrentItemId());
});
MetadataEditor.setCurrentItemId(null);
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
var data = event.detail;
export default function (view, params) {
view.addEventListener('viewshow', function () {
reload(this, MetadataEditor.getCurrentItemId());
});
MetadataEditor.setCurrentItemId(null);
view.querySelector('.libraryTree').addEventListener('itemclicked', function (event) {
var data = event.detail;
if (data.id != MetadataEditor.getCurrentItemId()) {
MetadataEditor.setCurrentItemId(data.id);
reload(view, data.id);
}
});
};
});
if (data.id != MetadataEditor.getCurrentItemId()) {
MetadataEditor.setCurrentItemId(data.id);
reload(view, data.id);
}
});
}

View File

@ -1,5 +1,15 @@
define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'apphost', 'layoutManager', 'focusManager', 'emby-itemscontainer', 'emby-scroller'], function (appRouter, cardBuilder, dom, globalize, connectionManager, appHost, layoutManager, focusManager) {
'use strict';
import appRouter from 'appRouter';
import cardBuilder from 'cardBuilder';
import dom from 'dom';
import globalize from 'globalize';
import connectionManager from 'connectionManager';
import appHost from 'apphost';
import layoutManager from 'layoutManager';
import focusManager from 'focusManager';
import 'emby-itemscontainer';
import 'emby-scroller';
/* eslint-disable indent */
function enableScrollX() {
return true;
@ -133,8 +143,8 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
function getFetchDataFn(section) {
return function () {
var apiClient = this.apiClient;
var options = {
const apiClient = this.apiClient;
const options = {
SortBy: (section.types, 'SeriesName,SortName'),
SortOrder: 'Ascending',
Filters: 'IsFavorite',
@ -145,7 +155,7 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
EnableTotalRecordCount: false
};
options.Limit = 20;
var userId = apiClient.getCurrentUserId();
const userId = apiClient.getCurrentUserId();
if (section.types === 'MusicArtist') {
return apiClient.getArtists(userId, options);
@ -170,16 +180,16 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
function getItemsHtmlFn(section) {
return function (items) {
var cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
cardLayout = false;
var serverId = this.apiClient.serverId();
var leadingButtons = layoutManager.tv ? [{
const serverId = this.apiClient.serverId();
const leadingButtons = layoutManager.tv ? [{
name: globalize.translate('All'),
id: 'more',
icon: 'favorite',
routeUrl: getRouteUrl(section, serverId)
}] : null;
var lines = 0;
let lines = 0;
if (section.showTitle) {
lines++;
@ -215,23 +225,12 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
};
}
function FavoritesTab(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
createSections(this, this.sectionsContainer, this.apiClient);
}
function createSections(instance, elem, apiClient) {
var i;
var length;
var sections = getSections();
var html = '';
const sections = getSections();
let html = '';
for (i = 0, length = sections.length; i < length; i++) {
var section = sections[i];
var sectionClass = 'verticalSection';
for (const section of sections) {
let sectionClass = 'verticalSection';
if (!section.showTitle) {
sectionClass += ' verticalSection-extrabottompadding';
@ -257,23 +256,32 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
}
elem.innerHTML = html;
var elems = elem.querySelectorAll('.itemsContainer');
const elems = elem.querySelectorAll('.itemsContainer');
for (i = 0, length = elems.length; i < length; i++) {
var itemsContainer = elems[i];
for (let i = 0, length = elems.length; i < length; i++) {
const itemsContainer = elems[i];
itemsContainer.fetchData = getFetchDataFn(sections[i]).bind(instance);
itemsContainer.getItemsHtml = getItemsHtmlFn(sections[i]).bind(instance);
itemsContainer.parentContainer = dom.parentWithClass(itemsContainer, 'verticalSection');
}
}
FavoritesTab.prototype.onResume = function (options) {
var promises = (this.apiClient, []);
var view = this.view;
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
class FavoritesTab {
constructor(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
createSections(this, this.sectionsContainer, this.apiClient);
}
for (var i = 0, length = elems.length; i < length; i++) {
promises.push(elems[i].resume(options));
onResume(options) {
const promises = (this.apiClient, []);
const view = this.view;
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
for (const elem of elems) {
promises.push(elem.resume(options));
}
Promise.all(promises).then(function () {
@ -281,30 +289,32 @@ define(['appRouter', 'cardBuilder', 'dom', 'globalize', 'connectionManager', 'ap
focusManager.autoFocus(view);
}
});
};
}
FavoritesTab.prototype.onPause = function () {
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
onPause() {
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
for (var i = 0, length = elems.length; i < length; i++) {
elems[i].pause();
for (const elem of elems) {
elem.pause();
}
};
}
FavoritesTab.prototype.destroy = function () {
destroy() {
this.view = null;
this.params = null;
this.apiClient = null;
var elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
const elems = this.sectionsContainer.querySelectorAll('.itemsContainer');
for (var i = 0, length = elems.length; i < length; i++) {
elems[i].fetchData = null;
elems[i].getItemsHtml = null;
elems[i].parentContainer = null;
for (const elem of elems) {
elem.fetchData = null;
elem.getItemsHtml = null;
elem.parentContainer = null;
}
this.sectionsContainer = null;
};
}
}
return FavoritesTab;
});
export default FavoritesTab;
/* eslint-enable indent */

View File

@ -40,7 +40,7 @@ define(['tabbedView', 'globalize', 'require', 'emby-tabs', 'emby-button', 'emby-
var controller = instance.tabControllers[index];
if (!controller) {
controller = new controllerFactory(instance.view.querySelector(".tabContent[data-index='" + index + "']"), instance.params);
controller = new controllerFactory.default(instance.view.querySelector(".tabContent[data-index='" + index + "']"), instance.params);
instance.tabControllers[index] = controller;
}

View File

@ -1,29 +1,21 @@
define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManager', 'focusManager', 'homeSections', 'emby-itemscontainer'], function (userSettings, loading, connectionManager, appHost, layoutManager, focusManager, homeSections) {
'use strict';
import * as userSettings from 'userSettings';
import loading from 'loading';
import connectionManager from 'connectionManager';
import focusManager from 'focusManager';
import homeSections from 'homeSections';
import 'emby-itemscontainer';
loading = loading.default || loading;
function HomeTab(view, params) {
class HomeTab {
constructor(view, params) {
this.view = view;
this.params = params;
this.apiClient = connectionManager.currentApiClient();
this.sectionsContainer = view.querySelector('.sections');
view.querySelector('.sections').addEventListener('settingschange', onHomeScreenSettingsChanged.bind(this));
}
function onHomeScreenSettingsChanged() {
this.sectionsRendered = false;
if (!this.paused) {
this.onResume({
refresh: true
});
}
}
HomeTab.prototype.onResume = function (options) {
onResume(options) {
if (this.sectionsRendered) {
var sectionsContainer = this.sectionsContainer;
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
return homeSections.resume(sectionsContainer, options);
@ -33,8 +25,8 @@ define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManage
}
loading.show();
var view = this.view;
var apiClient = this.apiClient;
const view = this.view;
const apiClient = this.apiClient;
this.destroyHomeSections();
this.sectionsRendered = true;
return apiClient.getCurrentUser().then(function (user) {
@ -46,31 +38,38 @@ define(['userSettings', 'loading', 'connectionManager', 'apphost', 'layoutManage
loading.hide();
});
});
};
HomeTab.prototype.onPause = function () {
var sectionsContainer = this.sectionsContainer;
}
onPause() {
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
homeSections.pause(sectionsContainer);
}
};
HomeTab.prototype.destroy = function () {
}
destroy() {
this.view = null;
this.params = null;
this.apiClient = null;
this.destroyHomeSections();
this.sectionsContainer = null;
};
HomeTab.prototype.destroyHomeSections = function () {
var sectionsContainer = this.sectionsContainer;
}
destroyHomeSections() {
const sectionsContainer = this.sectionsContainer;
if (sectionsContainer) {
homeSections.destroySections(sectionsContainer);
}
};
}
}
return HomeTab;
});
function onHomeScreenSettingsChanged() {
this.sectionsRendered = false;
if (!this.paused) {
this.onResume({
refresh: true
});
}
}
export default HomeTab;

View File

@ -1,3 +1,4 @@
import appHost from 'apphost';
import loading from 'loading';
import appRouter from 'appRouter';
import layoutManager from 'layoutManager';
@ -657,7 +658,7 @@ import 'emby-select';
setPeopleHeader(page, item);
loading.hide();
if (item.Type === 'Book') {
if (item.Type === 'Book' && item.CanDownload && appHost.supports('filedownload')) {
hideAll(page, 'btnDownload', true);
}

View File

@ -1,11 +1,21 @@
define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager', 'cardBuilder', 'loading', 'connectionManager', 'alphaNumericShortcuts', 'scroller', 'playbackManager', 'alphaPicker', 'emby-itemscontainer', 'emby-scroller'], function (globalize, listView, layoutManager, userSettings, focusManager, cardBuilder, loading, connectionManager, AlphaNumericShortcuts, scroller, playbackManager, AlphaPicker) {
'use strict';
import globalize from 'globalize';
import listView from 'listView';
import layoutManager from 'layoutManager';
import * as userSettings from 'userSettings';
import focusManager from 'focusManager';
import cardBuilder from 'cardBuilder';
import loading from 'loading';
import connectionManager from 'connectionManager';
import AlphaNumericShortcuts from 'alphaNumericShortcuts';
import playbackManager from 'playbackManager';
import AlphaPicker from 'alphaPicker';
import 'emby-itemscontainer';
import 'emby-scroller';
playbackManager = playbackManager.default || playbackManager;
loading = loading.default || loading;
/* eslint-disable indent */
function getInitialLiveTvQuery(instance, params) {
var query = {
const query = {
UserId: connectionManager.getApiClient(params.serverId).getCurrentUserId(),
StartIndex: 0,
Fields: 'ChannelInfo,PrimaryImageAspectRatio',
@ -62,7 +72,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function modifyQueryWithFilters(instance, query) {
var sortValues = instance.getSortValues();
const sortValues = instance.getSortValues();
if (!query.SortBy) {
query.SortBy = sortValues.sortBy;
@ -71,9 +81,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
query.Fields = query.Fields ? query.Fields + ',PrimaryImageAspectRatio' : 'PrimaryImageAspectRatio';
query.ImageTypeLimit = 1;
var hasFilters;
var queryFilters = [];
var filters = instance.getFilters();
let hasFilters;
const queryFilters = [];
const filters = instance.getFilters();
if (filters.IsPlayed) {
queryFilters.push('IsPlayed');
@ -167,21 +177,21 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function updateSortText(instance) {
var btnSortText = instance.btnSortText;
const btnSortText = instance.btnSortText;
if (btnSortText) {
var options = instance.getSortMenuOptions();
var values = instance.getSortValues();
var sortBy = values.sortBy;
const options = instance.getSortMenuOptions();
const values = instance.getSortValues();
const sortBy = values.sortBy;
for (var i = 0, length = options.length; i < length; i++) {
if (sortBy === options[i].value) {
btnSortText.innerHTML = globalize.translate('SortByValue', options[i].name);
for (const option of options) {
if (sortBy === option.value) {
btnSortText.innerHTML = globalize.translate('SortByValue', option.name);
break;
}
}
var btnSortIcon = instance.btnSortIcon;
const btnSortIcon = instance.btnSortIcon;
if (btnSortIcon) {
setSortButtonIcon(btnSortIcon, values.sortOrder === 'Descending' ? 'arrow_downward' : 'arrow_upward');
@ -201,10 +211,10 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
function updateAlphaPickerState(instance, numItems) {
if (instance.alphaPicker) {
var alphaPicker = instance.alphaPickerElement;
const alphaPicker = instance.alphaPickerElement;
if (alphaPicker) {
var values = instance.getSortValues();
const values = instance.getSortValues();
if (numItems == null) {
numItems = 100;
@ -222,7 +232,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function getItems(instance, params, item, sortBy, startIndex, limit) {
var apiClient = connectionManager.getApiClient(params.serverId);
const apiClient = connectionManager.getApiClient(params.serverId);
instance.queryRecursive = false;
if (params.type === 'Recordings') {
@ -251,7 +261,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
if (!item) {
instance.queryRecursive = true;
var method = 'getItems';
let method = 'getItems';
if (params.type === 'MusicArtist') {
method = 'getArtists';
@ -274,7 +284,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
if (item.Type === 'Genre' || item.Type === 'MusicGenre' || item.Type === 'Studio' || item.Type === 'Person') {
instance.queryRecursive = true;
var query = {
const query = {
StartIndex: startIndex,
Limit: limit,
Fields: 'PrimaryImageAspectRatio,SortName',
@ -323,8 +333,8 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
return Promise.resolve(null);
}
var apiClient = connectionManager.getApiClient(params.serverId);
var itemId = params.genreId || params.musicGenreId || params.studioId || params.personId || params.parentId;
const apiClient = connectionManager.getApiClient(params.serverId);
const itemId = params.genreId || params.musicGenreId || params.studioId || params.personId || params.parentId;
if (itemId) {
return apiClient.getItem(apiClient.getCurrentUserId(), itemId);
@ -334,9 +344,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function showViewSettingsMenu() {
var instance = this;
const instance = this;
require(['viewSettings'], function (ViewSettings) {
import('viewSettings').then(({default: ViewSettings}) => {
new ViewSettings().show({
settingsKey: instance.getSettingsKey(),
settings: instance.getViewSettings(),
@ -349,9 +359,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function showFilterMenu() {
var instance = this;
const instance = this;
require(['filterMenu'], function (FilterMenu) {
import('filterMenu').then(({default: FilterMenu}) => {
new FilterMenu().show({
settingsKey: instance.getSettingsKey(),
settings: instance.getFilters(),
@ -368,9 +378,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function showSortMenu() {
var instance = this;
const instance = this;
require(['sortMenu'], function (SortMenu) {
import('sortMenu').then(({default: SortMenu}) => {
new SortMenu().show({
settingsKey: instance.getSettingsKey(),
settings: instance.getSortValues(),
@ -386,10 +396,10 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function onNewItemClick() {
var instance = this;
const instance = this;
require(['playlistEditor'], function (playlistEditor) {
new playlistEditor.showEditor({
import('playlistEditor').then(({default: playlistEditor}) => {
new playlistEditor({
items: [],
serverId: instance.params.serverId
});
@ -397,22 +407,23 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function hideOrShowAll(elems, hide) {
for (var i = 0, length = elems.length; i < length; i++) {
for (const elem of elems) {
if (hide) {
elems[i].classList.add('hide');
elem.classList.add('hide');
} else {
elems[i].classList.remove('hide');
elem.classList.remove('hide');
}
}
}
function bindAll(elems, eventName, fn) {
for (var i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener(eventName, fn);
for (const elem of elems) {
elem.addEventListener(eventName, fn);
}
}
function ItemsView(view, params) {
class ItemsView {
constructor(view, params) {
function fetchData() {
return getItems(self, params, self.currentItem).then(function (result) {
if (self.totalItemCount == null) {
@ -425,7 +436,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function getItemsHtml(items) {
var settings = self.getViewSettings();
const settings = self.getViewSettings();
if (settings.imageType === 'list') {
return listView.getListViewHtml({
@ -433,13 +444,13 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
});
}
var shape;
var preferThumb;
var preferDisc;
var preferLogo;
var defaultShape;
var item = self.currentItem;
var lines = settings.showTitle ? 2 : 0;
let shape;
let preferThumb;
let preferDisc;
let preferLogo;
let defaultShape;
const item = self.currentItem;
let lines = settings.showTitle ? 2 : 0;
if (settings.imageType === 'banner') {
shape = 'banner';
@ -463,7 +474,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
shape = 'autoVertical';
}
var posterOptions = {
let posterOptions = {
shape: shape,
showTitle: settings.showTitle,
showYear: settings.showTitle,
@ -496,19 +507,19 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
lines = 1;
} else if (params.type === 'Programs') {
lines = settings.showTitle ? 1 : 0;
var showParentTitle = settings.showTitle && params.IsMovie !== 'true';
const showParentTitle = settings.showTitle && params.IsMovie !== 'true';
if (showParentTitle) {
lines++;
}
var showAirTime = settings.showTitle && params.type !== 'Recordings';
const showAirTime = settings.showTitle && params.type !== 'Recordings';
if (showAirTime) {
lines++;
}
var showYear = settings.showTitle && params.IsMovie === 'true' && params.type === 'Recordings';
const showYear = settings.showTitle && params.IsMovie === 'true' && params.type === 'Recordings';
if (showYear) {
lines++;
@ -541,13 +552,13 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
function initAlphaPicker() {
self.scroller = view.querySelector('.scrollFrameY');
var alphaPickerElement = self.alphaPickerElement;
const alphaPickerElement = self.alphaPickerElement;
alphaPickerElement.classList.add('alphaPicker-fixed-right');
alphaPickerElement.classList.add('focuscontainer-right');
self.itemsContainer.parentNode.classList.add('padded-right-withalphapicker');
self.alphaPicker = new AlphaPicker.default({
self.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
itemsContainer: layoutManager.tv ? self.itemsContainer : null,
itemClass: 'card',
@ -652,7 +663,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function play() {
var currentItem = self.currentItem;
const currentItem = self.currentItem;
if (currentItem && !self.hasFilters) {
playbackManager.play({
@ -668,7 +679,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function queue() {
var currentItem = self.currentItem;
const currentItem = self.currentItem;
if (currentItem && !self.hasFilters) {
playbackManager.queue({
@ -684,7 +695,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
function shuffle() {
var currentItem = self.currentItem;
const currentItem = self.currentItem;
if (currentItem && !self.hasFilters) {
playbackManager.shuffle(currentItem);
@ -697,7 +708,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
}
var self = this;
const self = this;
self.params = params;
this.itemsContainer = view.querySelector('.itemsContainer');
@ -711,20 +722,17 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
this.itemsContainer.setAttribute('data-refreshinterval', '300000');
}
var i;
var length;
var btnViewSettings = view.querySelectorAll('.btnViewSettings');
const btnViewSettings = view.querySelectorAll('.btnViewSettings');
for (i = 0, length = btnViewSettings.length; i < length; i++) {
btnViewSettings[i].addEventListener('click', showViewSettingsMenu.bind(this));
for (const btnViewSetting of btnViewSettings) {
btnViewSetting.addEventListener('click', showViewSettingsMenu.bind(this));
}
var filterButtons = view.querySelectorAll('.btnFilter');
const filterButtons = view.querySelectorAll('.btnFilter');
this.filterButtons = filterButtons;
var hasVisibleFilters = this.getVisibleFilters().length;
const hasVisibleFilters = this.getVisibleFilters().length;
for (i = 0, length = filterButtons.length; i < length; i++) {
var btnFilter = filterButtons[i];
for (const btnFilter of filterButtons) {
btnFilter.addEventListener('click', showFilterMenu.bind(this));
if (hasVisibleFilters) {
@ -734,10 +742,10 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
}
var sortButtons = view.querySelectorAll('.btnSort');
const sortButtons = view.querySelectorAll('.btnSort');
for (this.sortButtons = sortButtons, i = 0, length = sortButtons.length; i < length; i++) {
var sortButton = sortButtons[i];
this.sortButtons = sortButtons;
for (const sortButton of sortButtons) {
sortButton.addEventListener('click', showSortMenu.bind(this));
if (params.type !== 'nextup') {
@ -752,7 +760,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
self.itemsContainer.fetchData = fetchData;
self.itemsContainer.getItemsHtml = getItemsHtml;
view.addEventListener('viewshow', function (e) {
var isRestored = e.detail.isRestored;
const isRestored = e.detail.isRestored;
if (!isRestored) {
loading.show();
@ -764,7 +772,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
getItem(params).then(function (item) {
setTitle(item);
self.currentItem = item;
var refresh = !isRestored;
const refresh = !isRestored;
self.itemsContainer.resume({
refresh: refresh
}).then(function () {
@ -779,7 +787,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
initAlphaPicker();
}
var itemType = item ? item.Type : null;
const itemType = item ? item.Type : null;
if (itemType === 'MusicGenre' || params.type !== 'Programs' && itemType !== 'Channel') {
hideOrShowAll(view.querySelectorAll('.btnPlay'), false);
@ -806,18 +814,18 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
bindAll(view.querySelectorAll('.btnShuffle'), 'click', shuffle);
}
self.alphaNumericShortcuts = new AlphaNumericShortcuts.default({
self.alphaNumericShortcuts = new AlphaNumericShortcuts({
itemsContainer: self.itemsContainer
});
});
view.addEventListener('viewhide', function (e) {
var itemsContainer = self.itemsContainer;
const itemsContainer = self.itemsContainer;
if (itemsContainer) {
itemsContainer.pause();
}
var alphaNumericShortcuts = self.alphaNumericShortcuts;
const alphaNumericShortcuts = self.alphaNumericShortcuts;
if (alphaNumericShortcuts) {
alphaNumericShortcuts.destroy();
@ -845,8 +853,8 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
});
}
ItemsView.prototype.getFilters = function () {
var basekey = this.getSettingsKey();
getFilters() {
const basekey = this.getSettingsKey();
return {
IsPlayed: userSettings.getFilter(basekey + '-filter-IsPlayed') === 'true',
IsUnplayed: userSettings.getFilter(basekey + '-filter-IsUnplayed') === 'true',
@ -865,39 +873,37 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
HasThemeVideo: userSettings.getFilter(basekey + '-filter-HasThemeVideo'),
GenreIds: userSettings.getFilter(basekey + '-filter-GenreIds')
};
};
}
ItemsView.prototype.getSortValues = function () {
var basekey = this.getSettingsKey();
getSortValues() {
const basekey = this.getSettingsKey();
return {
sortBy: userSettings.getFilter(basekey + '-sortby') || this.getDefaultSortBy(),
sortOrder: userSettings.getFilter(basekey + '-sortorder') === 'Descending' ? 'Descending' : 'Ascending'
};
};
}
ItemsView.prototype.getDefaultSortBy = function () {
var params = this.params;
var sortNameOption = this.getNameSortOption(params);
getDefaultSortBy() {
const sortNameOption = this.getNameSortOption(this.params);
if (params.type) {
if (this.params.type) {
return sortNameOption.value;
}
return 'IsFolder,' + sortNameOption.value;
};
}
ItemsView.prototype.getSortMenuOptions = function () {
var sortBy = [];
var params = this.params;
getSortMenuOptions() {
const sortBy = [];
if (params.type === 'Programs') {
if (this.params.type === 'Programs') {
sortBy.push({
name: globalize.translate('AirDate'),
value: 'StartDate,SortName'
});
}
var option = this.getNameSortOption(params);
let option = this.getNameSortOption(this.params);
if (option) {
sortBy.push(option);
@ -915,7 +921,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
sortBy.push(option);
}
if (params.type !== 'Programs') {
if (this.params.type !== 'Programs') {
sortBy.push({
name: globalize.translate('DateAdded'),
value: 'DateCreated,SortName'
@ -928,8 +934,8 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
sortBy.push(option);
}
if (!params.type) {
option = this.getNameSortOption(params);
if (!this.params.type) {
option = this.getNameSortOption(this.params);
sortBy.push({
name: globalize.translate('Folders'),
value: 'IsFolder,' + option.value
@ -955,9 +961,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
value: 'Runtime,SortName'
});
return sortBy;
};
}
ItemsView.prototype.getNameSortOption = function (params) {
getNameSortOption(params) {
if (params.type === 'Episode') {
return {
name: globalize.translate('Name'),
@ -969,9 +975,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
name: globalize.translate('Name'),
value: 'SortName'
};
};
}
ItemsView.prototype.getPlayCountSortOption = function () {
getPlayCountSortOption() {
if (this.params.type === 'Programs') {
return null;
}
@ -980,9 +986,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
name: globalize.translate('PlayCount'),
value: 'PlayCount,SortName'
};
};
}
ItemsView.prototype.getDatePlayedSortOption = function () {
getDatePlayedSortOption() {
if (this.params.type === 'Programs') {
return null;
}
@ -991,9 +997,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
name: globalize.translate('DatePlayed'),
value: 'DatePlayed,SortName'
};
};
}
ItemsView.prototype.getCriticRatingSortOption = function () {
getCriticRatingSortOption() {
if (this.params.type === 'Programs') {
return null;
}
@ -1002,18 +1008,18 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
name: globalize.translate('CriticRating'),
value: 'CriticRating,SortName'
};
};
}
ItemsView.prototype.getCommunityRatingSortOption = function () {
getCommunityRatingSortOption() {
return {
name: globalize.translate('CommunityRating'),
value: 'CommunityRating,SortName'
};
};
}
ItemsView.prototype.getVisibleFilters = function () {
var filters = [];
var params = this.params;
getVisibleFilters() {
const filters = [];
const params = this.params;
if (!(params.type === 'nextup')) {
if (params.type === 'Programs') {
@ -1037,16 +1043,15 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
return filters;
};
}
ItemsView.prototype.setFilterStatus = function (hasFilters) {
setFilterStatus(hasFilters) {
this.hasFilters = hasFilters;
var filterButtons = this.filterButtons;
const filterButtons = this.filterButtons;
if (filterButtons.length) {
for (var i = 0, length = filterButtons.length; i < length; i++) {
var btnFilter = filterButtons[i];
var bubble = btnFilter.querySelector('.filterButtonBubble');
for (const btnFilter of filterButtons) {
let bubble = btnFilter.querySelector('.filterButtonBubble');
if (!bubble) {
if (!hasFilters) {
@ -1065,10 +1070,10 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
}
}
};
}
ItemsView.prototype.getFilterMenuOptions = function () {
var params = this.params;
getFilterMenuOptions() {
const params = this.params;
return {
IsAiring: params.IsAiring,
IsMovie: params.IsMovie,
@ -1078,11 +1083,11 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
IsSeries: params.IsSeries,
Recursive: this.queryRecursive
};
};
}
ItemsView.prototype.getVisibleViewSettings = function () {
var item = (this.params, this.currentItem);
var fields = ['showTitle'];
getVisibleViewSettings() {
const item = (this.params, this.currentItem);
const fields = ['showTitle'];
if (!item || item.Type !== 'PhotoAlbum' && item.Type !== 'ChannelFolderItem') {
fields.push('imageType');
@ -1090,13 +1095,13 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
fields.push('viewType');
return fields;
};
}
ItemsView.prototype.getViewSettings = function () {
var basekey = this.getSettingsKey();
var params = this.params;
var item = this.currentItem;
var showTitle = userSettings.get(basekey + '-showTitle');
getViewSettings() {
const basekey = this.getSettingsKey();
const params = this.params;
const item = this.currentItem;
let showTitle = userSettings.get(basekey + '-showTitle');
if (showTitle === 'true') {
showTitle = true;
@ -1108,7 +1113,7 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
showTitle = true;
}
var imageType = userSettings.get(basekey + '-imageType');
let imageType = userSettings.get(basekey + '-imageType');
if (!imageType && params.type === 'nextup') {
imageType = 'thumb';
@ -1120,10 +1125,10 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
imageType: imageType || 'primary',
viewType: userSettings.get(basekey + '-viewType') || 'images'
};
};
}
ItemsView.prototype.getItemTypes = function () {
var params = this.params;
getItemTypes() {
const params = this.params;
if (params.type === 'nextup') {
return ['Episode'];
@ -1134,12 +1139,12 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
return [];
};
}
ItemsView.prototype.getSettingsKey = function () {
var values = [];
getSettingsKey() {
const values = [];
values.push('items');
var params = this.params;
const params = this.params;
if (params.type) {
values.push(params.type);
@ -1196,7 +1201,9 @@ define(['globalize', 'listView', 'layoutManager', 'userSettings', 'focusManager'
}
return values.join('-');
};
}
}
return ItemsView;
});
export default ItemsView;
/* eslint-enable indent */

View File

@ -1,133 +1,134 @@
define(['cardBuilder', 'imageLoader', 'libraryBrowser', 'loading', 'events', 'userSettings', 'emby-itemscontainer'], function (cardBuilder, imageLoader, libraryBrowser, loading, events, userSettings) {
'use strict';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
import libraryBrowser from 'libraryBrowser';
import loading from 'loading';
import events from 'events';
import * as userSettings from 'userSettings';
import 'emby-itemscontainer';
loading = loading.default || loading;
libraryBrowser = libraryBrowser.default || libraryBrowser;
export default function (view, params, tabContent) {
function getPageData() {
if (!pageData) {
pageData = {
query: {
StartIndex: 0,
Fields: 'PrimaryImageAspectRatio'
}
};
}
return function (view, params, tabContent) {
function getPageData() {
if (!pageData) {
pageData = {
query: {
StartIndex: 0,
Fields: 'PrimaryImageAspectRatio'
}
};
if (userSettings.libraryPageSize() > 0) {
pageData.query['Limit'] = userSettings.libraryPageSize();
}
return pageData;
}
function getQuery() {
return getPageData().query;
}
function getChannelsHtml(channels) {
return cardBuilder.getCardsHtml({
items: channels,
shape: 'square',
showTitle: true,
lazy: true,
cardLayout: true,
showDetailsMenu: true,
showCurrentProgram: true,
showCurrentProgramTime: true
});
}
function renderChannels(context, result) {
function onNextPageClick() {
if (isLoading) {
return;
}
if (userSettings.libraryPageSize() > 0) {
pageData.query['Limit'] = userSettings.libraryPageSize();
query.StartIndex += query.Limit;
}
reloadItems(context);
}
function onPreviousPageClick() {
if (isLoading) {
return;
}
return pageData;
}
function getQuery() {
return getPageData().query;
}
function getChannelsHtml(channels) {
return cardBuilder.getCardsHtml({
items: channels,
shape: 'square',
showTitle: true,
lazy: true,
cardLayout: true,
showDetailsMenu: true,
showCurrentProgram: true,
showCurrentProgramTime: true
});
}
function renderChannels(context, result) {
function onNextPageClick() {
if (isLoading) {
return;
}
if (userSettings.libraryPageSize() > 0) {
query.StartIndex += query.Limit;
}
reloadItems(context);
}
function onPreviousPageClick() {
if (isLoading) {
return;
}
if (userSettings.libraryPageSize() > 0) {
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
}
reloadItems(context);
}
var query = getQuery();
context.querySelector('.paging').innerHTML = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
showLimit: false,
updatePageSizeSetting: false,
filterButton: false
});
var html = getChannelsHtml(result.Items);
var elem = context.querySelector('#items');
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
var i;
var length;
var elems;
for (elems = context.querySelectorAll('.btnNextPage'), i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onNextPageClick);
}
for (elems = context.querySelectorAll('.btnPreviousPage'), i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onPreviousPageClick);
if (userSettings.libraryPageSize() > 0) {
query.StartIndex = Math.max(0, query.StartIndex - query.Limit);
}
reloadItems(context);
}
function showFilterMenu(context) {
require(['components/filterdialog/filterdialog'], function ({default: filterDialogFactory}) {
var filterDialog = new filterDialogFactory({
query: getQuery(),
mode: 'livetvchannels',
serverId: ApiClient.serverId()
});
events.on(filterDialog, 'filterchange', function () {
reloadItems(context);
});
filterDialog.show();
});
}
function reloadItems(context, save) {
loading.show();
isLoading = true;
var query = getQuery();
var apiClient = ApiClient;
query.UserId = apiClient.getCurrentUserId();
apiClient.getLiveTvChannels(query).then(function (result) {
renderChannels(context, result);
loading.hide();
isLoading = false;
require(['autoFocuser'], function (autoFocuser) {
autoFocuser.autoFocus(view);
});
});
}
var pageData;
var self = this;
var isLoading = false;
tabContent.querySelector('.btnFilter').addEventListener('click', function () {
showFilterMenu(tabContent);
const query = getQuery();
context.querySelector('.paging').innerHTML = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
showLimit: false,
updatePageSizeSetting: false,
filterButton: false
});
const html = getChannelsHtml(result.Items);
const elem = context.querySelector('#items');
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
let i;
let length;
let elems;
self.renderTab = function () {
reloadItems(tabContent);
};
for (elems = context.querySelectorAll('.btnNextPage'), i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onNextPageClick);
}
for (elems = context.querySelectorAll('.btnPreviousPage'), i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onPreviousPageClick);
}
}
function showFilterMenu(context) {
import(['components/filterdialog/filterdialog']).then(({default: FilterDialog}) => {
const filterDialog = new FilterDialog({
query: getQuery(),
mode: 'livetvchannels',
serverId: ApiClient.serverId()
});
events.on(filterDialog, 'filterchange', function () {
reloadItems(context);
});
filterDialog.show();
});
}
function reloadItems(context, save) {
loading.show();
isLoading = true;
const query = getQuery();
const apiClient = ApiClient;
query.UserId = apiClient.getCurrentUserId();
apiClient.getLiveTvChannels(query).then(function (result) {
renderChannels(context, result);
loading.hide();
isLoading = false;
import('autoFocuser').then(({default: autoFocuser}) => {
autoFocuser.autoFocus(view);
});
});
}
let pageData;
const self = this;
let isLoading = false;
tabContent.querySelector('.btnFilter').addEventListener('click', function () {
showFilterMenu(tabContent);
});
self.renderTab = function () {
reloadItems(tabContent);
};
});
}

View File

@ -1,111 +1,112 @@
define(['layoutManager', 'loading', 'cardBuilder', 'apphost', 'imageLoader', 'scripts/livetvcomponents', 'listViewStyle', 'emby-itemscontainer'], function (layoutManager, loading, cardBuilder, appHost, imageLoader) {
'use strict';
import loading from 'loading';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
import 'scripts/livetvcomponents';
import 'listViewStyle';
import 'emby-itemscontainer';
loading = loading.default || loading;
function renderRecordings(elem, recordings, cardOptions, scrollX) {
if (!elem) {
return;
}
if (recordings.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
var recordingItems = elem.querySelector('.recordingItems');
if (scrollX) {
recordingItems.classList.add('scrollX');
recordingItems.classList.add('hiddenScrollX');
recordingItems.classList.remove('vertical-wrap');
} else {
recordingItems.classList.remove('scrollX');
recordingItems.classList.remove('hiddenScrollX');
recordingItems.classList.add('vertical-wrap');
}
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
items: recordings,
shape: scrollX ? 'autooverflow' : 'auto',
defaultShape: scrollX ? 'overflowBackdrop' : 'backdrop',
showTitle: true,
showParentTitle: true,
coverImage: true,
cardLayout: false,
centerText: true,
allowBottomPadding: !scrollX,
preferThumb: 'auto',
overlayText: false
}, cardOptions || {}));
imageLoader.lazyChildren(recordingItems);
function renderRecordings(elem, recordings, cardOptions, scrollX) {
if (!elem) {
return;
}
function renderLatestRecordings(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#latestRecordings'), result.Items, {
showYear: true,
lines: 2
}, false);
loading.hide();
});
if (recordings.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
function renderRecordingFolders(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#recordingFolders'), result.Items, {
showYear: false,
showParentTitle: false
}, false);
});
const recordingItems = elem.querySelector('.recordingItems');
if (scrollX) {
recordingItems.classList.add('scrollX');
recordingItems.classList.add('hiddenScrollX');
recordingItems.classList.remove('vertical-wrap');
} else {
recordingItems.classList.remove('scrollX');
recordingItems.classList.remove('hiddenScrollX');
recordingItems.classList.add('vertical-wrap');
}
function onMoreClick(e) {
var type = this.getAttribute('data-type');
var serverId = ApiClient.serverId();
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
items: recordings,
shape: scrollX ? 'autooverflow' : 'auto',
defaultShape: scrollX ? 'overflowBackdrop' : 'backdrop',
showTitle: true,
showParentTitle: true,
coverImage: true,
cardLayout: false,
centerText: true,
allowBottomPadding: !scrollX,
preferThumb: 'auto',
overlayText: false
}, cardOptions || {}));
imageLoader.lazyChildren(recordingItems);
}
switch (type) {
case 'latest':
Dashboard.navigate('list.html?type=Recordings&serverId=' + serverId);
}
function renderLatestRecordings(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#latestRecordings'), result.Items, {
showYear: true,
lines: 2
}, false);
loading.hide();
});
}
function renderRecordingFolders(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#recordingFolders'), result.Items, {
showYear: false,
showParentTitle: false
}, false);
});
}
function onMoreClick(e) {
const type = this.getAttribute('data-type');
const serverId = ApiClient.serverId();
switch (type) {
case 'latest':
Dashboard.navigate('list.html?type=Recordings&serverId=' + serverId);
}
}
export default function (view, params, tabContent) {
function enableFullRender() {
return new Date().getTime() - lastFullRender > 300000;
}
return function (view, params, tabContent) {
function enableFullRender() {
return new Date().getTime() - lastFullRender > 300000;
let foldersPromise;
let latestPromise;
const self = this;
let lastFullRender = 0;
const moreButtons = tabContent.querySelectorAll('.more');
for (let i = 0, length = moreButtons.length; i < length; i++) {
moreButtons[i].addEventListener('click', onMoreClick);
}
self.preRender = function () {
if (enableFullRender()) {
latestPromise = ApiClient.getLiveTvRecordings({
UserId: Dashboard.getCurrentUserId(),
Limit: 12,
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
EnableTotalRecordCount: false,
EnableImageTypes: 'Primary,Thumb,Backdrop'
});
foldersPromise = ApiClient.getRecordingFolders(Dashboard.getCurrentUserId());
}
var foldersPromise;
var latestPromise;
var self = this;
var lastFullRender = 0;
var moreButtons = tabContent.querySelectorAll('.more');
for (var i = 0, length = moreButtons.length; i < length; i++) {
moreButtons[i].addEventListener('click', onMoreClick);
}
self.preRender = function () {
if (enableFullRender()) {
latestPromise = ApiClient.getLiveTvRecordings({
UserId: Dashboard.getCurrentUserId(),
Limit: 12,
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
EnableTotalRecordCount: false,
EnableImageTypes: 'Primary,Thumb,Backdrop'
});
foldersPromise = ApiClient.getRecordingFolders(Dashboard.getCurrentUserId());
}
};
self.renderTab = function () {
if (enableFullRender()) {
loading.show();
renderLatestRecordings(tabContent, latestPromise);
renderRecordingFolders(tabContent, foldersPromise);
lastFullRender = new Date().getTime();
}
};
};
});
self.renderTab = function () {
if (enableFullRender()) {
loading.show();
renderLatestRecordings(tabContent, latestPromise);
renderRecordingFolders(tabContent, foldersPromise);
lastFullRender = new Date().getTime();
}
};
}

View File

@ -1,122 +1,124 @@
define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'scripts/livetvcomponents', 'emby-button', 'emby-itemscontainer'], function (layoutManager, cardBuilder, appHost, imageLoader, loading) {
'use strict';
import layoutManager from 'layoutManager';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
import loading from 'loading';
import 'scripts/livetvcomponents';
import 'emby-button';
import 'emby-itemscontainer';
loading = loading.default || loading;
function enableScrollX() {
return !layoutManager.desktop;
}
function enableScrollX() {
return !layoutManager.desktop;
function renderRecordings(elem, recordings, cardOptions) {
if (recordings.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
function renderRecordings(elem, recordings, cardOptions) {
if (recordings.length) {
const recordingItems = elem.querySelector('.recordingItems');
if (enableScrollX()) {
recordingItems.classList.add('scrollX');
if (layoutManager.tv) {
recordingItems.classList.add('smoothScrollX');
}
recordingItems.classList.add('hiddenScrollX');
recordingItems.classList.remove('vertical-wrap');
} else {
recordingItems.classList.remove('scrollX');
recordingItems.classList.remove('smoothScrollX');
recordingItems.classList.remove('hiddenScrollX');
recordingItems.classList.add('vertical-wrap');
}
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
items: recordings,
shape: enableScrollX() ? 'autooverflow' : 'auto',
showTitle: true,
showParentTitle: true,
coverImage: true,
cardLayout: false,
centerText: true,
allowBottomPadding: !enableScrollX(),
preferThumb: 'auto'
}, cardOptions || {}));
imageLoader.lazyChildren(recordingItems);
}
function getBackdropShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
function renderActiveRecordings(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
shape: enableScrollX() ? 'autooverflow' : 'auto',
defaultShape: getBackdropShape(),
showParentTitle: false,
showParentTitleOrTitle: true,
showTitle: false,
showAirTime: true,
showAirEndTime: true,
showChannelName: true,
coverImage: true,
overlayText: false,
overlayMoreButton: true
});
});
}
function renderTimers(context, timers, options) {
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
const elem = context;
if (html) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
var recordingItems = elem.querySelector('.recordingItems');
elem.querySelector('.recordingItems').innerHTML = html;
imageLoader.lazyChildren(elem);
});
}
if (enableScrollX()) {
recordingItems.classList.add('scrollX');
function renderUpcomingRecordings(context, promise) {
promise.then(function (result) {
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
loading.hide();
});
}
if (layoutManager.tv) {
recordingItems.classList.add('smoothScrollX');
}
export default function (view, params, tabContent) {
let activeRecordingsPromise;
let upcomingRecordingsPromise;
const self = this;
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
self.preRender();
self.renderTab();
});
recordingItems.classList.add('hiddenScrollX');
recordingItems.classList.remove('vertical-wrap');
} else {
recordingItems.classList.remove('scrollX');
recordingItems.classList.remove('smoothScrollX');
recordingItems.classList.remove('hiddenScrollX');
recordingItems.classList.add('vertical-wrap');
}
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
items: recordings,
shape: enableScrollX() ? 'autooverflow' : 'auto',
showTitle: true,
showParentTitle: true,
coverImage: true,
cardLayout: false,
centerText: true,
allowBottomPadding: !enableScrollX(),
preferThumb: 'auto'
}, cardOptions || {}));
imageLoader.lazyChildren(recordingItems);
}
function getBackdropShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
function renderActiveRecordings(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
shape: enableScrollX() ? 'autooverflow' : 'auto',
defaultShape: getBackdropShape(),
showParentTitle: false,
showParentTitleOrTitle: true,
showTitle: false,
showAirTime: true,
showAirEndTime: true,
showChannelName: true,
coverImage: true,
overlayText: false,
overlayMoreButton: true
});
self.preRender = function () {
activeRecordingsPromise = ApiClient.getLiveTvRecordings({
UserId: Dashboard.getCurrentUserId(),
IsInProgress: true,
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
EnableTotalRecordCount: false,
EnableImageTypes: 'Primary,Thumb,Backdrop'
});
}
function renderTimers(context, timers, options) {
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
var elem = context;
if (html) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
elem.querySelector('.recordingItems').innerHTML = html;
imageLoader.lazyChildren(elem);
upcomingRecordingsPromise = ApiClient.getLiveTvTimers({
IsActive: false,
IsScheduled: true
});
}
function renderUpcomingRecordings(context, promise) {
promise.then(function (result) {
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
loading.hide();
});
}
return function (view, params, tabContent) {
var activeRecordingsPromise;
var upcomingRecordingsPromise;
var self = this;
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
self.preRender();
self.renderTab();
});
self.preRender = function () {
activeRecordingsPromise = ApiClient.getLiveTvRecordings({
UserId: Dashboard.getCurrentUserId(),
IsInProgress: true,
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
EnableTotalRecordCount: false,
EnableImageTypes: 'Primary,Thumb,Backdrop'
});
upcomingRecordingsPromise = ApiClient.getLiveTvTimers({
IsActive: false,
IsScheduled: true
});
};
self.renderTab = function () {
loading.show();
renderActiveRecordings(tabContent, activeRecordingsPromise);
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
};
};
});
self.renderTab = function () {
loading.show();
renderActiveRecordings(tabContent, activeRecordingsPromise);
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
};
}

View File

@ -1,52 +1,52 @@
define(['datetime', 'cardBuilder', 'imageLoader', 'apphost', 'loading', 'paper-icon-button-light', 'emby-button'], function (datetime, cardBuilder, imageLoader, appHost, loading) {
'use strict';
import cardBuilder from 'cardBuilder';
import imageLoader from 'imageLoader';
import loading from 'loading';
import 'paper-icon-button-light';
import 'emby-button';
loading = loading.default || loading;
function renderTimers(context, timers) {
const html = cardBuilder.getCardsHtml({
items: timers,
shape: 'auto',
defaultShape: 'portrait',
showTitle: true,
cardLayout: false,
preferThumb: 'auto',
coverImage: true,
overlayText: false,
showSeriesTimerTime: true,
showSeriesTimerChannel: true,
centerText: true,
overlayMoreButton: true,
lines: 3
});
const elem = context.querySelector('#items');
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
loading.hide();
}
function renderTimers(context, timers) {
var html = '';
html += cardBuilder.getCardsHtml({
items: timers,
shape: 'auto',
defaultShape: 'portrait',
showTitle: true,
cardLayout: false,
preferThumb: 'auto',
coverImage: true,
overlayText: false,
showSeriesTimerTime: true,
showSeriesTimerChannel: true,
centerText: true,
overlayMoreButton: true,
lines: 3
});
var elem = context.querySelector('#items');
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
loading.hide();
}
function reload(context, promise) {
loading.show();
promise.then(function (result) {
renderTimers(context, result.Items);
});
}
function reload(context, promise) {
loading.show();
promise.then(function (result) {
renderTimers(context, result.Items);
});
}
const query = {
SortBy: 'SortName',
SortOrder: 'Ascending'
};
var query = {
SortBy: 'SortName',
SortOrder: 'Ascending'
export default function (view, params, tabContent) {
let timersPromise;
const self = this;
self.preRender = function () {
timersPromise = ApiClient.getLiveTvSeriesTimers(query);
};
return function (view, params, tabContent) {
var timersPromise;
var self = this;
self.preRender = function () {
timersPromise = ApiClient.getLiveTvSeriesTimers(query);
};
self.renderTab = function () {
reload(tabContent, timersPromise);
};
self.renderTab = function () {
reload(tabContent, timersPromise);
};
});
}

View File

@ -2,6 +2,7 @@ define(['layoutManager', 'userSettings', 'inputManager', 'loading', 'globalize',
'use strict';
loading = loading.default || loading;
layoutManager = layoutManager.default || layoutManager;
function enableScrollX() {
return !layoutManager.desktop;
@ -169,9 +170,6 @@ define(['layoutManager', 'userSettings', 'inputManager', 'loading', 'globalize',
name: globalize.translate('HeaderSchedule')
}, {
name: globalize.translate('TabSeries')
}, {
name: globalize.translate('ButtonSearch'),
cssClass: 'searchTabButton'
}];
}
@ -255,9 +253,6 @@ define(['layoutManager', 'userSettings', 'inputManager', 'loading', 'globalize',
case 5:
depends.push('controllers/livetv/livetvseriestimers');
break;
case 6:
depends.push('scripts/searchtab');
}
require(depends, function (controllerFactory) {

View File

@ -1,32 +1,30 @@
define(['events', 'loading', 'globalize'], function (events, loading, globalize) {
'use strict';
import events from 'events';
import loading from 'loading';
import globalize from 'globalize';
loading = loading.default || loading;
function onListingsSubmitted() {
Dashboard.navigate('livetvstatus.html');
}
function onListingsSubmitted() {
Dashboard.navigate('livetvstatus.html');
}
function init(page, type, providerId) {
const url = 'components/tvproviders/' + type + '.js';
function init(page, type, providerId) {
var url = 'components/tvproviders/' + type + '.js';
require([url], function (factory) {
var instance = new factory(page, providerId, {});
events.on(instance, 'submitted', onListingsSubmitted);
instance.init();
});
}
function loadTemplate(page, type, providerId) {
require(['text!./components/tvproviders/' + type + '.template.html'], function (html) {
page.querySelector('.providerTemplate').innerHTML = globalize.translateHtml(html);
init(page, type, providerId);
});
}
pageIdOn('pageshow', 'liveTvGuideProviderPage', function () {
loading.show();
var providerId = getParameterByName('id');
loadTemplate(this, getParameterByName('type'), providerId);
import(url).then(({default: factory}) => {
const instance = new factory(page, providerId, {});
events.on(instance, 'submitted', onListingsSubmitted);
instance.init();
});
}
function loadTemplate(page, type, providerId) {
import('text!./../components/tvproviders/' + type + '.template.html').then(({default: html}) => {
page.querySelector('.providerTemplate').innerHTML = globalize.translateHtml(html);
init(page, type, providerId);
});
}
pageIdOn('pageshow', 'liveTvGuideProviderPage', function () {
loading.show();
const providerId = getParameterByName('id');
loadTemplate(this, getParameterByName('type'), providerId);
});

View File

@ -1,13 +1,18 @@
define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (loading, events, libraryBrowser, imageLoader, listView, cardBuilder, userSettings, globalize) {
'use strict';
import loading from 'loading';
import libraryBrowser from 'libraryBrowser';
import imageLoader from 'imageLoader';
import listView from 'listView';
import cardBuilder from 'cardBuilder';
import * as userSettings from 'userSettings';
import globalize from 'globalize';
import 'emby-itemscontainer';
loading = loading.default || loading;
libraryBrowser = libraryBrowser.default || libraryBrowser;
/* eslint-disable indent */
return function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData(context) {
var key = getSavedQueryKey(context);
var pageData = data[key];
const key = getSavedQueryKey(context);
let pageData = data[key];
if (!pageData) {
pageData = data[key] = {
@ -47,9 +52,9 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
return context.savedQueryKey;
}
function onViewStyleChange() {
var viewStyle = self.getCurrentViewStyle();
var itemsContainer = tabContent.querySelector('.itemsContainer');
const onViewStyleChange = () => {
const viewStyle = this.getCurrentViewStyle();
const itemsContainer = tabContent.querySelector('.itemsContainer');
if (viewStyle == 'List') {
itemsContainer.classList.add('vertical-list');
@ -60,13 +65,13 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
}
itemsContainer.innerHTML = '';
}
};
function reloadItems(page) {
const reloadItems = (page) => {
loading.show();
isLoading = true;
var query = getQuery(page);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function (result) {
const query = getQuery(page);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
function onNextPageClick() {
if (isLoading) {
return;
@ -90,8 +95,8 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
}
window.scrollTo(0, 0);
var html;
var pagingHtml = libraryBrowser.getQueryPagingHtml({
let html;
const pagingHtml = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
@ -101,7 +106,7 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
sortButton: false,
filterButton: false
});
var viewStyle = self.getCurrentViewStyle();
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'Thumb') {
html = cardBuilder.getCardsHtml({
items: result.Items,
@ -155,22 +160,21 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
showTitle: true
});
}
var i;
var length;
var elems = tabContent.querySelectorAll('.paging');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].innerHTML = pagingHtml;
let elems = tabContent.querySelectorAll('.paging');
for (const elem of elems) {
elem.innerHTML = pagingHtml;
}
elems = tabContent.querySelectorAll('.btnNextPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onNextPageClick);
for (const elem of elems) {
elem.addEventListener('click', onNextPageClick);
}
elems = tabContent.querySelectorAll('.btnPreviousPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onPreviousPageClick);
for (const elem of elems) {
elem.addEventListener('click', onPreviousPageClick);
}
if (!result.Items.length) {
@ -182,28 +186,27 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
html += '</div>';
}
var itemsContainer = tabContent.querySelector('.itemsContainer');
const itemsContainer = tabContent.querySelector('.itemsContainer');
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(page), query);
loading.hide();
isLoading = false;
require(['autoFocuser'], function (autoFocuser) {
import('autoFocuser').then(({default: autoFocuser}) => {
autoFocuser.autoFocus(page);
});
});
}
};
var self = this;
var data = {};
var isLoading = false;
const data = {};
let isLoading = false;
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData(tabContent).view;
};
function initPage(tabContent) {
const initPage = (tabContent) => {
tabContent.querySelector('.btnSort').addEventListener('click', function (e) {
libraryBrowser.showSortMenu({
items: [{
@ -230,36 +233,37 @@ define(['loading', 'events', 'libraryBrowser', 'imageLoader', 'listView', 'cardB
button: e.target
});
});
var btnSelectView = tabContent.querySelector('.btnSelectView');
const btnSelectView = tabContent.querySelector('.btnSelectView');
btnSelectView.addEventListener('click', function (e) {
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle(), 'List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
});
btnSelectView.addEventListener('layoutchange', function (e) {
var viewStyle = e.detail.viewStyle;
const viewStyle = e.detail.viewStyle;
getPageData(tabContent).view = viewStyle;
libraryBrowser.saveViewSetting(getSavedQueryKey(tabContent), viewStyle);
getQuery(tabContent).StartIndex = 0;
onViewStyleChange();
reloadItems(tabContent);
});
tabContent.querySelector('.btnNewCollection').addEventListener('click', function () {
require(['collectionEditor'], function (collectionEditor) {
var serverId = ApiClient.serverInfo().Id;
tabContent.querySelector('.btnNewCollection').addEventListener('click', () => {
import('collectionEditor').then(({default: collectionEditor}) => {
const serverId = ApiClient.serverInfo().Id;
new collectionEditor.showEditor({
items: [],
serverId: serverId
});
});
});
}
};
initPage(tabContent);
onViewStyleChange();
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent);
};
self.destroy = function () {};
};
});
this.destroy = function () {};
}
/* eslint-enable indent */

View File

@ -1,13 +1,18 @@
define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader', 'apphost', 'globalize', 'appRouter', 'dom', 'emby-button'], function (layoutManager, loading, libraryBrowser, cardBuilder, lazyLoader, appHost, globalize, appRouter, dom) {
'use strict';
import layoutManager from 'layoutManager';
import loading from 'loading';
import libraryBrowser from 'libraryBrowser';
import cardBuilder from 'cardBuilder';
import lazyLoader from 'lazyLoader';
import globalize from 'globalize';
import appRouter from 'appRouter';
import 'emby-button';
loading = loading.default || loading;
libraryBrowser = libraryBrowser.default || libraryBrowser;
/* eslint-disable indent */
return function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData() {
var key = getSavedQueryKey();
var pageData = data[key];
const key = getSavedQueryKey();
let pageData = data[key];
if (!pageData) {
pageData = data[key] = {
@ -37,7 +42,7 @@ define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader
function getPromise() {
loading.show();
var query = getQuery();
const query = getQuery();
return ApiClient.getGenres(ApiClient.getCurrentUserId(), query);
}
@ -53,18 +58,18 @@ define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader
return enableScrollX() ? 'overflowPortrait' : 'portrait';
}
function fillItemsContainer(entry) {
var elem = entry.target;
var id = elem.getAttribute('data-id');
var viewStyle = self.getCurrentViewStyle();
var limit = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 5 : 9;
const fillItemsContainer = (entry) => {
const elem = entry.target;
const id = elem.getAttribute('data-id');
const viewStyle = this.getCurrentViewStyle();
let limit = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 5 : 9;
if (enableScrollX()) {
limit = 10;
}
var enableImageTypes = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 'Primary,Backdrop,Thumb' : 'Primary';
var query = {
const enableImageTypes = viewStyle == 'Thumb' || viewStyle == 'ThumbCard' ? 'Primary,Backdrop,Thumb' : 'Primary';
const query = {
SortBy: 'SortName',
SortOrder: 'Ascending',
IncludeItemTypes: 'Movie',
@ -126,17 +131,17 @@ define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader
tabContent.querySelector('.btnMoreFromGenre' + id + ' .material-icons').classList.remove('hide');
}
});
}
};
function reloadItems(context, promise) {
var query = getQuery();
const query = getQuery();
promise.then(function (result) {
var elem = context.querySelector('#items');
var html = '';
var items = result.Items;
const elem = context.querySelector('#items');
let html = '';
const items = result.Items;
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
for (let i = 0, length = items.length; i < length; i++) {
const item = items[i];
html += '<div class="verticalSection">';
html += '<div class="sectionTitleContainer sectionTitleContainer-cards padded-left">';
@ -151,7 +156,7 @@ define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader
html += '</a>';
html += '</div>';
if (enableScrollX()) {
var scrollXClass = 'scrollX hiddenScrollX';
let scrollXClass = 'scrollX hiddenScrollX';
if (layoutManager.tv) {
scrollXClass += 'smoothScrollX padded-top-focusscale padded-bottom-focusscale';
@ -182,37 +187,37 @@ define(['layoutManager', 'loading', 'libraryBrowser', 'cardBuilder', 'lazyLoader
});
}
function fullyReload() {
self.preRender();
self.renderTab();
}
const fullyReload = () => {
this.preRender();
this.renderTab();
};
var self = this;
var data = {};
const data = {};
self.getViewStyles = function () {
this.getViewStyles = function () {
return 'Poster,PosterCard,Thumb,ThumbCard'.split(',');
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData().view;
};
self.setCurrentViewStyle = function (viewStyle) {
this.setCurrentViewStyle = function (viewStyle) {
getPageData().view = viewStyle;
libraryBrowser.saveViewSetting(getSavedQueryKey(), viewStyle);
fullyReload();
};
self.enableViewSelection = true;
var promise;
this.enableViewSelection = true;
let promise;
self.preRender = function () {
this.preRender = function () {
promise = getPromise();
};
self.renderTab = function () {
this.renderTab = function () {
reloadItems(tabContent, promise);
};
};
});
}
/* eslint-enable indent */

View File

@ -1,12 +1,18 @@
define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser', 'alphaPicker', 'listView', 'cardBuilder', 'globalize', 'emby-itemscontainer'], function (loading, layoutManager, userSettings, events, libraryBrowser, AlphaPicker, listView, cardBuilder, globalize) {
'use strict';
import loading from 'loading';
import * as userSettings from 'userSettings';
import events from 'events';
import libraryBrowser from 'libraryBrowser';
import AlphaPicker from 'alphaPicker';
import listView from 'listView';
import cardBuilder from 'cardBuilder';
import globalize from 'globalize';
import 'emby-itemscontainer';
loading = loading.default || loading;
libraryBrowser = libraryBrowser.default || libraryBrowser;
/* eslint-disable indent */
return function (view, params, tabContent, options) {
function onViewStyleChange() {
if (self.getCurrentViewStyle() == 'List') {
export default function (view, params, tabContent, options) {
const onViewStyleChange = () => {
if (this.getCurrentViewStyle() == 'List') {
itemsContainer.classList.add('vertical-list');
itemsContainer.classList.remove('vertical-wrap');
} else {
@ -15,13 +21,13 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
}
itemsContainer.innerHTML = '';
}
};
function updateFilterControls() {
if (self.alphaPicker) {
self.alphaPicker.value(query.NameStartsWithOrGreater);
const updateFilterControls = () => {
if (this.alphaPicker) {
this.alphaPicker.value(query.NameStartsWithOrGreater);
}
}
};
function fetchData() {
isLoading = true;
@ -54,7 +60,7 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
window.scrollTo(0, 0);
updateFilterControls();
var pagingHtml = libraryBrowser.getQueryPagingHtml({
const pagingHtml = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
@ -64,35 +70,30 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
sortButton: false,
filterButton: false
});
var i;
var length;
var elems = tabContent.querySelectorAll('.paging');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].innerHTML = pagingHtml;
for (const elem of tabContent.querySelectorAll('.paging')) {
elem.innerHTML = pagingHtml;
}
elems = tabContent.querySelectorAll('.btnNextPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onNextPageClick);
for (const elem of tabContent.querySelectorAll('.btnNextPage')) {
elem.addEventListener('click', onNextPageClick);
}
elems = tabContent.querySelectorAll('.btnPreviousPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onPreviousPageClick);
for (const elem of tabContent.querySelectorAll('.btnPreviousPage')) {
elem.addEventListener('click', onPreviousPageClick);
}
isLoading = false;
loading.hide();
require(['autoFocuser'], function (autoFocuser) {
import('autoFocuser').then(({default: autoFocuser}) => {
autoFocuser.autoFocus(tabContent);
});
}
function getItemsHtml(items) {
var html;
var viewStyle = self.getCurrentViewStyle();
const getItemsHtml = (items) => {
let html;
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'Thumb') {
html = cardBuilder.getCardsHtml({
@ -156,22 +157,22 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
}
return html;
}
};
function initPage(tabContent) {
const initPage = (tabContent) => {
itemsContainer.fetchData = fetchData;
itemsContainer.getItemsHtml = getItemsHtml;
itemsContainer.afterRefresh = afterRefresh;
var alphaPickerElement = tabContent.querySelector('.alphaPicker');
let alphaPickerElement = tabContent.querySelector('.alphaPicker');
if (alphaPickerElement) {
alphaPickerElement.addEventListener('alphavaluechanged', function (e) {
var newValue = e.detail.value;
let newValue = e.detail.value;
query.NameStartsWithOrGreater = newValue;
query.StartIndex = 0;
itemsContainer.refreshItems();
});
self.alphaPicker = new AlphaPicker.default({
this.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
valueChangeEvent: 'click'
});
@ -181,14 +182,14 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
itemsContainer.classList.add('padded-right-withalphapicker');
}
var btnFilter = tabContent.querySelector('.btnFilter');
const btnFilter = tabContent.querySelector('.btnFilter');
if (btnFilter) {
btnFilter.addEventListener('click', function () {
self.showFilterMenu();
btnFilter.addEventListener('click', () => {
this.showFilterMenu();
});
}
var btnSort = tabContent.querySelector('.btnSort');
const btnSort = tabContent.querySelector('.btnSort');
if (btnSort) {
btnSort.addEventListener('click', function (e) {
@ -231,24 +232,23 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
});
});
}
var btnSelectView = tabContent.querySelector('.btnSelectView');
const btnSelectView = tabContent.querySelector('.btnSelectView');
btnSelectView.addEventListener('click', function (e) {
libraryBrowser.showLayoutMenu(e.target, self.getCurrentViewStyle(), 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
libraryBrowser.showLayoutMenu(e.target, this.getCurrentViewStyle, 'Banner,List,Poster,PosterCard,Thumb,ThumbCard'.split(','));
});
btnSelectView.addEventListener('layoutchange', function (e) {
var viewStyle = e.detail.viewStyle;
let viewStyle = e.detail.viewStyle;
userSettings.set(savedViewKey, viewStyle);
query.StartIndex = 0;
onViewStyleChange();
itemsContainer.refreshItems();
});
}
};
var self = this;
var itemsContainer = tabContent.querySelector('.itemsContainer');
var savedQueryKey = params.topParentId + '-' + options.mode;
var savedViewKey = savedQueryKey + '-view';
var query = {
let itemsContainer = tabContent.querySelector('.itemsContainer');
const savedQueryKey = params.topParentId + '-' + options.mode;
const savedViewKey = savedQueryKey + '-view';
let query = {
SortBy: 'SortName,ProductionYear',
SortOrder: 'Ascending',
IncludeItemTypes: 'Movie',
@ -264,7 +264,7 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
query['Limit'] = userSettings.libraryPageSize();
}
var isLoading = false;
let isLoading = false;
if (options.mode === 'favorites') {
query.IsFavorite = true;
@ -272,14 +272,14 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
query = userSettings.loadQuerySettings(savedQueryKey, query);
self.showFilterMenu = function () {
require(['components/filterdialog/filterdialog'], function ({default: filterDialogFactory}) {
var filterDialog = new filterDialogFactory({
this.showFilterMenu = function () {
import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => {
let filterDialog = new filterDialogFactory({
query: query,
mode: 'movies',
serverId: ApiClient.serverId()
});
events.on(filterDialog, 'filterchange', function () {
events.on(filterDialog, 'filterchange', () => {
query.StartIndex = 0;
itemsContainer.refreshItems();
});
@ -287,22 +287,23 @@ define(['loading', 'layoutManager', 'userSettings', 'events', 'libraryBrowser',
});
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return userSettings.get(savedViewKey) || 'Poster';
};
self.initTab = function () {
this.initTab = function () {
initPage(tabContent);
onViewStyleChange();
};
self.renderTab = function () {
this.renderTab = function () {
itemsContainer.refreshItems();
updateFilterControls();
};
self.destroy = function () {
this.destroy = function () {
itemsContainer = null;
};
};
});
}
/* eslint-enable indent */

View File

@ -1,7 +1,20 @@
define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu', 'mainTabsManager', 'cardBuilder', 'dom', 'imageLoader', 'playbackManager', 'globalize', 'emby-scroller', 'emby-itemscontainer', 'emby-tabs', 'emby-button'], function (events, layoutManager, inputManager, userSettings, libraryMenu, mainTabsManager, cardBuilder, dom, imageLoader, playbackManager, globalize) {
'use strict';
import events from 'events';
import layoutManager from 'layoutManager';
import inputManager from 'inputManager';
import * as userSettings from 'userSettings';
import libraryMenu from 'libraryMenu';
import * as mainTabsManager from 'mainTabsManager';
import cardBuilder from 'cardBuilder';
import dom from 'dom';
import imageLoader from 'imageLoader';
import playbackManager from 'playbackManager';
import globalize from 'globalize';
import 'emby-scroller';
import 'emby-itemscontainer';
import 'emby-tabs';
import 'emby-button';
playbackManager = playbackManager.default || playbackManager;
/* eslint-disable indent */
function enableScrollX() {
return !layoutManager.desktop;
@ -16,7 +29,7 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function loadLatest(page, userId, parentId) {
var options = {
const options = {
IncludeItemTypes: 'Movie',
Limit: 18,
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
@ -26,8 +39,8 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
EnableTotalRecordCount: false
};
ApiClient.getJSON(ApiClient.getUrl('Users/' + userId + '/Items/Latest', options)).then(function (items) {
var allowBottomPadding = !enableScrollX();
var container = page.querySelector('#recentlyAddedItems');
const allowBottomPadding = !enableScrollX();
const container = page.querySelector('#recentlyAddedItems');
cardBuilder.buildCards(items, {
itemsContainer: container,
shape: getPortraitShape(),
@ -45,8 +58,8 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function loadResume(page, userId, parentId) {
var screenWidth = dom.getWindowSize().innerWidth;
var options = {
let screenWidth = dom.getWindowSize().innerWidth;
const options = {
SortBy: 'DatePlayed',
SortOrder: 'Descending',
IncludeItemTypes: 'Movie',
@ -67,8 +80,8 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
page.querySelector('#resumableSection').classList.add('hide');
}
var allowBottomPadding = !enableScrollX();
var container = page.querySelector('#resumableItems');
const allowBottomPadding = !enableScrollX();
const container = page.querySelector('#resumableItems');
cardBuilder.buildCards(result.Items, {
itemsContainer: container,
preferThumb: true,
@ -88,8 +101,8 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function getRecommendationHtml(recommendation) {
var html = '';
var title = '';
let html = '';
let title = '';
switch (recommendation.RecommendationType) {
case 'SimilarToRecentlyPlayed':
@ -113,7 +126,7 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
html += '<div class="verticalSection">';
html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + title + '</h2>';
var allowBottomPadding = true;
const allowBottomPadding = true;
if (enableScrollX()) {
html += '<div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-mousewheel="false" data-centerfocus="true">';
@ -141,8 +154,8 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function loadSuggestions(page, userId, parentId) {
var screenWidth = dom.getWindowSize().innerWidth;
var url = ApiClient.getUrl('Movies/Recommendations', {
let screenWidth = dom.getWindowSize().innerWidth;
let url = ApiClient.getUrl('Movies/Recommendations', {
userId: userId,
categoryLimit: 6,
ItemLimit: screenWidth >= 1920 ? 8 : screenWidth >= 1600 ? 8 : screenWidth >= 1200 ? 6 : 5,
@ -157,9 +170,9 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
return;
}
var html = recommendations.map(getRecommendationHtml).join('');
const html = recommendations.map(getRecommendationHtml).join('');
page.querySelector('.noItemsMessage').classList.add('hide');
var recs = page.querySelector('.recommendations');
let recs = page.querySelector('.recommendations');
recs.innerHTML = html;
imageLoader.lazyChildren(recs);
@ -169,7 +182,7 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function autoFocus(page) {
require(['autoFocuser'], function (autoFocuser) {
import('autoFocuser').then(({default: autoFocuser}) => {
autoFocuser.autoFocus(page);
});
}
@ -195,17 +208,16 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
function initSuggestedTab(page, tabContent) {
var containers = tabContent.querySelectorAll('.itemsContainer');
const containers = tabContent.querySelectorAll('.itemsContainer');
for (var i = 0, length = containers.length; i < length; i++) {
setScrollClasses(containers[i], enableScrollX());
for (const container of containers) {
setScrollClasses(container, enableScrollX());
}
}
function loadSuggestionsTab(view, params, tabContent) {
var parentId = params.topParentId;
var userId = ApiClient.getCurrentUserId();
console.debug('loadSuggestionsTab');
const parentId = params.topParentId;
const userId = ApiClient.getCurrentUserId();
loadResume(tabContent, userId, parentId);
loadLatest(tabContent, userId, parentId);
loadSuggestions(tabContent, userId, parentId);
@ -224,9 +236,6 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
name: globalize.translate('TabCollections')
}, {
name: globalize.translate('TabGenres')
}, {
name: globalize.translate('ButtonSearch'),
cssClass: 'searchTabButton'
}];
}
@ -249,13 +258,13 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
}
return function (view, params) {
export default function (view, params) {
function onBeforeTabChange(e) {
preLoadTab(view, parseInt(e.detail.selectedTabIndex));
}
function onTabChange(e) {
var newIndex = parseInt(e.detail.selectedTabIndex);
const newIndex = parseInt(e.detail.selectedTabIndex);
loadTab(view, newIndex);
}
@ -267,52 +276,50 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
mainTabsManager.setTabs(view, currentTabIndex, getTabs, getTabContainers, onBeforeTabChange, onTabChange);
}
function getTabController(page, index, callback) {
var depends = [];
const getTabController = (page, index, callback) => {
let depends = '';
switch (index) {
case 0:
depends.push('controllers/movies/movies');
depends = 'controllers/movies/movies';
break;
case 1:
depends = 'controllers/movies/moviesrecommended.js';
break;
case 2:
depends.push('controllers/movies/movietrailers');
depends = 'controllers/movies/movietrailers';
break;
case 3:
depends.push('controllers/movies/movies');
depends = 'controllers/movies/movies';
break;
case 4:
depends.push('controllers/movies/moviecollections');
depends = 'controllers/movies/moviecollections';
break;
case 5:
depends.push('controllers/movies/moviegenres');
depends = 'controllers/movies/moviegenres';
break;
case 6:
depends.push('scripts/searchtab');
}
require(depends, function (controllerFactory) {
var tabContent;
import(depends).then(({default: controllerFactory}) => {
let tabContent;
if (index === suggestionsTabIndex) {
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
self.tabContent = tabContent;
this.tabContent = tabContent;
}
var controller = tabControllers[index];
let controller = tabControllers[index];
if (!controller) {
tabContent = view.querySelector(".pageTabContent[data-index='" + index + "']");
if (index === suggestionsTabIndex) {
controller = self;
controller = this;
} else if (index === 6) {
controller = new controllerFactory(view, tabContent, {
collectionType: 'movies',
@ -335,7 +342,7 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
callback(controller);
});
}
};
function preLoadTab(page, index) {
getTabController(page, index, function (controller) {
@ -347,12 +354,12 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
function loadTab(page, index) {
currentTabIndex = index;
getTabController(page, index, function (controller) {
getTabController(page, index, ((controller) => {
if (renderedTabs.indexOf(index) == -1) {
renderedTabs.push(index);
controller.renderTab();
}
});
}));
}
function onPlaybackStop(e, state) {
@ -370,22 +377,21 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
}
}
var self = this;
var currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
var suggestionsTabIndex = 1;
let currentTabIndex = parseInt(params.tab || getDefaultTabIndex(params.topParentId));
const suggestionsTabIndex = 1;
self.initTab = function () {
var tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
this.initTab = function () {
let tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
initSuggestedTab(view, tabContent);
};
self.renderTab = function () {
var tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
this.renderTab = function () {
let tabContent = view.querySelector(".pageTabContent[data-index='" + suggestionsTabIndex + "']");
loadSuggestionsTab(view, params, tabContent);
};
var tabControllers = [];
var renderedTabs = [];
let tabControllers = [];
let renderedTabs = [];
view.addEventListener('viewshow', function (e) {
initTabs();
if (!view.getAttribute('data-title')) {
@ -405,15 +411,14 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu'
events.on(playbackManager, 'playbackstop', onPlaybackStop);
inputManager.on(window, onInputCommand);
});
view.addEventListener('viewbeforehide', function (e) {
view.addEventListener('viewbeforehide', function () {
inputManager.off(window, onInputCommand);
});
view.addEventListener('viewdestroy', function (e) {
tabControllers.forEach(function (t) {
if (t.destroy) {
t.destroy();
}
});
});
};
});
for (const tabController of tabControllers) {
if (tabController.destroy) {
tabController.destroy();
}
}
}
/* eslint-enable indent */

View File

@ -1,13 +1,20 @@
define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', 'alphaPicker', 'listView', 'cardBuilder', 'userSettings', 'globalize', 'emby-itemscontainer'], function (layoutManager, loading, events, libraryBrowser, imageLoader, AlphaPicker, listView, cardBuilder, userSettings, globalize) {
'use strict';
import loading from 'loading';
import events from 'events';
import libraryBrowser from 'libraryBrowser';
import imageLoader from 'imageLoader';
import AlphaPicker from 'alphaPicker';
import listView from 'listView';
import cardBuilder from 'cardBuilder';
import * as userSettings from 'userSettings';
import globalize from 'globalize';
import 'emby-itemscontainer';
loading = loading.default || loading;
libraryBrowser = libraryBrowser.default || libraryBrowser;
/* eslint-disable indent */
return function (view, params, tabContent) {
export default function (view, params, tabContent) {
function getPageData(context) {
var key = getSavedQueryKey(context);
var pageData = data[key];
const key = getSavedQueryKey(context);
let pageData = data[key];
if (!pageData) {
pageData = data[key] = {
@ -46,11 +53,11 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
return context.savedQueryKey;
}
function reloadItems() {
const reloadItems = () => {
loading.show();
isLoading = true;
var query = getQuery(tabContent);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then(function (result) {
const query = getQuery(tabContent);
ApiClient.getItems(ApiClient.getCurrentUserId(), query).then((result) => {
function onNextPageClick() {
if (isLoading) {
return;
@ -75,7 +82,7 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
window.scrollTo(0, 0);
updateFilterControls(tabContent);
var pagingHtml = libraryBrowser.getQueryPagingHtml({
const pagingHtml = libraryBrowser.getQueryPagingHtml({
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
@ -85,8 +92,8 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
sortButton: false,
filterButton: false
});
var html;
var viewStyle = self.getCurrentViewStyle();
let html;
const viewStyle = this.getCurrentViewStyle();
if (viewStyle == 'Thumb') {
html = cardBuilder.getCardsHtml({
@ -142,22 +149,20 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
});
}
var i;
var length;
var elems = tabContent.querySelectorAll('.paging');
let elems = tabContent.querySelectorAll('.paging');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].innerHTML = pagingHtml;
for (const elem of elems) {
elem.innerHTML = pagingHtml;
}
elems = tabContent.querySelectorAll('.btnNextPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onNextPageClick);
for (const elem of elems) {
elem.addEventListener('click', onNextPageClick);
}
elems = tabContent.querySelectorAll('.btnPreviousPage');
for (i = 0, length = elems.length; i < length; i++) {
elems[i].addEventListener('click', onPreviousPageClick);
for (const elem of elems) {
elem.addEventListener('click', onPreviousPageClick);
}
if (!result.Items.length) {
@ -169,27 +174,26 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
html += '</div>';
}
var itemsContainer = tabContent.querySelector('.itemsContainer');
const itemsContainer = tabContent.querySelector('.itemsContainer');
itemsContainer.innerHTML = html;
imageLoader.lazyChildren(itemsContainer);
libraryBrowser.saveQueryValues(getSavedQueryKey(tabContent), query);
loading.hide();
isLoading = false;
});
}
};
function updateFilterControls(tabContent) {
var query = getQuery(tabContent);
self.alphaPicker.value(query.NameStartsWithOrGreater);
}
const updateFilterControls = (tabContent) => {
const query = getQuery(tabContent);
this.alphaPicker.value(query.NameStartsWithOrGreater);
};
var self = this;
var data = {};
var isLoading = false;
const data = {};
let isLoading = false;
self.showFilterMenu = function () {
require(['components/filterdialog/filterdialog'], function ({default: filterDialogFactory}) {
var filterDialog = new filterDialogFactory({
this.showFilterMenu = function () {
import('components/filterdialog/filterdialog').then(({default: filterDialogFactory}) => {
const filterDialog = new filterDialogFactory({
query: getQuery(tabContent),
mode: 'movies',
serverId: ApiClient.serverId()
@ -202,21 +206,21 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
});
};
self.getCurrentViewStyle = function () {
this.getCurrentViewStyle = function () {
return getPageData(tabContent).view;
};
function initPage(tabContent) {
var alphaPickerElement = tabContent.querySelector('.alphaPicker');
var itemsContainer = tabContent.querySelector('.itemsContainer');
const initPage = (tabContent) => {
const alphaPickerElement = tabContent.querySelector('.alphaPicker');
const itemsContainer = tabContent.querySelector('.itemsContainer');
alphaPickerElement.addEventListener('alphavaluechanged', function (e) {
var newValue = e.detail.value;
var query = getQuery(tabContent);
const newValue = e.detail.value;
const query = getQuery(tabContent);
query.NameStartsWithOrGreater = newValue;
query.StartIndex = 0;
reloadItems();
});
self.alphaPicker = new AlphaPicker.default({
this.alphaPicker = new AlphaPicker({
element: alphaPickerElement,
valueChangeEvent: 'click'
});
@ -226,7 +230,7 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
itemsContainer.classList.add('padded-right-withalphapicker');
tabContent.querySelector('.btnFilter').addEventListener('click', function () {
self.showFilterMenu();
this.showFilterMenu();
});
tabContent.querySelector('.btnSort').addEventListener('click', function (e) {
libraryBrowser.showSortMenu({
@ -260,15 +264,16 @@ define(['layoutManager', 'loading', 'events', 'libraryBrowser', 'imageLoader', '
button: e.target
});
});
}
};
initPage(tabContent);
self.renderTab = function () {
this.renderTab = function () {
reloadItems();
updateFilterControls(tabContent);
};
self.destroy = function () {};
};
});
this.destroy = function () {};
}
/* eslint-enable indent */

View File

@ -191,9 +191,6 @@ import 'flexStyles';
name: globalize.translate('TabSongs')
}, {
name: globalize.translate('TabGenres')
}, {
name: globalize.translate('ButtonSearch'),
cssClass: 'searchTabButton'
}];
}
@ -295,10 +292,6 @@ import 'flexStyles';
case 6:
depends = 'controllers/music/musicgenres';
break;
case 7:
depends = 'scripts/searchtab';
break;
}
import(depends).then(({default: controllerFactory}) => {

View File

@ -30,9 +30,6 @@ import 'emby-button';
name: globalize.translate('TabNetworks')
}, {
name: globalize.translate('TabEpisodes')
}, {
name: globalize.translate('ButtonSearch'),
cssClass: 'searchTabButton'
}];
}
@ -217,10 +214,6 @@ import 'emby-button';
case 6:
depends = 'controllers/shows/episodes';
break;
case 7:
depends = 'scripts/searchtab';
break;
}
import(depends).then(({default: controllerFactory}) => {

View File

@ -230,3 +230,18 @@
margin: 0;
padding: 0.5em 0.75em;
}
/* FIXME: 'sliderContainer' is used to wrap slider's pieces */
.sliderContainer-settings {
margin-bottom: 1.8em;
position: relative;
}
.sliderContainer-settings .mdl-slider-container {
height: 2.83em; /* similar to emby-input with its 110% font-size */
}
.sliderLabel {
display: block;
margin-bottom: 0.25em;
}

View File

@ -150,6 +150,16 @@ import 'emby-input';
this.classList.add('show-focus');
}
const topContainer = dom.parentWithClass(this, 'sliderContainer-settings');
if (topContainer && this.getAttribute('label')) {
const label = this.ownerDocument.createElement('label');
label.innerHTML = this.getAttribute('label');
label.classList.add('sliderLabel');
label.htmlFor = this.id;
topContainer.insertBefore(label, topContainer.firstChild);
}
const containerElement = this.parentNode;
containerElement.classList.add('mdl-slider-container');

View File

@ -1,13 +1,11 @@
<!DOCTYPE html>
<html class="preload">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<link rel="manifest" href="manifest.json">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta http-equiv="X-UA-Compatibility" content="IE=Edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
@ -15,10 +13,9 @@
<meta name="robots" content="noindex, nofollow, noarchive">
<meta property="og:title" content="Jellyfin">
<meta property="og:site_name" content="Jellyfin">
<meta property="og:url" content="http://jellyfin.media">
<meta property="og:description" content="The Free Software Media System.">
<meta property="og:url" content="http://jellyfin.org">
<meta property="og:description" content="The Free Software Media System">
<meta property="og:type" content="article">
<meta property="fb:app_id" content="1618309211750238">
<link rel="apple-touch-icon" sizes="180x180" href="touchicon.png">
<!-- iPhone 5 -->
@ -64,7 +61,6 @@
<link rel="shortcut icon" href="favicon.ico">
<meta name="msapplication-TileImage" content="touchicon144.png">
<meta name="msapplication-TileColor" content="#333333">
<meta name="theme-color" content="#101010">
<title>Jellyfin</title>

View File

@ -1,354 +1,357 @@
define(["browser", "dom", "css!./navdrawer", "scrollStyles"], function (browser, dom) {
"use strict";
/* Cleaning this file properly is not neecessary, since it's an outdated library
* and will be replaced soon by a Vue component.
*/
browser = browser.default || browser;
import browser from 'browser';
import dom from 'dom';
import 'css!./navdrawer';
import 'scrollStyles';
return function (options) {
function getTouches(e) {
return e.changedTouches || e.targetTouches || e.touches;
export default function (options) {
function getTouches(e) {
return e.changedTouches || e.targetTouches || e.touches;
}
function onMenuTouchStart(e) {
options.target.classList.remove('transition');
var touches = getTouches(e);
var touch = touches[0] || {};
menuTouchStartX = touch.clientX;
menuTouchStartY = touch.clientY;
menuTouchStartTime = new Date().getTime();
}
function setVelocity(deltaX) {
var time = new Date().getTime() - (menuTouchStartTime || 0);
velocity = Math.abs(deltaX) / time;
}
function onMenuTouchMove(e) {
var isOpen = self.visible;
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
var endY = touch.clientY || 0;
var deltaX = endX - (menuTouchStartX || 0);
var deltaY = endY - (menuTouchStartY || 0);
setVelocity(deltaX);
if (isOpen && dragMode !== 1 && deltaX > 0) {
dragMode = 2;
}
function onMenuTouchStart(e) {
options.target.classList.remove("transition");
var touches = getTouches(e);
var touch = touches[0] || {};
menuTouchStartX = touch.clientX;
menuTouchStartY = touch.clientY;
menuTouchStartTime = new Date().getTime();
if (dragMode === 0 && (!isOpen || Math.abs(deltaX) >= 10) && Math.abs(deltaY) < 5) {
dragMode = 1;
scrollContainer.addEventListener('scroll', disableEvent);
self.showMask();
} else if (dragMode === 0 && Math.abs(deltaY) >= 5) {
dragMode = 2;
}
function setVelocity(deltaX) {
var time = new Date().getTime() - (menuTouchStartTime || 0);
velocity = Math.abs(deltaX) / time;
if (dragMode === 1) {
newPos = currentPos + deltaX;
self.changeMenuPos();
}
}
function onMenuTouchMove(e) {
var isOpen = self.visible;
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
var endY = touch.clientY || 0;
var deltaX = endX - (menuTouchStartX || 0);
var deltaY = endY - (menuTouchStartY || 0);
setVelocity(deltaX);
function onMenuTouchEnd(e) {
options.target.classList.add('transition');
scrollContainer.removeEventListener('scroll', disableEvent);
dragMode = 0;
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
var endY = touch.clientY || 0;
var deltaX = endX - (menuTouchStartX || 0);
var deltaY = endY - (menuTouchStartY || 0);
currentPos = deltaX;
self.checkMenuState(deltaX, deltaY);
}
if (isOpen && 1 !== dragMode && deltaX > 0) {
dragMode = 2;
}
function onEdgeTouchStart(e) {
if (isPeeking) {
onMenuTouchMove(e);
} else {
if (((getTouches(e)[0] || {}).clientX || 0) <= options.handleSize) {
isPeeking = true;
if (0 === dragMode && (!isOpen || Math.abs(deltaX) >= 10) && Math.abs(deltaY) < 5) {
dragMode = 1;
scrollContainer.addEventListener("scroll", disableEvent);
self.showMask();
} else if (0 === dragMode && Math.abs(deltaY) >= 5) {
dragMode = 2;
}
if (1 === dragMode) {
newPos = currentPos + deltaX;
self.changeMenuPos();
}
}
function onMenuTouchEnd(e) {
options.target.classList.add("transition");
scrollContainer.removeEventListener("scroll", disableEvent);
dragMode = 0;
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
var endY = touch.clientY || 0;
var deltaX = endX - (menuTouchStartX || 0);
var deltaY = endY - (menuTouchStartY || 0);
currentPos = deltaX;
self.checkMenuState(deltaX, deltaY);
}
function onEdgeTouchStart(e) {
if (isPeeking) {
onMenuTouchMove(e);
} else {
if (((getTouches(e)[0] || {}).clientX || 0) <= options.handleSize) {
isPeeking = true;
if (e.type === "touchstart") {
dom.removeEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {});
dom.addEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {});
}
onMenuTouchStart(e);
if (e.type === 'touchstart') {
dom.removeEventListener(edgeContainer, 'touchmove', onEdgeTouchMove, {});
dom.addEventListener(edgeContainer, 'touchmove', onEdgeTouchMove, {});
}
onMenuTouchStart(e);
}
}
}
function onEdgeTouchMove(e) {
e.preventDefault();
e.stopPropagation();
onEdgeTouchStart(e);
function onEdgeTouchMove(e) {
e.preventDefault();
e.stopPropagation();
onEdgeTouchStart(e);
}
function onEdgeTouchEnd(e) {
if (isPeeking) {
isPeeking = false;
dom.removeEventListener(edgeContainer, 'touchmove', onEdgeTouchMove, {});
onMenuTouchEnd(e);
}
}
function onEdgeTouchEnd(e) {
if (isPeeking) {
isPeeking = false;
dom.removeEventListener(edgeContainer, "touchmove", onEdgeTouchMove, {});
onMenuTouchEnd(e);
}
}
function disableEvent(e) {
e.preventDefault();
e.stopPropagation();
}
function disableEvent(e) {
e.preventDefault();
e.stopPropagation();
}
function onBackgroundTouchStart(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
backgroundTouchStartX = touch.clientX;
backgroundTouchStartTime = new Date().getTime();
}
function onBackgroundTouchStart(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
backgroundTouchStartX = touch.clientX;
backgroundTouchStartTime = new Date().getTime();
}
function onBackgroundTouchMove(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
function onBackgroundTouchMove(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
if (endX <= options.width && self.isVisible) {
countStart++;
var deltaX = endX - (backgroundTouchStartX || 0);
if (countStart == 1) {
startPoint = deltaX;
}
if (deltaX < 0 && dragMode !== 2) {
dragMode = 1;
newPos = deltaX - startPoint + options.width;
self.changeMenuPos();
var time = new Date().getTime() - (backgroundTouchStartTime || 0);
velocity = Math.abs(deltaX) / time;
}
}
e.preventDefault();
e.stopPropagation();
}
function onBackgroundTouchEnd(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
if (endX <= options.width && self.isVisible) {
countStart++;
var deltaX = endX - (backgroundTouchStartX || 0);
self.checkMenuState(deltaX);
countStart = 0;
}
function onMaskTransitionEnd() {
var classList = mask.classList;
if (!classList.contains("backdrop")) {
classList.add("hide");
if (countStart == 1) {
startPoint = deltaX;
}
if (deltaX < 0 && dragMode !== 2) {
dragMode = 1;
newPos = deltaX - startPoint + options.width;
self.changeMenuPos();
var time = new Date().getTime() - (backgroundTouchStartTime || 0);
velocity = Math.abs(deltaX) / time;
}
}
var self;
var defaults;
var mask;
var newPos = 0;
var currentPos = 0;
var startPoint = 0;
var countStart = 0;
var velocity = 0;
options.target.classList.add("transition");
var dragMode = 0;
var scrollContainer = options.target.querySelector(".mainDrawer-scrollContainer");
scrollContainer.classList.add("scrollY");
e.preventDefault();
e.stopPropagation();
}
var TouchMenuLA = function () {
self = this;
defaults = {
width: 260,
handleSize: 10,
disableMask: false,
maxMaskOpacity: 0.5
};
this.isVisible = false;
this.initialize();
function onBackgroundTouchEnd(e) {
var touches = getTouches(e);
var touch = touches[0] || {};
var endX = touch.clientX || 0;
var deltaX = endX - (backgroundTouchStartX || 0);
self.checkMenuState(deltaX);
countStart = 0;
}
function onMaskTransitionEnd() {
var classList = mask.classList;
if (!classList.contains('backdrop')) {
classList.add('hide');
}
}
var self;
var defaults;
var mask;
var newPos = 0;
var currentPos = 0;
var startPoint = 0;
var countStart = 0;
var velocity = 0;
options.target.classList.add('transition');
var dragMode = 0;
var scrollContainer = options.target.querySelector('.mainDrawer-scrollContainer');
scrollContainer.classList.add('scrollY');
var TouchMenuLA = function () {
self = this;
defaults = {
width: 260,
handleSize: 10,
disableMask: false,
maxMaskOpacity: 0.5
};
this.isVisible = false;
this.initialize();
};
TouchMenuLA.prototype.initElements = function () {
options.target.classList.add("touch-menu-la");
options.target.style.width = options.width + "px";
options.target.style.left = -options.width + "px";
TouchMenuLA.prototype.initElements = function () {
options.target.classList.add('touch-menu-la');
options.target.style.width = options.width + 'px';
options.target.style.left = -options.width + 'px';
if (!options.disableMask) {
mask = document.createElement("div");
mask.className = "tmla-mask hide";
document.body.appendChild(mask);
dom.addEventListener(mask, dom.whichTransitionEvent(), onMaskTransitionEnd, {
passive: true
});
}
};
var menuTouchStartX;
var menuTouchStartY;
var menuTouchStartTime;
var edgeContainer = document.querySelector(".mainDrawerHandle");
var isPeeking = false;
TouchMenuLA.prototype.animateToPosition = function (pos) {
requestAnimationFrame(function () {
options.target.style.transform = pos ? "translateX(" + pos + "px)" : "none";
if (!options.disableMask) {
mask = document.createElement('div');
mask.className = 'tmla-mask hide';
document.body.appendChild(mask);
dom.addEventListener(mask, dom.whichTransitionEvent(), onMaskTransitionEnd, {
passive: true
});
};
}
};
TouchMenuLA.prototype.changeMenuPos = function () {
if (newPos <= options.width) {
this.animateToPosition(newPos);
}
};
var menuTouchStartX;
var menuTouchStartY;
var menuTouchStartTime;
var edgeContainer = document.querySelector('.mainDrawerHandle');
var isPeeking = false;
TouchMenuLA.prototype.clickMaskClose = function () {
mask.addEventListener("click", function () {
TouchMenuLA.prototype.animateToPosition = function (pos) {
requestAnimationFrame(function () {
options.target.style.transform = pos ? 'translateX(' + pos + 'px)' : 'none';
});
};
TouchMenuLA.prototype.changeMenuPos = function () {
if (newPos <= options.width) {
this.animateToPosition(newPos);
}
};
TouchMenuLA.prototype.clickMaskClose = function () {
mask.addEventListener('click', function () {
self.close();
});
};
TouchMenuLA.prototype.checkMenuState = function (deltaX, deltaY) {
if (velocity >= 0.4) {
if (deltaX >= 0 || Math.abs(deltaY || 0) >= 70) {
self.open();
} else {
self.close();
});
};
TouchMenuLA.prototype.checkMenuState = function (deltaX, deltaY) {
if (velocity >= 0.4) {
if (deltaX >= 0 || Math.abs(deltaY || 0) >= 70) {
self.open();
} else {
}
} else {
if (newPos >= 100) {
self.open();
} else {
if (newPos) {
self.close();
}
} else {
if (newPos >= 100) {
self.open();
} else {
if (newPos) {
self.close();
}
}
}
};
TouchMenuLA.prototype.open = function () {
this.animateToPosition(options.width);
currentPos = options.width;
this.isVisible = true;
options.target.classList.add("drawer-open");
self.showMask();
self.invoke(options.onChange);
};
TouchMenuLA.prototype.close = function () {
this.animateToPosition(0);
currentPos = 0;
self.isVisible = false;
options.target.classList.remove("drawer-open");
self.hideMask();
self.invoke(options.onChange);
};
TouchMenuLA.prototype.toggle = function () {
if (self.isVisible) {
self.close();
} else {
self.open();
}
};
var backgroundTouchStartX;
var backgroundTouchStartTime;
TouchMenuLA.prototype.showMask = function () {
mask.classList.remove("hide");
mask.classList.add("backdrop");
};
TouchMenuLA.prototype.hideMask = function () {
mask.classList.add("hide");
mask.classList.remove("backdrop");
};
TouchMenuLA.prototype.invoke = function (fn) {
if (fn) {
fn.apply(self);
}
};
var _edgeSwipeEnabled;
TouchMenuLA.prototype.setEdgeSwipeEnabled = function (enabled) {
if (!options.disableEdgeSwipe) {
if (browser.touch) {
if (enabled) {
if (!_edgeSwipeEnabled) {
_edgeSwipeEnabled = true;
dom.addEventListener(edgeContainer, "touchstart", onEdgeTouchStart, {
passive: true
});
dom.addEventListener(edgeContainer, "touchend", onEdgeTouchEnd, {
passive: true
});
dom.addEventListener(edgeContainer, "touchcancel", onEdgeTouchEnd, {
passive: true
});
}
} else {
if (_edgeSwipeEnabled) {
_edgeSwipeEnabled = false;
dom.removeEventListener(edgeContainer, "touchstart", onEdgeTouchStart, {
passive: true
});
dom.removeEventListener(edgeContainer, "touchend", onEdgeTouchEnd, {
passive: true
});
dom.removeEventListener(edgeContainer, "touchcancel", onEdgeTouchEnd, {
passive: true
});
}
}
}
}
};
TouchMenuLA.prototype.initialize = function () {
options = Object.assign(defaults, options || {});
if (browser.edge) {
options.disableEdgeSwipe = true;
}
self.initElements();
if (browser.touch) {
dom.addEventListener(options.target, "touchstart", onMenuTouchStart, {
passive: true
});
dom.addEventListener(options.target, "touchmove", onMenuTouchMove, {
passive: true
});
dom.addEventListener(options.target, "touchend", onMenuTouchEnd, {
passive: true
});
dom.addEventListener(options.target, "touchcancel", onMenuTouchEnd, {
passive: true
});
dom.addEventListener(mask, "touchstart", onBackgroundTouchStart, {
passive: true
});
dom.addEventListener(mask, "touchmove", onBackgroundTouchMove, {});
dom.addEventListener(mask, "touchend", onBackgroundTouchEnd, {
passive: true
});
dom.addEventListener(mask, "touchcancel", onBackgroundTouchEnd, {
passive: true
});
}
self.clickMaskClose();
};
return new TouchMenuLA();
}
};
});
TouchMenuLA.prototype.open = function () {
this.animateToPosition(options.width);
currentPos = options.width;
this.isVisible = true;
options.target.classList.add('drawer-open');
self.showMask();
self.invoke(options.onChange);
};
TouchMenuLA.prototype.close = function () {
this.animateToPosition(0);
currentPos = 0;
self.isVisible = false;
options.target.classList.remove('drawer-open');
self.hideMask();
self.invoke(options.onChange);
};
TouchMenuLA.prototype.toggle = function () {
if (self.isVisible) {
self.close();
} else {
self.open();
}
};
var backgroundTouchStartX;
var backgroundTouchStartTime;
TouchMenuLA.prototype.showMask = function () {
mask.classList.remove('hide');
mask.classList.add('backdrop');
};
TouchMenuLA.prototype.hideMask = function () {
mask.classList.add('hide');
mask.classList.remove('backdrop');
};
TouchMenuLA.prototype.invoke = function (fn) {
if (fn) {
fn.apply(self);
}
};
var _edgeSwipeEnabled;
TouchMenuLA.prototype.setEdgeSwipeEnabled = function (enabled) {
if (!options.disableEdgeSwipe) {
if (browser.touch) {
if (enabled) {
if (!_edgeSwipeEnabled) {
_edgeSwipeEnabled = true;
dom.addEventListener(edgeContainer, 'touchstart', onEdgeTouchStart, {
passive: true
});
dom.addEventListener(edgeContainer, 'touchend', onEdgeTouchEnd, {
passive: true
});
dom.addEventListener(edgeContainer, 'touchcancel', onEdgeTouchEnd, {
passive: true
});
}
} else {
if (_edgeSwipeEnabled) {
_edgeSwipeEnabled = false;
dom.removeEventListener(edgeContainer, 'touchstart', onEdgeTouchStart, {
passive: true
});
dom.removeEventListener(edgeContainer, 'touchend', onEdgeTouchEnd, {
passive: true
});
dom.removeEventListener(edgeContainer, 'touchcancel', onEdgeTouchEnd, {
passive: true
});
}
}
}
}
};
TouchMenuLA.prototype.initialize = function () {
options = Object.assign(defaults, options || {});
if (browser.edge) {
options.disableEdgeSwipe = true;
}
self.initElements();
if (browser.touch) {
dom.addEventListener(options.target, 'touchstart', onMenuTouchStart, {
passive: true
});
dom.addEventListener(options.target, 'touchmove', onMenuTouchMove, {
passive: true
});
dom.addEventListener(options.target, 'touchend', onMenuTouchEnd, {
passive: true
});
dom.addEventListener(options.target, 'touchcancel', onMenuTouchEnd, {
passive: true
});
dom.addEventListener(mask, 'touchstart', onBackgroundTouchStart, {
passive: true
});
dom.addEventListener(mask, 'touchmove', onBackgroundTouchMove, {});
dom.addEventListener(mask, 'touchend', onBackgroundTouchEnd, {
passive: true
});
dom.addEventListener(mask, 'touchcancel', onBackgroundTouchEnd, {
passive: true
});
}
self.clickMaskClose();
};
return new TouchMenuLA();
}

View File

@ -1,134 +1,128 @@
define(["events", "playbackManager", "pluginManager", "inputManager", "connectionManager", "userSettings"], function (events, playbackManager, pluginManager, inputManager, connectionManager, userSettings) {
"use strict";
import events from 'events';
import playbackManager from 'playbackManager';
import pluginManager from 'pluginManager';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import * as userSettings from 'userSettings';
playbackManager = playbackManager.default || playbackManager;
function getMinIdleTime() {
// Returns the minimum amount of idle time required before the screen saver can be displayed
//time units used Millisecond
return 180000;
}
function getMinIdleTime() {
// Returns the minimum amount of idle time required before the screen saver can be displayed
//time units used Millisecond
return 180000;
let lastFunctionalEvent = 0;
function getFunctionalEventIdleTime() {
return new Date().getTime() - lastFunctionalEvent;
}
events.on(playbackManager, 'playbackstop', function (e, stopInfo) {
const state = stopInfo.state;
if (state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video') {
lastFunctionalEvent = new Date().getTime();
}
var lastFunctionalEvent = 0;
function getFunctionalEventIdleTime() {
return new Date().getTime() - lastFunctionalEvent;
}
events.on(playbackManager, "playbackstop", function (e, stopInfo) {
var state = stopInfo.state;
if (state.NowPlayingItem && state.NowPlayingItem.MediaType == "Video") {
lastFunctionalEvent = new Date().getTime();
}
});
function getScreensaverPlugin(isLoggedIn) {
var option;
try {
option = userSettings.get("screensaver", false);
} catch (err) {
option = isLoggedIn ? "backdropscreensaver" : "logoscreensaver";
}
var plugins = pluginManager.ofType("screensaver");
for (var i = 0, length = plugins.length; i < length; i++) {
var plugin = plugins[i];
if (plugin.id === option) {
return plugin;
}
}
return null;
}
function ScreenSaverManager() {
var self = this;
var activeScreenSaver;
function showScreenSaver(screensaver) {
if (activeScreenSaver) {
throw new Error("An existing screensaver is already active.");
}
console.debug("Showing screensaver " + screensaver.name);
screensaver.show();
activeScreenSaver = screensaver;
if (screensaver.hideOnClick !== false) {
window.addEventListener("click", hide, true);
}
if (screensaver.hideOnMouse !== false) {
window.addEventListener("mousemove", hide, true);
}
if (screensaver.hideOnKey !== false) {
window.addEventListener("keydown", hide, true);
}
}
function hide() {
if (activeScreenSaver) {
console.debug("Hiding screensaver");
activeScreenSaver.hide();
activeScreenSaver = null;
}
window.removeEventListener("click", hide, true);
window.removeEventListener("mousemove", hide, true);
window.removeEventListener("keydown", hide, true);
}
self.isShowing = function () {
return activeScreenSaver != null;
};
self.show = function () {
var isLoggedIn;
var apiClient = connectionManager.currentApiClient();
if (apiClient && apiClient.isLoggedIn()) {
isLoggedIn = true;
}
var screensaver = getScreensaverPlugin(isLoggedIn);
if (screensaver) {
showScreenSaver(screensaver);
}
};
self.hide = function () {
hide();
};
function onInterval() {
if (self.isShowing()) {
return;
}
if (inputManager.idleTime() < getMinIdleTime()) {
return;
}
if (getFunctionalEventIdleTime < getMinIdleTime()) {
return;
}
if (playbackManager.isPlayingVideo()) {
return;
}
self.show();
}
setInterval(onInterval, 10000);
}
return new ScreenSaverManager();
});
function getScreensaverPlugin(isLoggedIn) {
let option;
try {
option = userSettings.get('screensaver', false);
} catch (err) {
option = isLoggedIn ? 'backdropscreensaver' : 'logoscreensaver';
}
const plugins = pluginManager.ofType('screensaver');
for (const plugin of plugins) {
if (plugin.id === option) {
return plugin;
}
}
return null;
}
function ScreenSaverManager() {
let activeScreenSaver;
function showScreenSaver(screensaver) {
if (activeScreenSaver) {
throw new Error('An existing screensaver is already active.');
}
console.debug('Showing screensaver ' + screensaver.name);
screensaver.show();
activeScreenSaver = screensaver;
if (screensaver.hideOnClick !== false) {
window.addEventListener('click', hide, true);
}
if (screensaver.hideOnMouse !== false) {
window.addEventListener('mousemove', hide, true);
}
if (screensaver.hideOnKey !== false) {
window.addEventListener('keydown', hide, true);
}
}
function hide() {
if (activeScreenSaver) {
console.debug('Hiding screensaver');
activeScreenSaver.hide();
activeScreenSaver = null;
}
window.removeEventListener('click', hide, true);
window.removeEventListener('mousemove', hide, true);
window.removeEventListener('keydown', hide, true);
}
this.isShowing = () => {
return activeScreenSaver != null;
};
this.show = function () {
let isLoggedIn;
const apiClient = connectionManager.currentApiClient();
if (apiClient && apiClient.isLoggedIn()) {
isLoggedIn = true;
}
const screensaver = getScreensaverPlugin(isLoggedIn);
if (screensaver) {
showScreenSaver(screensaver);
}
};
this.hide = function () {
hide();
};
const onInterval = () => {
if (this.isShowing()) {
return;
}
if (inputManager.idleTime() < getMinIdleTime()) {
return;
}
if (getFunctionalEventIdleTime < getMinIdleTime()) {
return;
}
if (playbackManager.isPlayingVideo()) {
return;
}
this.show();
};
setInterval(onInterval, 10000);
}
export default new ScreenSaverManager;

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "Jellyfin",
"description": "Jellyfin: the Free Software Media System.",
"description": "The Free Software Media System",
"lang": "en-US",
"short_name": "Jellyfin",
"start_url": "index.html#!/home.html",

View File

@ -365,7 +365,7 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
}
return new Promise(function (resolve, reject) {
require(['chromecastHelper'], function (chromecastHelper) {
require(['./chromecastHelper'], function (chromecastHelper) {
chromecastHelper.getServerAddress(apiClient).then(function (serverAddress) {
message.serverAddress = serverAddress;
player.sendMessageInternal(message).then(resolve, reject);
@ -577,7 +577,7 @@ define(['appSettings', 'userSettings', 'playbackManager', 'connectionManager', '
this.isLocalPlayer = false;
this.lastPlayerData = {};
castSenderApiLoader.load().then(initializeChromecast.bind(this));
new castSenderApiLoader.default().load().then(initializeChromecast.bind(this));
}
ChromecastPlayer.prototype.tryPair = function (target) {

View File

@ -1132,7 +1132,7 @@ function tryRemoveElement(elem) {
*/
getCueCss(appearance, selector) {
return `${selector}::cue {
${appearance.text.map((s) => `${s.name}:${s.value}!important;`).join('')}
${appearance.text.map((s) => s.value !== undefined && s.value !== '' ? `${s.name}:${s.value}!important;` : '').join('')}
}`;
}
@ -1150,7 +1150,7 @@ function tryRemoveElement(elem) {
document.getElementsByTagName('head')[0].appendChild(styleElem);
}
styleElem.innerHTML = this.getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings(), true), '.htmlvideoplayer');
styleElem.innerHTML = this.getCueCss(subtitleAppearanceHelper.getStyles(userSettings.getSubtitleAppearanceSettings()), '.htmlvideoplayer');
});
}
@ -1195,17 +1195,28 @@ function tryRemoveElement(elem) {
// download the track json
this.fetchSubtitles(track, item).then(function (data) {
// show in ui
console.debug(`downloaded ${data.TrackEvents.length} track events`);
// add some cues to show the text
// in safari, the cues need to be added before setting the track mode to showing
for (const trackEvent of data.TrackEvents) {
const trackCueObject = window.VTTCue || window.TextTrackCue;
const cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text, false));
import('userSettings').then((userSettings) => {
// show in ui
console.debug(`downloaded ${data.TrackEvents.length} track events`);
trackElement.addCue(cue);
}
trackElement.mode = 'showing';
const subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
const cueLine = parseInt(subtitleAppearance.verticalPosition, 10);
// add some cues to show the text
// in safari, the cues need to be added before setting the track mode to showing
for (const trackEvent of data.TrackEvents) {
const trackCueObject = window.VTTCue || window.TextTrackCue;
const cue = new trackCueObject(trackEvent.StartPositionTicks / 10000000, trackEvent.EndPositionTicks / 10000000, normalizeTrackEventText(trackEvent.Text, false));
if (cue.line === 'auto') {
cue.line = cueLine;
}
trackElement.addCue(cue);
}
trackElement.mode = 'showing';
});
});
}

View File

@ -33,16 +33,22 @@ video::-webkit-media-controls {
text-shadow: 0.14em 0.14em 0.14em rgba(0, 0, 0, 1);
-webkit-font-smoothing: antialiased;
font-family: inherit;
line-height: normal; /* Restore value. See -webkit-media-text-track-container 'line-height' */
}
.htmlvideoplayer-moveupsubtitles::-webkit-media-text-track-display {
/* style the text itself */
margin-top: -2em;
.htmlvideoplayer::-webkit-media-text-track-container {
font-size: 170% !important; /* Override element inline style */
line-height: 50%; /* Child element cannot set line height smaller than its parent has. This allow smaller values for children */
}
.htmlvideoplayer::-webkit-media-text-track-display {
max-width: 70%;
margin-left: 15%;
}
.videoSubtitles {
position: fixed;
bottom: 10%;
bottom: 0;
text-align: center;
left: 0;
right: 0;
@ -53,7 +59,6 @@ video::-webkit-media-controls {
.videoSubtitlesInner {
max-width: 70%;
background-color: rgba(0, 0, 0, 0.8);
padding: 0.25em;
margin: auto;
display: inline-block;
}

View File

@ -1,165 +1,165 @@
define(['pluginManager'], function (pluginManager) {
return function () {
var self = this;
import pluginManager from 'pluginManager';
self.name = 'Logo ScreenSaver';
self.type = 'screensaver';
self.id = 'logoscreensaver';
self.supportsAnonymous = true;
export default function () {
const self = this;
var interval;
self.name = 'Logo ScreenSaver';
self.type = 'screensaver';
self.id = 'logoscreensaver';
self.supportsAnonymous = true;
function animate() {
var animations = [
let interval;
bounceInLeft,
bounceInRight,
swing,
tada,
wobble,
rotateIn,
rotateOut
];
function animate() {
const animations = [
var elem = document.querySelector('.logoScreenSaverImage');
bounceInLeft,
bounceInRight,
swing,
tada,
wobble,
rotateIn,
rotateOut
];
if (elem && elem.animate) {
var random = getRandomInt(0, animations.length - 1);
const elem = document.querySelector('.logoScreenSaverImage');
animations[random](elem, 1);
if (elem && elem.animate) {
const random = getRandomInt(0, animations.length - 1);
animations[random](elem, 1);
}
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function bounceInLeft(elem, iterations) {
const keyframes = [
{ transform: 'translate3d(-3000px, 0, 0)', opacity: '0', offset: 0 },
{ transform: 'translate3d(25px, 0, 0)', opacity: '1', offset: 0.6 },
{ transform: 'translate3d(-100px, 0, 0)', offset: 0.75 },
{ transform: 'translate3d(5px, 0, 0)', offset: 0.9 },
{ transform: 'none', opacity: '1', offset: 1 }];
const timing = { duration: 900, iterations: iterations, easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' };
return elem.animate(keyframes, timing);
}
function bounceInRight(elem, iterations) {
const keyframes = [
{ transform: 'translate3d(3000px, 0, 0)', opacity: '0', offset: 0 },
{ transform: 'translate3d(-25px, 0, 0)', opacity: '1', offset: 0.6 },
{ transform: 'translate3d(100px, 0, 0)', offset: 0.75 },
{ transform: 'translate3d(-5px, 0, 0)', offset: 0.9 },
{ transform: 'none', opacity: '1', offset: 1 }];
const timing = { duration: 900, iterations: iterations, easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' };
return elem.animate(keyframes, timing);
}
function swing(elem, iterations) {
const keyframes = [
{ transform: 'translate(0%)', offset: 0 },
{ transform: 'rotate3d(0, 0, 1, 15deg)', offset: 0.2 },
{ transform: 'rotate3d(0, 0, 1, -10deg)', offset: 0.4 },
{ transform: 'rotate3d(0, 0, 1, 5deg)', offset: 0.6 },
{ transform: 'rotate3d(0, 0, 1, -5deg)', offset: 0.8 },
{ transform: 'rotate3d(0, 0, 1, 0deg)', offset: 1 }];
const timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function tada(elem, iterations) {
const keyframes = [
{ transform: 'scale3d(1, 1, 1)', offset: 0 },
{ transform: 'scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg)', offset: 0.1 },
{ transform: 'scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg)', offset: 0.2 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.3 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.4 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.5 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.6 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.7 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.8 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.9 },
{ transform: 'scale3d(1, 1, 1)', offset: 1 }];
const timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function wobble(elem, iterations) {
const keyframes = [
{ transform: 'translate(0%)', offset: 0 },
{ transform: 'translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg)', offset: 0.15 },
{ transform: 'translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg)', offset: 0.45 },
{ transform: 'translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg)', offset: 0.6 },
{ transform: 'translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg)', offset: 0.75 },
{ transform: 'translateX(0%)', offset: 1 }];
const timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function rotateIn(elem, iterations) {
const keyframes = [{ transform: 'rotate3d(0, 0, 1, -200deg)', opacity: '0', transformOrigin: 'center', offset: 0 },
{ transform: 'none', opacity: '1', transformOrigin: 'center', offset: 1 }];
const timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function rotateOut(elem, iterations) {
const keyframes = [{ transform: 'none', opacity: '1', transformOrigin: 'center', offset: 0 },
{ transform: 'rotate3d(0, 0, 1, 200deg)', opacity: '0', transformOrigin: 'center', offset: 1 }];
const timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function fadeOut(elem, iterations) {
const keyframes = [
{ opacity: '1', offset: 0 },
{ opacity: '0', offset: 1 }];
const timing = { duration: 400, iterations: iterations };
return elem.animate(keyframes, timing);
}
function stopInterval() {
if (interval) {
clearInterval(interval);
interval = null;
}
}
self.show = function () {
import('css!' + pluginManager.mapPath(self, 'style.css')).then(() => {
let elem = document.querySelector('.logoScreenSaver');
if (!elem) {
elem = document.createElement('div');
elem.classList.add('logoScreenSaver');
document.body.appendChild(elem);
elem.innerHTML = '<img class="logoScreenSaverImage" src="assets/img/banner-light.png" />';
}
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function bounceInLeft(elem, iterations) {
var keyframes = [
{ transform: 'translate3d(-3000px, 0, 0)', opacity: '0', offset: 0 },
{ transform: 'translate3d(25px, 0, 0)', opacity: '1', offset: 0.6 },
{ transform: 'translate3d(-100px, 0, 0)', offset: 0.75 },
{ transform: 'translate3d(5px, 0, 0)', offset: 0.9 },
{ transform: 'none', opacity: '1', offset: 1 }];
var timing = { duration: 900, iterations: iterations, easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' };
return elem.animate(keyframes, timing);
}
function bounceInRight(elem, iterations) {
var keyframes = [
{ transform: 'translate3d(3000px, 0, 0)', opacity: '0', offset: 0 },
{ transform: 'translate3d(-25px, 0, 0)', opacity: '1', offset: 0.6 },
{ transform: 'translate3d(100px, 0, 0)', offset: 0.75 },
{ transform: 'translate3d(-5px, 0, 0)', offset: 0.9 },
{ transform: 'none', opacity: '1', offset: 1 }];
var timing = { duration: 900, iterations: iterations, easing: 'cubic-bezier(0.215, 0.610, 0.355, 1.000)' };
return elem.animate(keyframes, timing);
}
function swing(elem, iterations) {
var keyframes = [
{ transform: 'translate(0%)', offset: 0 },
{ transform: 'rotate3d(0, 0, 1, 15deg)', offset: 0.2 },
{ transform: 'rotate3d(0, 0, 1, -10deg)', offset: 0.4 },
{ transform: 'rotate3d(0, 0, 1, 5deg)', offset: 0.6 },
{ transform: 'rotate3d(0, 0, 1, -5deg)', offset: 0.8 },
{ transform: 'rotate3d(0, 0, 1, 0deg)', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function tada(elem, iterations) {
var keyframes = [
{ transform: 'scale3d(1, 1, 1)', offset: 0 },
{ transform: 'scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg)', offset: 0.1 },
{ transform: 'scale3d(.9, .9, .9) rotate3d(0, 0, 1, -3deg)', offset: 0.2 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.3 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.4 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.5 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.6 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.7 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg)', offset: 0.8 },
{ transform: 'scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg)', offset: 0.9 },
{ transform: 'scale3d(1, 1, 1)', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function wobble(elem, iterations) {
var keyframes = [
{ transform: 'translate(0%)', offset: 0 },
{ transform: 'translate3d(20%, 0, 0) rotate3d(0, 0, 1, 3deg)', offset: 0.15 },
{ transform: 'translate3d(-15%, 0, 0) rotate3d(0, 0, 1, -3deg)', offset: 0.45 },
{ transform: 'translate3d(10%, 0, 0) rotate3d(0, 0, 1, 2deg)', offset: 0.6 },
{ transform: 'translate3d(-5%, 0, 0) rotate3d(0, 0, 1, -1deg)', offset: 0.75 },
{ transform: 'translateX(0%)', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function rotateIn(elem, iterations) {
var keyframes = [{ transform: 'rotate3d(0, 0, 1, -200deg)', opacity: '0', transformOrigin: 'center', offset: 0 },
{ transform: 'none', opacity: '1', transformOrigin: 'center', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function rotateOut(elem, iterations) {
var keyframes = [{ transform: 'none', opacity: '1', transformOrigin: 'center', offset: 0 },
{ transform: 'rotate3d(0, 0, 1, 200deg)', opacity: '0', transformOrigin: 'center', offset: 1 }];
var timing = { duration: 900, iterations: iterations };
return elem.animate(keyframes, timing);
}
function fadeOut(elem, iterations) {
var keyframes = [
{ opacity: '1', offset: 0 },
{ opacity: '0', offset: 1 }];
var timing = { duration: 400, iterations: iterations };
return elem.animate(keyframes, timing);
}
function stopInterval() {
if (interval) {
clearInterval(interval);
interval = null;
}
}
self.show = function () {
require(['css!' + pluginManager.mapPath(self, 'style.css')], function () {
var elem = document.querySelector('.logoScreenSaver');
if (!elem) {
elem = document.createElement('div');
elem.classList.add('logoScreenSaver');
document.body.appendChild(elem);
elem.innerHTML = '<img class="logoScreenSaverImage" src="assets/img/banner-light.png" />';
}
stopInterval();
interval = setInterval(animate, 3000);
});
};
self.hide = function () {
stopInterval();
var elem = document.querySelector('.logoScreenSaver');
if (elem) {
var onAnimationFinish = function () {
elem.parentNode.removeChild(elem);
};
if (elem.animate) {
var animation = fadeOut(elem, 1);
animation.onfinish = onAnimationFinish;
} else {
onAnimationFinish();
}
}
};
interval = setInterval(animate, 3000);
});
};
});
self.hide = function () {
stopInterval();
const elem = document.querySelector('.logoScreenSaver');
if (elem) {
const onAnimationFinish = function () {
elem.parentNode.removeChild(elem);
};
if (elem.animate) {
const animation = fadeOut(elem, 1);
animation.onfinish = onAnimationFinish;
} else {
onAnimationFinish();
}
}
};
}

View File

@ -1,33 +1,26 @@
define(['connectionManager', 'globalize'], function (connectionManager, globalize) {
'use strict';
import connectionManager from 'connectionManager';
import globalize from 'globalize';
function getRequirePromise(deps) {
return new Promise(function (resolve, reject) {
require(deps, resolve);
});
}
function showErrorMessage() {
return import('alert').then(({default: alert}) => {
return alert(globalize.translate('MessagePlayAccessRestricted'));
});
}
function showErrorMessage() {
return getRequirePromise(['alert']).then(function (alert) {
return alert(globalize.translate('MessagePlayAccessRestricted')).then(function () {
return Promise.reject();
});
});
}
function PlayAccessValidation() {
class PlayAccessValidation {
constructor() {
this.name = 'Playback validation';
this.type = 'preplayintercept';
this.id = 'playaccessvalidation';
this.order = -2;
}
PlayAccessValidation.prototype.intercept = function (options) {
var item = options.item;
intercept(options) {
const item = options.item;
if (!item) {
return Promise.resolve();
}
var serverId = item.ServerId;
const serverId = item.ServerId;
if (!serverId) {
return Promise.resolve();
}
@ -44,7 +37,7 @@ define(['connectionManager', 'globalize'], function (connectionManager, globaliz
return showErrorMessage();
});
};
}
}
return PlayAccessValidation;
});
export default PlayAccessValidation;

View File

@ -1,6 +1,7 @@
define(['playbackManager', 'events', 'serverNotifications', 'connectionManager'], function (playbackManager, events, serverNotifications, connectionManager) {
'use strict';
serverNotifications = serverNotifications.default || serverNotifications;
playbackManager = playbackManager.default || playbackManager;
function getActivePlayerId() {

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
};

Some files were not shown because too many files have changed in this diff Show More