From 8fb8dacdf1bca533c4021dc9adff35cfd98b9aea Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Sun, 26 Jul 2020 22:45:00 +0200 Subject: [PATCH 1/6] Migrate shell, serverNotifications to ES6 + remove searchtab --- package.json | 2 + src/assets/css/librarybrowser.css | 6 - src/components/guide/guide.js | 2 + src/components/itemsrefresher.js | 2 + src/components/notifications/notifications.js | 2 + src/components/playback/playbackmanager.js | 1 + .../recordingcreator/recordingfields.js | 2 + src/controllers/livetv/livetvsuggested.js | 6 - src/controllers/movies/moviesrecommended.js | 6 - src/controllers/music/musicrecommended.js | 6 - src/controllers/shows/tvrecommended.js | 7 - src/plugins/sessionPlayer/plugin.js | 2 + src/scripts/searchtab.js | 57 --- src/scripts/serverNotifications.js | 407 +++++++++--------- src/scripts/shell.js | 43 +- 15 files changed, 239 insertions(+), 312 deletions(-) delete mode 100644 src/scripts/searchtab.js diff --git a/package.json b/package.json index d1831b13ee..12ed63929a 100644 --- a/package.json +++ b/package.json @@ -250,9 +250,11 @@ "src/scripts/inputManager.js", "src/scripts/keyboardNavigation.js", "src/scripts/playlists.js", + "src/scripts/serverNotifications.js", "src/scripts/settings/appSettings.js", "src/scripts/settings/userSettings.js", "src/scripts/settings/webSettings.js", + "src/scripts/shell.js", "src/scripts/taskbutton.js", "src/scripts/themeLoader.js", "src/scripts/touchHelper.js" diff --git a/src/assets/css/librarybrowser.css b/src/assets/css/librarybrowser.css index 61815a590f..644dba9371 100644 --- a/src/assets/css/librarybrowser.css +++ b/src/assets/css/librarybrowser.css @@ -236,12 +236,6 @@ text-align: center; } -.layout-desktop .searchTabButton, -.layout-mobile .searchTabButton, -.layout-tv .headerSearchButton { - display: none !important; -} - .mainDrawer-scrollContainer { padding-bottom: 10vh; } diff --git a/src/components/guide/guide.js b/src/components/guide/guide.js index bb4a36497c..e18f053a5a 100644 --- a/src/components/guide/guide.js +++ b/src/components/guide/guide.js @@ -1,6 +1,8 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager', 'scrollHelper', 'serverNotifications', 'loading', 'datetime', 'focusManager', 'playbackManager', 'userSettings', 'imageLoader', 'events', 'layoutManager', 'itemShortcuts', 'dom', 'css!./guide.css', 'programStyles', 'material-icons', 'scrollStyles', 'emby-programcell', 'emby-button', 'paper-icon-button-light', 'emby-tabs', 'emby-scroller', 'flexStyles', 'webcomponents'], function (require, inputManager, browser, globalize, connectionManager, scrollHelper, serverNotifications, loading, datetime, focusManager, playbackManager, userSettings, imageLoader, events, layoutManager, itemShortcuts, dom) { 'use strict'; + serverNotifications = serverNotifications.default || serverNotifications; + function showViewSettings(instance) { require(['guide-settings-dialog'], function (guideSettingsDialog) { diff --git a/src/components/itemsrefresher.js b/src/components/itemsrefresher.js index 6da74eef80..f50813a7e0 100644 --- a/src/components/itemsrefresher.js +++ b/src/components/itemsrefresher.js @@ -1,6 +1,8 @@ define(['playbackManager', 'serverNotifications', 'events'], function (playbackManager, serverNotifications, events) { 'use strict'; + serverNotifications = serverNotifications.default || serverNotifications; + function onUserDataChanged(e, apiClient, userData) { var instance = this; diff --git a/src/components/notifications/notifications.js b/src/components/notifications/notifications.js index c8480e4f15..d12b14cc01 100644 --- a/src/components/notifications/notifications.js +++ b/src/components/notifications/notifications.js @@ -1,6 +1,8 @@ define(['serverNotifications', 'playbackManager', 'events', 'globalize', 'require'], function (serverNotifications, playbackManager, events, globalize, require) { 'use strict'; + serverNotifications = serverNotifications.default || serverNotifications; + function onOneDocumentClick() { document.removeEventListener('click', onOneDocumentClick); document.removeEventListener('keydown', onOneDocumentClick); diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index fe3ff11250..a6fc3942be 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -3455,6 +3455,7 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla if (apphost.supports('remotecontrol')) { require(['serverNotifications'], function (serverNotifications) { + serverNotifications = serverNotifications.default || serverNotifications; events.on(serverNotifications, 'ServerShuttingDown', self.setDefaultPlayerActive.bind(self)); events.on(serverNotifications, 'ServerRestarting', self.setDefaultPlayerActive.bind(self)); }); diff --git a/src/components/recordingcreator/recordingfields.js b/src/components/recordingcreator/recordingfields.js index 84348fcfbc..5fc0f24af4 100644 --- a/src/components/recordingcreator/recordingfields.js +++ b/src/components/recordingcreator/recordingfields.js @@ -1,6 +1,8 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) { 'use strict'; + serverNotifications = serverNotifications.default || serverNotifications; + function loadData(parent, program, apiClient) { if (program.IsSeries) { parent.querySelector('.recordSeriesContainer').classList.remove('hide'); diff --git a/src/controllers/livetv/livetvsuggested.js b/src/controllers/livetv/livetvsuggested.js index 036eee9fc6..16cee8a496 100644 --- a/src/controllers/livetv/livetvsuggested.js +++ b/src/controllers/livetv/livetvsuggested.js @@ -167,9 +167,6 @@ define(['layoutManager', 'userSettings', 'inputManager', 'loading', 'globalize', name: globalize.translate('HeaderSchedule') }, { name: globalize.translate('TabSeries') - }, { - name: globalize.translate('ButtonSearch'), - cssClass: 'searchTabButton' }]; } @@ -253,9 +250,6 @@ define(['layoutManager', 'userSettings', 'inputManager', 'loading', 'globalize', case 5: depends.push('controllers/livetv/livetvseriestimers'); break; - - case 6: - depends.push('scripts/searchtab'); } require(depends, function (controllerFactory) { diff --git a/src/controllers/movies/moviesrecommended.js b/src/controllers/movies/moviesrecommended.js index d948c1cef7..11aa6e3fec 100644 --- a/src/controllers/movies/moviesrecommended.js +++ b/src/controllers/movies/moviesrecommended.js @@ -222,9 +222,6 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu' name: globalize.translate('TabCollections') }, { name: globalize.translate('TabGenres') - }, { - name: globalize.translate('ButtonSearch'), - cssClass: 'searchTabButton' }]; } @@ -291,9 +288,6 @@ define(['events', 'layoutManager', 'inputManager', 'userSettings', 'libraryMenu' case 5: depends.push('controllers/movies/moviegenres'); break; - - case 6: - depends.push('scripts/searchtab'); } require(depends, function (controllerFactory) { diff --git a/src/controllers/music/musicrecommended.js b/src/controllers/music/musicrecommended.js index 3f025799f6..1409d6de3f 100644 --- a/src/controllers/music/musicrecommended.js +++ b/src/controllers/music/musicrecommended.js @@ -180,9 +180,6 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', ' name: globalize.translate('TabSongs') }, { name: globalize.translate('TabGenres') - }, { - name: globalize.translate('ButtonSearch'), - cssClass: 'searchTabButton' }]; } @@ -283,9 +280,6 @@ define(['browser', 'layoutManager', 'userSettings', 'inputManager', 'loading', ' case 6: depends.push('controllers/music/musicgenres'); break; - - case 7: - depends.push('scripts/searchtab'); } require(depends, function (controllerFactory) { diff --git a/src/controllers/shows/tvrecommended.js b/src/controllers/shows/tvrecommended.js index 7edd2ab501..25459b7b6a 100644 --- a/src/controllers/shows/tvrecommended.js +++ b/src/controllers/shows/tvrecommended.js @@ -30,9 +30,6 @@ import 'emby-button'; name: globalize.translate('TabNetworks') }, { name: globalize.translate('TabEpisodes') - }, { - name: globalize.translate('ButtonSearch'), - cssClass: 'searchTabButton' }]; } @@ -217,10 +214,6 @@ import 'emby-button'; case 6: depends = 'controllers/shows/episodes'; break; - - case 7: - depends = 'scripts/searchtab'; - break; } import(depends).then(({default: controllerFactory}) => { diff --git a/src/plugins/sessionPlayer/plugin.js b/src/plugins/sessionPlayer/plugin.js index 084aa027cf..a8cb1e3579 100644 --- a/src/plugins/sessionPlayer/plugin.js +++ b/src/plugins/sessionPlayer/plugin.js @@ -1,6 +1,8 @@ define(['playbackManager', 'events', 'serverNotifications', 'connectionManager'], function (playbackManager, events, serverNotifications, connectionManager) { 'use strict'; + serverNotifications = serverNotifications.default || serverNotifications; + function getActivePlayerId() { var info = playbackManager.getPlayerInfo(); return info ? info.id : null; diff --git a/src/scripts/searchtab.js b/src/scripts/searchtab.js deleted file mode 100644 index e012b8a4b2..0000000000 --- a/src/scripts/searchtab.js +++ /dev/null @@ -1,57 +0,0 @@ -define(['searchFields', 'searchResults', 'events'], function (SearchFields, SearchResults, events) { - 'use strict'; - - SearchFields = SearchFields.default || SearchFields; - SearchResults = SearchResults.default || SearchResults; - - function init(instance, tabContent, options) { - tabContent.innerHTML = '
'; - instance.searchFields = new SearchFields({ - element: tabContent.querySelector('.searchFields') - }); - instance.searchResults = new SearchResults({ - element: tabContent.querySelector('.searchResults'), - serverId: ApiClient.serverId(), - parentId: options.parentId, - collectionType: options.collectionType - }); - events.on(instance.searchFields, 'search', function (e, value) { - instance.searchResults.search(value); - }); - } - - function SearchTab(view, tabContent, options) { - var self = this; - options = options || {}; - init(this, tabContent, options); - - self.preRender = function () {}; - - self.renderTab = function () { - var searchFields = this.searchFields; - - if (searchFields) { - searchFields.focus(); - } - }; - } - - SearchTab.prototype.destroy = function () { - var searchFields = this.searchFields; - - if (searchFields) { - searchFields.destroy(); - } - - this.searchFields = null; - var searchResults = this.searchResults; - - if (searchResults) { - searchResults.destroy(); - } - - this.searchResults = null; - }; - - return SearchTab; -}); diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index 331a75329c..83af40c4e6 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -1,211 +1,216 @@ -define(['connectionManager', 'playbackManager', 'syncPlayManager', 'events', 'inputManager', 'focusManager', 'appRouter'], function (connectionManager, playbackManager, syncPlayManager, events, inputManager, focusManager, appRouter) { - 'use strict'; +import connectionManager from 'connectionManager'; +import playbackManager from 'playbackManager'; +import syncPlayManager from 'syncPlayManager'; +import events from 'events'; +import inputManager from 'inputManager'; +import focusManager from 'focusManager'; +import appRouter from 'appRouter'; - var serverNotifications = {}; +const serverNotifications = {}; - function notifyApp() { - inputManager.notify(); - } +function notifyApp() { + inputManager.notify(); +} - function displayMessage(cmd) { - var args = cmd.Arguments; - if (args.TimeoutMs) { - require(['toast'], function (toast) { - toast({ title: args.Header, text: args.Text }); - }); - } else { - require(['alert'], function (alert) { - alert.default({ title: args.Header, text: args.Text }); - }); - } - } - - function displayContent(cmd, apiClient) { - if (!playbackManager.isPlayingLocally(['Video', 'Book'])) { - appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId()); - } - } - - function playTrailers(apiClient, itemId) { - apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) { - playbackManager.playTrailers(item); +function displayMessage(cmd) { + const args = cmd.Arguments; + if (args.TimeoutMs) { + require(['toast'], function (toast) { + toast({ title: args.Header, text: args.Text }); + }); + } else { + require(['alert'], function (alert) { + alert.default({ title: args.Header, text: args.Text }); }); } +} - function processGeneralCommand(cmd, apiClient) { - console.debug('Received command: ' + cmd.Name); - switch (cmd.Name) { - case 'Select': - inputManager.handleCommand('select'); - return; - case 'Back': - inputManager.handleCommand('back'); - return; - case 'MoveUp': - inputManager.handleCommand('up'); - return; - case 'MoveDown': - inputManager.handleCommand('down'); - return; - case 'MoveLeft': - inputManager.handleCommand('left'); - return; - case 'MoveRight': - inputManager.handleCommand('right'); - return; - case 'PageUp': - inputManager.handleCommand('pageup'); - return; - case 'PageDown': - inputManager.handleCommand('pagedown'); - return; - case 'PlayTrailers': - playTrailers(apiClient, cmd.Arguments.ItemId); - break; - case 'SetRepeatMode': - playbackManager.setRepeatMode(cmd.Arguments.RepeatMode); - break; - case 'SetShuffleQueue': - playbackManager.setQueueShuffleMode(cmd.Arguments.ShuffleMode); - break; - case 'VolumeUp': - inputManager.handleCommand('volumeup'); - return; - case 'VolumeDown': - inputManager.handleCommand('volumedown'); - return; - case 'ChannelUp': - inputManager.handleCommand('channelup'); - return; - case 'ChannelDown': - inputManager.handleCommand('channeldown'); - return; - case 'Mute': - inputManager.handleCommand('mute'); - return; - case 'Unmute': - inputManager.handleCommand('unmute'); - return; - case 'ToggleMute': - inputManager.handleCommand('togglemute'); - return; - case 'SetVolume': - notifyApp(); - playbackManager.setVolume(cmd.Arguments.Volume); - break; - case 'SetAudioStreamIndex': - notifyApp(); - playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index)); - break; - case 'SetSubtitleStreamIndex': - notifyApp(); - playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index)); - break; - case 'ToggleFullscreen': - inputManager.handleCommand('togglefullscreen'); - return; - case 'GoHome': - inputManager.handleCommand('home'); - return; - case 'GoToSettings': - inputManager.handleCommand('settings'); - return; - case 'DisplayContent': - displayContent(cmd, apiClient); - break; - case 'GoToSearch': - inputManager.handleCommand('search'); - return; - case 'DisplayMessage': - displayMessage(cmd); - break; - case 'ToggleOsd': - // todo - break; - case 'ToggleContextMenu': - // todo - break; - case 'TakeScreenShot': - // todo - break; - case 'SendKey': - // todo - break; - case 'SendString': - // todo - focusManager.sendText(cmd.Arguments.String); - break; - default: - console.debug('processGeneralCommand does not recognize: ' + cmd.Name); - break; - } - - notifyApp(); +function displayContent(cmd, apiClient) { + if (!playbackManager.isPlayingLocally(['Video', 'Book'])) { + appRouter.showItem(cmd.Arguments.ItemId, apiClient.serverId()); } +} - function onMessageReceived(e, msg) { - var apiClient = this; - if (msg.MessageType === 'Play') { - notifyApp(); - var serverId = apiClient.serverInfo().Id; - if (msg.Data.PlayCommand === 'PlayNext') { - playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId }); - } else if (msg.Data.PlayCommand === 'PlayLast') { - playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId }); - } else { - playbackManager.play({ - ids: msg.Data.ItemIds, - startPositionTicks: msg.Data.StartPositionTicks, - mediaSourceId: msg.Data.MediaSourceId, - audioStreamIndex: msg.Data.AudioStreamIndex, - subtitleStreamIndex: msg.Data.SubtitleStreamIndex, - startIndex: msg.Data.StartIndex, - serverId: serverId - }); - } - } else if (msg.MessageType === 'Playstate') { - if (msg.Data.Command === 'Stop') { - inputManager.handleCommand('stop'); - } else if (msg.Data.Command === 'Pause') { - inputManager.handleCommand('pause'); - } else if (msg.Data.Command === 'Unpause') { - inputManager.handleCommand('play'); - } else if (msg.Data.Command === 'PlayPause') { - inputManager.handleCommand('playpause'); - } else if (msg.Data.Command === 'Seek') { - playbackManager.seek(msg.Data.SeekPositionTicks); - } else if (msg.Data.Command === 'NextTrack') { - inputManager.handleCommand('next'); - } else if (msg.Data.Command === 'PreviousTrack') { - inputManager.handleCommand('previous'); - } else { - notifyApp(); - } - } else if (msg.MessageType === 'GeneralCommand') { - var cmd = msg.Data; - processGeneralCommand(cmd, apiClient); - } else if (msg.MessageType === 'UserDataChanged') { - if (msg.Data.UserId === apiClient.getCurrentUserId()) { - for (var i = 0, length = msg.Data.UserDataList.length; i < length; i++) { - events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]); - } - } - } else if (msg.MessageType === 'SyncPlayCommand') { - syncPlayManager.processCommand(msg.Data, apiClient); - } else if (msg.MessageType === 'SyncPlayGroupUpdate') { - syncPlayManager.processGroupUpdate(msg.Data, apiClient); - } else { - events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]); - } - } - function bindEvents(apiClient) { - events.off(apiClient, 'message', onMessageReceived); - events.on(apiClient, 'message', onMessageReceived); - } - - connectionManager.getApiClients().forEach(bindEvents); - events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) { - bindEvents(newApiClient); +function playTrailers(apiClient, itemId) { + apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) { + playbackManager.playTrailers(item); }); - return serverNotifications; +} + +function processGeneralCommand(cmd, apiClient) { + console.debug('Received command: ' + cmd.Name); + switch (cmd.Name) { + case 'Select': + inputManager.handleCommand('select'); + return; + case 'Back': + inputManager.handleCommand('back'); + return; + case 'MoveUp': + inputManager.handleCommand('up'); + return; + case 'MoveDown': + inputManager.handleCommand('down'); + return; + case 'MoveLeft': + inputManager.handleCommand('left'); + return; + case 'MoveRight': + inputManager.handleCommand('right'); + return; + case 'PageUp': + inputManager.handleCommand('pageup'); + return; + case 'PageDown': + inputManager.handleCommand('pagedown'); + return; + case 'PlayTrailers': + playTrailers(apiClient, cmd.Arguments.ItemId); + break; + case 'SetRepeatMode': + playbackManager.setRepeatMode(cmd.Arguments.RepeatMode); + break; + case 'SetShuffleQueue': + playbackManager.setQueueShuffleMode(cmd.Arguments.ShuffleMode); + break; + case 'VolumeUp': + inputManager.handleCommand('volumeup'); + return; + case 'VolumeDown': + inputManager.handleCommand('volumedown'); + return; + case 'ChannelUp': + inputManager.handleCommand('channelup'); + return; + case 'ChannelDown': + inputManager.handleCommand('channeldown'); + return; + case 'Mute': + inputManager.handleCommand('mute'); + return; + case 'Unmute': + inputManager.handleCommand('unmute'); + return; + case 'ToggleMute': + inputManager.handleCommand('togglemute'); + return; + case 'SetVolume': + notifyApp(); + playbackManager.setVolume(cmd.Arguments.Volume); + break; + case 'SetAudioStreamIndex': + notifyApp(); + playbackManager.setAudioStreamIndex(parseInt(cmd.Arguments.Index)); + break; + case 'SetSubtitleStreamIndex': + notifyApp(); + playbackManager.setSubtitleStreamIndex(parseInt(cmd.Arguments.Index)); + break; + case 'ToggleFullscreen': + inputManager.handleCommand('togglefullscreen'); + return; + case 'GoHome': + inputManager.handleCommand('home'); + return; + case 'GoToSettings': + inputManager.handleCommand('settings'); + return; + case 'DisplayContent': + displayContent(cmd, apiClient); + break; + case 'GoToSearch': + inputManager.handleCommand('search'); + return; + case 'DisplayMessage': + displayMessage(cmd); + break; + case 'ToggleOsd': + // todo + break; + case 'ToggleContextMenu': + // todo + break; + case 'TakeScreenShot': + // todo + break; + case 'SendKey': + // todo + break; + case 'SendString': + // todo + focusManager.sendText(cmd.Arguments.String); + break; + default: + console.debug('processGeneralCommand does not recognize: ' + cmd.Name); + break; + } + + notifyApp(); +} + +function onMessageReceived(e, msg) { + const apiClient = this; + if (msg.MessageType === 'Play') { + notifyApp(); + const serverId = apiClient.serverInfo().Id; + if (msg.Data.PlayCommand === 'PlayNext') { + playbackManager.queueNext({ ids: msg.Data.ItemIds, serverId: serverId }); + } else if (msg.Data.PlayCommand === 'PlayLast') { + playbackManager.queue({ ids: msg.Data.ItemIds, serverId: serverId }); + } else { + playbackManager.play({ + ids: msg.Data.ItemIds, + startPositionTicks: msg.Data.StartPositionTicks, + mediaSourceId: msg.Data.MediaSourceId, + audioStreamIndex: msg.Data.AudioStreamIndex, + subtitleStreamIndex: msg.Data.SubtitleStreamIndex, + startIndex: msg.Data.StartIndex, + serverId: serverId + }); + } + } else if (msg.MessageType === 'Playstate') { + if (msg.Data.Command === 'Stop') { + inputManager.handleCommand('stop'); + } else if (msg.Data.Command === 'Pause') { + inputManager.handleCommand('pause'); + } else if (msg.Data.Command === 'Unpause') { + inputManager.handleCommand('play'); + } else if (msg.Data.Command === 'PlayPause') { + inputManager.handleCommand('playpause'); + } else if (msg.Data.Command === 'Seek') { + playbackManager.seek(msg.Data.SeekPositionTicks); + } else if (msg.Data.Command === 'NextTrack') { + inputManager.handleCommand('next'); + } else if (msg.Data.Command === 'PreviousTrack') { + inputManager.handleCommand('previous'); + } else { + notifyApp(); + } + } else if (msg.MessageType === 'GeneralCommand') { + const cmd = msg.Data; + processGeneralCommand(cmd, apiClient); + } else if (msg.MessageType === 'UserDataChanged') { + if (msg.Data.UserId === apiClient.getCurrentUserId()) { + for (let i = 0, length = msg.Data.UserDataList.length; i < length; i++) { + events.trigger(serverNotifications, 'UserDataChanged', [apiClient, msg.Data.UserDataList[i]]); + } + } + } else if (msg.MessageType === 'SyncPlayCommand') { + syncPlayManager.processCommand(msg.Data, apiClient); + } else if (msg.MessageType === 'SyncPlayGroupUpdate') { + syncPlayManager.processGroupUpdate(msg.Data, apiClient); + } else { + events.trigger(serverNotifications, msg.MessageType, [apiClient, msg.Data]); + } +} +function bindEvents(apiClient) { + events.off(apiClient, 'message', onMessageReceived); + events.on(apiClient, 'message', onMessageReceived); +} + +connectionManager.getApiClients().forEach(bindEvents); +events.on(connectionManager, 'apiclientcreated', function (e, newApiClient) { + bindEvents(newApiClient); }); + +export default serverNotifications; diff --git a/src/scripts/shell.js b/src/scripts/shell.js index 4f1aa0c8de..390ddae82c 100644 --- a/src/scripts/shell.js +++ b/src/scripts/shell.js @@ -1,24 +1,21 @@ -define([], function () { - 'use strict'; - - return { - openUrl: function (url, target) { - if (window.NativeShell) { - window.NativeShell.openUrl(url, target); - } else { - window.open(url, target || '_blank'); - } - - }, - enableFullscreen: function () { - if (window.NativeShell) { - window.NativeShell.enableFullscreen(); - } - }, - disableFullscreen: function () { - if (window.NativeShell) { - window.NativeShell.disableFullscreen(); - } +// TODO: This seems like a good candidate for deprecation +export default { + openUrl: function (url, target) { + if (window.NativeShell) { + window.NativeShell.openUrl(url, target); + } else { + window.open(url, target || '_blank'); } - }; -}); + + }, + enableFullscreen: function () { + if (window.NativeShell) { + window.NativeShell.enableFullscreen(); + } + }, + disableFullscreen: function () { + if (window.NativeShell) { + window.NativeShell.disableFullscreen(); + } + } +}; From 4fce7f8be5076cb8cc05546c6ef0b33ebee6f14e Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Sun, 26 Jul 2020 22:52:55 +0200 Subject: [PATCH 2/6] Migrate scrollHelper to ES6 --- package.json | 1 + .../collectionEditor/collectionEditor.js | 2 +- src/components/dialogHelper/dialogHelper.js | 2 +- src/components/filtermenu/filtermenu.js | 1 + src/components/guide/guide-settings.js | 2 + src/components/guide/guide.js | 2 + .../imageDownloader/imageDownloader.js | 2 + src/components/imageeditor/imageeditor.js | 2 + .../playlisteditor/playlisteditor.js | 2 +- .../recordingcreator/recordingcreator.js | 2 + .../recordingcreator/recordingeditor.js | 2 + .../recordingcreator/seriesrecordingeditor.js | 2 + src/components/refreshdialog/refreshdialog.js | 1 + src/components/sortmenu/sortmenu.js | 1 + .../subtitleeditor/subtitleeditor.js | 1 + src/components/tunerPicker.js | 2 + src/components/viewSettings/viewSettings.js | 1 + src/scripts/scrollHelper.js | 250 +++++++++--------- 18 files changed, 150 insertions(+), 128 deletions(-) diff --git a/package.json b/package.json index 12ed63929a..7a80b89140 100644 --- a/package.json +++ b/package.json @@ -250,6 +250,7 @@ "src/scripts/inputManager.js", "src/scripts/keyboardNavigation.js", "src/scripts/playlists.js", + "src/scripts/scrollHelper.js", "src/scripts/serverNotifications.js", "src/scripts/settings/appSettings.js", "src/scripts/settings/userSettings.js", diff --git a/src/components/collectionEditor/collectionEditor.js b/src/components/collectionEditor/collectionEditor.js index 18cc0d311f..67daad9f2e 100644 --- a/src/components/collectionEditor/collectionEditor.js +++ b/src/components/collectionEditor/collectionEditor.js @@ -212,7 +212,7 @@ import 'flexStyles'; } function centerFocus(elem, horiz, on) { - import('scrollHelper').then(scrollHelper => { + import('scrollHelper').then((scrollHelper) => { const fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index ca7c94a416..af1a278cb4 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -376,7 +376,7 @@ import 'scrollStyles'; } function centerFocus(elem, horiz, on) { - import('scrollHelper').then(scrollHelper => { + import('scrollHelper').then((scrollHelper) => { const fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/filtermenu/filtermenu.js b/src/components/filtermenu/filtermenu.js index 936e2b0407..075af143d2 100644 --- a/src/components/filtermenu/filtermenu.js +++ b/src/components/filtermenu/filtermenu.js @@ -194,6 +194,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'apphost', function centerFocus(elem, horiz, on) { require(['scrollHelper'], function (scrollHelper) { + scrollHelper = scrollHelper.default || scrollHelper; var fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/guide/guide-settings.js b/src/components/guide/guide-settings.js index 77a3637251..aded7ac5dd 100644 --- a/src/components/guide/guide-settings.js +++ b/src/components/guide/guide-settings.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'globalize', 'userSettings', 'layoutManager', 'connectionManager', 'require', 'loading', 'scrollHelper', 'emby-checkbox', 'emby-radio', 'css!./../formdialog', 'material-icons'], function (dialogHelper, globalize, userSettings, layoutManager, connectionManager, require, loading, scrollHelper) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + function saveCategories(context, options) { var categories = []; diff --git a/src/components/guide/guide.js b/src/components/guide/guide.js index e18f053a5a..0d3c721e2d 100644 --- a/src/components/guide/guide.js +++ b/src/components/guide/guide.js @@ -1,6 +1,8 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager', 'scrollHelper', 'serverNotifications', 'loading', 'datetime', 'focusManager', 'playbackManager', 'userSettings', 'imageLoader', 'events', 'layoutManager', 'itemShortcuts', 'dom', 'css!./guide.css', 'programStyles', 'material-icons', 'scrollStyles', 'emby-programcell', 'emby-button', 'paper-icon-button-light', 'emby-tabs', 'emby-scroller', 'flexStyles', 'webcomponents'], function (require, inputManager, browser, globalize, connectionManager, scrollHelper, serverNotifications, loading, datetime, focusManager, playbackManager, userSettings, imageLoader, events, layoutManager, itemShortcuts, dom) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + serverNotifications = serverNotifications.default || serverNotifications; function showViewSettings(instance) { diff --git a/src/components/imageDownloader/imageDownloader.js b/src/components/imageDownloader/imageDownloader.js index fbe98c532f..9ad65dd157 100644 --- a/src/components/imageDownloader/imageDownloader.js +++ b/src/components/imageDownloader/imageDownloader.js @@ -1,6 +1,8 @@ define(['dom', 'loading', 'apphost', 'dialogHelper', 'connectionManager', 'imageLoader', 'browser', 'layoutManager', 'scrollHelper', 'globalize', 'require', 'emby-checkbox', 'paper-icon-button-light', 'emby-button', 'formDialogStyle', 'cardStyle'], function (dom, loading, appHost, dialogHelper, connectionManager, imageLoader, browser, layoutManager, scrollHelper, globalize, require) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var enableFocusTransform = !browser.slow && !browser.edge; var currentItemId; diff --git a/src/components/imageeditor/imageeditor.js b/src/components/imageeditor/imageeditor.js index 0a873fa4c7..766304f9aa 100644 --- a/src/components/imageeditor/imageeditor.js +++ b/src/components/imageeditor/imageeditor.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'connectionManager', 'loading', 'dom', 'layoutManager', 'focusManager', 'globalize', 'scrollHelper', 'imageLoader', 'require', 'browser', 'apphost', 'cardStyle', 'formDialogStyle', 'emby-button', 'paper-icon-button-light', 'css!./imageeditor'], function (dialogHelper, connectionManager, loading, dom, layoutManager, focusManager, globalize, scrollHelper, imageLoader, require, browser, appHost) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var enableFocusTransform = !browser.slow && !browser.edge; var currentItem; diff --git a/src/components/playlisteditor/playlisteditor.js b/src/components/playlisteditor/playlisteditor.js index 7b1e915e1f..78f0cf3dec 100644 --- a/src/components/playlisteditor/playlisteditor.js +++ b/src/components/playlisteditor/playlisteditor.js @@ -210,7 +210,7 @@ import 'emby-button'; } function centerFocus(elem, horiz, on) { - import('scrollHelper').then(scrollHelper => { + import('scrollHelper').then((scrollHelper) => { const fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/recordingcreator/recordingcreator.js b/src/components/recordingcreator/recordingcreator.js index d18d5fcb6c..3b7cbe49aa 100644 --- a/src/components/recordingcreator/recordingcreator.js +++ b/src/components/recordingcreator/recordingcreator.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'datetime', 'imageLoader', 'recordingFields', 'events', 'emby-checkbox', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, datetime, imageLoader, recordingFields, events) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var currentDialog; var closeAction; var currentRecordingFields; diff --git a/src/components/recordingcreator/recordingeditor.js b/src/components/recordingcreator/recordingeditor.js index c3f40fcddb..2fde735404 100644 --- a/src/components/recordingcreator/recordingeditor.js +++ b/src/components/recordingcreator/recordingeditor.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var currentDialog; var recordingDeleted = false; var currentItemId; diff --git a/src/components/recordingcreator/seriesrecordingeditor.js b/src/components/recordingcreator/seriesrecordingeditor.js index a101ce53ec..053dd1a12c 100644 --- a/src/components/recordingcreator/seriesrecordingeditor.js +++ b/src/components/recordingcreator/seriesrecordingeditor.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'datetime', 'scrollStyles', 'emby-button', 'emby-checkbox', 'emby-input', 'emby-select', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader, datetime) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var currentDialog; var recordingUpdated = false; var recordingDeleted = false; diff --git a/src/components/refreshdialog/refreshdialog.js b/src/components/refreshdialog/refreshdialog.js index 3edb725c4a..593cc0dc2d 100644 --- a/src/components/refreshdialog/refreshdialog.js +++ b/src/components/refreshdialog/refreshdialog.js @@ -42,6 +42,7 @@ define(['dom', 'shell', 'dialogHelper', 'loading', 'layoutManager', 'connectionM function centerFocus(elem, horiz, on) { require(['scrollHelper'], function (scrollHelper) { + scrollHelper = scrollHelper.default || scrollHelper; var fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/sortmenu/sortmenu.js b/src/components/sortmenu/sortmenu.js index dbf7ef1a7f..abe55a6092 100644 --- a/src/components/sortmenu/sortmenu.js +++ b/src/components/sortmenu/sortmenu.js @@ -17,6 +17,7 @@ define(['require', 'dom', 'focusManager', 'dialogHelper', 'loading', 'layoutMana function centerFocus(elem, horiz, on) { require(['scrollHelper'], function (scrollHelper) { + scrollHelper = scrollHelper.default || scrollHelper; var fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/subtitleeditor/subtitleeditor.js b/src/components/subtitleeditor/subtitleeditor.js index 9c0992c53c..4c33252574 100644 --- a/src/components/subtitleeditor/subtitleeditor.js +++ b/src/components/subtitleeditor/subtitleeditor.js @@ -420,6 +420,7 @@ define(['dialogHelper', 'require', 'layoutManager', 'globalize', 'userSettings', function centerFocus(elem, horiz, on) { require(['scrollHelper'], function (scrollHelper) { + scrollHelper = scrollHelper.default || scrollHelper; var fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/components/tunerPicker.js b/src/components/tunerPicker.js index e7c92851a4..f064f95152 100644 --- a/src/components/tunerPicker.js +++ b/src/components/tunerPicker.js @@ -1,6 +1,8 @@ define(['dialogHelper', 'dom', 'layoutManager', 'connectionManager', 'globalize', 'loading', 'browser', 'focusManager', 'scrollHelper', 'material-icons', 'formDialogStyle', 'emby-button', 'emby-itemscontainer', 'cardStyle'], function (dialogHelper, dom, layoutManager, connectionManager, globalize, loading, browser, focusManager, scrollHelper) { 'use strict'; + scrollHelper = scrollHelper.default || scrollHelper; + var enableFocusTransform = !browser.slow && !browser.edge; function getEditorHtml() { diff --git a/src/components/viewSettings/viewSettings.js b/src/components/viewSettings/viewSettings.js index 28a9854c34..198c0a541c 100644 --- a/src/components/viewSettings/viewSettings.js +++ b/src/components/viewSettings/viewSettings.js @@ -33,6 +33,7 @@ define(['require', 'dialogHelper', 'loading', 'apphost', 'layoutManager', 'conne function centerFocus(elem, horiz, on) { require(['scrollHelper'], function (scrollHelper) { + scrollHelper = scrollHelper.default || scrollHelper; var fn = on ? 'on' : 'off'; scrollHelper.centerFocus[fn](elem, horiz); }); diff --git a/src/scripts/scrollHelper.js b/src/scripts/scrollHelper.js index 1a36594026..020888a2e3 100644 --- a/src/scripts/scrollHelper.js +++ b/src/scripts/scrollHelper.js @@ -1,137 +1,137 @@ -define(['focusManager', 'dom', 'scrollStyles'], function (focusManager, dom) { - 'use strict'; +import focusManager from 'focusManager'; +import dom from 'dom'; +import 'scrollStyles'; - function getBoundingClientRect(elem) { +function getBoundingClientRect(elem) { - // Support: BlackBerry 5, iOS 3 (original iPhone) - // If we don't have gBCR, just use 0,0 rather than error - if (elem.getBoundingClientRect) { - return elem.getBoundingClientRect(); - } else { - return { top: 0, left: 0 }; - } + // Support: BlackBerry 5, iOS 3 (original iPhone) + // If we don't have gBCR, just use 0,0 rather than error + if (elem.getBoundingClientRect) { + return elem.getBoundingClientRect(); + } else { + return { top: 0, left: 0 }; + } +} + +export function getPosition(scrollContainer, item, horizontal) { + + const slideeOffset = getBoundingClientRect(scrollContainer); + const itemOffset = getBoundingClientRect(item); + + let offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top; + let size = horizontal ? itemOffset.width : itemOffset.height; + if (!size && size !== 0) { + size = item[horizontal ? 'offsetWidth' : 'offsetHeight']; } - function getPosition(scrollContainer, item, horizontal) { + const currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop; - var slideeOffset = getBoundingClientRect(scrollContainer); - var itemOffset = getBoundingClientRect(item); + offset += currentStart; - var offset = horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top; - var size = horizontal ? itemOffset.width : itemOffset.height; - if (!size && size !== 0) { - size = item[horizontal ? 'offsetWidth' : 'offsetHeight']; - } + const frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight; - var currentStart = horizontal ? scrollContainer.scrollLeft : scrollContainer.scrollTop; + const currentEnd = currentStart + frameSize; - offset += currentStart; - - var frameSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight; - - var currentEnd = currentStart + frameSize; - - var isVisible = offset >= currentStart && (offset + size) <= currentEnd; - - return { - start: offset, - center: (offset - (frameSize / 2) + (size / 2)), - end: offset - frameSize + size, - size: size, - isVisible: isVisible - }; - } - - function toCenter(container, elem, horizontal, skipWhenVisible) { - var pos = getPosition(container, elem, horizontal); - - if (skipWhenVisible && pos.isVisible) { - return; - } - - if (container.scrollTo) { - if (horizontal) { - container.scrollTo(pos.center, 0); - } else { - container.scrollTo(0, pos.center); - } - } else { - if (horizontal) { - container.scrollLeft = Math.round(pos.center); - } else { - container.scrollTop = Math.round(pos.center); - } - } - } - - function toStart(container, elem, horizontal, skipWhenVisible) { - var pos = getPosition(container, elem, horizontal); - - if (skipWhenVisible && pos.isVisible) { - return; - } - - if (container.scrollTo) { - if (horizontal) { - container.scrollTo(pos.start, 0); - } else { - container.scrollTo(0, pos.start); - } - } else { - if (horizontal) { - container.scrollLeft = Math.round(pos.start); - } else { - container.scrollTop = Math.round(pos.start); - } - } - } - - function centerOnFocus(e, scrollSlider, horizontal) { - var focused = focusManager.focusableParent(e.target); - - if (focused) { - toCenter(scrollSlider, focused, horizontal); - } - } - - function centerOnFocusHorizontal(e) { - centerOnFocus(e, this, true); - } - function centerOnFocusVertical(e) { - centerOnFocus(e, this, false); - } + const isVisible = offset >= currentStart && (offset + size) <= currentEnd; return { - getPosition: getPosition, - centerFocus: { - on: function (element, horizontal) { - if (horizontal) { - dom.addEventListener(element, 'focus', centerOnFocusHorizontal, { - capture: true, - passive: true - }); - } else { - dom.addEventListener(element, 'focus', centerOnFocusVertical, { - capture: true, - passive: true - }); - } - }, - off: function (element, horizontal) { - if (horizontal) { - dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, { - capture: true, - passive: true - }); - } else { - dom.removeEventListener(element, 'focus', centerOnFocusVertical, { - capture: true, - passive: true - }); - } + start: offset, + center: (offset - (frameSize / 2) + (size / 2)), + end: offset - frameSize + size, + size: size, + isVisible: isVisible + }; +} + +export function toCenter(container, elem, horizontal, skipWhenVisible) { + const pos = getPosition(container, elem, horizontal); + + if (skipWhenVisible && pos.isVisible) { + return; + } + + if (container.scrollTo) { + if (horizontal) { + container.scrollTo(pos.center, 0); + } else { + container.scrollTo(0, pos.center); + } + } else { + if (horizontal) { + container.scrollLeft = Math.round(pos.center); + } else { + container.scrollTop = Math.round(pos.center); + } + } +} + +export function toStart(container, elem, horizontal, skipWhenVisible) { + const pos = getPosition(container, elem, horizontal); + + if (skipWhenVisible && pos.isVisible) { + return; + } + + if (container.scrollTo) { + if (horizontal) { + container.scrollTo(pos.start, 0); + } else { + container.scrollTo(0, pos.start); + } + } else { + if (horizontal) { + container.scrollLeft = Math.round(pos.start); + } else { + container.scrollTop = Math.round(pos.start); + } + } +} + +function centerOnFocus(e, scrollSlider, horizontal) { + const focused = focusManager.focusableParent(e.target); + + if (focused) { + toCenter(scrollSlider, focused, horizontal); + } +} + +function centerOnFocusHorizontal(e) { + centerOnFocus(e, this, true); +} +function centerOnFocusVertical(e) { + centerOnFocus(e, this, false); +} + +export default { + getPosition: getPosition, + centerFocus: { + on: function (element, horizontal) { + if (horizontal) { + dom.addEventListener(element, 'focus', centerOnFocusHorizontal, { + capture: true, + passive: true + }); + } else { + dom.addEventListener(element, 'focus', centerOnFocusVertical, { + capture: true, + passive: true + }); } }, - toCenter: toCenter, - toStart: toStart - }; -}); + off: function (element, horizontal) { + if (horizontal) { + dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, { + capture: true, + passive: true + }); + } else { + dom.removeEventListener(element, 'focus', centerOnFocusVertical, { + capture: true, + passive: true + }); + } + } + }, + toCenter: toCenter, + toStart: toStart +}; From 161488616f5dc789f54c8965f955a08d5402001a Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Thu, 6 Aug 2020 22:28:52 +0200 Subject: [PATCH 3/6] Fix suggestions --- src/scripts/scrollHelper.js | 59 +++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/scripts/scrollHelper.js b/src/scripts/scrollHelper.js index 020888a2e3..1ce30768af 100644 --- a/src/scripts/scrollHelper.js +++ b/src/scripts/scrollHelper.js @@ -98,40 +98,43 @@ function centerOnFocus(e, scrollSlider, horizontal) { function centerOnFocusHorizontal(e) { centerOnFocus(e, this, true); } + function centerOnFocusVertical(e) { centerOnFocus(e, this, false); } -export default { - getPosition: getPosition, - centerFocus: { - on: function (element, horizontal) { - if (horizontal) { - dom.addEventListener(element, 'focus', centerOnFocusHorizontal, { - capture: true, - passive: true - }); - } else { - dom.addEventListener(element, 'focus', centerOnFocusVertical, { - capture: true, - passive: true - }); - } - }, - off: function (element, horizontal) { - if (horizontal) { - dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, { - capture: true, - passive: true - }); - } else { - dom.removeEventListener(element, 'focus', centerOnFocusVertical, { - capture: true, - passive: true - }); - } +export const centerFocus = { + on: function (element, horizontal) { + if (horizontal) { + dom.addEventListener(element, 'focus', centerOnFocusHorizontal, { + capture: true, + passive: true + }); + } else { + dom.addEventListener(element, 'focus', centerOnFocusVertical, { + capture: true, + passive: true + }); } }, + off: function (element, horizontal) { + if (horizontal) { + dom.removeEventListener(element, 'focus', centerOnFocusHorizontal, { + capture: true, + passive: true + }); + } else { + dom.removeEventListener(element, 'focus', centerOnFocusVertical, { + capture: true, + passive: true + }); + } + } +} + +export default { + getPosition: getPosition, + centerFocus: centerFocus, toCenter: toCenter, toStart: toStart }; From 453079fe068250dca9d4964ad15692e474b7b8af Mon Sep 17 00:00:00 2001 From: MrTimscampi Date: Thu, 6 Aug 2020 22:48:26 +0200 Subject: [PATCH 4/6] Fix require --- src/components/guide/guide.js | 3 ++- src/scripts/scrollHelper.js | 4 +--- src/scripts/serverNotifications.js | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/guide/guide.js b/src/components/guide/guide.js index 50eb55f834..05fa2b608d 100644 --- a/src/components/guide/guide.js +++ b/src/components/guide/guide.js @@ -4,7 +4,8 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager', playbackManager = playbackManager.default || playbackManager; browser = browser.default || browser; loading = loading.default || loading; - focusManager = focusManager.default || focusManager;scrollHelper = scrollHelper.default || scrollHelper; + focusManager = focusManager.default || focusManager; + scrollHelper = scrollHelper.default || scrollHelper; serverNotifications = serverNotifications.default || serverNotifications; function showViewSettings(instance) { diff --git a/src/scripts/scrollHelper.js b/src/scripts/scrollHelper.js index 1ce30768af..b867123683 100644 --- a/src/scripts/scrollHelper.js +++ b/src/scripts/scrollHelper.js @@ -3,7 +3,6 @@ import dom from 'dom'; import 'scrollStyles'; function getBoundingClientRect(elem) { - // Support: BlackBerry 5, iOS 3 (original iPhone) // If we don't have gBCR, just use 0,0 rather than error if (elem.getBoundingClientRect) { @@ -14,7 +13,6 @@ function getBoundingClientRect(elem) { } export function getPosition(scrollContainer, item, horizontal) { - const slideeOffset = getBoundingClientRect(scrollContainer); const itemOffset = getBoundingClientRect(item); @@ -130,7 +128,7 @@ export const centerFocus = { }); } } -} +}; export default { getPosition: getPosition, diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index 83af40c4e6..2345cf327a 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -15,12 +15,12 @@ function notifyApp() { function displayMessage(cmd) { const args = cmd.Arguments; if (args.TimeoutMs) { - require(['toast'], function (toast) { + import('toast').then((toast) => { toast({ title: args.Header, text: args.Text }); }); } else { - require(['alert'], function (alert) { - alert.default({ title: args.Header, text: args.Text }); + import('alert').then((alert) => { + alert({ title: args.Header, text: args.Text }); }); } } From 232ccb6b9fce607adf6bb4319f0bd6abd40ad48f Mon Sep 17 00:00:00 2001 From: Julien Machiels Date: Thu, 6 Aug 2020 23:26:51 +0200 Subject: [PATCH 5/6] Update src/scripts/serverNotifications.js Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com> --- src/scripts/serverNotifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index 2345cf327a..c84377c880 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -15,7 +15,7 @@ function notifyApp() { function displayMessage(cmd) { const args = cmd.Arguments; if (args.TimeoutMs) { - import('toast').then((toast) => { + import('toast').then(({default: toast}) => { toast({ title: args.Header, text: args.Text }); }); } else { From 915a423997914e09b020dc8cd8dfc15614518886 Mon Sep 17 00:00:00 2001 From: Julien Machiels Date: Thu, 6 Aug 2020 23:26:59 +0200 Subject: [PATCH 6/6] Update src/scripts/serverNotifications.js Co-authored-by: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com> --- src/scripts/serverNotifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index c84377c880..2566d148f6 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -19,7 +19,7 @@ function displayMessage(cmd) { toast({ title: args.Header, text: args.Text }); }); } else { - import('alert').then((alert) => { + import('alert').then(({default: alert}) => { alert({ title: args.Header, text: args.Text }); }); }