import optimizations for site.js
transfered pageIdOn and pageClassOn to clientUtils
This commit is contained in:
parent
5d94812220
commit
4e11e3ba66
9 changed files with 86 additions and 93 deletions
|
@ -4,6 +4,7 @@ import dom from '../../scripts/dom';
|
|||
import globalize from '../../scripts/globalize';
|
||||
import '../../elements/emby-button/emby-button';
|
||||
import confirm from '../../components/confirm/confirm';
|
||||
import { pageIdOn } from '../../scripts/clientUtils';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import dom from '../../scripts/dom';
|
|||
import imageHelper from '../../scripts/imagehelper';
|
||||
import '../../components/cardbuilder/card.css';
|
||||
import '../../elements/emby-itemrefreshindicator/emby-itemrefreshindicator';
|
||||
import Dashboard from '../../scripts/clientUtils';
|
||||
import Dashboard, { pageClassOn, pageIdOn } from '../../scripts/clientUtils';
|
||||
import confirm from '../../components/confirm/confirm';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
|
|
@ -4,7 +4,7 @@ import dom from '../../../../scripts/dom';
|
|||
import globalize from '../../../../scripts/globalize';
|
||||
import '../../../../components/cardbuilder/card.css';
|
||||
import '../../../../elements/emby-button/emby-button';
|
||||
import Dashboard from '../../../../scripts/clientUtils';
|
||||
import Dashboard, { pageIdOn } from '../../../../scripts/clientUtils';
|
||||
import confirm from '../../../../components/confirm/confirm';
|
||||
|
||||
function deletePlugin(page, uniqueid, name) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import '../../../components/cardbuilder/card.css';
|
|||
import '../../../elements/emby-button/emby-button';
|
||||
import '../../../components/indicators/indicators.css';
|
||||
import '../../../assets/css/flexstyles.scss';
|
||||
import Dashboard from '../../../scripts/clientUtils';
|
||||
import Dashboard, { pageIdOn } from '../../../scripts/clientUtils';
|
||||
import confirm from '../../../components/confirm/confirm';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Events } from 'jellyfin-apiclient';
|
||||
import loading from '../components/loading/loading';
|
||||
import globalize from '../scripts/globalize';
|
||||
import Dashboard from '../scripts/clientUtils';
|
||||
import Dashboard, { pageIdOn } from '../scripts/clientUtils';
|
||||
|
||||
function onListingsSubmitted() {
|
||||
Dashboard.navigate('livetvstatus.html');
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import backdrop from '../components/backdrop/backdrop';
|
||||
import * as userSettings from './settings/userSettings';
|
||||
import libraryMenu from './libraryMenu';
|
||||
import { pageClassOn } from './clientUtils';
|
||||
|
||||
const cache = {};
|
||||
|
||||
|
|
|
@ -158,6 +158,26 @@ export function confirm(message, title, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
export const pageClassOn = function(eventName, className, fn) {
|
||||
document.addEventListener(eventName, function (event) {
|
||||
const target = event.target;
|
||||
|
||||
if (target.classList.contains(className)) {
|
||||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const pageIdOn = function(eventName, id, fn) {
|
||||
document.addEventListener(eventName, function (event) {
|
||||
const target = event.target;
|
||||
|
||||
if (target.id === id) {
|
||||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const Dashboard = {
|
||||
alert,
|
||||
capabilities,
|
||||
|
|
|
@ -15,7 +15,7 @@ import '../elements/emby-button/paper-icon-button-light';
|
|||
import 'material-design-icons-iconfont';
|
||||
import '../assets/css/scrollstyles.css';
|
||||
import '../assets/css/flexstyles.scss';
|
||||
import Dashboard from './clientUtils';
|
||||
import Dashboard, { pageClassOn } from './clientUtils';
|
||||
import ServerConnections from '../components/ServerConnections';
|
||||
import Headroom from 'headroom.js';
|
||||
|
||||
|
|
|
@ -20,6 +20,16 @@ import { getPlugins } from './settings/webSettings';
|
|||
import { pluginManager } from '../components/pluginManager';
|
||||
import packageManager from '../components/packageManager';
|
||||
import { appRouter } from '../components/appRouter';
|
||||
import '../elements/emby-button/emby-button';
|
||||
import './autoThemes';
|
||||
import './libraryMenu';
|
||||
import './routes';
|
||||
import '../components/themeMediaPlayer';
|
||||
import './autoBackdrops';
|
||||
import { pageClassOn } from './clientUtils';
|
||||
import '../libraries/screensavermanager';
|
||||
import './serverNotifications';
|
||||
import '../components/playback/playerSelectionMenu';
|
||||
|
||||
// TODO: Move this elsewhere
|
||||
window.getWindowLocationSearch = function(win) {
|
||||
|
@ -50,28 +60,6 @@ window.getParameterByName = function(name, url) {
|
|||
return decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
// TODO: Move this elsewhere
|
||||
window.pageClassOn = function(eventName, className, fn) {
|
||||
document.addEventListener(eventName, function (event) {
|
||||
const target = event.target;
|
||||
|
||||
if (target.classList.contains(className)) {
|
||||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// TODO: Move this elsewhere
|
||||
window.pageIdOn = function(eventName, id, fn) {
|
||||
document.addEventListener(eventName, function (event) {
|
||||
const target = event.target;
|
||||
|
||||
if (target.id === id) {
|
||||
fn.call(target, event);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (window.appMode === 'cordova' || window.appMode === 'android' || window.appMode === 'standalone') {
|
||||
AppInfo.isNativeApp = true;
|
||||
}
|
||||
|
@ -153,7 +141,7 @@ function loadPlugins() {
|
|||
Promise.all(list.map((plugin) => {
|
||||
return pluginManager.loadPlugin(import(/* webpackChunkName: "[request]" */ `../plugins/${plugin}`));
|
||||
}))
|
||||
.then(function (pluginPromises) {
|
||||
.then(function () {
|
||||
console.debug('finished loading plugins');
|
||||
})
|
||||
.catch(() => console.debug('failed loading plugins')
|
||||
|
@ -175,21 +163,11 @@ function onAppReady() {
|
|||
import('../assets/css/ios.scss');
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
import('../elements/emby-button/emby-button'),
|
||||
import('./autoThemes'),
|
||||
import('./libraryMenu'),
|
||||
import('./routes')
|
||||
])
|
||||
.then(() => {
|
||||
appRouter.start({
|
||||
click: false,
|
||||
hashbang: true
|
||||
});
|
||||
|
||||
import('../components/themeMediaPlayer');
|
||||
import('./autoBackdrops');
|
||||
|
||||
if (!browser.tv && !browser.xboxOne && !browser.ps4) {
|
||||
import('../components/nowPlayingBar/nowPlayingBar');
|
||||
}
|
||||
|
@ -199,8 +177,6 @@ function onAppReady() {
|
|||
import('../components/playback/remotecontrolautoplay');
|
||||
}
|
||||
|
||||
import('../libraries/screensavermanager');
|
||||
|
||||
if (!appHost.supports('physicalvolumecontrol') || browser.touch) {
|
||||
import('../components/playback/volumeosd');
|
||||
}
|
||||
|
@ -210,8 +186,6 @@ function onAppReady() {
|
|||
import('../components/playback/mediasession');
|
||||
}
|
||||
|
||||
import('./serverNotifications');
|
||||
|
||||
if (!browser.tv && !browser.xboxOne) {
|
||||
import('../components/playback/playbackorientation');
|
||||
registerServiceWorker();
|
||||
|
@ -221,8 +195,6 @@ function onAppReady() {
|
|||
}
|
||||
}
|
||||
|
||||
import('../components/playback/playerSelectionMenu');
|
||||
|
||||
const apiClient = ServerConnections.currentApiClient();
|
||||
if (apiClient) {
|
||||
fetch(apiClient.getUrl('Branding/Css'))
|
||||
|
@ -247,7 +219,6 @@ function onAppReady() {
|
|||
console.warn('Error applying custom css', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function registerServiceWorker() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue