mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1654 from Camc314/migrate-to-ES6-42
Migration of toast and upnextdialog to ES6 modules
This commit is contained in:
commit
0ef8f3d038
5 changed files with 84 additions and 74 deletions
|
@ -166,6 +166,8 @@
|
||||||
"src/components/syncPlay/playbackPermissionManager.js",
|
"src/components/syncPlay/playbackPermissionManager.js",
|
||||||
"src/components/syncPlay/syncPlayManager.js",
|
"src/components/syncPlay/syncPlayManager.js",
|
||||||
"src/components/syncPlay/timeSyncManager.js",
|
"src/components/syncPlay/timeSyncManager.js",
|
||||||
|
"src/components/toast/toast.js",
|
||||||
|
"src/components/upnextdialog/upnextdialog.js",
|
||||||
"src/components/viewContainer.js",
|
"src/components/viewContainer.js",
|
||||||
"src/controllers/session/addServer/index.js",
|
"src/controllers/session/addServer/index.js",
|
||||||
"src/controllers/session/forgotPassword/index.js",
|
"src/controllers/session/forgotPassword/index.js",
|
||||||
|
|
|
@ -59,8 +59,8 @@ import 'css!./imageeditor';
|
||||||
currentItem = item;
|
currentItem = item;
|
||||||
|
|
||||||
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
|
apiClient.getRemoteImageProviders(getBaseRemoteOptions()).then(function (providers) {
|
||||||
const btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
|
var btnBrowseAllImages = page.querySelectorAll('.btnBrowseAllImages');
|
||||||
for (let i = 0, length = btnBrowseAllImages.length; i < length; i++) {
|
for (var i = 0, length = btnBrowseAllImages.length; i < length; i++) {
|
||||||
if (providers.length) {
|
if (providers.length) {
|
||||||
btnBrowseAllImages[i].classList.remove('hide');
|
btnBrowseAllImages[i].classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
define(['css!./toast'], function () {
|
import 'css!./toast';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function remove(elem) {
|
function remove(elem) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
|
@ -14,14 +13,14 @@ define(['css!./toast'], function () {
|
||||||
}, 3300);
|
}, 3300);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function (options) {
|
export default function (options) {
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = {
|
options = {
|
||||||
text: options
|
text: options
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = document.createElement('div');
|
const elem = document.createElement('div');
|
||||||
elem.classList.add('toast');
|
elem.classList.add('toast');
|
||||||
elem.innerHTML = options.text;
|
elem.innerHTML = options.text;
|
||||||
|
|
||||||
|
@ -32,5 +31,4 @@ define(['css!./toast'], function () {
|
||||||
|
|
||||||
animateRemove(elem);
|
animateRemove(elem);
|
||||||
}, 300);
|
}, 300);
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'layoutManager', 'focusManager', 'globalize', 'itemHelper', 'css!./upnextdialog', 'emby-button', 'flexStyles'], function (dom, playbackManager, connectionManager, events, mediaInfo, layoutManager, focusManager, globalize, itemHelper) {
|
import dom from 'dom';
|
||||||
'use strict';
|
import playbackManager from 'playbackManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import events from 'events';
|
||||||
|
import mediaInfo from 'mediaInfo';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import focusManager from 'focusManager';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import itemHelper from 'itemHelper';
|
||||||
|
import 'css!./upnextdialog';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
playbackManager = playbackManager.default || playbackManager;
|
/* eslint-disable indent */
|
||||||
|
|
||||||
var transitionEndEventName = dom.whichTransitionEvent();
|
const transitionEndEventName = dom.whichTransitionEvent();
|
||||||
|
|
||||||
function seriesImageUrl(item, options) {
|
function seriesImageUrl(item, options) {
|
||||||
if (item.Type !== 'Episode') {
|
if (item.Type !== 'Episode') {
|
||||||
|
@ -58,7 +68,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
|
|
||||||
function setPoster(osdPoster, item, secondaryItem) {
|
function setPoster(osdPoster, item, secondaryItem) {
|
||||||
if (item) {
|
if (item) {
|
||||||
var imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
|
let imgUrl = seriesImageUrl(item, { type: 'Primary' }) ||
|
||||||
seriesImageUrl(item, { type: 'Thumb' }) ||
|
seriesImageUrl(item, { type: 'Thumb' }) ||
|
||||||
imageUrl(item, { type: 'Primary' });
|
imageUrl(item, { type: 'Primary' });
|
||||||
|
|
||||||
|
@ -78,7 +88,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHtml() {
|
function getHtml() {
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
html += '<div class="upNextDialog-poster">';
|
html += '<div class="upNextDialog-poster">';
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
@ -114,17 +124,17 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNextVideoText() {
|
function setNextVideoText() {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
var secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
|
const secondsRemaining = Math.max(Math.round(getTimeRemainingMs(instance) / 1000), 0);
|
||||||
|
|
||||||
console.debug('up next seconds remaining: ' + secondsRemaining);
|
console.debug('up next seconds remaining: ' + secondsRemaining);
|
||||||
|
|
||||||
var timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
|
const timeText = '<span class="upNextDialog-countdownText">' + globalize.translate('HeaderSecondsValue', secondsRemaining) + '</span>';
|
||||||
|
|
||||||
var nextVideoText = instance.itemType === 'Episode' ?
|
const nextVideoText = instance.itemType === 'Episode' ?
|
||||||
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
|
globalize.translate('HeaderNextEpisodePlayingInValue', timeText) :
|
||||||
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
|
globalize.translate('HeaderNextVideoPlayingInValue', timeText);
|
||||||
|
|
||||||
|
@ -132,9 +142,9 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillItem(item) {
|
function fillItem(item) {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
setPoster(elem.querySelector('.upNextDialog-poster'), item);
|
setPoster(elem.querySelector('.upNextDialog-poster'), item);
|
||||||
|
|
||||||
|
@ -143,7 +153,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
elem.querySelector('.upNextDialog-mediainfo').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(item, {
|
elem.querySelector('.upNextDialog-mediainfo').innerHTML = mediaInfo.getPrimaryMediaInfoHtml(item, {
|
||||||
});
|
});
|
||||||
|
|
||||||
var title = itemHelper.getDisplayName(item);
|
let title = itemHelper.getDisplayName(item);
|
||||||
if (item.SeriesName) {
|
if (item.SeriesName) {
|
||||||
title = item.SeriesName + ' - ' + title;
|
title = item.SeriesName + ' - ' + title;
|
||||||
}
|
}
|
||||||
|
@ -163,10 +173,10 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function onStartNowClick() {
|
function onStartNowClick() {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
var player = options.player;
|
const player = options.player;
|
||||||
|
|
||||||
this.hide();
|
this.hide();
|
||||||
|
|
||||||
|
@ -188,7 +198,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearHideAnimationEventListeners(instance, elem) {
|
function clearHideAnimationEventListeners(instance, elem) {
|
||||||
var fn = instance._onHideAnimationComplete;
|
const fn = instance._onHideAnimationComplete;
|
||||||
|
|
||||||
if (fn) {
|
if (fn) {
|
||||||
dom.removeEventListener(elem, transitionEndEventName, fn, {
|
dom.removeEventListener(elem, transitionEndEventName, fn, {
|
||||||
|
@ -198,8 +208,8 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHideAnimationComplete(e) {
|
function onHideAnimationComplete(e) {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
var elem = e.target;
|
const elem = e.target;
|
||||||
|
|
||||||
elem.classList.add('hide');
|
elem.classList.add('hide');
|
||||||
|
|
||||||
|
@ -208,14 +218,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideComingUpNext() {
|
function hideComingUpNext() {
|
||||||
var instance = this;
|
const instance = this;
|
||||||
clearCountdownTextTimeout(this);
|
clearCountdownTextTimeout(this);
|
||||||
|
|
||||||
if (!instance.options) {
|
if (!instance.options) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var elem = instance.options.parent;
|
const elem = instance.options.parent;
|
||||||
|
|
||||||
if (!elem) {
|
if (!elem) {
|
||||||
return;
|
return;
|
||||||
|
@ -232,7 +242,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
|
|
||||||
elem.classList.add('upNextDialog-hidden');
|
elem.classList.add('upNextDialog-hidden');
|
||||||
|
|
||||||
var fn = onHideAnimationComplete.bind(instance);
|
const fn = onHideAnimationComplete.bind(instance);
|
||||||
instance._onHideAnimationComplete = fn;
|
instance._onHideAnimationComplete = fn;
|
||||||
|
|
||||||
dom.addEventListener(elem, transitionEndEventName, fn, {
|
dom.addEventListener(elem, transitionEndEventName, fn, {
|
||||||
|
@ -241,12 +251,12 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimeRemainingMs(instance) {
|
function getTimeRemainingMs(instance) {
|
||||||
var options = instance.options;
|
const options = instance.options;
|
||||||
if (options) {
|
if (options) {
|
||||||
var runtimeTicks = playbackManager.duration(options.player);
|
const runtimeTicks = playbackManager.duration(options.player);
|
||||||
|
|
||||||
if (runtimeTicks) {
|
if (runtimeTicks) {
|
||||||
var timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
|
const timeRemainingTicks = runtimeTicks - playbackManager.currentTime(options.player);
|
||||||
|
|
||||||
return Math.round(timeRemainingTicks / 10000);
|
return Math.round(timeRemainingTicks / 10000);
|
||||||
}
|
}
|
||||||
|
@ -256,7 +266,7 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
function startComingUpNextHideTimer(instance) {
|
function startComingUpNextHideTimer(instance) {
|
||||||
var timeRemainingMs = getTimeRemainingMs(instance);
|
const timeRemainingMs = getTimeRemainingMs(instance);
|
||||||
|
|
||||||
if (timeRemainingMs <= 0) {
|
if (timeRemainingMs <= 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -268,14 +278,14 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
|
instance._countdownTextTimeout = setInterval(setNextVideoText.bind(instance), 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpNextDialog(options) {
|
class UpNextDialog {
|
||||||
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
init(this, options);
|
init(this, options);
|
||||||
}
|
}
|
||||||
|
show() {
|
||||||
UpNextDialog.prototype.show = function () {
|
const elem = this.options.parent;
|
||||||
var elem = this.options.parent;
|
|
||||||
|
|
||||||
clearHideAnimationEventListeners(this, elem);
|
clearHideAnimationEventListeners(this, elem);
|
||||||
|
|
||||||
|
@ -293,18 +303,18 @@ define(['dom', 'playbackManager', 'connectionManager', 'events', 'mediaInfo', 'l
|
||||||
}
|
}
|
||||||
|
|
||||||
startComingUpNextHideTimer(this);
|
startComingUpNextHideTimer(this);
|
||||||
};
|
}
|
||||||
|
hide() {
|
||||||
UpNextDialog.prototype.hide = function () {
|
|
||||||
hideComingUpNext.call(this);
|
hideComingUpNext.call(this);
|
||||||
};
|
}
|
||||||
|
destroy() {
|
||||||
UpNextDialog.prototype.destroy = function () {
|
|
||||||
hideComingUpNext.call(this);
|
hideComingUpNext.call(this);
|
||||||
|
|
||||||
this.options = null;
|
this.options = null;
|
||||||
this.itemType = null;
|
this.itemType = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return UpNextDialog;
|
export default UpNextDialog;
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -152,13 +152,13 @@ var Dashboard = {
|
||||||
processPluginConfigurationUpdateResult: function () {
|
processPluginConfigurationUpdateResult: function () {
|
||||||
require(['loading', 'toast'], function (loading, toast) {
|
require(['loading', 'toast'], function (loading, toast) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
toast(Globalize.translate('MessageSettingsSaved'));
|
toast.default(Globalize.translate('MessageSettingsSaved'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
processServerConfigurationUpdateResult: function (result) {
|
processServerConfigurationUpdateResult: function (result) {
|
||||||
require(['loading', 'toast'], function (loading, toast) {
|
require(['loading', 'toast'], function (loading, toast) {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
toast(Globalize.translate('MessageSettingsSaved'));
|
toast.default(Globalize.translate('MessageSettingsSaved'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
processErrorResponse: function (response) {
|
processErrorResponse: function (response) {
|
||||||
|
@ -180,7 +180,7 @@ var Dashboard = {
|
||||||
alert: function (options) {
|
alert: function (options) {
|
||||||
if (typeof options == 'string') {
|
if (typeof options == 'string') {
|
||||||
return void require(['toast'], function (toast) {
|
return void require(['toast'], function (toast) {
|
||||||
toast({
|
toast.default({
|
||||||
text: options
|
text: options
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue