mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
remove rerquire and update var declerations
This commit is contained in:
parent
8af1a74fd2
commit
e3d9518574
2 changed files with 61 additions and 61 deletions
|
@ -12,13 +12,13 @@ import actionsheet from 'actionsheet';
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
export function getCommands(options) {
|
export function getCommands(options) {
|
||||||
var item = options.item;
|
const item = options.item;
|
||||||
var user = options.user;
|
const user = options.user;
|
||||||
|
|
||||||
var canPlay = playbackManager.canPlay(item);
|
const canPlay = playbackManager.canPlay(item);
|
||||||
var restrictOptions = (browser.operaTv || browser.web0s) && !user.Policy.IsAdministrator;
|
const restrictOptions = (browser.operaTv || browser.web0s) && !user.Policy.IsAdministrator;
|
||||||
|
|
||||||
var commands = [];
|
let commands = [];
|
||||||
|
|
||||||
if (canPlay && item.MediaType !== 'Photo') {
|
if (canPlay && item.MediaType !== 'Photo') {
|
||||||
if (options.play !== false) {
|
if (options.play !== false) {
|
||||||
|
@ -171,10 +171,10 @@ import actionsheet from 'actionsheet';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var canEdit = itemHelper.canEdit(user, item);
|
const canEdit = itemHelper.canEdit(user, item);
|
||||||
if (canEdit) {
|
if (canEdit) {
|
||||||
if (options.edit !== false && item.Type !== 'SeriesTimer') {
|
if (options.edit !== false && item.Type !== 'SeriesTimer') {
|
||||||
var text = (item.Type === 'Timer' || item.Type === 'SeriesTimer') ? globalize.translate('Edit') : globalize.translate('EditMetadata');
|
const text = (item.Type === 'Timer' || item.Type === 'SeriesTimer') ? globalize.translate('Edit') : globalize.translate('EditMetadata');
|
||||||
commands.push({
|
commands.push({
|
||||||
name: text,
|
name: text,
|
||||||
id: 'edit',
|
id: 'edit',
|
||||||
|
@ -321,31 +321,31 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeCommand(item, id, options) {
|
function executeCommand(item, id, options) {
|
||||||
var itemId = item.Id;
|
const itemId = item.Id;
|
||||||
var serverId = item.ServerId;
|
const serverId = item.ServerId;
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'addtocollection':
|
case 'addtocollection':
|
||||||
require(['collectionEditor'], function (collectionEditor) {
|
import('collectionEditor').then(({default: collectionEditor}) => {
|
||||||
new collectionEditor.showEditor({
|
new collectionEditor({
|
||||||
items: [itemId],
|
items: [itemId],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'addtoplaylist':
|
case 'addtoplaylist':
|
||||||
require(['playlistEditor'], function (playlistEditor) {
|
import('playlistEditor').then(({default: playlistEditor}) => {
|
||||||
new playlistEditor.showEditor({
|
new playlistEditor({
|
||||||
items: [itemId],
|
items: [itemId],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'download':
|
case 'download':
|
||||||
require(['fileDownloader'], function (fileDownloader) {
|
import('fileDownloader').then(({default: fileDownloader}) => {
|
||||||
var downloadHref = apiClient.getItemDownloadUrl(itemId);
|
const downloadHref = apiClient.getItemDownloadUrl(itemId);
|
||||||
fileDownloader.download([{
|
fileDownloader.download([{
|
||||||
url: downloadHref,
|
url: downloadHref,
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
|
@ -357,16 +357,16 @@ import actionsheet from 'actionsheet';
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'copy-stream':
|
case 'copy-stream':
|
||||||
var downloadHref = apiClient.getItemDownloadUrl(itemId);
|
const downloadHref = apiClient.getItemDownloadUrl(itemId);
|
||||||
var textAreaCopy = function () {
|
const textAreaCopy = function () {
|
||||||
var textArea = document.createElement('textarea');
|
let textArea = document.createElement('textarea');
|
||||||
textArea.value = downloadHref;
|
textArea.value = downloadHref;
|
||||||
document.body.appendChild(textArea);
|
document.body.appendChild(textArea);
|
||||||
textArea.focus();
|
textArea.focus();
|
||||||
textArea.select();
|
textArea.select();
|
||||||
|
|
||||||
if (document.execCommand('copy')) {
|
if (document.execCommand('copy')) {
|
||||||
require(['toast'], function (toast) {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(globalize.translate('CopyStreamURLSuccess'));
|
toast(globalize.translate('CopyStreamURLSuccess'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -381,7 +381,7 @@ import actionsheet from 'actionsheet';
|
||||||
} else {
|
} else {
|
||||||
/* eslint-disable-next-line compat/compat */
|
/* eslint-disable-next-line compat/compat */
|
||||||
navigator.clipboard.writeText(downloadHref).then(function () {
|
navigator.clipboard.writeText(downloadHref).then(function () {
|
||||||
require(['toast'], function (toast) {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(globalize.translate('CopyStreamURLSuccess'));
|
toast(globalize.translate('CopyStreamURLSuccess'));
|
||||||
});
|
});
|
||||||
}).catch(function () {
|
}).catch(function () {
|
||||||
|
@ -391,7 +391,7 @@ import actionsheet from 'actionsheet';
|
||||||
getResolveFunction(resolve, id)();
|
getResolveFunction(resolve, id)();
|
||||||
break;
|
break;
|
||||||
case 'editsubtitles':
|
case 'editsubtitles':
|
||||||
require(['subtitleEditor'], function (subtitleEditor) {
|
import('subtitleEditor').then(({default: subtitleEditor}) => {
|
||||||
subtitleEditor.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
subtitleEditor.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -399,7 +399,7 @@ import actionsheet from 'actionsheet';
|
||||||
editItem(apiClient, item).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
editItem(apiClient, item).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
break;
|
break;
|
||||||
case 'editimages':
|
case 'editimages':
|
||||||
require(['imageEditor'], function (imageEditor) {
|
import('imageEditor').then(({default: imageEditor}) => {
|
||||||
imageEditor.show({
|
imageEditor.show({
|
||||||
itemId: itemId,
|
itemId: itemId,
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
|
@ -407,12 +407,12 @@ import actionsheet from 'actionsheet';
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'identify':
|
case 'identify':
|
||||||
require(['itemIdentifier'], function (itemIdentifier) {
|
import('itemIdentifier').then(({default:itemIdentifier }) => {
|
||||||
itemIdentifier.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
itemIdentifier.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'moremediainfo':
|
case 'moremediainfo':
|
||||||
require(['itemMediaInfo'], function (itemMediaInfo) {
|
import('itemMediaInfo').then(({default: itemMediaInfo}) => {
|
||||||
itemMediaInfo.show(itemId, serverId).then(getResolveFunction(resolve, id), getResolveFunction(resolve, id));
|
itemMediaInfo.show(itemId, serverId).then(getResolveFunction(resolve, id), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -441,7 +441,7 @@ import actionsheet from 'actionsheet';
|
||||||
getResolveFunction(resolve, id)();
|
getResolveFunction(resolve, id)();
|
||||||
break;
|
break;
|
||||||
case 'record':
|
case 'record':
|
||||||
require(['recordingCreator'], function (recordingCreator) {
|
import('recordingCreator').then(({default: recordingCreator}) => {
|
||||||
recordingCreator.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
recordingCreator.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -512,8 +512,8 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTimer(apiClient, item, resolve, command) {
|
function deleteTimer(apiClient, item, resolve, command) {
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
import('recordingHelper').then(({default: recordingHelper}) => {
|
||||||
var timerId = item.TimerId || item.Id;
|
const timerId = item.TimerId || item.Id;
|
||||||
recordingHelper.cancelTimerWithConfirmation(timerId, item.ServerId).then(function () {
|
recordingHelper.cancelTimerWithConfirmation(timerId, item.ServerId).then(function () {
|
||||||
getResolveFunction(resolve, command, true)();
|
getResolveFunction(resolve, command, true)();
|
||||||
});
|
});
|
||||||
|
@ -521,7 +521,7 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteSeriesTimer(apiClient, item, resolve, command) {
|
function deleteSeriesTimer(apiClient, item, resolve, command) {
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
import('recordingHelper').then(({default: recordingHelper}) => {
|
||||||
recordingHelper.cancelSeriesTimerWithConfirmation(item.Id, item.ServerId).then(function () {
|
recordingHelper.cancelSeriesTimerWithConfirmation(item.Id, item.ServerId).then(function () {
|
||||||
getResolveFunction(resolve, command, true)();
|
getResolveFunction(resolve, command, true)();
|
||||||
});
|
});
|
||||||
|
@ -529,9 +529,9 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
function play(item, resume, queue, queueNext) {
|
function play(item, resume, queue, queueNext) {
|
||||||
var method = queue ? (queueNext ? 'queueNext' : 'queue') : 'play';
|
const method = queue ? (queueNext ? 'queueNext' : 'queue') : 'play';
|
||||||
|
|
||||||
var startPosition = 0;
|
let startPosition = 0;
|
||||||
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
||||||
startPosition = item.UserData.PlaybackPositionTicks;
|
startPosition = item.UserData.PlaybackPositionTicks;
|
||||||
}
|
}
|
||||||
|
@ -552,18 +552,18 @@ import actionsheet from 'actionsheet';
|
||||||
|
|
||||||
function editItem(apiClient, item) {
|
function editItem(apiClient, item) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
var serverId = apiClient.serverInfo().Id;
|
const serverId = apiClient.serverInfo().Id;
|
||||||
|
|
||||||
if (item.Type === 'Timer') {
|
if (item.Type === 'Timer') {
|
||||||
require(['recordingEditor'], function (recordingEditor) {
|
import('recordingEditor').then(({default: recordingEditor}) => {
|
||||||
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
||||||
});
|
});
|
||||||
} else if (item.Type === 'SeriesTimer') {
|
} else if (item.Type === 'SeriesTimer') {
|
||||||
require(['seriesRecordingEditor'], function (recordingEditor) {
|
import('seriesRecordingEditor').then(({default: recordingEditor}) => {
|
||||||
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
require(['metadataEditor'], function (metadataEditor) {
|
import('metadataEditor').then(({default: metadataEditor}) => {
|
||||||
metadataEditor.show(item.Id, serverId).then(resolve, reject);
|
metadataEditor.show(item.Id, serverId).then(resolve, reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -572,7 +572,7 @@ import actionsheet from 'actionsheet';
|
||||||
|
|
||||||
function deleteItem(apiClient, item) {
|
function deleteItem(apiClient, item) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['deleteHelper'], function (deleteHelper) {
|
import('deleteHelper').then(({default: deleteHelper}) => {
|
||||||
deleteHelper.deleteItem({
|
deleteHelper.deleteItem({
|
||||||
item: item,
|
item: item,
|
||||||
navigate: false
|
navigate: false
|
||||||
|
@ -584,7 +584,7 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh(apiClient, item) {
|
function refresh(apiClient, item) {
|
||||||
require(['refreshDialog'], function (refreshDialog) {
|
import('refreshDialog').then(({default: refreshDialog}) => {
|
||||||
new refreshDialog({
|
new refreshDialog({
|
||||||
itemIds: [item.Id],
|
itemIds: [item.Id],
|
||||||
serverId: apiClient.serverInfo().Id,
|
serverId: apiClient.serverInfo().Id,
|
||||||
|
@ -594,7 +594,7 @@ import actionsheet from 'actionsheet';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function show(options) {
|
export function show(options) {
|
||||||
var commands = getCommands(options);
|
const commands = getCommands(options);
|
||||||
if (!commands.length) {
|
if (!commands.length) {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ import 'emby-button';
|
||||||
|
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
var tabOwnerView;
|
let tabOwnerView;
|
||||||
var queryScope = document.querySelector('.skinHeader');
|
const queryScope = document.querySelector('.skinHeader');
|
||||||
var footerTabsContainer;
|
let footerTabsContainer;
|
||||||
var headerTabsContainer;
|
let headerTabsContainer;
|
||||||
var tabsElem;
|
let tabsElem;
|
||||||
|
|
||||||
function enableTabsInFooter() {
|
function enableTabsInFooter() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -49,7 +49,7 @@ import 'emby-button';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var classList = elem.classList;
|
const classList = elem.classList;
|
||||||
if (classList) {
|
if (classList) {
|
||||||
return !classList.contains('scrollX') && !classList.contains('animatedScrollX');
|
return !classList.contains('scrollX') && !classList.contains('animatedScrollX');
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ import 'emby-button';
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parent = target;
|
let parent = target;
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
if (!allowSwipeOn(parent)) {
|
if (!allowSwipeOn(parent)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -75,22 +75,22 @@ import 'emby-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
// implement without hammer
|
// implement without hammer
|
||||||
var pageCount = getTabContainersFn().length;
|
const pageCount = getTabContainersFn().length;
|
||||||
var onSwipeLeft = function (e, target) {
|
onSwipeLeft = function (e, target) {
|
||||||
if (allowSwipe(target) && view.contains(target)) {
|
if (allowSwipe(target) && view.contains(target)) {
|
||||||
tabsElem.selectNext();
|
tabsElem.selectNext();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onSwipeRight = function (e, target) {
|
onSwipeRight = function (e, target) {
|
||||||
if (allowSwipe(target) && view.contains(target)) {
|
if (allowSwipe(target) && view.contains(target)) {
|
||||||
tabsElem.selectPrevious();
|
tabsElem.selectPrevious();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
require(['touchHelper'], function (TouchHelper) {
|
import('touchHelper').then(({default: TouchHelper}) => {
|
||||||
|
|
||||||
var touchHelper = new TouchHelper(view.parentNode.parentNode);
|
const touchHelper = new TouchHelper(view.parentNode.parentNode);
|
||||||
|
|
||||||
events.on(touchHelper, 'swipeleft', onSwipeLeft);
|
events.on(touchHelper, 'swipeleft', onSwipeLeft);
|
||||||
events.on(touchHelper, 'swiperight', onSwipeRight);
|
events.on(touchHelper, 'swiperight', onSwipeRight);
|
||||||
|
@ -103,7 +103,7 @@ import 'emby-button';
|
||||||
|
|
||||||
export function setTabs(view, selectedIndex, getTabsFn, getTabContainersFn, onBeforeTabChange, onTabChange, setSelectedIndex) {
|
export function setTabs(view, selectedIndex, getTabsFn, getTabContainersFn, onBeforeTabChange, onTabChange, setSelectedIndex) {
|
||||||
|
|
||||||
var enableInFooter = enableTabsInFooter();
|
const enableInFooter = enableTabsInFooter();
|
||||||
|
|
||||||
if (!view) {
|
if (!view) {
|
||||||
if (tabOwnerView) {
|
if (tabOwnerView) {
|
||||||
|
@ -134,7 +134,7 @@ import 'emby-button';
|
||||||
|
|
||||||
ensureElements(enableInFooter);
|
ensureElements(enableInFooter);
|
||||||
|
|
||||||
var tabsContainerElem = enableInFooter ? footerTabsContainer : headerTabsContainer;
|
const tabsContainerElem = enableInFooter ? footerTabsContainer : headerTabsContainer;
|
||||||
|
|
||||||
if (!tabOwnerView) {
|
if (!tabOwnerView) {
|
||||||
tabsContainerElem.classList.remove('hide');
|
tabsContainerElem.classList.remove('hide');
|
||||||
|
@ -142,18 +142,18 @@ import 'emby-button';
|
||||||
|
|
||||||
if (tabOwnerView !== view) {
|
if (tabOwnerView !== view) {
|
||||||
|
|
||||||
var index = 0;
|
let index = 0;
|
||||||
|
|
||||||
var indexAttribute = selectedIndex == null ? '' : (' data-index="' + selectedIndex + '"');
|
const indexAttribute = selectedIndex == null ? '' : (' data-index="' + selectedIndex + '"');
|
||||||
var tabsHtml = '<div is="emby-tabs"' + indexAttribute + ' class="tabs-viewmenubar"><div class="emby-tabs-slider" style="white-space:nowrap;">' + getTabsFn().map(function (t) {
|
const tabsHtml = '<div is="emby-tabs"' + indexAttribute + ' class="tabs-viewmenubar"><div class="emby-tabs-slider" style="white-space:nowrap;">' + getTabsFn().map(function (t) {
|
||||||
|
|
||||||
var tabClass = 'emby-tab-button';
|
let tabClass = 'emby-tab-button';
|
||||||
|
|
||||||
if (t.enabled === false) {
|
if (t.enabled === false) {
|
||||||
tabClass += ' hide';
|
tabClass += ' hide';
|
||||||
}
|
}
|
||||||
|
|
||||||
var tabHtml;
|
let tabHtml;
|
||||||
|
|
||||||
if (t.cssClass) {
|
if (t.cssClass) {
|
||||||
tabClass += ' ' + t.cssClass;
|
tabClass += ' ' + t.cssClass;
|
||||||
|
@ -182,16 +182,16 @@ import 'emby-button';
|
||||||
|
|
||||||
tabsElem.addEventListener('beforetabchange', function (e) {
|
tabsElem.addEventListener('beforetabchange', function (e) {
|
||||||
|
|
||||||
var tabContainers = getTabContainersFn();
|
const tabContainers = getTabContainersFn();
|
||||||
if (e.detail.previousIndex != null) {
|
if (e.detail.previousIndex != null) {
|
||||||
|
|
||||||
var previousPanel = tabContainers[e.detail.previousIndex];
|
const previousPanel = tabContainers[e.detail.previousIndex];
|
||||||
if (previousPanel) {
|
if (previousPanel) {
|
||||||
previousPanel.classList.remove('is-active');
|
previousPanel.classList.remove('is-active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newPanel = tabContainers[e.detail.selectedTabIndex];
|
const newPanel = tabContainers[e.detail.selectedTabIndex];
|
||||||
|
|
||||||
//if (e.detail.previousIndex != null && e.detail.previousIndex != e.detail.selectedTabIndex) {
|
//if (e.detail.previousIndex != null && e.detail.previousIndex != e.detail.selectedTabIndex) {
|
||||||
// if (newPanel.animate && (animateTabs || []).indexOf(e.detail.selectedTabIndex) != -1) {
|
// if (newPanel.animate && (animateTabs || []).indexOf(e.detail.selectedTabIndex) != -1) {
|
||||||
|
@ -248,7 +248,7 @@ import 'emby-button';
|
||||||
|
|
||||||
export function selectedTabIndex(index) {
|
export function selectedTabIndex(index) {
|
||||||
|
|
||||||
var tabsContainerElem = headerTabsContainer;
|
const tabsContainerElem = headerTabsContainer;
|
||||||
|
|
||||||
if (!tabsElem) {
|
if (!tabsElem) {
|
||||||
tabsElem = tabsContainerElem.querySelector('[is="emby-tabs"]');
|
tabsElem = tabsContainerElem.querySelector('[is="emby-tabs"]');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue