Merge pull request #1743 from matjaz321/migrated-livetvschedule-to-es6-module

Migrated livetvschedule.js to ES6 module
This commit is contained in:
dkanada 2020-08-06 01:29:50 +09:00 committed by GitHub
commit df9303aabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 110 additions and 107 deletions

View File

@ -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",

View File

@ -1,20 +1,23 @@
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() {
function enableScrollX() {
return !layoutManager.desktop;
}
}
function renderRecordings(elem, recordings, cardOptions) {
function renderRecordings(elem, recordings, cardOptions) {
if (recordings.length) {
elem.classList.remove('hide');
} else {
elem.classList.add('hide');
}
var recordingItems = elem.querySelector('.recordingItems');
const recordingItems = elem.querySelector('.recordingItems');
if (enableScrollX()) {
recordingItems.classList.add('scrollX');
@ -44,13 +47,13 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
preferThumb: 'auto'
}, cardOptions || {}));
imageLoader.lazyChildren(recordingItems);
}
}
function getBackdropShape() {
function getBackdropShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
}
function renderActiveRecordings(context, promise) {
function renderActiveRecordings(context, promise) {
promise.then(function (result) {
renderRecordings(context.querySelector('#activeRecordings'), result.Items, {
shape: enableScrollX() ? 'autooverflow' : 'auto',
@ -66,11 +69,11 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
overlayMoreButton: true
});
});
}
}
function renderTimers(context, timers, options) {
function renderTimers(context, timers, options) {
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
var elem = context;
const elem = context;
if (html) {
elem.classList.remove('hide');
@ -81,19 +84,19 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
elem.querySelector('.recordingItems').innerHTML = html;
imageLoader.lazyChildren(elem);
});
}
}
function renderUpcomingRecordings(context, promise) {
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;
export default function (view, params, tabContent) {
let activeRecordingsPromise;
let upcomingRecordingsPromise;
const self = this;
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
self.preRender();
self.renderTab();
@ -118,5 +121,4 @@ define(['layoutManager', 'cardBuilder', 'apphost', 'imageLoader', 'loading', 'sc
renderActiveRecordings(tabContent, activeRecordingsPromise);
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
};
};
});
}