diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js
index 9629e9bb23..3e285514e1 100644
--- a/src/components/dialog/dialog.js
+++ b/src/components/dialog/dialog.js
@@ -10,132 +10,129 @@ import '../../elements/emby-button/emby-button';
import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-input/emby-input';
import '../formdialog.scss';
-import '../../assets/css/flexstyles.scss';
+import '../../styles/flexstyles.scss';
import template from './dialog.template.html';
-/* eslint-disable indent */
+function showDialog(options = { dialogOptions: {}, buttons: [] }) {
+ const dialogOptions = {
+ removeOnClose: true,
+ scrollY: false,
+ ...options.dialogOptions
+ };
- function showDialog(options = { dialogOptions: {}, buttons: [] }) {
- const dialogOptions = {
- removeOnClose: true,
- scrollY: false,
- ...options.dialogOptions
- };
+ const enableTvLayout = layoutManager.tv;
- const enableTvLayout = layoutManager.tv;
+ if (enableTvLayout) {
+ dialogOptions.size = 'fullscreen';
+ }
- if (enableTvLayout) {
- dialogOptions.size = 'fullscreen';
+ const dlg = dialogHelper.createDialog(dialogOptions);
+
+ dlg.classList.add('formDialog');
+
+ dlg.innerHTML = globalize.translateHtml(template, 'core');
+
+ dlg.classList.add('align-items-center');
+ dlg.classList.add('justify-content-center');
+ const formDialogContent = dlg.querySelector('.formDialogContent');
+ formDialogContent.classList.add('no-grow');
+
+ if (enableTvLayout) {
+ formDialogContent.style['max-width'] = '50%';
+ formDialogContent.style['max-height'] = '60%';
+ scrollHelper.centerFocus.on(formDialogContent, false);
+ } else {
+ formDialogContent.style.maxWidth = `${Math.min((options.buttons.length * 150) + 200, dom.getWindowSize().innerWidth - 50)}px`;
+ dlg.classList.add('dialog-fullscreen-lowres');
+ }
+
+ if (options.title) {
+ dlg.querySelector('.formDialogHeaderTitle').innerText = options.title || '';
+ } else {
+ dlg.querySelector('.formDialogHeaderTitle').classList.add('hide');
+ }
+
+ const displayText = options.html || options.text || '';
+ dlg.querySelector('.text').innerHTML = DOMPurify.sanitize(displayText);
+
+ if (!displayText) {
+ dlg.querySelector('.dialogContentInner').classList.add('hide');
+ }
+
+ let i;
+ let length;
+ let html = '';
+ let hasDescriptions = false;
+
+ for (i = 0, length = options.buttons.length; i < length; i++) {
+ const item = options.buttons[i];
+ const autoFocus = i === 0 ? ' autofocus' : '';
+
+ let buttonClass = 'btnOption raised formDialogFooterItem formDialogFooterItem-autosize';
+
+ if (item.type) {
+ buttonClass += ` button-${item.type}`;
}
- const dlg = dialogHelper.createDialog(dialogOptions);
-
- dlg.classList.add('formDialog');
-
- dlg.innerHTML = globalize.translateHtml(template, 'core');
-
- dlg.classList.add('align-items-center');
- dlg.classList.add('justify-content-center');
- const formDialogContent = dlg.querySelector('.formDialogContent');
- formDialogContent.classList.add('no-grow');
-
- if (enableTvLayout) {
- formDialogContent.style['max-width'] = '50%';
- formDialogContent.style['max-height'] = '60%';
- scrollHelper.centerFocus.on(formDialogContent, false);
- } else {
- formDialogContent.style.maxWidth = `${Math.min((options.buttons.length * 150) + 200, dom.getWindowSize().innerWidth - 50)}px`;
- dlg.classList.add('dialog-fullscreen-lowres');
+ if (item.description) {
+ hasDescriptions = true;
}
- if (options.title) {
- dlg.querySelector('.formDialogHeaderTitle').innerText = options.title || '';
- } else {
- dlg.querySelector('.formDialogHeaderTitle').classList.add('hide');
- }
-
- const displayText = options.html || options.text || '';
- dlg.querySelector('.text').innerHTML = DOMPurify.sanitize(displayText);
-
- if (!displayText) {
- dlg.querySelector('.dialogContentInner').classList.add('hide');
- }
-
- let i;
- let length;
- let html = '';
- let hasDescriptions = false;
-
- for (i = 0, length = options.buttons.length; i < length; i++) {
- const item = options.buttons[i];
- const autoFocus = i === 0 ? ' autofocus' : '';
-
- let buttonClass = 'btnOption raised formDialogFooterItem formDialogFooterItem-autosize';
-
- if (item.type) {
- buttonClass += ` button-${item.type}`;
- }
-
- if (item.description) {
- hasDescriptions = true;
- }
-
- if (hasDescriptions) {
- buttonClass += ' formDialogFooterItem-vertical formDialogFooterItem-nomarginbottom';
- }
-
- html += `
${escapeHtml(item.name)} `;
-
- if (item.description) {
- html += ``;
- }
- }
-
- dlg.querySelector('.formDialogFooter').innerHTML = html;
-
if (hasDescriptions) {
- dlg.querySelector('.formDialogFooter').classList.add('formDialogFooter-vertical');
+ buttonClass += ' formDialogFooterItem-vertical formDialogFooterItem-nomarginbottom';
}
- let dialogResult;
- function onButtonClick() {
- dialogResult = this.getAttribute('data-id');
- dialogHelper.close(dlg);
+ html += `
${escapeHtml(item.name)} `;
+
+ if (item.description) {
+ html += ``;
}
-
- const buttons = dlg.querySelectorAll('.btnOption');
- for (i = 0, length = buttons.length; i < length; i++) {
- buttons[i].addEventListener('click', onButtonClick);
- }
-
- return dialogHelper.open(dlg).then(() => {
- if (enableTvLayout) {
- scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
- }
-
- if (dialogResult) {
- return dialogResult;
- } else {
- return Promise.reject();
- }
- });
}
- export function show(text, title) {
- let options;
- if (typeof text === 'string') {
- options = {
- title: title,
- text: text
- };
+ dlg.querySelector('.formDialogFooter').innerHTML = html;
+
+ if (hasDescriptions) {
+ dlg.querySelector('.formDialogFooter').classList.add('formDialogFooter-vertical');
+ }
+
+ let dialogResult;
+ function onButtonClick() {
+ dialogResult = this.getAttribute('data-id');
+ dialogHelper.close(dlg);
+ }
+
+ const buttons = dlg.querySelectorAll('.btnOption');
+ for (i = 0, length = buttons.length; i < length; i++) {
+ buttons[i].addEventListener('click', onButtonClick);
+ }
+
+ return dialogHelper.open(dlg).then(() => {
+ if (enableTvLayout) {
+ scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
+ }
+
+ if (dialogResult) {
+ return dialogResult;
} else {
- options = text;
+ return Promise.reject();
}
+ });
+}
- return showDialog(options);
+export function show(text, title) {
+ let options;
+ if (typeof text === 'string') {
+ options = {
+ title: title,
+ text: text
+ };
+ } else {
+ options = text;
}
-/* eslint-enable indent */
+ return showDialog(options);
+}
+
export default {
show: show
};
diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js
index 9c1ecec625..b03ff9052c 100644
--- a/src/components/dialogHelper/dialogHelper.js
+++ b/src/components/dialogHelper/dialogHelper.js
@@ -1,4 +1,4 @@
-import { history } from '../appRouter';
+import { history } from '../router/appRouter';
import focusManager from '../focusManager';
import browser from '../../scripts/browser';
import layoutManager from '../layoutManager';
@@ -7,508 +7,503 @@ import { toBoolean } from '../../utils/string.ts';
import dom from '../../scripts/dom';
import './dialoghelper.scss';
-import '../../assets/css/scrollstyles.scss';
+import '../../styles/scrollstyles.scss';
-/* eslint-disable indent */
+let globalOnOpenCallback;
- let globalOnOpenCallback;
-
- function enableAnimation() {
- // too slow
- if (browser.tv) {
- return false;
- }
-
- return browser.supportsCssAnimation();
+function enableAnimation() {
+ // too slow
+ if (browser.tv) {
+ return false;
}
- function removeCenterFocus(dlg) {
- if (layoutManager.tv) {
- if (dlg.classList.contains('scrollX')) {
- centerFocus(dlg, true, false);
- } else if (dlg.classList.contains('smoothScrollY')) {
- centerFocus(dlg, false, false);
- }
+ return browser.supportsCssAnimation();
+}
+
+function removeCenterFocus(dlg) {
+ if (layoutManager.tv) {
+ if (dlg.classList.contains('scrollX')) {
+ centerFocus(dlg, true, false);
+ } else if (dlg.classList.contains('smoothScrollY')) {
+ centerFocus(dlg, false, false);
+ }
+ }
+}
+
+function tryRemoveElement(elem) {
+ const parentNode = elem.parentNode;
+ if (parentNode) {
+ // Seeing crashes in edge webview
+ try {
+ parentNode.removeChild(elem);
+ } catch (err) {
+ console.error('[dialogHelper] error removing dialog element: ' + err);
+ }
+ }
+}
+
+function DialogHashHandler(dlg, hash, resolve) {
+ const self = this;
+ self.originalUrl = window.location.href;
+ const activeElement = document.activeElement;
+ let removeScrollLockOnClose = false;
+ let unlisten;
+
+ function onHashChange({ location }) {
+ const dialogs = location.state?.dialogs || [];
+ const shouldClose = !dialogs.includes(hash);
+
+ if ((shouldClose || !isOpened(dlg)) && unlisten) {
+ unlisten();
+ unlisten = null;
+ }
+
+ if (shouldClose) {
+ close(dlg);
}
}
- function tryRemoveElement(elem) {
- const parentNode = elem.parentNode;
- if (parentNode) {
- // Seeing crashes in edge webview
- try {
- parentNode.removeChild(elem);
- } catch (err) {
- console.error('[dialogHelper] error removing dialog element: ' + err);
- }
- }
- }
-
- function DialogHashHandler(dlg, hash, resolve) {
- const self = this;
- self.originalUrl = window.location.href;
- const activeElement = document.activeElement;
- let removeScrollLockOnClose = false;
- let unlisten;
-
- function onHashChange({ location }) {
- const dialogs = location.state?.dialogs || [];
- const shouldClose = !dialogs.includes(hash);
-
- if ((shouldClose || !isOpened(dlg)) && unlisten) {
- unlisten();
- unlisten = null;
- }
-
- if (shouldClose) {
- close(dlg);
- }
+ function finishClose() {
+ if (unlisten) {
+ unlisten();
+ unlisten = null;
}
- function finishClose() {
- if (unlisten) {
- unlisten();
- unlisten = null;
- }
-
- dlg.dispatchEvent(new CustomEvent('close', {
- bubbles: false,
- cancelable: false
- }));
-
- resolve({
- element: dlg
- });
- }
-
- function onBackCommand(e) {
- if (e.detail.command === 'back') {
- e.preventDefault();
- e.stopPropagation();
- close(dlg);
- }
- }
-
- function onDialogClosed() {
- if (!isHistoryEnabled(dlg)) {
- inputManager.off(dlg, onBackCommand);
- }
-
- if (unlisten) {
- unlisten();
- unlisten = null;
- }
-
- removeBackdrop(dlg);
- dlg.classList.remove('opened');
-
- if (removeScrollLockOnClose) {
- document.body.classList.remove('noScroll');
- }
-
- if (isHistoryEnabled(dlg)) {
- const state = history.location.state || {};
- if (state.dialogs?.length > 0) {
- if (state.dialogs[state.dialogs.length - 1] === hash) {
- unlisten = history.listen(finishClose);
- history.back();
- } else if (state.dialogs.includes(hash)) {
- console.warn('[dialogHelper] dialog "%s" was closed, but is not the last dialog opened', hash);
-
- unlisten = history.listen(finishClose);
-
- // Remove the closed dialog hash from the history state
- history.replace(
- `${history.location.pathname}${history.location.search}`,
- {
- ...state,
- dialogs: state.dialogs.filter(dialog => dialog !== hash)
- }
- );
- }
- }
- }
-
- if (layoutManager.tv) {
- focusManager.focus(activeElement);
- }
-
- if (toBoolean(dlg.getAttribute('data-removeonclose'), true)) {
- removeCenterFocus(dlg);
-
- const dialogContainer = dlg.dialogContainer;
- if (dialogContainer) {
- tryRemoveElement(dialogContainer);
- dlg.dialogContainer = null;
- } else {
- tryRemoveElement(dlg);
- }
- }
-
- if (!unlisten) {
- finishClose();
- }
- }
-
- dlg.addEventListener('_close', onDialogClosed);
-
- const center = !dlg.classList.contains('dialog-fixedSize');
- if (center) {
- dlg.classList.add('centeredDialog');
- }
-
- dlg.classList.remove('hide');
-
- addBackdropOverlay(dlg);
-
- dlg.classList.add('opened');
- dlg.dispatchEvent(new CustomEvent('open', {
+ dlg.dispatchEvent(new CustomEvent('close', {
bubbles: false,
cancelable: false
}));
- if (dlg.getAttribute('data-lockscroll') === 'true' && !document.body.classList.contains('noScroll')) {
- document.body.classList.add('noScroll');
- removeScrollLockOnClose = true;
+ resolve({
+ element: dlg
+ });
+ }
+
+ function onBackCommand(e) {
+ if (e.detail.command === 'back') {
+ e.preventDefault();
+ e.stopPropagation();
+ close(dlg);
+ }
+ }
+
+ function onDialogClosed() {
+ if (!isHistoryEnabled(dlg)) {
+ inputManager.off(dlg, onBackCommand);
}
- animateDialogOpen(dlg);
+ if (unlisten) {
+ unlisten();
+ unlisten = null;
+ }
+
+ removeBackdrop(dlg);
+ dlg.classList.remove('opened');
+
+ if (removeScrollLockOnClose) {
+ document.body.classList.remove('noScroll');
+ }
if (isHistoryEnabled(dlg)) {
const state = history.location.state || {};
- const dialogs = state.dialogs || [];
- // Add new dialog to the list of open dialogs
- dialogs.push(hash);
+ if (state.dialogs?.length > 0) {
+ if (state.dialogs[state.dialogs.length - 1] === hash) {
+ unlisten = history.listen(finishClose);
+ history.back();
+ } else if (state.dialogs.includes(hash)) {
+ console.warn('[dialogHelper] dialog "%s" was closed, but is not the last dialog opened', hash);
- history.push(
- `${history.location.pathname}${history.location.search}`,
- {
- ...state,
- dialogs
+ unlisten = history.listen(finishClose);
+
+ // Remove the closed dialog hash from the history state
+ history.replace(
+ `${history.location.pathname}${history.location.search}`,
+ {
+ ...state,
+ dialogs: state.dialogs.filter(dialog => dialog !== hash)
+ }
+ );
}
- );
-
- unlisten = history.listen(onHashChange);
- } else {
- inputManager.on(dlg, onBackCommand);
- }
- }
-
- function addBackdropOverlay(dlg) {
- const backdrop = document.createElement('div');
- backdrop.classList.add('dialogBackdrop');
-
- const backdropParent = dlg.dialogContainer || dlg;
- backdropParent.parentNode.insertBefore(backdrop, backdropParent);
- dlg.backdrop = backdrop;
-
- // trigger reflow or the backdrop will not animate
- void backdrop.offsetWidth;
- backdrop.classList.add('dialogBackdropOpened');
-
- dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
- if (e.target === dlg.dialogContainer) {
- close(dlg);
}
- }, {
- passive: true
- });
+ }
- dom.addEventListener((dlg.dialogContainer || backdrop), 'contextmenu', e => {
- if (e.target === dlg.dialogContainer) {
- // Close the application dialog menu
- close(dlg);
- // Prevent the default browser context menu from appearing
- e.preventDefault();
+ if (layoutManager.tv) {
+ focusManager.focus(activeElement);
+ }
+
+ if (toBoolean(dlg.getAttribute('data-removeonclose'), true)) {
+ removeCenterFocus(dlg);
+
+ const dialogContainer = dlg.dialogContainer;
+ if (dialogContainer) {
+ tryRemoveElement(dialogContainer);
+ dlg.dialogContainer = null;
+ } else {
+ tryRemoveElement(dlg);
}
- });
- }
-
- function isHistoryEnabled(dlg) {
- return dlg.getAttribute('data-history') === 'true';
- }
-
- export function open(dlg) {
- if (globalOnOpenCallback) {
- globalOnOpenCallback(dlg);
}
- const parent = dlg.parentNode;
- if (parent) {
- parent.removeChild(dlg);
+ if (!unlisten) {
+ finishClose();
}
-
- const dialogContainer = document.createElement('div');
- dialogContainer.classList.add('dialogContainer');
- dialogContainer.appendChild(dlg);
- dlg.dialogContainer = dialogContainer;
- document.body.appendChild(dialogContainer);
-
- return new Promise((resolve) => {
- new DialogHashHandler(dlg, `dlg${new Date().getTime()}`, resolve);
- });
}
- function isOpened(dlg) {
- //return dlg.opened;
- return !dlg.classList.contains('hide');
+ dlg.addEventListener('_close', onDialogClosed);
+
+ const center = !dlg.classList.contains('dialog-fixedSize');
+ if (center) {
+ dlg.classList.add('centeredDialog');
}
- export function close(dlg) {
- if (!dlg.classList.contains('hide')) {
- dlg.dispatchEvent(new CustomEvent('closing', {
+ dlg.classList.remove('hide');
+
+ addBackdropOverlay(dlg);
+
+ dlg.classList.add('opened');
+ dlg.dispatchEvent(new CustomEvent('open', {
+ bubbles: false,
+ cancelable: false
+ }));
+
+ if (dlg.getAttribute('data-lockscroll') === 'true' && !document.body.classList.contains('noScroll')) {
+ document.body.classList.add('noScroll');
+ removeScrollLockOnClose = true;
+ }
+
+ animateDialogOpen(dlg);
+
+ if (isHistoryEnabled(dlg)) {
+ const state = history.location.state || {};
+ const dialogs = state.dialogs || [];
+ // Add new dialog to the list of open dialogs
+ dialogs.push(hash);
+
+ history.push(
+ `${history.location.pathname}${history.location.search}`,
+ {
+ ...state,
+ dialogs
+ }
+ );
+
+ unlisten = history.listen(onHashChange);
+ } else {
+ inputManager.on(dlg, onBackCommand);
+ }
+}
+
+function addBackdropOverlay(dlg) {
+ const backdrop = document.createElement('div');
+ backdrop.classList.add('dialogBackdrop');
+
+ const backdropParent = dlg.dialogContainer || dlg;
+ backdropParent.parentNode.insertBefore(backdrop, backdropParent);
+ dlg.backdrop = backdrop;
+
+ // trigger reflow or the backdrop will not animate
+ void backdrop.offsetWidth;
+ backdrop.classList.add('dialogBackdropOpened');
+
+ dom.addEventListener((dlg.dialogContainer || backdrop), 'click', e => {
+ if (e.target === dlg.dialogContainer) {
+ close(dlg);
+ }
+ }, {
+ passive: true
+ });
+
+ dom.addEventListener((dlg.dialogContainer || backdrop), 'contextmenu', e => {
+ if (e.target === dlg.dialogContainer) {
+ // Close the application dialog menu
+ close(dlg);
+ // Prevent the default browser context menu from appearing
+ e.preventDefault();
+ }
+ });
+}
+
+function isHistoryEnabled(dlg) {
+ return dlg.getAttribute('data-history') === 'true';
+}
+
+export function open(dlg) {
+ if (globalOnOpenCallback) {
+ globalOnOpenCallback(dlg);
+ }
+
+ const parent = dlg.parentNode;
+ if (parent) {
+ parent.removeChild(dlg);
+ }
+
+ const dialogContainer = document.createElement('div');
+ dialogContainer.classList.add('dialogContainer');
+ dialogContainer.appendChild(dlg);
+ dlg.dialogContainer = dialogContainer;
+ document.body.appendChild(dialogContainer);
+
+ return new Promise((resolve) => {
+ new DialogHashHandler(dlg, `dlg${new Date().getTime()}`, resolve);
+ });
+}
+
+function isOpened(dlg) {
+ return !dlg.classList.contains('hide');
+}
+
+export function close(dlg) {
+ if (!dlg.classList.contains('hide')) {
+ dlg.dispatchEvent(new CustomEvent('closing', {
+ bubbles: false,
+ cancelable: false
+ }));
+
+ const onAnimationFinish = () => {
+ focusManager.popScope(dlg);
+
+ dlg.classList.add('hide');
+ dlg.dispatchEvent(new CustomEvent('_close', {
bubbles: false,
cancelable: false
}));
+ };
- const onAnimationFinish = () => {
- focusManager.popScope(dlg);
-
- dlg.classList.add('hide');
- dlg.dispatchEvent(new CustomEvent('_close', {
- bubbles: false,
- cancelable: false
- }));
- };
-
- animateDialogClose(dlg, onAnimationFinish);
- }
+ animateDialogClose(dlg, onAnimationFinish);
}
+}
- const getAnimationEndHandler = (dlg, callback) => function handler() {
- dom.removeEventListener(dlg, dom.whichAnimationEvent(), handler, { once: true });
- callback();
+const getAnimationEndHandler = (dlg, callback) => function handler() {
+ dom.removeEventListener(dlg, dom.whichAnimationEvent(), handler, { once: true });
+ callback();
+};
+
+function animateDialogOpen(dlg) {
+ const onAnimationFinish = () => {
+ focusManager.pushScope(dlg);
+
+ if (dlg.getAttribute('data-autofocus') === 'true') {
+ focusManager.autoFocus(dlg);
+ }
+
+ if (document.activeElement && !dlg.contains(document.activeElement)) {
+ // Blur foreign element to prevent triggering of an action from the previous scope
+ document.activeElement.blur();
+ }
};
- function animateDialogOpen(dlg) {
- const onAnimationFinish = () => {
- focusManager.pushScope(dlg);
+ if (enableAnimation()) {
+ dom.addEventListener(
+ dlg,
+ dom.whichAnimationEvent(),
+ getAnimationEndHandler(dlg, onAnimationFinish),
+ { once: true });
- if (dlg.getAttribute('data-autofocus') === 'true') {
- focusManager.autoFocus(dlg);
- }
+ return;
+ }
- if (document.activeElement && !dlg.contains(document.activeElement)) {
- // Blur foreign element to prevent triggering of an action from the previous scope
- document.activeElement.blur();
- }
- };
+ onAnimationFinish();
+}
- if (enableAnimation()) {
- dom.addEventListener(
- dlg,
- dom.whichAnimationEvent(),
- getAnimationEndHandler(dlg, onAnimationFinish),
- { once: true });
+function animateDialogClose(dlg, onAnimationFinish) {
+ if (enableAnimation()) {
+ let animated = true;
+ switch (dlg.animationConfig.exit.name) {
+ case 'fadeout':
+ dlg.style.animation = `fadeout ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
+ break;
+ case 'scaledown':
+ dlg.style.animation = `scaledown ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
+ break;
+ case 'slidedown':
+ dlg.style.animation = `slidedown ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
+ break;
+ default:
+ animated = false;
+ break;
+ }
+
+ dom.addEventListener(
+ dlg,
+ dom.whichAnimationEvent(),
+ getAnimationEndHandler(dlg, onAnimationFinish),
+ { once: true });
+
+ if (animated) {
return;
}
-
- onAnimationFinish();
}
- function animateDialogClose(dlg, onAnimationFinish) {
- if (enableAnimation()) {
- let animated = true;
+ onAnimationFinish();
+}
- switch (dlg.animationConfig.exit.name) {
- case 'fadeout':
- dlg.style.animation = `fadeout ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
- break;
- case 'scaledown':
- dlg.style.animation = `scaledown ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
- break;
- case 'slidedown':
- dlg.style.animation = `slidedown ${dlg.animationConfig.exit.timing.duration}ms ease-out normal both`;
- break;
- default:
- animated = false;
- break;
+const supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style;
+
+function shouldLockDocumentScroll(options) {
+ if (options.lockScroll != null) {
+ return options.lockScroll;
+ }
+
+ if (options.size === 'fullscreen') {
+ return true;
+ }
+
+ if (supportsOverscrollBehavior && (options.size || !browser.touch)) {
+ return false;
+ }
+
+ if (options.size) {
+ return true;
+ }
+
+ return browser.touch;
+}
+
+function removeBackdrop(dlg) {
+ const backdrop = dlg.backdrop;
+
+ if (!backdrop) {
+ return;
+ }
+
+ dlg.backdrop = null;
+
+ const onAnimationFinish = () => {
+ tryRemoveElement(backdrop);
+ };
+
+ if (enableAnimation()) {
+ backdrop.classList.remove('dialogBackdropOpened');
+
+ // this is not firing animationend
+ setTimeout(onAnimationFinish, 300);
+ return;
+ }
+
+ onAnimationFinish();
+}
+
+function centerFocus(elem, horiz, on) {
+ import('../../scripts/scrollHelper').then((scrollHelper) => {
+ const fn = on ? 'on' : 'off';
+ scrollHelper.centerFocus[fn](elem, horiz);
+ });
+}
+
+export function createDialog(options = {}) {
+ // If there's no native dialog support, use a plain div
+ // Also not working well in samsung tizen browser, content inside not clickable
+ // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog
+ const dlg = document.createElement('div');
+
+ // Add an id so we can access the dialog element
+ if (options.id) {
+ dlg.id = options.id;
+ }
+
+ dlg.classList.add('focuscontainer');
+ dlg.classList.add('hide');
+
+ if (shouldLockDocumentScroll(options)) {
+ dlg.setAttribute('data-lockscroll', 'true');
+ }
+
+ if (options.enableHistory !== false) {
+ dlg.setAttribute('data-history', 'true');
+ }
+
+ // without this safari will scroll the background instead of the dialog contents
+ // but not needed here since this is already on top of an existing dialog
+ // but skip it in IE because it's causing the entire browser to hang
+ // Also have to disable for firefox because it's causing select elements to not be clickable
+ if (options.modal !== false) {
+ dlg.setAttribute('modal', 'modal');
+ }
+
+ if (options.autoFocus !== false) {
+ dlg.setAttribute('data-autofocus', 'true');
+ }
+
+ const defaultEntryAnimation = 'scaleup';
+ const defaultExitAnimation = 'scaledown';
+ const entryAnimation = options.entryAnimation || defaultEntryAnimation;
+ const exitAnimation = options.exitAnimation || defaultExitAnimation;
+
+ // If it's not fullscreen then lower the default animation speed to make it open really fast
+ const entryAnimationDuration = options.entryAnimationDuration || (options.size !== 'fullscreen' ? 180 : 280);
+ const exitAnimationDuration = options.exitAnimationDuration || (options.size !== 'fullscreen' ? 120 : 220);
+
+ dlg.animationConfig = {
+ // scale up
+ 'entry': {
+ name: entryAnimation,
+ timing: {
+ duration: entryAnimationDuration,
+ easing: 'ease-out'
}
-
- dom.addEventListener(
- dlg,
- dom.whichAnimationEvent(),
- getAnimationEndHandler(dlg, onAnimationFinish),
- { once: true });
-
- if (animated) {
- return;
+ },
+ // fade out
+ 'exit': {
+ name: exitAnimation,
+ timing: {
+ duration: exitAnimationDuration,
+ easing: 'ease-out',
+ fill: 'both'
}
}
+ };
- onAnimationFinish();
+ dlg.classList.add('dialog');
+
+ if (options.scrollX) {
+ dlg.classList.add('scrollX');
+ dlg.classList.add('smoothScrollX');
+
+ if (layoutManager.tv) {
+ centerFocus(dlg, true, true);
+ }
+ } else if (options.scrollY !== false) {
+ dlg.classList.add('smoothScrollY');
+
+ if (layoutManager.tv) {
+ centerFocus(dlg, false, true);
+ }
}
- const supportsOverscrollBehavior = 'overscroll-behavior-y' in document.body.style;
-
- function shouldLockDocumentScroll(options) {
- if (options.lockScroll != null) {
- return options.lockScroll;
- }
-
- if (options.size === 'fullscreen') {
- return true;
- }
-
- if (supportsOverscrollBehavior && (options.size || !browser.touch)) {
- return false;
- }
-
- if (options.size) {
- return true;
- }
-
- return browser.touch;
+ if (options.removeOnClose) {
+ dlg.setAttribute('data-removeonclose', 'true');
}
- function removeBackdrop(dlg) {
- const backdrop = dlg.backdrop;
-
- if (!backdrop) {
- return;
- }
-
- dlg.backdrop = null;
-
- const onAnimationFinish = () => {
- tryRemoveElement(backdrop);
- };
-
- if (enableAnimation()) {
- backdrop.classList.remove('dialogBackdropOpened');
-
- // this is not firing animationend
- setTimeout(onAnimationFinish, 300);
- return;
- }
-
- onAnimationFinish();
+ if (options.size) {
+ dlg.classList.add('dialog-fixedSize');
+ dlg.classList.add(`dialog-${options.size}`);
}
- function centerFocus(elem, horiz, on) {
- import('../../scripts/scrollHelper').then((scrollHelper) => {
- const fn = on ? 'on' : 'off';
- scrollHelper.centerFocus[fn](elem, horiz);
- });
+ if (enableAnimation()) {
+ switch (dlg.animationConfig.entry.name) {
+ case 'fadein':
+ dlg.style.animation = `fadein ${entryAnimationDuration}ms ease-out normal`;
+ break;
+ case 'scaleup':
+ dlg.style.animation = `scaleup ${entryAnimationDuration}ms ease-out normal both`;
+ break;
+ case 'slideup':
+ dlg.style.animation = `slideup ${entryAnimationDuration}ms ease-out normal`;
+ break;
+ case 'slidedown':
+ dlg.style.animation = `slidedown ${entryAnimationDuration}ms ease-out normal`;
+ break;
+ default:
+ break;
+ }
}
- export function createDialog(options = {}) {
- // If there's no native dialog support, use a plain div
- // Also not working well in samsung tizen browser, content inside not clickable
- // Just go ahead and always use a plain div because we're seeing issues overlaying absoltutely positioned content over a modal dialog
- const dlg = document.createElement('div');
+ return dlg;
+}
- // Add an id so we can access the dialog element
- if (options.id) {
- dlg.id = options.id;
- }
-
- dlg.classList.add('focuscontainer');
- dlg.classList.add('hide');
-
- if (shouldLockDocumentScroll(options)) {
- dlg.setAttribute('data-lockscroll', 'true');
- }
-
- if (options.enableHistory !== false) {
- dlg.setAttribute('data-history', 'true');
- }
-
- // without this safari will scroll the background instead of the dialog contents
- // but not needed here since this is already on top of an existing dialog
- // but skip it in IE because it's causing the entire browser to hang
- // Also have to disable for firefox because it's causing select elements to not be clickable
- if (options.modal !== false) {
- dlg.setAttribute('modal', 'modal');
- }
-
- if (options.autoFocus !== false) {
- dlg.setAttribute('data-autofocus', 'true');
- }
-
- const defaultEntryAnimation = 'scaleup';
- const defaultExitAnimation = 'scaledown';
- const entryAnimation = options.entryAnimation || defaultEntryAnimation;
- const exitAnimation = options.exitAnimation || defaultExitAnimation;
-
- // If it's not fullscreen then lower the default animation speed to make it open really fast
- const entryAnimationDuration = options.entryAnimationDuration || (options.size !== 'fullscreen' ? 180 : 280);
- const exitAnimationDuration = options.exitAnimationDuration || (options.size !== 'fullscreen' ? 120 : 220);
-
- dlg.animationConfig = {
- // scale up
- 'entry': {
- name: entryAnimation,
- timing: {
- duration: entryAnimationDuration,
- easing: 'ease-out'
- }
- },
- // fade out
- 'exit': {
- name: exitAnimation,
- timing: {
- duration: exitAnimationDuration,
- easing: 'ease-out',
- fill: 'both'
- }
- }
- };
-
- dlg.classList.add('dialog');
-
- if (options.scrollX) {
- dlg.classList.add('scrollX');
- dlg.classList.add('smoothScrollX');
-
- if (layoutManager.tv) {
- centerFocus(dlg, true, true);
- }
- } else if (options.scrollY !== false) {
- dlg.classList.add('smoothScrollY');
-
- if (layoutManager.tv) {
- centerFocus(dlg, false, true);
- }
- }
-
- if (options.removeOnClose) {
- dlg.setAttribute('data-removeonclose', 'true');
- }
-
- if (options.size) {
- dlg.classList.add('dialog-fixedSize');
- dlg.classList.add(`dialog-${options.size}`);
- }
-
- if (enableAnimation()) {
- switch (dlg.animationConfig.entry.name) {
- case 'fadein':
- dlg.style.animation = `fadein ${entryAnimationDuration}ms ease-out normal`;
- break;
- case 'scaleup':
- dlg.style.animation = `scaleup ${entryAnimationDuration}ms ease-out normal both`;
- break;
- case 'slideup':
- dlg.style.animation = `slideup ${entryAnimationDuration}ms ease-out normal`;
- break;
- case 'slidedown':
- dlg.style.animation = `slidedown ${entryAnimationDuration}ms ease-out normal`;
- break;
- default:
- break;
- }
- }
-
- return dlg;
- }
-
- export function setOnOpen(val) {
- globalOnOpenCallback = val;
- }
-
-/* eslint-enable indent */
+export function setOnOpen(val) {
+ globalOnOpenCallback = val;
+}
export default {
open: open,
diff --git a/src/components/directorybrowser/directorybrowser.js b/src/components/directorybrowser/directorybrowser.js
index 2accc1520f..4a9119266b 100644
--- a/src/components/directorybrowser/directorybrowser.js
+++ b/src/components/directorybrowser/directorybrowser.js
@@ -43,7 +43,7 @@ function refreshDirectoryBrowser(page, path, fileOptions, updatePathOnError) {
Promise.all(promises).then(
responses => {
const folders = responses[0];
- const parentPath = responses[1] || '';
+ const parentPath = (responses[1] ? JSON.parse(responses[1]) : '') || '';
let html = '';
page.querySelector('.results').scrollTop = 0;
diff --git a/src/components/displaySettings/displaySettings.js b/src/components/displaySettings/displaySettings.js
index f351368a9a..c0ede8aec5 100644
--- a/src/components/displaySettings/displaySettings.js
+++ b/src/components/displaySettings/displaySettings.js
@@ -8,6 +8,7 @@ import datetime from '../../scripts/datetime';
import globalize from '../../scripts/globalize';
import loading from '../loading/loading';
import skinManager from '../../scripts/themeManager';
+import { PluginType } from '../../types/plugin.ts';
import Events from '../../utils/events.ts';
import '../../elements/emby-select/emby-select';
import '../../elements/emby-checkbox/emby-checkbox';
@@ -17,238 +18,235 @@ import ServerConnections from '../ServerConnections';
import toast from '../toast/toast';
import template from './displaySettings.template.html';
-/* eslint-disable indent */
-
- function fillThemes(select, selectedTheme) {
- skinManager.getThemes().then(themes => {
- select.innerHTML = themes.map(t => {
- return `
${escapeHtml(t.name)} `;
- }).join('');
-
- // get default theme
- const defaultTheme = themes.find(theme => theme.default);
-
- // set the current theme
- select.value = selectedTheme || defaultTheme.id;
- });
- }
-
- function loadScreensavers(context, userSettings) {
- const selectScreensaver = context.querySelector('.selectScreensaver');
- const options = pluginManager.ofType('screensaver').map(plugin => {
- return {
- name: plugin.name,
- value: plugin.id
- };
- });
-
- options.unshift({
- name: globalize.translate('None'),
- value: 'none'
- });
-
- selectScreensaver.innerHTML = options.map(o => {
- return `
${escapeHtml(o.name)} `;
+function fillThemes(select, selectedTheme) {
+ skinManager.getThemes().then(themes => {
+ select.innerHTML = themes.map(t => {
+ return `
${escapeHtml(t.name)} `;
}).join('');
- selectScreensaver.value = userSettings.screensaver();
+ // get default theme
+ const defaultTheme = themes.find(theme => theme.default);
- if (!selectScreensaver.value) {
- // TODO: set the default instead of none
- selectScreensaver.value = 'none';
- }
+ // set the current theme
+ select.value = selectedTheme || defaultTheme.id;
+ });
+}
+
+function loadScreensavers(context, userSettings) {
+ const selectScreensaver = context.querySelector('.selectScreensaver');
+ const options = pluginManager.ofType(PluginType.Screensaver).map(plugin => {
+ return {
+ name: plugin.name,
+ value: plugin.id
+ };
+ });
+
+ options.unshift({
+ name: globalize.translate('None'),
+ value: 'none'
+ });
+
+ selectScreensaver.innerHTML = options.map(o => {
+ return `
${escapeHtml(o.name)} `;
+ }).join('');
+
+ selectScreensaver.value = userSettings.screensaver();
+
+ if (!selectScreensaver.value) {
+ // TODO: set the default instead of none
+ selectScreensaver.value = 'none';
+ }
+}
+
+function showOrHideMissingEpisodesField(context) {
+ if (browser.tizen || browser.web0s) {
+ context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
+ return;
}
- function showOrHideMissingEpisodesField(context) {
- if (browser.tizen || browser.web0s) {
- context.querySelector('.fldDisplayMissingEpisodes').classList.add('hide');
- return;
- }
+ context.querySelector('.fldDisplayMissingEpisodes').classList.remove('hide');
+}
- context.querySelector('.fldDisplayMissingEpisodes').classList.remove('hide');
+function loadForm(context, user, userSettings) {
+ if (appHost.supports('displaylanguage')) {
+ context.querySelector('.languageSection').classList.remove('hide');
+ } else {
+ context.querySelector('.languageSection').classList.add('hide');
}
- function loadForm(context, user, userSettings) {
- if (appHost.supports('displaylanguage')) {
- context.querySelector('.languageSection').classList.remove('hide');
- } else {
- context.querySelector('.languageSection').classList.add('hide');
- }
-
- if (appHost.supports('displaymode')) {
- context.querySelector('.fldDisplayMode').classList.remove('hide');
- } else {
- context.querySelector('.fldDisplayMode').classList.add('hide');
- }
-
- if (appHost.supports('externallinks')) {
- context.querySelector('.learnHowToContributeContainer').classList.remove('hide');
- } else {
- context.querySelector('.learnHowToContributeContainer').classList.add('hide');
- }
-
- context.querySelector('.selectDashboardThemeContainer').classList.toggle('hide', !user.Policy.IsAdministrator);
-
- if (appHost.supports('screensaver')) {
- context.querySelector('.selectScreensaverContainer').classList.remove('hide');
- } else {
- context.querySelector('.selectScreensaverContainer').classList.add('hide');
- }
-
- if (datetime.supportsLocalization()) {
- context.querySelector('.fldDateTimeLocale').classList.remove('hide');
- } else {
- context.querySelector('.fldDateTimeLocale').classList.add('hide');
- }
-
- fillThemes(context.querySelector('#selectTheme'), userSettings.theme());
- fillThemes(context.querySelector('#selectDashboardTheme'), userSettings.dashboardTheme());
-
- loadScreensavers(context, userSettings);
-
- context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
-
- context.querySelector('#chkThemeSong').checked = userSettings.enableThemeSongs();
- context.querySelector('#chkThemeVideo').checked = userSettings.enableThemeVideos();
- context.querySelector('#chkFadein').checked = userSettings.enableFastFadein();
- context.querySelector('#chkBlurhash').checked = userSettings.enableBlurhash();
- context.querySelector('#chkBackdrops').checked = userSettings.enableBackdrops();
- context.querySelector('#chkDetailsBanner').checked = userSettings.detailsBanner();
-
- context.querySelector('#chkDisableCustomCss').checked = userSettings.disableCustomCss();
- context.querySelector('#txtLocalCustomCss').value = userSettings.customCss();
-
- context.querySelector('#selectLanguage').value = userSettings.language() || '';
- context.querySelector('.selectDateTimeLocale').value = userSettings.dateTimeLocale() || '';
-
- context.querySelector('#txtLibraryPageSize').value = userSettings.libraryPageSize();
-
- context.querySelector('#txtMaxDaysForNextUp').value = userSettings.maxDaysForNextUp();
- context.querySelector('#chkRewatchingNextUp').checked = userSettings.enableRewatchingInNextUp();
- context.querySelector('#chkUseEpisodeImagesInNextUp').checked = userSettings.useEpisodeImagesInNextUpAndResume();
-
- context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
-
- showOrHideMissingEpisodesField(context);
-
- loading.hide();
+ if (appHost.supports('displaymode')) {
+ context.querySelector('.fldDisplayMode').classList.remove('hide');
+ } else {
+ context.querySelector('.fldDisplayMode').classList.add('hide');
}
- function saveUser(context, user, userSettingsInstance, apiClient) {
- user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
-
- if (appHost.supports('displaylanguage')) {
- userSettingsInstance.language(context.querySelector('#selectLanguage').value);
- }
-
- userSettingsInstance.dateTimeLocale(context.querySelector('.selectDateTimeLocale').value);
-
- userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
- userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
- userSettingsInstance.theme(context.querySelector('#selectTheme').value);
- userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
- userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
-
- userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);
-
- userSettingsInstance.maxDaysForNextUp(context.querySelector('#txtMaxDaysForNextUp').value);
- userSettingsInstance.enableRewatchingInNextUp(context.querySelector('#chkRewatchingNextUp').checked);
- userSettingsInstance.useEpisodeImagesInNextUpAndResume(context.querySelector('#chkUseEpisodeImagesInNextUp').checked);
-
- userSettingsInstance.enableFastFadein(context.querySelector('#chkFadein').checked);
- userSettingsInstance.enableBlurhash(context.querySelector('#chkBlurhash').checked);
- userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);
- userSettingsInstance.detailsBanner(context.querySelector('#chkDetailsBanner').checked);
-
- userSettingsInstance.disableCustomCss(context.querySelector('#chkDisableCustomCss').checked);
- userSettingsInstance.customCss(context.querySelector('#txtLocalCustomCss').value);
-
- if (user.Id === apiClient.getCurrentUserId()) {
- skinManager.setTheme(userSettingsInstance.theme());
- }
-
- layoutManager.setLayout(context.querySelector('.selectLayout').value);
- return apiClient.updateUserConfiguration(user.Id, user.Configuration);
+ if (appHost.supports('externallinks')) {
+ context.querySelector('.learnHowToContributeContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.learnHowToContributeContainer').classList.add('hide');
}
- function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
+ context.querySelector('.selectDashboardThemeContainer').classList.toggle('hide', !user.Policy.IsAdministrator);
+
+ if (appHost.supports('screensaver')) {
+ context.querySelector('.selectScreensaverContainer').classList.remove('hide');
+ } else {
+ context.querySelector('.selectScreensaverContainer').classList.add('hide');
+ }
+
+ if (datetime.supportsLocalization()) {
+ context.querySelector('.fldDateTimeLocale').classList.remove('hide');
+ } else {
+ context.querySelector('.fldDateTimeLocale').classList.add('hide');
+ }
+
+ fillThemes(context.querySelector('#selectTheme'), userSettings.theme());
+ fillThemes(context.querySelector('#selectDashboardTheme'), userSettings.dashboardTheme());
+
+ loadScreensavers(context, userSettings);
+
+ context.querySelector('.chkDisplayMissingEpisodes').checked = user.Configuration.DisplayMissingEpisodes || false;
+
+ context.querySelector('#chkThemeSong').checked = userSettings.enableThemeSongs();
+ context.querySelector('#chkThemeVideo').checked = userSettings.enableThemeVideos();
+ context.querySelector('#chkFadein').checked = userSettings.enableFastFadein();
+ context.querySelector('#chkBlurhash').checked = userSettings.enableBlurhash();
+ context.querySelector('#chkBackdrops').checked = userSettings.enableBackdrops();
+ context.querySelector('#chkDetailsBanner').checked = userSettings.detailsBanner();
+
+ context.querySelector('#chkDisableCustomCss').checked = userSettings.disableCustomCss();
+ context.querySelector('#txtLocalCustomCss').value = userSettings.customCss();
+
+ context.querySelector('#selectLanguage').value = userSettings.language() || '';
+ context.querySelector('.selectDateTimeLocale').value = userSettings.dateTimeLocale() || '';
+
+ context.querySelector('#txtLibraryPageSize').value = userSettings.libraryPageSize();
+
+ context.querySelector('#txtMaxDaysForNextUp').value = userSettings.maxDaysForNextUp();
+ context.querySelector('#chkRewatchingNextUp').checked = userSettings.enableRewatchingInNextUp();
+ context.querySelector('#chkUseEpisodeImagesInNextUp').checked = userSettings.useEpisodeImagesInNextUpAndResume();
+
+ context.querySelector('.selectLayout').value = layoutManager.getSavedLayout() || '';
+
+ showOrHideMissingEpisodesField(context);
+
+ loading.hide();
+}
+
+function saveUser(context, user, userSettingsInstance, apiClient) {
+ user.Configuration.DisplayMissingEpisodes = context.querySelector('.chkDisplayMissingEpisodes').checked;
+
+ if (appHost.supports('displaylanguage')) {
+ userSettingsInstance.language(context.querySelector('#selectLanguage').value);
+ }
+
+ userSettingsInstance.dateTimeLocale(context.querySelector('.selectDateTimeLocale').value);
+
+ userSettingsInstance.enableThemeSongs(context.querySelector('#chkThemeSong').checked);
+ userSettingsInstance.enableThemeVideos(context.querySelector('#chkThemeVideo').checked);
+ userSettingsInstance.theme(context.querySelector('#selectTheme').value);
+ userSettingsInstance.dashboardTheme(context.querySelector('#selectDashboardTheme').value);
+ userSettingsInstance.screensaver(context.querySelector('.selectScreensaver').value);
+
+ userSettingsInstance.libraryPageSize(context.querySelector('#txtLibraryPageSize').value);
+
+ userSettingsInstance.maxDaysForNextUp(context.querySelector('#txtMaxDaysForNextUp').value);
+ userSettingsInstance.enableRewatchingInNextUp(context.querySelector('#chkRewatchingNextUp').checked);
+ userSettingsInstance.useEpisodeImagesInNextUpAndResume(context.querySelector('#chkUseEpisodeImagesInNextUp').checked);
+
+ userSettingsInstance.enableFastFadein(context.querySelector('#chkFadein').checked);
+ userSettingsInstance.enableBlurhash(context.querySelector('#chkBlurhash').checked);
+ userSettingsInstance.enableBackdrops(context.querySelector('#chkBackdrops').checked);
+ userSettingsInstance.detailsBanner(context.querySelector('#chkDetailsBanner').checked);
+
+ userSettingsInstance.disableCustomCss(context.querySelector('#chkDisableCustomCss').checked);
+ userSettingsInstance.customCss(context.querySelector('#txtLocalCustomCss').value);
+
+ if (user.Id === apiClient.getCurrentUserId()) {
+ skinManager.setTheme(userSettingsInstance.theme());
+ }
+
+ layoutManager.setLayout(context.querySelector('.selectLayout').value);
+ return apiClient.updateUserConfiguration(user.Id, user.Configuration);
+}
+
+function save(instance, context, userId, userSettings, apiClient, enableSaveConfirmation) {
+ loading.show();
+
+ apiClient.getUser(userId).then(user => {
+ saveUser(context, user, userSettings, apiClient).then(() => {
+ loading.hide();
+ if (enableSaveConfirmation) {
+ toast(globalize.translate('SettingsSaved'));
+ }
+ Events.trigger(instance, 'saved');
+ }, () => {
+ loading.hide();
+ });
+ });
+}
+
+function onSubmit(e) {
+ const self = this;
+ const apiClient = ServerConnections.getApiClient(self.options.serverId);
+ const userId = self.options.userId;
+ const userSettings = self.options.userSettings;
+
+ userSettings.setUserInfo(userId, apiClient).then(() => {
+ const enableSaveConfirmation = self.options.enableSaveConfirmation;
+ save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation);
+ });
+
+ // Disable default form submission
+ if (e) {
+ e.preventDefault();
+ }
+ return false;
+}
+
+function embed(options, self) {
+ options.element.innerHTML = globalize.translateHtml(template, 'core');
+ options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
+ if (options.enableSaveButton) {
+ options.element.querySelector('.btnSave').classList.remove('hide');
+ }
+ self.loadData(options.autoFocus);
+}
+
+class DisplaySettings {
+ constructor(options) {
+ this.options = options;
+ embed(options, this);
+ }
+
+ loadData(autoFocus) {
+ const self = this;
+ const context = self.options.element;
+
loading.show();
- apiClient.getUser(userId).then(user => {
- saveUser(context, user, userSettings, apiClient).then(() => {
- loading.hide();
- if (enableSaveConfirmation) {
- toast(globalize.translate('SettingsSaved'));
- }
- Events.trigger(instance, 'saved');
- }, () => {
- loading.hide();
- });
- });
- }
-
- function onSubmit(e) {
- const self = this;
- const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userId = self.options.userId;
+ const apiClient = ServerConnections.getApiClient(self.options.serverId);
const userSettings = self.options.userSettings;
- userSettings.setUserInfo(userId, apiClient).then(() => {
- const enableSaveConfirmation = self.options.enableSaveConfirmation;
- save(self, self.options.element, userId, userSettings, apiClient, enableSaveConfirmation);
- });
-
- // Disable default form submission
- if (e) {
- e.preventDefault();
- }
- return false;
- }
-
- function embed(options, self) {
- options.element.innerHTML = globalize.translateHtml(template, 'core');
- options.element.querySelector('form').addEventListener('submit', onSubmit.bind(self));
- if (options.enableSaveButton) {
- options.element.querySelector('.btnSave').classList.remove('hide');
- }
- self.loadData(options.autoFocus);
- }
-
- class DisplaySettings {
- constructor(options) {
- this.options = options;
- embed(options, this);
- }
-
- loadData(autoFocus) {
- const self = this;
- const context = self.options.element;
-
- loading.show();
-
- const userId = self.options.userId;
- const apiClient = ServerConnections.getApiClient(self.options.serverId);
- const userSettings = self.options.userSettings;
-
- return apiClient.getUser(userId).then(user => {
- return userSettings.setUserInfo(userId, apiClient).then(() => {
- self.dataLoaded = true;
- loadForm(context, user, userSettings);
- if (autoFocus) {
- focusManager.autoFocus(context);
- }
- });
+ return apiClient.getUser(userId).then(user => {
+ return userSettings.setUserInfo(userId, apiClient).then(() => {
+ self.dataLoaded = true;
+ loadForm(context, user, userSettings);
+ if (autoFocus) {
+ focusManager.autoFocus(context);
+ }
});
- }
-
- submit() {
- onSubmit.call(this);
- }
-
- destroy() {
- this.options = null;
- }
+ });
}
-/* eslint-enable indent */
+ submit() {
+ onSubmit.call(this);
+ }
+
+ destroy() {
+ this.options = null;
+ }
+}
+
export default DisplaySettings;
diff --git a/src/components/displaySettings/displaySettings.template.html b/src/components/displaySettings/displaySettings.template.html
index a37d95749c..a61537cbf3 100644
--- a/src/components/displaySettings/displaySettings.template.html
+++ b/src/components/displaySettings/displaySettings.template.html
@@ -172,6 +172,7 @@
${Desktop}
${Mobile}
${TV}
+
${Experimental}
${DisplayModeHelp}
${LabelPleaseRestart}
diff --git a/src/components/favoriteitems.js b/src/components/favoriteitems.js
index 67137b9174..ac0f3c0de0 100644
--- a/src/components/favoriteitems.js
+++ b/src/components/favoriteitems.js
@@ -6,239 +6,235 @@ import imageLoader from './images/imageLoader';
import globalize from '../scripts/globalize';
import layoutManager from './layoutManager';
import { getParameterByName } from '../utils/url.ts';
-import '../assets/css/scrollstyles.scss';
+import '../styles/scrollstyles.scss';
import '../elements/emby-itemscontainer/emby-itemscontainer';
-/* eslint-disable indent */
+function enableScrollX() {
+ return !layoutManager.desktop;
+}
- function enableScrollX() {
- return !layoutManager.desktop;
+function getThumbShape() {
+ return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
+}
+
+function getPosterShape() {
+ return enableScrollX() ? 'overflowPortrait' : 'portrait';
+}
+
+function getSquareShape() {
+ return enableScrollX() ? 'overflowSquare' : 'square';
+}
+
+function getSections() {
+ return [{
+ name: 'Movies',
+ types: 'Movie',
+ id: 'favoriteMovies',
+ shape: getPosterShape(),
+ showTitle: false,
+ overlayPlayButton: true
+ }, {
+ name: 'Shows',
+ types: 'Series',
+ id: 'favoriteShows',
+ shape: getPosterShape(),
+ showTitle: false,
+ overlayPlayButton: true
+ }, {
+ name: 'Episodes',
+ types: 'Episode',
+ id: 'favoriteEpisode',
+ shape: getThumbShape(),
+ preferThumb: false,
+ showTitle: true,
+ showParentTitle: true,
+ overlayPlayButton: true,
+ overlayText: false,
+ centerText: true
+ }, {
+ name: 'Videos',
+ types: 'Video,MusicVideo',
+ id: 'favoriteVideos',
+ shape: getThumbShape(),
+ preferThumb: true,
+ showTitle: true,
+ overlayPlayButton: true,
+ overlayText: false,
+ centerText: true
+ }, {
+ name: 'Artists',
+ types: 'MusicArtist',
+ id: 'favoriteArtists',
+ shape: getSquareShape(),
+ preferThumb: false,
+ showTitle: true,
+ overlayText: false,
+ showParentTitle: false,
+ centerText: true,
+ overlayPlayButton: true,
+ coverImage: true
+ }, {
+ name: 'Albums',
+ types: 'MusicAlbum',
+ id: 'favoriteAlbums',
+ shape: getSquareShape(),
+ preferThumb: false,
+ showTitle: true,
+ overlayText: false,
+ showParentTitle: true,
+ centerText: true,
+ overlayPlayButton: true,
+ coverImage: true
+ }, {
+ name: 'Songs',
+ types: 'Audio',
+ id: 'favoriteSongs',
+ shape: getSquareShape(),
+ preferThumb: false,
+ showTitle: true,
+ overlayText: false,
+ showParentTitle: true,
+ centerText: true,
+ overlayMoreButton: true,
+ action: 'instantmix',
+ coverImage: true
+ }];
+}
+
+function loadSection(elem, userId, topParentId, section, isSingleSection) {
+ const screenWidth = dom.getWindowSize().innerWidth;
+ const options = {
+ SortBy: 'SortName',
+ SortOrder: 'Ascending',
+ Filters: 'IsFavorite',
+ Recursive: true,
+ Fields: 'PrimaryImageAspectRatio,BasicSyncInfo',
+ CollapseBoxSetItems: false,
+ ExcludeLocationTypes: 'Virtual',
+ EnableTotalRecordCount: false
+ };
+
+ if (topParentId) {
+ options.ParentId = topParentId;
}
- function getThumbShape() {
- return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
- }
+ if (!isSingleSection) {
+ options.Limit = 6;
- function getPosterShape() {
- return enableScrollX() ? 'overflowPortrait' : 'portrait';
- }
-
- function getSquareShape() {
- return enableScrollX() ? 'overflowSquare' : 'square';
- }
-
- function getSections() {
- return [{
- name: 'Movies',
- types: 'Movie',
- id: 'favoriteMovies',
- shape: getPosterShape(),
- showTitle: false,
- overlayPlayButton: true
- }, {
- name: 'Shows',
- types: 'Series',
- id: 'favoriteShows',
- shape: getPosterShape(),
- showTitle: false,
- overlayPlayButton: true
- }, {
- name: 'Episodes',
- types: 'Episode',
- id: 'favoriteEpisode',
- shape: getThumbShape(),
- preferThumb: false,
- showTitle: true,
- showParentTitle: true,
- overlayPlayButton: true,
- overlayText: false,
- centerText: true
- }, {
- name: 'Videos',
- types: 'Video,MusicVideo',
- id: 'favoriteVideos',
- shape: getThumbShape(),
- preferThumb: true,
- showTitle: true,
- overlayPlayButton: true,
- overlayText: false,
- centerText: true
- }, {
- name: 'Artists',
- types: 'MusicArtist',
- id: 'favoriteArtists',
- shape: getSquareShape(),
- preferThumb: false,
- showTitle: true,
- overlayText: false,
- showParentTitle: false,
- centerText: true,
- overlayPlayButton: true,
- coverImage: true
- }, {
- name: 'Albums',
- types: 'MusicAlbum',
- id: 'favoriteAlbums',
- shape: getSquareShape(),
- preferThumb: false,
- showTitle: true,
- overlayText: false,
- showParentTitle: true,
- centerText: true,
- overlayPlayButton: true,
- coverImage: true
- }, {
- name: 'Songs',
- types: 'Audio',
- id: 'favoriteSongs',
- shape: getSquareShape(),
- preferThumb: false,
- showTitle: true,
- overlayText: false,
- showParentTitle: true,
- centerText: true,
- overlayMoreButton: true,
- action: 'instantmix',
- coverImage: true
- }];
- }
-
- function loadSection(elem, userId, topParentId, section, isSingleSection) {
- const screenWidth = dom.getWindowSize().innerWidth;
- const options = {
- SortBy: 'SortName',
- SortOrder: 'Ascending',
- Filters: 'IsFavorite',
- Recursive: true,
- Fields: 'PrimaryImageAspectRatio,BasicSyncInfo',
- CollapseBoxSetItems: false,
- ExcludeLocationTypes: 'Virtual',
- EnableTotalRecordCount: false
- };
-
- if (topParentId) {
- options.ParentId = topParentId;
+ if (enableScrollX()) {
+ options.Limit = 20;
+ } else if (screenWidth >= 1920) {
+ options.Limit = 10;
+ } else if (screenWidth >= 1440) {
+ options.Limit = 8;
}
+ }
- if (!isSingleSection) {
- options.Limit = 6;
+ let promise;
+ if (section.types === 'MusicArtist') {
+ promise = ApiClient.getArtists(userId, options);
+ } else {
+ options.IncludeItemTypes = section.types;
+ promise = ApiClient.getItems(userId, options);
+ }
+
+ return promise.then(function (result) {
+ let html = '';
+
+ if (result.Items.length) {
+ html += '
';
if (enableScrollX()) {
- options.Limit = 20;
- } else if (screenWidth >= 1920) {
- options.Limit = 10;
- } else if (screenWidth >= 1440) {
- options.Limit = 8;
- }
- }
-
- let promise;
-
- if (section.types === 'MusicArtist') {
- promise = ApiClient.getArtists(userId, options);
- } else {
- options.IncludeItemTypes = section.types;
- promise = ApiClient.getItems(userId, options);
- }
-
- return promise.then(function (result) {
- let html = '';
-
- if (result.Items.length) {
- html += '
';
- if (enableScrollX()) {
- let scrollXClass = 'scrollX hiddenScrollX';
- if (layoutManager.tv) {
- scrollXClass += ' smoothScrollX';
- }
-
- html += '
';
- } else {
- html += '
';
- }
-
- let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
- cardLayout = false;
- html += cardBuilder.getCardsHtml(result.Items, {
- preferThumb: section.preferThumb,
- shape: section.shape,
- centerText: section.centerText && !cardLayout,
- overlayText: section.overlayText !== false,
- showTitle: section.showTitle,
- showParentTitle: section.showParentTitle,
- scalable: true,
- coverImage: section.coverImage,
- overlayPlayButton: section.overlayPlayButton,
- overlayMoreButton: section.overlayMoreButton && !cardLayout,
- action: section.action,
- allowBottomPadding: !enableScrollX(),
- cardLayout: cardLayout
- });
- html += '
';
+ html += '
';
+ } else {
+ html += '
';
}
- elem.innerHTML = html;
- imageLoader.lazyChildren(elem);
+ let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
+ cardLayout = false;
+ html += cardBuilder.getCardsHtml(result.Items, {
+ preferThumb: section.preferThumb,
+ shape: section.shape,
+ centerText: section.centerText && !cardLayout,
+ overlayText: section.overlayText !== false,
+ showTitle: section.showTitle,
+ showParentTitle: section.showParentTitle,
+ scalable: true,
+ coverImage: section.coverImage,
+ overlayPlayButton: section.overlayPlayButton,
+ overlayMoreButton: section.overlayMoreButton && !cardLayout,
+ action: section.action,
+ allowBottomPadding: !enableScrollX(),
+ cardLayout: cardLayout
+ });
+ html += '
';
+ }
+
+ elem.innerHTML = html;
+ imageLoader.lazyChildren(elem);
+ });
+}
+
+export function loadSections(page, userId, topParentId, types) {
+ loading.show();
+ let sections = getSections();
+ const sectionid = getParameterByName('sectionid');
+
+ if (sectionid) {
+ sections = sections.filter(function (s) {
+ return s.id === sectionid;
});
}
- export function loadSections(page, userId, topParentId, types) {
- loading.show();
- let sections = getSections();
- const sectionid = getParameterByName('sectionid');
+ if (types) {
+ sections = sections.filter(function (s) {
+ return types.indexOf(s.id) !== -1;
+ });
+ }
- if (sectionid) {
- sections = sections.filter(function (s) {
- return s.id === sectionid;
- });
- }
+ let elem = page.querySelector('.favoriteSections');
- if (types) {
- sections = sections.filter(function (s) {
- return types.indexOf(s.id) !== -1;
- });
- }
-
- let elem = page.querySelector('.favoriteSections');
-
- if (!elem.innerHTML) {
- let html = '';
-
- for (let i = 0, length = sections.length; i < length; i++) {
- html += '
';
- }
-
- elem.innerHTML = html;
- }
-
- const promises = [];
+ if (!elem.innerHTML) {
+ let html = '';
for (let i = 0, length = sections.length; i < length; i++) {
- const section = sections[i];
- elem = page.querySelector('.section' + section.id);
- promises.push(loadSection(elem, userId, topParentId, section, sections.length === 1));
+ html += '
';
}
- Promise.all(promises).then(function () {
- loading.hide();
- });
+ elem.innerHTML = html;
}
+ const promises = [];
+
+ for (let i = 0, length = sections.length; i < length; i++) {
+ const section = sections[i];
+ elem = page.querySelector('.section' + section.id);
+ promises.push(loadSection(elem, userId, topParentId, section, sections.length === 1));
+ }
+
+ Promise.all(promises).then(function () {
+ loading.hide();
+ });
+}
+
export default {
render: loadSections
};
-
-/* eslint-enable indent */
diff --git a/src/components/fetchhelper.js b/src/components/fetchhelper.js
index efc490fc66..f63fa62ced 100644
--- a/src/components/fetchhelper.js
+++ b/src/components/fetchhelper.js
@@ -1,110 +1,108 @@
-/* eslint-disable indent */
- export function getFetchPromise(request) {
- const headers = request.headers || {};
+export function getFetchPromise(request) {
+ const headers = request.headers || {};
- if (request.dataType === 'json') {
- headers.accept = 'application/json';
- }
-
- const fetchRequest = {
- headers: headers,
- method: request.type,
- credentials: 'same-origin'
- };
-
- let contentType = request.contentType;
-
- if (request.data) {
- if (typeof request.data === 'string') {
- fetchRequest.body = request.data;
- } else {
- fetchRequest.body = paramsToString(request.data);
-
- contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8';
- }
- }
-
- if (contentType) {
- headers['Content-Type'] = contentType;
- }
-
- let url = request.url;
-
- if (request.query) {
- const paramString = paramsToString(request.query);
- if (paramString) {
- url += `?${paramString}`;
- }
- }
-
- if (!request.timeout) {
- return fetch(url, fetchRequest);
- }
-
- return fetchWithTimeout(url, fetchRequest, request.timeout);
+ if (request.dataType === 'json') {
+ headers.accept = 'application/json';
}
- function fetchWithTimeout(url, options, timeoutMs) {
- console.debug(`fetchWithTimeout: timeoutMs: ${timeoutMs}, url: ${url}`);
+ const fetchRequest = {
+ headers: headers,
+ method: request.type,
+ credentials: 'same-origin'
+ };
- return new Promise(function (resolve, reject) {
- const timeout = setTimeout(reject, timeoutMs);
+ let contentType = request.contentType;
- options = options || {};
- options.credentials = 'same-origin';
+ if (request.data) {
+ if (typeof request.data === 'string') {
+ fetchRequest.body = request.data;
+ } else {
+ fetchRequest.body = paramsToString(request.data);
- fetch(url, options).then(function (response) {
- clearTimeout(timeout);
+ contentType = contentType || 'application/x-www-form-urlencoded; charset=UTF-8';
+ }
+ }
- console.debug(`fetchWithTimeout: succeeded connecting to url: ${url}`);
+ if (contentType) {
+ headers['Content-Type'] = contentType;
+ }
- resolve(response);
- }, function (error) {
- clearTimeout(timeout);
+ let url = request.url;
- console.debug(`fetchWithTimeout: timed out connecting to url: ${url}`);
+ if (request.query) {
+ const paramString = paramsToString(request.query);
+ if (paramString) {
+ url += `?${paramString}`;
+ }
+ }
- reject(error);
- });
+ if (!request.timeout) {
+ return fetch(url, fetchRequest);
+ }
+
+ return fetchWithTimeout(url, fetchRequest, request.timeout);
+}
+
+function fetchWithTimeout(url, options, timeoutMs) {
+ console.debug(`fetchWithTimeout: timeoutMs: ${timeoutMs}, url: ${url}`);
+
+ return new Promise(function (resolve, reject) {
+ const timeout = setTimeout(reject, timeoutMs);
+
+ options = options || {};
+ options.credentials = 'same-origin';
+
+ fetch(url, options).then(function (response) {
+ clearTimeout(timeout);
+
+ console.debug(`fetchWithTimeout: succeeded connecting to url: ${url}`);
+
+ resolve(response);
+ }, function (error) {
+ clearTimeout(timeout);
+
+ console.debug(`fetchWithTimeout: timed out connecting to url: ${url}`);
+
+ reject(error);
});
- }
+ });
+}
- /**
+/**
* @param params {Record
}
* @returns {string} Query string
*/
- function paramsToString(params) {
- return Object.entries(params)
- .filter(([, v]) => v !== null && v !== undefined && v !== '')
- .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
- .join('&');
+function paramsToString(params) {
+ return Object.entries(params)
+ .filter(([, v]) => v !== null && v !== undefined && v !== '')
+ .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
+ .join('&');
+}
+
+export function ajax(request) {
+ if (!request) {
+ throw new Error('Request cannot be null');
}
- export function ajax(request) {
- if (!request) {
- throw new Error('Request cannot be null');
- }
+ request.headers = request.headers || {};
- request.headers = request.headers || {};
+ console.debug(`requesting url: ${request.url}`);
- console.debug(`requesting url: ${request.url}`);
-
- return getFetchPromise(request).then(function (response) {
- console.debug(`response status: ${response.status}, url: ${request.url}`);
- if (response.status < 400) {
- if (request.dataType === 'json' || request.headers.accept === 'application/json') {
- return response.json();
- } else if (request.dataType === 'text' || (response.headers.get('Content-Type') || '').toLowerCase().startsWith('text/')) {
- return response.text();
- } else {
- return response;
- }
+ return getFetchPromise(request).then(function (response) {
+ console.debug(`response status: ${response.status}, url: ${request.url}`);
+ if (response.status < 400) {
+ if (request.dataType === 'json' || request.headers.accept === 'application/json') {
+ return response.json();
+ } else if (request.dataType === 'text' || (response.headers.get('Content-Type') || '').toLowerCase().startsWith('text/')) {
+ return response.text();
} else {
- return Promise.reject(response);
+ return response;
}
- }, function (err) {
- console.error(`request failed to url: ${request.url}`);
- throw err;
- });
- }
-/* eslint-enable indent */
+ } else {
+ return Promise.reject(response);
+ }
+ }, function (err) {
+ console.error(`request failed to url: ${request.url}`);
+ throw err;
+ });
+}
diff --git a/src/components/filterdialog/filterdialog.js b/src/components/filterdialog/filterdialog.js
index c18e6d4a5f..2301dcd404 100644
--- a/src/components/filterdialog/filterdialog.js
+++ b/src/components/filterdialog/filterdialog.js
@@ -8,432 +8,414 @@ import './style.scss';
import ServerConnections from '../ServerConnections';
import template from './filterdialog.template.html';
-/* eslint-disable indent */
- function renderOptions(context, selector, cssClass, items, isCheckedFn) {
- const elem = context.querySelector(selector);
- if (items.length) {
- elem.classList.remove('hide');
- } else {
- elem.classList.add('hide');
- }
- let html = '';
- html += '';
- html += items.map(function (filter) {
- let itemHtml = '';
- const checkedHtml = isCheckedFn(filter) ? 'checked' : '';
- itemHtml += '';
- itemHtml += ` `;
- itemHtml += `${filter} `;
- itemHtml += ' ';
- return itemHtml;
- }).join('');
- html += '
';
- elem.querySelector('.filterOptions').innerHTML = html;
+function renderOptions(context, selector, cssClass, items, isCheckedFn) {
+ const elem = context.querySelector(selector);
+ if (items.length) {
+ elem.classList.remove('hide');
+ } else {
+ elem.classList.add('hide');
}
+ let html = '';
+ html += '';
+ html += items.map(function (filter) {
+ let itemHtml = '';
+ const checkedHtml = isCheckedFn(filter) ? 'checked' : '';
+ itemHtml += '';
+ itemHtml += ` `;
+ itemHtml += `${filter} `;
+ itemHtml += ' ';
+ return itemHtml;
+ }).join('');
+ html += '
';
+ elem.querySelector('.filterOptions').innerHTML = html;
+}
- function renderFilters(context, result, query) {
- renderOptions(context, '.genreFilters', 'chkGenreFilter', result.Genres, function (i) {
- const delimeter = '|';
- return (delimeter + (query.Genres || '') + delimeter).includes(delimeter + i + delimeter);
- });
- renderOptions(context, '.officialRatingFilters', 'chkOfficialRatingFilter', result.OfficialRatings, function (i) {
- const delimeter = '|';
- return (delimeter + (query.OfficialRatings || '') + delimeter).includes(delimeter + i + delimeter);
- });
- renderOptions(context, '.tagFilters', 'chkTagFilter', result.Tags, function (i) {
- const delimeter = '|';
- return (delimeter + (query.Tags || '') + delimeter).includes(delimeter + i + delimeter);
- });
- renderOptions(context, '.yearFilters', 'chkYearFilter', result.Years, function (i) {
- const delimeter = ',';
- return (delimeter + (query.Years || '') + delimeter).includes(delimeter + i + delimeter);
- });
- }
+function renderFilters(context, result, query) {
+ renderOptions(context, '.genreFilters', 'chkGenreFilter', result.Genres, function (i) {
+ const delimeter = '|';
+ return (delimeter + (query.Genres || '') + delimeter).includes(delimeter + i + delimeter);
+ });
+ renderOptions(context, '.officialRatingFilters', 'chkOfficialRatingFilter', result.OfficialRatings, function (i) {
+ const delimeter = '|';
+ return (delimeter + (query.OfficialRatings || '') + delimeter).includes(delimeter + i + delimeter);
+ });
+ renderOptions(context, '.tagFilters', 'chkTagFilter', result.Tags, function (i) {
+ const delimeter = '|';
+ return (delimeter + (query.Tags || '') + delimeter).includes(delimeter + i + delimeter);
+ });
+ renderOptions(context, '.yearFilters', 'chkYearFilter', result.Years, function (i) {
+ const delimeter = ',';
+ return (delimeter + (query.Years || '') + delimeter).includes(delimeter + i + delimeter);
+ });
+}
- function loadDynamicFilters(context, apiClient, userId, itemQuery) {
- return apiClient.getJSON(apiClient.getUrl('Items/Filters', {
- UserId: userId,
- ParentId: itemQuery.ParentId,
- IncludeItemTypes: itemQuery.IncludeItemTypes
- })).then(function (result) {
- renderFilters(context, result, itemQuery);
- });
- }
+function loadDynamicFilters(context, apiClient, userId, itemQuery) {
+ return apiClient.getJSON(apiClient.getUrl('Items/Filters', {
+ UserId: userId,
+ ParentId: itemQuery.ParentId,
+ IncludeItemTypes: itemQuery.IncludeItemTypes
+ })).then(function (result) {
+ renderFilters(context, result, itemQuery);
+ });
+}
- /**
+/**
* @param context {HTMLDivElement} Dialog
* @param options {any} Options
*/
- function updateFilterControls(context, options) {
- const query = options.query;
+function updateFilterControls(context, options) {
+ const query = options.query;
- if (options.mode === 'livetvchannels') {
- context.querySelector('.chkFavorite').checked = query.IsFavorite === true;
- context.querySelector('.chkLikes').checked = query.IsLiked === true;
- context.querySelector('.chkDislikes').checked = query.IsDisliked === true;
+ if (options.mode === 'livetvchannels') {
+ context.querySelector('.chkFavorite').checked = query.IsFavorite === true;
+ } else {
+ for (const elem of context.querySelectorAll('.chkStandardFilter')) {
+ const filters = `,${query.Filters || ''}`;
+ const filterName = elem.getAttribute('data-filter');
+ elem.checked = filters.includes(`,${filterName}`);
+ }
+ }
+
+ for (const elem of context.querySelectorAll('.chkVideoTypeFilter')) {
+ const filters = `,${query.VideoTypes || ''}`;
+ const filterName = elem.getAttribute('data-filter');
+ elem.checked = filters.includes(`,${filterName}`);
+ }
+ context.querySelector('.chk3DFilter').checked = query.Is3D === true;
+ context.querySelector('.chkHDFilter').checked = query.IsHD === true;
+ context.querySelector('.chk4KFilter').checked = query.Is4K === true;
+ context.querySelector('.chkSDFilter').checked = query.IsHD === false;
+ context.querySelector('#chkSubtitle').checked = query.HasSubtitles === true;
+ context.querySelector('#chkTrailer').checked = query.HasTrailer === true;
+ context.querySelector('#chkThemeSong').checked = query.HasThemeSong === true;
+ context.querySelector('#chkThemeVideo').checked = query.HasThemeVideo === true;
+ context.querySelector('#chkSpecialFeature').checked = query.HasSpecialFeature === true;
+ context.querySelector('#chkSpecialEpisode').checked = query.ParentIndexNumber === 0;
+ context.querySelector('#chkMissingEpisode').checked = query.IsMissing === true;
+ context.querySelector('#chkFutureEpisode').checked = query.IsUnaired === true;
+ for (const elem of context.querySelectorAll('.chkStatus')) {
+ const filters = `,${query.SeriesStatus || ''}`;
+ const filterName = elem.getAttribute('data-filter');
+ elem.checked = filters.includes(`,${filterName}`);
+ }
+}
+
+/**
+ * @param instance {FilterDialog} An instance of FilterDialog
+ */
+function triggerChange(instance) {
+ Events.trigger(instance, 'filterchange');
+}
+
+function setVisibility(context, options) {
+ if (options.mode === 'livetvchannels' || options.mode === 'albums' || options.mode === 'artists' || options.mode === 'albumartists' || options.mode === 'songs') {
+ hideByClass(context, 'videoStandard');
+ }
+
+ if (enableDynamicFilters(options.mode)) {
+ context.querySelector('.genreFilters').classList.remove('hide');
+ context.querySelector('.officialRatingFilters').classList.remove('hide');
+ context.querySelector('.tagFilters').classList.remove('hide');
+ context.querySelector('.yearFilters').classList.remove('hide');
+ }
+
+ if (options.mode === 'movies' || options.mode === 'episodes') {
+ context.querySelector('.videoTypeFilters').classList.remove('hide');
+ }
+
+ if (options.mode === 'movies' || options.mode === 'series' || options.mode === 'episodes') {
+ context.querySelector('.features').classList.remove('hide');
+ }
+
+ if (options.mode === 'series') {
+ context.querySelector('.seriesStatus').classList.remove('hide');
+ }
+
+ if (options.mode === 'episodes') {
+ showByClass(context, 'episodeFilter');
+ }
+}
+
+function showByClass(context, className) {
+ for (const elem of context.querySelectorAll(`.${className}`)) {
+ elem.classList.remove('hide');
+ }
+}
+
+function hideByClass(context, className) {
+ for (const elem of context.querySelectorAll(`.${className}`)) {
+ elem.classList.add('hide');
+ }
+}
+
+function enableDynamicFilters(mode) {
+ return mode === 'movies' || mode === 'series' || mode === 'albums' || mode === 'albumartists' || mode === 'artists' || mode === 'songs' || mode === 'episodes';
+}
+
+class FilterDialog {
+ constructor(options) {
+ /**
+ * @private
+ */
+ this.options = options;
+ }
+
+ /**
+ * @private
+ */
+ onFavoriteChange(elem) {
+ const query = this.options.query;
+ query.StartIndex = 0;
+ query.IsFavorite = !!elem.checked || null;
+ triggerChange(this);
+ }
+
+ /**
+ * @private
+ */
+ onStandardFilterChange(elem) {
+ const query = this.options.query;
+ const filterName = elem.getAttribute('data-filter');
+ let filters = query.Filters || '';
+ filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
+
+ if (elem.checked) {
+ filters = filters ? `${filters},${filterName}` : filterName;
+ }
+
+ query.StartIndex = 0;
+ query.Filters = filters;
+ triggerChange(this);
+ }
+
+ /**
+ * @private
+ */
+ onVideoTypeFilterChange(elem) {
+ const query = this.options.query;
+ const filterName = elem.getAttribute('data-filter');
+ let filters = query.VideoTypes || '';
+ filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
+
+ if (elem.checked) {
+ filters = filters ? `${filters},${filterName}` : filterName;
+ }
+
+ query.StartIndex = 0;
+ query.VideoTypes = filters;
+ triggerChange(this);
+ }
+
+ /**
+ * @private
+ */
+ onStatusChange(elem) {
+ const query = this.options.query;
+ const filterName = elem.getAttribute('data-filter');
+ let filters = query.SeriesStatus || '';
+ filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
+
+ if (elem.checked) {
+ filters = filters ? `${filters},${filterName}` : filterName;
+ }
+
+ query.SeriesStatus = filters;
+ query.StartIndex = 0;
+ triggerChange(this);
+ }
+
+ /**
+ * @param context {HTMLDivElement} The dialog
+ */
+ bindEvents(context) {
+ const query = this.options.query;
+
+ if (this.options.mode === 'livetvchannels') {
+ for (const elem of context.querySelectorAll('.chkFavorite')) {
+ elem.addEventListener('change', () => this.onFavoriteChange(elem));
+ }
} else {
for (const elem of context.querySelectorAll('.chkStandardFilter')) {
- const filters = `,${query.Filters || ''}`;
- const filterName = elem.getAttribute('data-filter');
- elem.checked = filters.includes(`,${filterName}`);
+ elem.addEventListener('change', () => this.onStandardFilterChange(elem));
}
}
for (const elem of context.querySelectorAll('.chkVideoTypeFilter')) {
- const filters = `,${query.VideoTypes || ''}`;
- const filterName = elem.getAttribute('data-filter');
- elem.checked = filters.includes(`,${filterName}`);
+ elem.addEventListener('change', () => this.onVideoTypeFilterChange(elem));
}
- context.querySelector('.chk3DFilter').checked = query.Is3D === true;
- context.querySelector('.chkHDFilter').checked = query.IsHD === true;
- context.querySelector('.chk4KFilter').checked = query.Is4K === true;
- context.querySelector('.chkSDFilter').checked = query.IsHD === false;
- context.querySelector('#chkSubtitle').checked = query.HasSubtitles === true;
- context.querySelector('#chkTrailer').checked = query.HasTrailer === true;
- context.querySelector('#chkThemeSong').checked = query.HasThemeSong === true;
- context.querySelector('#chkThemeVideo').checked = query.HasThemeVideo === true;
- context.querySelector('#chkSpecialFeature').checked = query.HasSpecialFeature === true;
- context.querySelector('#chkSpecialEpisode').checked = query.ParentIndexNumber === 0;
- context.querySelector('#chkMissingEpisode').checked = query.IsMissing === true;
- context.querySelector('#chkFutureEpisode').checked = query.IsUnaired === true;
- for (const elem of context.querySelectorAll('.chkStatus')) {
- const filters = `,${query.SeriesStatus || ''}`;
- const filterName = elem.getAttribute('data-filter');
- elem.checked = filters.includes(`,${filterName}`);
- }
- }
-
- /**
- * @param instance {FilterDialog} An instance of FilterDialog
- */
- function triggerChange(instance) {
- Events.trigger(instance, 'filterchange');
- }
-
- function setVisibility(context, options) {
- if (options.mode === 'livetvchannels' || options.mode === 'albums' || options.mode === 'artists' || options.mode === 'albumartists' || options.mode === 'songs') {
- hideByClass(context, 'videoStandard');
- }
-
- if (enableDynamicFilters(options.mode)) {
- context.querySelector('.genreFilters').classList.remove('hide');
- context.querySelector('.officialRatingFilters').classList.remove('hide');
- context.querySelector('.tagFilters').classList.remove('hide');
- context.querySelector('.yearFilters').classList.remove('hide');
- }
-
- if (options.mode === 'movies' || options.mode === 'episodes') {
- context.querySelector('.videoTypeFilters').classList.remove('hide');
- }
-
- if (options.mode === 'movies' || options.mode === 'series' || options.mode === 'episodes') {
- context.querySelector('.features').classList.remove('hide');
- }
-
- if (options.mode === 'series') {
- context.querySelector('.seriesStatus').classList.remove('hide');
- }
-
- if (options.mode === 'episodes') {
- showByClass(context, 'episodeFilter');
- }
- }
-
- function showByClass(context, className) {
- for (const elem of context.querySelectorAll(`.${className}`)) {
- elem.classList.remove('hide');
- }
- }
-
- function hideByClass(context, className) {
- for (const elem of context.querySelectorAll(`.${className}`)) {
- elem.classList.add('hide');
- }
- }
-
- function enableDynamicFilters(mode) {
- return mode === 'movies' || mode === 'series' || mode === 'albums' || mode === 'albumartists' || mode === 'artists' || mode === 'songs' || mode === 'episodes';
- }
-
- class FilterDialog {
- constructor(options) {
- /**
- * @private
- */
- this.options = options;
- }
-
- /**
- * @private
- */
- onFavoriteChange(elem) {
- const query = this.options.query;
+ const chk3DFilter = context.querySelector('.chk3DFilter');
+ chk3DFilter.addEventListener('change', () => {
query.StartIndex = 0;
- query.IsFavorite = !!elem.checked || null;
+ query.Is3D = chk3DFilter.checked ? true : null;
triggerChange(this);
- }
-
- /**
- * @private
- */
- onStandardFilterChange(elem) {
- const query = this.options.query;
- const filterName = elem.getAttribute('data-filter');
- let filters = query.Filters || '';
- filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
-
- if (elem.checked) {
- filters = filters ? `${filters},${filterName}` : filterName;
- }
-
+ });
+ const chk4KFilter = context.querySelector('.chk4KFilter');
+ chk4KFilter.addEventListener('change', () => {
query.StartIndex = 0;
- query.Filters = filters;
+ query.Is4K = chk4KFilter.checked ? true : null;
triggerChange(this);
- }
-
- /**
- * @private
- */
- onVideoTypeFilterChange(elem) {
- const query = this.options.query;
- const filterName = elem.getAttribute('data-filter');
- let filters = query.VideoTypes || '';
- filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
-
- if (elem.checked) {
- filters = filters ? `${filters},${filterName}` : filterName;
- }
-
+ });
+ const chkHDFilter = context.querySelector('.chkHDFilter');
+ const chkSDFilter = context.querySelector('.chkSDFilter');
+ chkHDFilter.addEventListener('change', () => {
query.StartIndex = 0;
- query.VideoTypes = filters;
- triggerChange(this);
- }
-
- /**
- * @private
- */
- onStatusChange(elem) {
- const query = this.options.query;
- const filterName = elem.getAttribute('data-filter');
- let filters = query.SeriesStatus || '';
- filters = (`,${filters}`).replace(`,${filterName}`, '').substring(1);
-
- if (elem.checked) {
- filters = filters ? `${filters},${filterName}` : filterName;
- }
-
- query.SeriesStatus = filters;
- query.StartIndex = 0;
- triggerChange(this);
- }
-
- /**
- * @param context {HTMLDivElement} The dialog
- */
- bindEvents(context) {
- const query = this.options.query;
-
- if (this.options.mode === 'livetvchannels') {
- for (const elem of context.querySelectorAll('.chkFavorite')) {
- elem.addEventListener('change', () => this.onFavoriteChange(elem));
- }
-
- const chkLikes = context.querySelector('.chkLikes');
- chkLikes.addEventListener('change', () => {
- query.StartIndex = 0;
- query.IsLiked = chkLikes.checked ? true : null;
- triggerChange(this);
- });
- const chkDislikes = context.querySelector('.chkDislikes');
- chkDislikes.addEventListener('change', () => {
- query.StartIndex = 0;
- query.IsDisliked = chkDislikes.checked ? true : null;
- triggerChange(this);
- });
+ if (chkHDFilter.checked) {
+ chkSDFilter.checked = false;
+ query.IsHD = true;
} else {
- for (const elem of context.querySelectorAll('.chkStandardFilter')) {
- elem.addEventListener('change', () => this.onStandardFilterChange(elem));
- }
+ query.IsHD = null;
}
-
- for (const elem of context.querySelectorAll('.chkVideoTypeFilter')) {
- elem.addEventListener('change', () => this.onVideoTypeFilterChange(elem));
+ triggerChange(this);
+ });
+ chkSDFilter.addEventListener('change', () => {
+ query.StartIndex = 0;
+ if (chkSDFilter.checked) {
+ chkHDFilter.checked = false;
+ query.IsHD = false;
+ } else {
+ query.IsHD = null;
}
- const chk3DFilter = context.querySelector('.chk3DFilter');
- chk3DFilter.addEventListener('change', () => {
- query.StartIndex = 0;
- query.Is3D = chk3DFilter.checked ? true : null;
- triggerChange(this);
- });
- const chk4KFilter = context.querySelector('.chk4KFilter');
- chk4KFilter.addEventListener('change', () => {
- query.StartIndex = 0;
- query.Is4K = chk4KFilter.checked ? true : null;
- triggerChange(this);
- });
- const chkHDFilter = context.querySelector('.chkHDFilter');
- const chkSDFilter = context.querySelector('.chkSDFilter');
- chkHDFilter.addEventListener('change', () => {
- query.StartIndex = 0;
- if (chkHDFilter.checked) {
- chkSDFilter.checked = false;
- query.IsHD = true;
- } else {
- query.IsHD = null;
- }
- triggerChange(this);
- });
- chkSDFilter.addEventListener('change', () => {
- query.StartIndex = 0;
- if (chkSDFilter.checked) {
- chkHDFilter.checked = false;
- query.IsHD = false;
- } else {
- query.IsHD = null;
- }
- triggerChange(this);
- });
- for (const elem of context.querySelectorAll('.chkStatus')) {
- elem.addEventListener('change', () => this.onStatusChange(elem));
- }
- const chkTrailer = context.querySelector('#chkTrailer');
- chkTrailer.addEventListener('change', () => {
- query.StartIndex = 0;
- query.HasTrailer = chkTrailer.checked ? true : null;
- triggerChange(this);
- });
- const chkThemeSong = context.querySelector('#chkThemeSong');
- chkThemeSong.addEventListener('change', () => {
- query.StartIndex = 0;
- query.HasThemeSong = chkThemeSong.checked ? true : null;
- triggerChange(this);
- });
- const chkSpecialFeature = context.querySelector('#chkSpecialFeature');
- chkSpecialFeature.addEventListener('change', () => {
- query.StartIndex = 0;
- query.HasSpecialFeature = chkSpecialFeature.checked ? true : null;
- triggerChange(this);
- });
- const chkThemeVideo = context.querySelector('#chkThemeVideo');
- chkThemeVideo.addEventListener('change', () => {
- query.StartIndex = 0;
- query.HasThemeVideo = chkThemeVideo.checked ? true : null;
- triggerChange(this);
- });
- const chkMissingEpisode = context.querySelector('#chkMissingEpisode');
- chkMissingEpisode.addEventListener('change', () => {
- query.StartIndex = 0;
- query.IsMissing = !!chkMissingEpisode.checked;
- triggerChange(this);
- });
- const chkSpecialEpisode = context.querySelector('#chkSpecialEpisode');
- chkSpecialEpisode.addEventListener('change', () => {
- query.StartIndex = 0;
- query.ParentIndexNumber = chkSpecialEpisode.checked ? 0 : null;
- triggerChange(this);
- });
- const chkFutureEpisode = context.querySelector('#chkFutureEpisode');
- chkFutureEpisode.addEventListener('change', () => {
- query.StartIndex = 0;
- if (chkFutureEpisode.checked) {
- query.IsUnaired = true;
- query.IsVirtualUnaired = null;
- } else {
- query.IsUnaired = null;
- query.IsVirtualUnaired = false;
- }
- triggerChange(this);
- });
- const chkSubtitle = context.querySelector('#chkSubtitle');
- chkSubtitle.addEventListener('change', () => {
- query.StartIndex = 0;
- query.HasSubtitles = chkSubtitle.checked ? true : null;
- triggerChange(this);
- });
- context.addEventListener('change', (e) => {
- const chkGenreFilter = dom.parentWithClass(e.target, 'chkGenreFilter');
- if (chkGenreFilter) {
- const filterName = chkGenreFilter.getAttribute('data-filter');
- let filters = query.Genres || '';
- const delimiter = '|';
- filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
- if (chkGenreFilter.checked) {
- filters = filters ? (filters + delimiter + filterName) : filterName;
- }
- query.StartIndex = 0;
- query.Genres = filters;
- triggerChange(this);
- return;
- }
- const chkTagFilter = dom.parentWithClass(e.target, 'chkTagFilter');
- if (chkTagFilter) {
- const filterName = chkTagFilter.getAttribute('data-filter');
- let filters = query.Tags || '';
- const delimiter = '|';
- filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
- if (chkTagFilter.checked) {
- filters = filters ? (filters + delimiter + filterName) : filterName;
- }
- query.StartIndex = 0;
- query.Tags = filters;
- triggerChange(this);
- return;
- }
- const chkYearFilter = dom.parentWithClass(e.target, 'chkYearFilter');
- if (chkYearFilter) {
- const filterName = chkYearFilter.getAttribute('data-filter');
- let filters = query.Years || '';
- const delimiter = ',';
- filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
- if (chkYearFilter.checked) {
- filters = filters ? (filters + delimiter + filterName) : filterName;
- }
- query.StartIndex = 0;
- query.Years = filters;
- triggerChange(this);
- return;
- }
- const chkOfficialRatingFilter = dom.parentWithClass(e.target, 'chkOfficialRatingFilter');
- if (chkOfficialRatingFilter) {
- const filterName = chkOfficialRatingFilter.getAttribute('data-filter');
- let filters = query.OfficialRatings || '';
- const delimiter = '|';
- filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
- if (chkOfficialRatingFilter.checked) {
- filters = filters ? (filters + delimiter + filterName) : filterName;
- }
- query.StartIndex = 0;
- query.OfficialRatings = filters;
- triggerChange(this);
- }
- });
+ triggerChange(this);
+ });
+ for (const elem of context.querySelectorAll('.chkStatus')) {
+ elem.addEventListener('change', () => this.onStatusChange(elem));
}
-
- show() {
- return new Promise((resolve) => {
- const dlg = dialogHelper.createDialog({
- removeOnClose: true,
- modal: false
- });
- dlg.classList.add('ui-body-a');
- dlg.classList.add('background-theme-a');
- dlg.classList.add('formDialog');
- dlg.classList.add('filterDialog');
- dlg.innerHTML = globalize.translateHtml(template);
- setVisibility(dlg, this.options);
- dialogHelper.open(dlg);
- dlg.addEventListener('close', resolve);
- updateFilterControls(dlg, this.options);
- this.bindEvents(dlg);
- if (enableDynamicFilters(this.options.mode)) {
- dlg.classList.add('dynamicFilterDialog');
- const apiClient = ServerConnections.getApiClient(this.options.serverId);
- loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), this.options.query);
+ const chkTrailer = context.querySelector('#chkTrailer');
+ chkTrailer.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.HasTrailer = chkTrailer.checked ? true : null;
+ triggerChange(this);
+ });
+ const chkThemeSong = context.querySelector('#chkThemeSong');
+ chkThemeSong.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.HasThemeSong = chkThemeSong.checked ? true : null;
+ triggerChange(this);
+ });
+ const chkSpecialFeature = context.querySelector('#chkSpecialFeature');
+ chkSpecialFeature.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.HasSpecialFeature = chkSpecialFeature.checked ? true : null;
+ triggerChange(this);
+ });
+ const chkThemeVideo = context.querySelector('#chkThemeVideo');
+ chkThemeVideo.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.HasThemeVideo = chkThemeVideo.checked ? true : null;
+ triggerChange(this);
+ });
+ const chkMissingEpisode = context.querySelector('#chkMissingEpisode');
+ chkMissingEpisode.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.IsMissing = !!chkMissingEpisode.checked;
+ triggerChange(this);
+ });
+ const chkSpecialEpisode = context.querySelector('#chkSpecialEpisode');
+ chkSpecialEpisode.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.ParentIndexNumber = chkSpecialEpisode.checked ? 0 : null;
+ triggerChange(this);
+ });
+ const chkFutureEpisode = context.querySelector('#chkFutureEpisode');
+ chkFutureEpisode.addEventListener('change', () => {
+ query.StartIndex = 0;
+ if (chkFutureEpisode.checked) {
+ query.IsUnaired = true;
+ query.IsVirtualUnaired = null;
+ } else {
+ query.IsUnaired = null;
+ query.IsVirtualUnaired = false;
+ }
+ triggerChange(this);
+ });
+ const chkSubtitle = context.querySelector('#chkSubtitle');
+ chkSubtitle.addEventListener('change', () => {
+ query.StartIndex = 0;
+ query.HasSubtitles = chkSubtitle.checked ? true : null;
+ triggerChange(this);
+ });
+ context.addEventListener('change', (e) => {
+ const chkGenreFilter = dom.parentWithClass(e.target, 'chkGenreFilter');
+ if (chkGenreFilter) {
+ const filterName = chkGenreFilter.getAttribute('data-filter');
+ let filters = query.Genres || '';
+ const delimiter = '|';
+ filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
+ if (chkGenreFilter.checked) {
+ filters = filters ? (filters + delimiter + filterName) : filterName;
}
- });
- }
+ query.StartIndex = 0;
+ query.Genres = filters;
+ triggerChange(this);
+ return;
+ }
+ const chkTagFilter = dom.parentWithClass(e.target, 'chkTagFilter');
+ if (chkTagFilter) {
+ const filterName = chkTagFilter.getAttribute('data-filter');
+ let filters = query.Tags || '';
+ const delimiter = '|';
+ filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
+ if (chkTagFilter.checked) {
+ filters = filters ? (filters + delimiter + filterName) : filterName;
+ }
+ query.StartIndex = 0;
+ query.Tags = filters;
+ triggerChange(this);
+ return;
+ }
+ const chkYearFilter = dom.parentWithClass(e.target, 'chkYearFilter');
+ if (chkYearFilter) {
+ const filterName = chkYearFilter.getAttribute('data-filter');
+ let filters = query.Years || '';
+ const delimiter = ',';
+ filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
+ if (chkYearFilter.checked) {
+ filters = filters ? (filters + delimiter + filterName) : filterName;
+ }
+ query.StartIndex = 0;
+ query.Years = filters;
+ triggerChange(this);
+ return;
+ }
+ const chkOfficialRatingFilter = dom.parentWithClass(e.target, 'chkOfficialRatingFilter');
+ if (chkOfficialRatingFilter) {
+ const filterName = chkOfficialRatingFilter.getAttribute('data-filter');
+ let filters = query.OfficialRatings || '';
+ const delimiter = '|';
+ filters = (delimiter + filters).replace(delimiter + filterName, '').substring(1);
+ if (chkOfficialRatingFilter.checked) {
+ filters = filters ? (filters + delimiter + filterName) : filterName;
+ }
+ query.StartIndex = 0;
+ query.OfficialRatings = filters;
+ triggerChange(this);
+ }
+ });
}
-/* eslint-enable indent */
+ show() {
+ return new Promise((resolve) => {
+ const dlg = dialogHelper.createDialog({
+ removeOnClose: true,
+ modal: false
+ });
+ dlg.classList.add('ui-body-a');
+ dlg.classList.add('background-theme-a');
+ dlg.classList.add('formDialog');
+ dlg.classList.add('filterDialog');
+ dlg.innerHTML = globalize.translateHtml(template);
+ setVisibility(dlg, this.options);
+ dialogHelper.open(dlg);
+ dlg.addEventListener('close', resolve);
+ updateFilterControls(dlg, this.options);
+ this.bindEvents(dlg);
+ if (enableDynamicFilters(this.options.mode)) {
+ dlg.classList.add('dynamicFilterDialog');
+ const apiClient = ServerConnections.getApiClient(this.options.serverId);
+ loadDynamicFilters(dlg, apiClient, apiClient.getCurrentUserId(), this.options.query);
+ }
+ });
+ }
+}
export default FilterDialog;
diff --git a/src/components/filterdialog/filterdialog.template.html b/src/components/filterdialog/filterdialog.template.html
index 9e873c28dc..0979d01128 100644
--- a/src/components/filterdialog/filterdialog.template.html
+++ b/src/components/filterdialog/filterdialog.template.html
@@ -23,15 +23,6 @@
data-filter="IsFavorite" />
${Favorites}
-
-
- ${OptionLikes}
-
-
-
- ${OptionDislikes}
-
${OptionSpecialEpisode}
@@ -59,6 +50,10 @@
${Ended}
+
+
+ ${Unreleased}
+
diff --git a/src/components/filterdialog/style.scss b/src/components/filterdialog/style.scss
index f05ef2e4a8..3dcd418b4d 100644
--- a/src/components/filterdialog/style.scss
+++ b/src/components/filterdialog/style.scss
@@ -5,7 +5,6 @@
margin-top: 0 !important;
margin-bottom: 0 !important;
margin-right: 0 !important;
- -webkit-border-radius: 0 !important;
border-radius: 0 !important;
max-height: none !important;
max-width: none !important;
diff --git a/src/components/filtermenu/filtermenu.js b/src/components/filtermenu/filtermenu.js
index d6b85256a9..d7e9c87650 100644
--- a/src/components/filtermenu/filtermenu.js
+++ b/src/components/filtermenu/filtermenu.js
@@ -13,7 +13,7 @@ import '../../elements/emby-button/paper-icon-button-light';
import '../../elements/emby-select/emby-select';
import 'material-design-icons-iconfont';
import '../formdialog.scss';
-import '../../assets/css/flexstyles.scss';
+import '../../styles/flexstyles.scss';
import ServerConnections from '../ServerConnections';
import template from './filtermenu.template.html';
@@ -297,10 +297,8 @@ class FilterMenu {
}
if (submitted) {
- //if (!options.onChange) {
saveValues(dlg, options.settings, options.settingsKey, options.setfilters);
return resolve();
- //}
}
return resolve();
});
diff --git a/src/components/filtermenu/filtermenu.template.html b/src/components/filtermenu/filtermenu.template.html
index cacc69cf43..cf65bcf5db 100644
--- a/src/components/filtermenu/filtermenu.template.html
+++ b/src/components/filtermenu/filtermenu.template.html
@@ -35,6 +35,10 @@