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/dashboard/logs.js",
"src/controllers/user/subtitles.js", "src/controllers/user/subtitles.js",
"src/controllers/dashboard/plugins/repositories.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/plugin.js",
"src/plugins/bookPlayer/tableOfContents.js", "src/plugins/bookPlayer/tableOfContents.js",
"src/plugins/photoPlayer/plugin.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) { import itemShortcuts from 'itemShortcuts';
'use strict'; 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); var ItemsContainerPrototype = Object.create(HTMLDivElement.prototype);
@ -62,7 +75,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
} }
var self = this; var self = this;
require(['multiSelect'], function (MultiSelect) { import('multiSelect').then(({default: MultiSelect}) => {
self.multiSelect = new MultiSelect({ self.multiSelect = new MultiSelect({
container: self, container: self,
bindOnClick: false bindOnClick: false
@ -122,7 +135,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
} }
var self = this; var self = this;
require(['sortable'], function (Sortable) { import('sortable').then(({default: Sortable}) => {
self.sortable = new Sortable(self, { self.sortable = new Sortable(self, {
draggable: '.listItem', draggable: '.listItem',
handle: '.listViewDragHandle', handle: '.listViewDragHandle',
@ -139,7 +152,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
var itemsContainer = this; var itemsContainer = this;
require(['cardBuilder'], function (cardBuilder) { import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onUserDataChanged(userData, itemsContainer); cardBuilder.onUserDataChanged(userData, itemsContainer);
}); });
@ -175,7 +188,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
// This could be null, not supported by all tv providers // This could be null, not supported by all tv providers
var newTimerId = data.Id; var newTimerId = data.Id;
require(['cardBuilder'], function (cardBuilder) { import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer); cardBuilder.onTimerCreated(programId, newTimerId, itemsContainer);
}); });
} }
@ -195,7 +208,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
return; return;
} }
require(['cardBuilder'], function (cardBuilder) { import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onTimerCancelled(data.Id, itemsContainer); cardBuilder.onTimerCancelled(data.Id, itemsContainer);
}); });
} }
@ -207,7 +220,7 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
return; return;
} }
require(['cardBuilder'], function (cardBuilder) { import('cardBuilder').then(({default: cardBuilder}) => {
cardBuilder.onSeriesTimerCancelled(data.Id, itemsContainer); cardBuilder.onSeriesTimerCancelled(data.Id, itemsContainer);
}); });
} }
@ -479,4 +492,5 @@ define(['itemShortcuts', 'inputManager', 'connectionManager', 'playbackManager',
prototype: ItemsContainerPrototype, prototype: ItemsContainerPrototype,
extends: 'div' extends: 'div'
}); });
});
/* eslint-enable indent */

View File

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

View File

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