Migrate emby-itemscontainer, playstatebutton, programcell to ES6 modules

This commit is contained in:
Cameron 2020-07-08 18:01:19 +01:00
parent 1f8ce6e6f4
commit d07a0aa3a9
4 changed files with 44 additions and 25 deletions

View File

@ -132,6 +132,9 @@
"src/controllers/dashboard/logs.js",
"src/controllers/user/subtitles.js",
"src/controllers/dashboard/plugins/repositories.js",
"src/elements/emby-itemscontainer/emby-itemscontainer.js",
"src/elements/emby-programcell/emby-programcell.js",
"src/elements/emby-playstatebutton/emby-playstatebutton.js",
"src/plugins/bookPlayer/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js",
"src/plugins/photoPlayer/plugin.js",

View File

@ -1,5 +1,18 @@
define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager', 'imageLoader', 'layoutManager', 'browser', 'dom', 'loading', 'focusManager', 'serverNotifications', 'events', 'registerElement'], function (itemShortcuts, inputManager, connectionManager, playbackManager, imageLoader, layoutManager, browser, dom, loading, focusManager, serverNotifications, events) {
'use strict';
import itemShortcuts from 'itemShortcuts';
import inputManager from 'inputManager';
import connectionManager from 'connectionManager';
import playbackManager from 'playbackManager';
import imageLoader from 'imageLoader';
import layoutManager from 'layoutManager';
import browser from 'browser';
import dom from 'dom';
import loading from 'loading';
import focusManager from 'focusManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
import 'registerElement';
/* eslint-disable indent */
var ItemsContainerPrototype = Object.create(HTMLDivElement.prototype);
@ -62,7 +75,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
}
var self = this;
require(['multiSelect'], function (MultiSelect) {
import('multiSelect').then(({default: MultiSelect}) => {
self.multiSelect = new MultiSelect({
container: self,
bindOnClick: false
@ -122,7 +135,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
}
var self = this;
require(['sortable'], function (Sortable) {
import('sortable').then(({default: Sortable}) => {
self.sortable = new Sortable(self, {
draggable: '.listItem',
handle: '.listViewDragHandle',
@ -139,7 +152,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
var itemsContainer = this;
require(['cardBuilder'], function (cardBuilder) {
import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onUserDataChanged(userData, itemsContainer);
});
@ -175,7 +188,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
// This could be null, not supported by all tv providers
var newTimerId = data.Id;
require(['cardBuilder'], function (cardBuilder) {
import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer);
});
}
@ -195,7 +208,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
return;
}
require(['cardBuilder'], function (cardBuilder) {
import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onTimerCancelled(data.Id, itemsContainer);
});
}
@ -207,7 +220,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
return;
}
require(['cardBuilder'], function (cardBuilder) {
import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onSeriesTimerCancelled(data.Id, itemsContainer);
});
}
@ -479,4 +492,5 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
prototype: ItemsContainerPrototype,
extends: 'div'
});
});
/* eslint-enable indent */

View File

@ -1,5 +1,10 @@
define(['connectionManager', 'serverNotifications', 'events', 'globalize', 'emby-button'], function (connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) {
'use strict';
import connectionManager from 'connectionManager';
import serverNotifications from 'serverNotifications';
import events from 'events';
import globalize from 'globalize';
import EmbyButtonPrototype from 'emby-button';
/* eslint-disable indent */
function addNotificationEvent(instance, name, handler) {
var localHandler = handler.bind(instance);
@ -156,4 +161,5 @@ define(['connectionManager', 'serverNotifications', 'events', 'globalize', 'emby
prototype: EmbyPlaystateButtonPrototype,
extends: 'button'
});
});
/* eslint-enable indent */

View File

@ -1,16 +1,12 @@
define([], function() {
'use strict';
var ProgramCellPrototype = Object.create(HTMLButtonElement.prototype);
var ProgramCellPrototype = Object.create(HTMLButtonElement.prototype);
ProgramCellPrototype.detachedCallback = function () {
this.posLeft = null;
this.posWidth = null;
this.guideProgramName = null;
};
ProgramCellPrototype.detachedCallback = function () {
this.posLeft = null;
this.posWidth = null;
this.guideProgramName = null;
};
document.registerElement('emby-programcell', {
prototype: ProgramCellPrototype,
extends: 'button'
});
document.registerElement('emby-programcell', {
prototype: ProgramCellPrototype,
extends: 'button'
});