mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Merge pull request #1743 from matjaz321/migrated-livetvschedule-to-es6-module
Migrated livetvschedule.js to ES6 module
This commit is contained in:
commit
df9303aabd
@ -224,6 +224,7 @@
|
||||
"src/controllers/livetvstatus.js",
|
||||
"src/controllers/livetvguideprovider.js",
|
||||
"src/controllers/livetvsettings.js",
|
||||
"src/controllers/livetv/livetvschedule.js",
|
||||
"src/controllers/livetv/livetvseriestimers.js",
|
||||
"src/controllers/livetv/livetvchannels.js",
|
||||
"src/controllers/shows/episodes.js",
|
||||
|
@ -1,122 +1,124 @@
|
||||
define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'scripts/livetvcomponents', 'emby-button', 'emby-itemscontainer'], function (layoutManager, cardBuilder, appHost, imageLoader, loading) {
|
||||
'use strict';
|
||||
import layoutManager from 'layoutManager';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
import imageLoader from 'imageLoader';
|
||||
import loading from 'loading';
|
||||
import 'scripts/livetvcomponents';
|
||||
import 'emby-button';
|
||||
import 'emby-itemscontainer';
|
||||
|
||||
loading = loading.default || loading;
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
}
|
||||
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop;
|
||||
function renderRecordings(elem, recordings, cardOptions) {
|
||||
if (recordings.length) {
|
||||
elem.classList.remove('hide');
|
||||
} else {
|
||||
elem.classList.add('hide');
|
||||
}
|
||||
|
||||
function renderRecordings(elem, recordings, cardOptions) {
|
||||
if (recordings.length) {
|
||||
const recordingItems = elem.querySelector('.recordingItems');
|
||||
|
||||
if (enableScrollX()) {
|
||||
recordingItems.classList.add('scrollX');
|
||||
|
||||
if (layoutManager.tv) {
|
||||
recordingItems.classList.add('smoothScrollX');
|
||||
}
|
||||
|
||||
recordingItems.classList.add('hiddenScrollX');
|
||||
recordingItems.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
recordingItems.classList.remove('scrollX');
|
||||
recordingItems.classList.remove('smoothScrollX');
|
||||
recordingItems.classList.remove('hiddenScrollX');
|
||||
recordingItems.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
|
||||
items: recordings,
|
||||
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
coverImage: true,
|
||||
cardLayout: false,
|
||||
centerText: true,
|
||||
allowBottomPadding: !enableScrollX(),
|
||||
preferThumb: 'auto'
|
||||
}, cardOptions || {}));
|
||||
imageLoader.lazyChildren(recordingItems);
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function renderActiveRecordings(context, promise) {
|
||||
promise.then(function (result) {
|
||||
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
|
||||
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
||||
defaultShape: getBackdropShape(),
|
||||
showParentTitle: false,
|
||||
showParentTitleOrTitle: true,
|
||||
showTitle: false,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: true,
|
||||
coverImage: true,
|
||||
overlayText: false,
|
||||
overlayMoreButton: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function renderTimers(context, timers, options) {
|
||||
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
|
||||
const elem = context;
|
||||
|
||||
if (html) {
|
||||
elem.classList.remove('hide');
|
||||
} else {
|
||||
elem.classList.add('hide');
|
||||
}
|
||||
|
||||
var recordingItems = elem.querySelector('.recordingItems');
|
||||
elem.querySelector('.recordingItems').innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
});
|
||||
}
|
||||
|
||||
if (enableScrollX()) {
|
||||
recordingItems.classList.add('scrollX');
|
||||
function renderUpcomingRecordings(context, promise) {
|
||||
promise.then(function (result) {
|
||||
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
if (layoutManager.tv) {
|
||||
recordingItems.classList.add('smoothScrollX');
|
||||
}
|
||||
export default function (view, params, tabContent) {
|
||||
let activeRecordingsPromise;
|
||||
let upcomingRecordingsPromise;
|
||||
const self = this;
|
||||
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
||||
self.preRender();
|
||||
self.renderTab();
|
||||
});
|
||||
|
||||
recordingItems.classList.add('hiddenScrollX');
|
||||
recordingItems.classList.remove('vertical-wrap');
|
||||
} else {
|
||||
recordingItems.classList.remove('scrollX');
|
||||
recordingItems.classList.remove('smoothScrollX');
|
||||
recordingItems.classList.remove('hiddenScrollX');
|
||||
recordingItems.classList.add('vertical-wrap');
|
||||
}
|
||||
|
||||
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
|
||||
items: recordings,
|
||||
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
||||
showTitle: true,
|
||||
showParentTitle: true,
|
||||
coverImage: true,
|
||||
cardLayout: false,
|
||||
centerText: true,
|
||||
allowBottomPadding: !enableScrollX(),
|
||||
preferThumb: 'auto'
|
||||
}, cardOptions || {}));
|
||||
imageLoader.lazyChildren(recordingItems);
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
||||
}
|
||||
|
||||
function renderActiveRecordings(context, promise) {
|
||||
promise.then(function (result) {
|
||||
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
|
||||
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
||||
defaultShape: getBackdropShape(),
|
||||
showParentTitle: false,
|
||||
showParentTitleOrTitle: true,
|
||||
showTitle: false,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: true,
|
||||
coverImage: true,
|
||||
overlayText: false,
|
||||
overlayMoreButton: true
|
||||
});
|
||||
self.preRender = function () {
|
||||
activeRecordingsPromise = ApiClient.getLiveTvRecordings({
|
||||
UserId: Dashboard.getCurrentUserId(),
|
||||
IsInProgress: true,
|
||||
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
||||
EnableTotalRecordCount: false,
|
||||
EnableImageTypes: 'Primary,Thumb,Backdrop'
|
||||
});
|
||||
}
|
||||
|
||||
function renderTimers(context, timers, options) {
|
||||
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
|
||||
var elem = context;
|
||||
|
||||
if (html) {
|
||||
elem.classList.remove('hide');
|
||||
} else {
|
||||
elem.classList.add('hide');
|
||||
}
|
||||
|
||||
elem.querySelector('.recordingItems').innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
upcomingRecordingsPromise = ApiClient.getLiveTvTimers({
|
||||
IsActive: false,
|
||||
IsScheduled: true
|
||||
});
|
||||
}
|
||||
|
||||
function renderUpcomingRecordings(context, promise) {
|
||||
promise.then(function (result) {
|
||||
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
return function (view, params, tabContent) {
|
||||
var activeRecordingsPromise;
|
||||
var upcomingRecordingsPromise;
|
||||
var self = this;
|
||||
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
||||
self.preRender();
|
||||
self.renderTab();
|
||||
});
|
||||
|
||||
self.preRender = function () {
|
||||
activeRecordingsPromise = ApiClient.getLiveTvRecordings({
|
||||
UserId: Dashboard.getCurrentUserId(),
|
||||
IsInProgress: true,
|
||||
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
||||
EnableTotalRecordCount: false,
|
||||
EnableImageTypes: 'Primary,Thumb,Backdrop'
|
||||
});
|
||||
upcomingRecordingsPromise = ApiClient.getLiveTvTimers({
|
||||
IsActive: false,
|
||||
IsScheduled: true
|
||||
});
|
||||
};
|
||||
|
||||
self.renderTab = function () {
|
||||
loading.show();
|
||||
renderActiveRecordings(tabContent, activeRecordingsPromise);
|
||||
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
self.renderTab = function () {
|
||||
loading.show();
|
||||
renderActiveRecordings(tabContent, activeRecordingsPromise);
|
||||
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user