diff --git a/dashboard-ui/channelitems.html b/dashboard-ui/channelitems.html index f0f4534bdb..f604b0f24f 100644 --- a/dashboard-ui/channelitems.html +++ b/dashboard-ui/channelitems.html @@ -4,7 +4,7 @@ Emby -
+
${TabLatest} diff --git a/dashboard-ui/channelslatest.html b/dashboard-ui/channelslatest.html index a2eb5f16a5..95eacc00d2 100644 --- a/dashboard-ui/channelslatest.html +++ b/dashboard-ui/channelslatest.html @@ -4,7 +4,7 @@ Emby -
+
${TabLatest} diff --git a/dashboard-ui/connectlogin.html b/dashboard-ui/connectlogin.html index 92e870334e..2e1bad1297 100644 --- a/dashboard-ui/connectlogin.html +++ b/dashboard-ui/connectlogin.html @@ -4,7 +4,7 @@ ${TitleSignIn} -
+
@@ -97,11 +97,6 @@
- -
diff --git a/dashboard-ui/cordovaindex.html b/dashboard-ui/cordovaindex.html deleted file mode 100644 index cceb9af568..0000000000 --- a/dashboard-ui/cordovaindex.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - Emby - - - - - - \ No newline at end of file diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index 3a17ea195f..6a6c57bbbf 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -1465,10 +1465,6 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { display: none !important; } -.homeLatestTabDisabled .homeLatestTab { - display: none !important; -} - .movieTrailersTabDisabled .movieTrailersTab { display: none !important; } diff --git a/dashboard-ui/favorites.html b/dashboard-ui/favorites.html index 2c9cb06a5c..c8cc41a3b5 100644 --- a/dashboard-ui/favorites.html +++ b/dashboard-ui/favorites.html @@ -4,13 +4,13 @@ Emby -
+
diff --git a/dashboard-ui/homelatest.html b/dashboard-ui/homelatest.html index 99db89845f..3d2fbcfbd3 100644 --- a/dashboard-ui/homelatest.html +++ b/dashboard-ui/homelatest.html @@ -4,13 +4,13 @@ Emby -
+
diff --git a/dashboard-ui/index.html b/dashboard-ui/index.html index 35870c5c08..709ab25a5d 100644 --- a/dashboard-ui/index.html +++ b/dashboard-ui/index.html @@ -8,9 +8,9 @@ @@ -28,23 +28,6 @@
- -
-
- -

${HeaderMyPreferences}

-
- -
- -

${HeaderWelcomeExclamation}

-

${MyPreferencesWelcomeMessage1}

-

${MyPreferencesWelcomeMessage2}

- ${ButtonMyPreferencesWelcomeYes} - ${ButtonMyPreferencesWelcomeNo} -
${ToAccessPreferencesHelp}
-
-
diff --git a/dashboard-ui/itemdetails.html b/dashboard-ui/itemdetails.html index dae4b84877..4fc2c2429e 100644 --- a/dashboard-ui/itemdetails.html +++ b/dashboard-ui/itemdetails.html @@ -9,8 +9,8 @@ diff --git a/dashboard-ui/reports.html b/dashboard-ui/reports.html index 85be72b9b5..25079ae2a1 100644 --- a/dashboard-ui/reports.html +++ b/dashboard-ui/reports.html @@ -4,7 +4,7 @@ Emby -
+
diff --git a/dashboard-ui/scripts/aboutpage.js b/dashboard-ui/scripts/aboutpage.js index a179062dfd..6607272194 100644 --- a/dashboard-ui/scripts/aboutpage.js +++ b/dashboard-ui/scripts/aboutpage.js @@ -1,6 +1,6 @@ (function ($, document) { - $(document).on('pageshown', "#aboutPage", function () { + $(document).on('pageshowready', "#aboutPage", function () { var page = this; diff --git a/dashboard-ui/scripts/addpluginpage.js b/dashboard-ui/scripts/addpluginpage.js index e7831efad0..012df87d91 100644 --- a/dashboard-ui/scripts/addpluginpage.js +++ b/dashboard-ui/scripts/addpluginpage.js @@ -169,7 +169,7 @@ Dashboard.hideLoadingMsg(); } - $(document).on('pageshown', "#addPluginPage", function () { + $(document).on('pageshowready', "#addPluginPage", function () { var page = this; diff --git a/dashboard-ui/scripts/advancedconfigurationpage.js b/dashboard-ui/scripts/advancedconfigurationpage.js index 2de0ad2db9..3ec31d6ee7 100644 --- a/dashboard-ui/scripts/advancedconfigurationpage.js +++ b/dashboard-ui/scripts/advancedconfigurationpage.js @@ -59,7 +59,7 @@ return false; } - $(document).on('pageshown', "#advancedConfigurationPage", function () { + $(document).on('pageshowready', "#advancedConfigurationPage", function () { Dashboard.showLoadingMsg(); diff --git a/dashboard-ui/scripts/alphapicker.js b/dashboard-ui/scripts/alphapicker.js index fd20f65a31..c05f7f0b49 100644 --- a/dashboard-ui/scripts/alphapicker.js +++ b/dashboard-ui/scripts/alphapicker.js @@ -35,7 +35,7 @@ return html; } - $(document).on('pageinit', ".libraryPage", function () { + $(document).on('pageinitdepends', ".libraryPage", function () { var page = this; diff --git a/dashboard-ui/scripts/backdrops.js b/dashboard-ui/scripts/backdrops.js index bd72a90d92..4df75a91a5 100644 --- a/dashboard-ui/scripts/backdrops.js +++ b/dashboard-ui/scripts/backdrops.js @@ -195,7 +195,7 @@ } } - $(document).on('pagebeforeshow', ".page", function () { + $(document).on('pagebeforeshowready', ".page", function () { var page = this; diff --git a/dashboard-ui/scripts/channelitems.js b/dashboard-ui/scripts/channelitems.js index cd0b70c4be..ee2d980906 100644 --- a/dashboard-ui/scripts/channelitems.js +++ b/dashboard-ui/scripts/channelitems.js @@ -203,7 +203,7 @@ $('#selectPageSize', page).val(query.Limit).selectmenu('refresh'); } - $(document).on('pageinit', "#channelItemsPage", function () { + $(document).on('pageinitdepends', "#channelItemsPage", function () { var page = this; @@ -256,10 +256,7 @@ reloadItems(page); }); - }).on('pagebeforeshow', "#channelItemsPage", function () { - - - }).on('pageshow', "#channelItemsPage", function () { + }).on('pageshowready', "#channelItemsPage", function () { var page = this; var limit = LibraryBrowser.getDefaultPageSize(); diff --git a/dashboard-ui/scripts/channels.js b/dashboard-ui/scripts/channels.js index bb202d8212..5bd2ac9226 100644 --- a/dashboard-ui/scripts/channels.js +++ b/dashboard-ui/scripts/channels.js @@ -60,7 +60,7 @@ } - $(document).on('pageshown', "#channelsPage", function () { + $(document).on('pageshowready', "#channelsPage", function () { LibraryBrowser.loadSavedQueryValues('channels', query); diff --git a/dashboard-ui/scripts/channelslatest.js b/dashboard-ui/scripts/channelslatest.js index 337dc07223..63eca5776f 100644 --- a/dashboard-ui/scripts/channelslatest.js +++ b/dashboard-ui/scripts/channelslatest.js @@ -5,7 +5,7 @@ Sections.loadLatestChannelItems($(".items", page), Dashboard.getCurrentUserId()); } - $(document).on('pagebeforeshow', "#channelsLatestPage", function () { + $(document).on('pageshowready', "#channelsLatestPage", function () { reloadItems(this); diff --git a/dashboard-ui/scripts/connectlogin.js b/dashboard-ui/scripts/connectlogin.js index 9c7991abc6..76dc8196d8 100644 --- a/dashboard-ui/scripts/connectlogin.js +++ b/dashboard-ui/scripts/connectlogin.js @@ -123,7 +123,23 @@ Dashboard.navigate('selectserver.html'); } - $(document).on('pageinit', "#connectLoginPage", function () { + function onSubmit() { + var page = $(this).parents('.page'); + + submit(page); + + return false; + } + + function onManualServerSubmit() { + var page = $(this).parents('.page'); + + submitManualServer(page); + + return false; + } + + $(document).on('pageinitdepends', "#connectLoginPage", function () { var page = this; @@ -131,7 +147,10 @@ skip(); }); - }).on('pageshow', "#connectLoginPage", function () { + $('.connectLoginForm').off('submit', onSubmit).on('submit', onSubmit); + $('.manualServerForm').off('submit', onManualServerSubmit).on('submit', onManualServerSubmit); + + }).on('pageshowready', "#connectLoginPage", function () { var page = this; @@ -179,25 +198,4 @@ login(page, user, password); } - window.ConnectLoginPage = { - - onSubmit: function () { - - var page = $(this).parents('.page'); - - submit(page); - - return false; - }, - - onManualServerSubmit: function () { - var page = $(this).parents('.page'); - - submitManualServer(page); - - return false; - - } - }; - })(); \ No newline at end of file diff --git a/dashboard-ui/scripts/dashboardhosting.js b/dashboard-ui/scripts/dashboardhosting.js index b8d548e792..2aa9dca9b7 100644 --- a/dashboard-ui/scripts/dashboardhosting.js +++ b/dashboard-ui/scripts/dashboardhosting.js @@ -40,7 +40,7 @@ return false; } - $(document).on('pageshown', "#dashboardHostingPage", function () { + $(document).on('pageshowready', "#dashboardHostingPage", function () { Dashboard.showLoadingMsg(); diff --git a/dashboard-ui/scripts/dashboardpage.js b/dashboard-ui/scripts/dashboardpage.js index d2048f0ae7..1f203993ae 100644 --- a/dashboard-ui/scripts/dashboardpage.js +++ b/dashboard-ui/scripts/dashboardpage.js @@ -6,6 +6,12 @@ var page = this; + var apiClient = ApiClient; + + if (!apiClient) { + return; + } + if (Dashboard.lastSystemInfo) { Dashboard.setPageTitle(Dashboard.lastSystemInfo.ServerName); } @@ -14,9 +20,9 @@ Dashboard.showLoadingMsg(); DashboardPage.pollForInfo(page); - DashboardPage.startInterval(); + DashboardPage.startInterval(apiClient); - $(ApiClient).on("websocketmessage", DashboardPage.onWebSocketMessage) + $(apiClient).on("websocketmessage", DashboardPage.onWebSocketMessage) .on("websocketopen", DashboardPage.onWebSocketOpen); DashboardPage.lastAppUpdateCheck = null; @@ -33,7 +39,7 @@ $('.activityItems', page).activityLogList(); - $('.swaggerLink', page).attr('href', ApiClient.getUrl('swagger-ui/index.html')); + $('.swaggerLink', page).attr('href', apiClient.getUrl('swagger-ui/index.html')); }, onPageHide: function () { @@ -42,8 +48,10 @@ $('.activityItems', page).activityLogList('destroy'); - $(ApiClient).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange); - DashboardPage.stopInterval(); + var apiClient = ApiClient; + + $(apiClient).off("websocketmessage", DashboardPage.onWebSocketMessage).off("websocketopen", DashboardPage.onWebSocketConnectionChange).off("websocketerror", DashboardPage.onWebSocketConnectionChange).off("websocketclose", DashboardPage.onWebSocketConnectionChange); + DashboardPage.stopInterval(apiClient); if (DashboardPage.sessionUpdateTimer) { clearInterval(DashboardPage.sessionUpdateTimer); @@ -152,19 +160,19 @@ }, - startInterval: function () { + startInterval: function (apiClient) { - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("SessionsStart", "0,1500"); - ApiClient.sendWebSocketMessage("ScheduledTasksInfoStart", "0,1000"); + if (apiClient.isWebSocketOpen()) { + apiClient.sendWebSocketMessage("SessionsStart", "0,1500"); + apiClient.sendWebSocketMessage("ScheduledTasksInfoStart", "0,1000"); } }, - stopInterval: function () { + stopInterval: function (apiClient) { - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("SessionsStop"); - ApiClient.sendWebSocketMessage("ScheduledTasksInfoStop"); + if (apiClient.isWebSocketOpen()) { + apiClient.sendWebSocketMessage("SessionsStop"); + apiClient.sendWebSocketMessage("ScheduledTasksInfoStop"); } }, @@ -199,16 +207,24 @@ onWebSocketOpen: function () { - DashboardPage.startInterval(); + var apiClient = this; + + DashboardPage.startInterval(apiClient); }, pollForInfo: function (page, forceUpdate) { - ApiClient.getSessions().done(function (sessions) { + var apiClient = window.ApiClient; + + if (!apiClient) { + return; + } + + apiClient.getSessions().done(function (sessions) { DashboardPage.renderInfo(page, sessions, forceUpdate); }); - ApiClient.getScheduledTasks().done(function (tasks) { + apiClient.getScheduledTasks().done(function (tasks) { DashboardPage.renderRunningTasks(page, tasks); }); @@ -991,7 +1007,7 @@ } }; -$(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) +$(document).on('pagebeforeshowready', "#dashboardPage", DashboardPage.onPageShow) .on('pagehide', "#dashboardPage", DashboardPage.onPageHide); (function ($, document, window) { @@ -1204,7 +1220,13 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) reloadData(this); }); - $(ApiClient).on('websocketmessage.activityloglistener', function (e, data) { + var apiClient = ApiClient; + + if (!apiClient) { + return; + } + + $(apiClient).on('websocketmessage.activityloglistener', function (e, data) { var msg = data; @@ -1217,31 +1239,35 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) }).on('websocketopen.activityloglistener', function (e, data) { - startListening(); + startListening(apiClient); }); } - function startListening() { + function startListening(apiClient) { - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("ActivityLogEntryStart", "0,1500"); + if (apiClient.isWebSocketOpen()) { + apiClient.sendWebSocketMessage("ActivityLogEntryStart", "0,1500"); } } - function stopListening() { + function stopListening(apiClient) { - if (ApiClient.isWebSocketOpen()) { - ApiClient.sendWebSocketMessage("ActivityLogEntryStop", "0,1500"); + if (apiClient.isWebSocketOpen()) { + apiClient.sendWebSocketMessage("ActivityLogEntryStop", "0,1500"); } } function destroyList(elem) { - $(ApiClient).off('websocketopen.activityloglistener').off('websocketmessage.activityloglistener'); + var apiClient = ApiClient; - stopListening(); + if (apiClient) { + $(apiClient).off('websocketopen.activityloglistener').off('websocketmessage.activityloglistener'); + + stopListening(apiClient); + } return this; } @@ -1254,7 +1280,7 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) createList(this); } - startListening(); + startListening(ApiClient); return this; }; @@ -1277,11 +1303,11 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) }); } - function showWelcomeIfNeeded(page) { + function showWelcomeIfNeeded(page, apiClient) { var userId = Dashboard.getCurrentUserId(); - ApiClient.getDisplayPreferences('dashboard', userId, 'dashboard').done(function (result) { + apiClient.getDisplayPreferences('dashboard', userId, 'dashboard').done(function (result) { if (result.CustomPrefs[welcomeTourKey] == welcomeDismissValue) { $('.welcomeMessage', page).hide(); @@ -1330,21 +1356,23 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) }); } - $(document).on('pageinit', "#dashboardPage", function () { + $(document).on('pageinitdepends', "#dashboardPage", function () { var page = this; - var userId = Dashboard.getCurrentUserId(); - $('.btnTakeTour', page).on('click', function () { - takeTour(page, userId); + takeTour(page, Dashboard.getCurrentUserId()); }); - }).on('pagebeforeshow.checktour', "#dashboardPage", function () { + }).on('pagebeforeshowready.checktour', "#dashboardPage", function () { var page = this; - showWelcomeIfNeeded(page); + var apiClient = ApiClient; + + if (apiClient) { + showWelcomeIfNeeded(page, apiClient); + } }); @@ -1352,7 +1380,7 @@ $(document).on('pagebeforeshow', "#dashboardPage", DashboardPage.onPageShow) (function () { - $(document).on('pagebeforeshow', ".type-interior", function () { + $(document).on('pagebeforeshowready', ".type-interior", function () { var page = this; diff --git a/dashboard-ui/scripts/device.js b/dashboard-ui/scripts/device.js index fee97ebcde..3685301f94 100644 --- a/dashboard-ui/scripts/device.js +++ b/dashboard-ui/scripts/device.js @@ -82,7 +82,7 @@ $('.deviceForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#devicePage", function () { + }).on('pageshowready', "#devicePage", function () { var page = this; diff --git a/dashboard-ui/scripts/devices.js b/dashboard-ui/scripts/devices.js index 3213a0339e..09db217965 100644 --- a/dashboard-ui/scripts/devices.js +++ b/dashboard-ui/scripts/devices.js @@ -89,7 +89,7 @@ }); } - $(document).on('pageshown', "#devicesPage", function () { + $(document).on('pageshowready', "#devicesPage", function () { var page = this; diff --git a/dashboard-ui/scripts/edititemimages.js b/dashboard-ui/scripts/edititemimages.js index 2a8d8cfde5..561fe709f8 100644 --- a/dashboard-ui/scripts/edititemimages.js +++ b/dashboard-ui/scripts/edititemimages.js @@ -569,7 +569,7 @@ $('.uploadItemImageForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#editItemImagesPage", function () { + }).on('pageshowready', "#editItemImagesPage", function () { var page = this; diff --git a/dashboard-ui/scripts/episodes.js b/dashboard-ui/scripts/episodes.js index fe5d252d13..dddfe553da 100644 --- a/dashboard-ui/scripts/episodes.js +++ b/dashboard-ui/scripts/episodes.js @@ -321,7 +321,7 @@ reloadItems(page); }); - }).on('pageshown', "#episodesPage", function () { + }).on('pageshowready', "#episodesPage", function () { var page = this; query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/favorites.js b/dashboard-ui/scripts/favorites.js index 2187f26fec..4ed039799a 100644 --- a/dashboard-ui/scripts/favorites.js +++ b/dashboard-ui/scripts/favorites.js @@ -105,7 +105,7 @@ } } - $(document).on('pagebeforeshow', "#favoritesPage", function () { + $(document).on('pageshowready', "#favoritesPage", function () { var page = this; diff --git a/dashboard-ui/scripts/gamegenrepage.js b/dashboard-ui/scripts/gamegenrepage.js index 2eacd786ef..802683800d 100644 --- a/dashboard-ui/scripts/gamegenrepage.js +++ b/dashboard-ui/scripts/gamegenrepage.js @@ -96,7 +96,7 @@ reloadItems(page); }); - }).on('pageshown', "#gameGenresPage", function () { + }).on('pageshowready', "#gameGenresPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/gamespage.js b/dashboard-ui/scripts/gamespage.js index c4988a73f2..d082261e4d 100644 --- a/dashboard-ui/scripts/gamespage.js +++ b/dashboard-ui/scripts/gamespage.js @@ -239,7 +239,7 @@ reloadItems(page); }); - }).on('pageshown', "#gamesPage", function () { + }).on('pageshowready', "#gamesPage", function () { var page = this; query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/gamesrecommendedpage.js b/dashboard-ui/scripts/gamesrecommendedpage.js index ffeb12f54b..d8f4655996 100644 --- a/dashboard-ui/scripts/gamesrecommendedpage.js +++ b/dashboard-ui/scripts/gamesrecommendedpage.js @@ -1,6 +1,6 @@ (function ($, document) { - $(document).on('pageshown', "#gamesRecommendedPage", function () { + $(document).on('pageshowready', "#gamesRecommendedPage", function () { var parentId = LibraryMenu.getTopParentId(); var userId = Dashboard.getCurrentUserId(); diff --git a/dashboard-ui/scripts/gamestudiospage.js b/dashboard-ui/scripts/gamestudiospage.js index 1a5c5287a0..f85bf82aac 100644 --- a/dashboard-ui/scripts/gamestudiospage.js +++ b/dashboard-ui/scripts/gamestudiospage.js @@ -98,7 +98,7 @@ reloadItems(page); }); - }).on('pageshown', "#gameStudiosPage", function () { + }).on('pageshowready', "#gameStudiosPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/gamesystemspage.js b/dashboard-ui/scripts/gamesystemspage.js index 4fcc965ee2..1b7cba7f7b 100644 --- a/dashboard-ui/scripts/gamesystemspage.js +++ b/dashboard-ui/scripts/gamesystemspage.js @@ -52,7 +52,7 @@ // Reset form values using the last used query } - $(document).on('pageshown', "#gamesystemsPage", function () { + $(document).on('pageshowready', "#gamesystemsPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/homelatest.js b/dashboard-ui/scripts/homelatest.js index 35576025c8..d9f3e2cb66 100644 --- a/dashboard-ui/scripts/homelatest.js +++ b/dashboard-ui/scripts/homelatest.js @@ -31,7 +31,7 @@ Sections.loadLatestChannelItems($(".section2", page), userId); } - $(document).on('pagebeforeshow', "#homeLatestPage", function () { + $(document).on('pageshowready', "#homeLatestPage", function () { var page = this; diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js index f5ba8aa7f3..3c3506c532 100644 --- a/dashboard-ui/scripts/indexpage.js +++ b/dashboard-ui/scripts/indexpage.js @@ -607,57 +607,38 @@ afterClose: function () { dismissWelcome(page, userId); $('.welcomeMessage', page).hide(); - - loadConfigureViewsWelcomeMessage(page, userId); }, hideBarsDelay: 30000 }); }); } - function loadConfigureViewsWelcomeMessage(page, userId) { - - Dashboard.getCurrentUser().done(function (user) { - - if (user.Policy.EnableUserPreferenceAccess) { - $('.btnMyPreferences', page).attr('href', 'mypreferencesdisplay.html?userId=' + userId); - - // Need the timeout because previous methods in the chain have popups that will be in the act of closing - setTimeout(function () { - - $('.popupConfigureViews', page).popup('open'); - - }, 500); - } - }); - } - - $(document).on('pageinit', "#indexPage", function () { + $(document).on('pageinitdepends', "#indexPage", function () { var page = this; - var userId = Dashboard.getCurrentUserId(); - $('.btnTakeTour', page).on('click', function () { - takeTour(page, userId); + takeTour(page, Dashboard.getCurrentUserId()); }); - }).on('pagebeforeshow', "#indexPage", function () { + }).on('pagebeforeshowready', "#indexPage", function () { var page = this; - var userId = Dashboard.getCurrentUserId(); + if (window.ApiClient) { + var userId = Dashboard.getCurrentUserId(); - getDisplayPreferences('home', userId).done(function (result) { + getDisplayPreferences('home', userId).done(function (result) { - Dashboard.getCurrentUser().done(function (user) { + Dashboard.getCurrentUser().done(function (user) { + + loadSections(page, user, result).done(function () { + showWelcomeIfNeeded(page, result); + }); - loadSections(page, user, result).done(function () { - showWelcomeIfNeeded(page, result); }); - }); - }); + } }); diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js index 0a2cfc6188..a8a63d99b8 100644 --- a/dashboard-ui/scripts/itemlistpage.js +++ b/dashboard-ui/scripts/itemlistpage.js @@ -244,7 +244,7 @@ $(page).on('click', '.mediaItem', onListItemClick); - }).on('pageshown', "#itemListPage", function () { + }).on('pageshowready', "#itemListPage", function () { var page = this; diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index 33456a0176..ac3583c8c3 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -1082,7 +1082,7 @@ $('cardImage', page).remove(); } - $(document).on('pageinit', ".libraryPage", function () { + $(document).on('pageinitdepends', ".libraryPage", function () { var page = this; @@ -1127,7 +1127,7 @@ $('.itemsContainer', page).createCardMenus(); - }).on('pagebeforeshow', ".libraryPage", function () { + }).on('pagebeforeshowready', ".libraryPage", function () { var page = this; @@ -1212,9 +1212,15 @@ $(apiClient).off('websocketmessage.librarylist', onWebSocketMessage).on('websocketmessage.librarylist', onWebSocketMessage); } - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + Dashboard.ready(function () { - initializeApiClient(apiClient); + if (window.ApiClient) { + initializeApiClient(window.ApiClient); + } + + $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + initializeApiClient(apiClient); + }); }); })(jQuery, document, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/librarymenu.js b/dashboard-ui/scripts/librarymenu.js index 5e7d57f7a7..e6e2d41d08 100644 --- a/dashboard-ui/scripts/librarymenu.js +++ b/dashboard-ui/scripts/librarymenu.js @@ -502,7 +502,7 @@ }); - }).on('pagebeforeshow', ".page:not(.standalonePage)", function () { + }).on('pagebeforeshowready', ".page:not(.standalonePage)", function () { var page = this; var viewMenuBar = $('.viewMenuBar'); @@ -535,7 +535,7 @@ $(document.body).removeClass('dashboardDocument').removeClass('libraryDocument'); } - }).on('pagebeforeshow', ".libraryPage", function () { + }).on('pagebeforeshowready', ".libraryPage", function () { var page = this; @@ -587,22 +587,23 @@ function initializeApiClient(apiClient) { + requiresLibraryMenuRefresh = true; $(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage); } - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + Dashboard.ready(function () { - requiresLibraryMenuRefresh = true; - initializeApiClient(apiClient); + if (window.ApiClient) { + initializeApiClient(window.ApiClient); + } - }).on('localusersignedin', function () { + $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + initializeApiClient(apiClient); - requiresLibraryMenuRefresh = true; - - }).on('localusersignedout', function () { - - $('.viewMenuBar').remove(); - requiresLibraryMenuRefresh = true; + }).on('localusersignedin localusersignedout', function () { + $('.viewMenuBar').remove(); + requiresLibraryMenuRefresh = true; + }); }); $(function () { diff --git a/dashboard-ui/scripts/livetvchannels.js b/dashboard-ui/scripts/livetvchannels.js index f4976c6cb1..8aebcb4263 100644 --- a/dashboard-ui/scripts/livetvchannels.js +++ b/dashboard-ui/scripts/livetvchannels.js @@ -109,7 +109,7 @@ reloadItems(page); }); - }).on('pageshown', "#liveTvChannelsPage", function () { + }).on('pageshowready', "#liveTvChannelsPage", function () { // Can't use pagebeforeshow here or the loading popup won't center correctly var page = this; diff --git a/dashboard-ui/scripts/livetvitems.js b/dashboard-ui/scripts/livetvitems.js index dbe93fd18f..83e5388353 100644 --- a/dashboard-ui/scripts/livetvitems.js +++ b/dashboard-ui/scripts/livetvitems.js @@ -137,7 +137,7 @@ reloadItems(page); }); - }).on('pageshown', "#liveTvItemsPage", function () { + }).on('pageshowready', "#liveTvItemsPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/livetvrecordings.js b/dashboard-ui/scripts/livetvrecordings.js index dc336c1fa6..3e8dc548ca 100644 --- a/dashboard-ui/scripts/livetvrecordings.js +++ b/dashboard-ui/scripts/livetvrecordings.js @@ -102,7 +102,7 @@ }); } - $(document).on('pageshown', "#liveTvRecordingsPage", function () { + $(document).on('pageshowready', "#liveTvRecordingsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvseriestimers.js b/dashboard-ui/scripts/livetvseriestimers.js index 326e3d8dd1..b9294d95f7 100644 --- a/dashboard-ui/scripts/livetvseriestimers.js +++ b/dashboard-ui/scripts/livetvseriestimers.js @@ -116,7 +116,7 @@ }).checkboxradio('refresh'); } - $(document).on('pageshown', "#liveTvSeriesTimersPage", function () { + $(document).on('pageshowready', "#liveTvSeriesTimersPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvsuggested.js b/dashboard-ui/scripts/livetvsuggested.js index d0c45707ba..b3649f6789 100644 --- a/dashboard-ui/scripts/livetvsuggested.js +++ b/dashboard-ui/scripts/livetvsuggested.js @@ -104,7 +104,7 @@ }); } - $(document).on('pageshown', "#liveTvSuggestedPage", function () { + $(document).on('pageshowready', "#liveTvSuggestedPage", function () { var page = this; diff --git a/dashboard-ui/scripts/livetvtimers.js b/dashboard-ui/scripts/livetvtimers.js index 52b51cebfc..d7be045b67 100644 --- a/dashboard-ui/scripts/livetvtimers.js +++ b/dashboard-ui/scripts/livetvtimers.js @@ -107,7 +107,7 @@ }); } - $(document).on('pageshown', "#liveTvTimersPage", function () { + $(document).on('pageshowready', "#liveTvTimersPage", function () { var page = this; diff --git a/dashboard-ui/scripts/loginpage.js b/dashboard-ui/scripts/loginpage.js index 4625249511..632be937c8 100644 --- a/dashboard-ui/scripts/loginpage.js +++ b/dashboard-ui/scripts/loginpage.js @@ -63,7 +63,7 @@ showManualForm: function (page, showCancel, focusPassword) { $('.visualLoginForm', page).hide(); - $('#manualLoginForm', page).show(); + $('.manualLoginForm', page).show(); if (focusPassword) { $('#txtManualPassword', page).focus(); @@ -80,7 +80,7 @@ showVisualForm: function (page) { $('.visualLoginForm', page).show(); - $('#manualLoginForm', page).hide(); + $('.manualLoginForm', page).hide(); }, getLastSeenText: function (lastActivityDate) { @@ -215,4 +215,10 @@ } }; -$(document).on('pageshow', "#loginPage", LoginPage.onPageShow); +$(document).on('pageinitdepends', "#loginPage", function () { + + var page = this; + + $('.manualLoginForm', page).off('submit', LoginPage.onManualSubmit).on('submit', LoginPage.onManualSubmit); + +}).on('pageshowready', "#loginPage", LoginPage.onPageShow); diff --git a/dashboard-ui/scripts/logpage.js b/dashboard-ui/scripts/logpage.js index b73d9be888..05f0a85d6c 100644 --- a/dashboard-ui/scripts/logpage.js +++ b/dashboard-ui/scripts/logpage.js @@ -1,6 +1,6 @@ (function () { - $(document).on('pageshown', "#logPage", function () { + $(document).on('pageshowready', "#logPage", function () { var page = this; diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index ec7b0564b4..eaa0df8aab 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -169,6 +169,13 @@ }; + self.removeActiveTarget = function (id) { + + if (self.getPlayerInfo().id == id) { + self.setDefaultPlayerActive(); + } + }; + self.getPlayers = function() { return players; }; @@ -450,6 +457,20 @@ return bottomText ? topText + '
' + bottomText : topText; }; + + self.showPlaybackInfoErrorMessage = function(errorCode) { + + // This timeout is messy, but if jqm is in the act of hiding a popup, it will not show a new one + // If we're coming from the popup play menu, this will be a problem + + setTimeout(function() { + Dashboard.alert({ + message: Globalize.translate('MessagePlaybackError' + errorCode), + title: Globalize.translate('HeaderPlaybackError') + }); + }, 300); + + }; } window.MediaController = new mediaController(); @@ -512,15 +533,19 @@ } } - - function initializeApiClient(apiClient) { - $(apiClient).on("websocketmessage", onWebSocketMessageReceived); + $(apiClient).off("websocketmessage", onWebSocketMessageReceived).on("websocketmessage", onWebSocketMessageReceived); } - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + Dashboard.ready(function () { - initializeApiClient(apiClient); + if (window.ApiClient) { + initializeApiClient(window.ApiClient); + } + + $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + initializeApiClient(apiClient); + }); }); function getTargetsHtml(targets) { @@ -705,9 +730,8 @@ showPlayerSelection($.mobile.activePage); }); - }); - $(document).on('pagebeforeshow', ".page", function () { + }).on('pagebeforeshow', ".page", function () { var page = this; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index d090aecb3f..c5fa0537de 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -215,20 +215,16 @@ profile.ContainerProfiles = []; var audioConditions = []; - var videoAudioMp3Conditions = []; var maxAudioChannels = $.browser.msie || $.browser.safari ? '2' : '6'; - var channelCondition = { + audioConditions.push({ Condition: 'LessThanEqual', Property: 'AudioChannels', Value: maxAudioChannels - }; - - audioConditions.push(channelCondition); - videoAudioMp3Conditions.push(channelCondition); + }); profile.CodecProfiles = []; profile.CodecProfiles.push({ @@ -236,20 +232,21 @@ Conditions: audioConditions }); - if (videoAudioMp3Conditions.length) { - profile.CodecProfiles.push({ - Type: 'VideoAudio', - Codec: 'mp3', - Conditions: videoAudioMp3Conditions - }); - } + profile.CodecProfiles.push({ + Type: 'VideoAudio', + Codec: 'mp3', + Conditions: [{ + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: maxAudioChannels + }] + }); profile.CodecProfiles.push({ Type: 'VideoAudio', Codec: 'aac', Container: 'mkv,mov', Conditions: [ - channelCondition, { Condition: 'NotEquals', Property: 'AudioProfile', @@ -266,9 +263,12 @@ profile.CodecProfiles.push({ Type: 'VideoAudio', Codec: 'aac', - Container: 'mp4,m4v', Conditions: [ - channelCondition + { + Condition: 'LessThanEqual', + Property: 'AudioChannels', + Value: maxAudioChannels + } ] }); @@ -868,7 +868,7 @@ } if (item.IsPlaceHolder) { - showPlaybackInfoErrorMessage('PlaceHolder'); + MediaController.showPlaybackInfoErrorMessage('PlaceHolder'); return; } @@ -901,7 +901,7 @@ } } else { Dashboard.hideModalLoadingMsg(); - showPlaybackInfoErrorMessage('NoCompatibleStream'); + MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream'); } } @@ -934,27 +934,13 @@ if (result.ErrorCode) { - showPlaybackInfoErrorMessage(result.ErrorCode); + MediaController.showPlaybackInfoErrorMessage(result.ErrorCode); return false; } return true; } - function showPlaybackInfoErrorMessage(errorCode) { - - // This timeout is messy, but if jqm is in the act of hiding a popup, it will not show a new one - // If we're coming from the popup play menu, this will be a problem - - setTimeout(function () { - Dashboard.alert({ - message: Globalize.translate('MessagePlaybackError' + errorCode), - title: Globalize.translate('HeaderPlaybackError') - }); - }, 300); - - } - self.getPosterUrl = function (item) { var screenWidth = Math.max(screen.height, screen.width); @@ -1748,8 +1734,10 @@ window.MediaPlayer = new mediaPlayer(); - window.MediaController.registerPlayer(window.MediaPlayer); - window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargets()[0]); + Dashboard.ready(function() { + window.MediaController.registerPlayer(window.MediaPlayer); + window.MediaController.setActivePlayer(window.MediaPlayer, window.MediaPlayer.getTargets()[0]); + }); })(document, setTimeout, clearTimeout, screen, window.store, $, setInterval, window); \ No newline at end of file diff --git a/dashboard-ui/scripts/metadataadvanced.js b/dashboard-ui/scripts/metadataadvanced.js index 28ff206467..bd93757050 100644 --- a/dashboard-ui/scripts/metadataadvanced.js +++ b/dashboard-ui/scripts/metadataadvanced.js @@ -150,7 +150,23 @@ }); } - $(document).on('pageinit', "#advancedMetadataConfigurationPage", function () { + function onSubmit() { + var form = this; + + Dashboard.showLoadingMsg(); + + saveAdvancedConfig(form); + saveChapters(form); + saveMetadata(form); + saveTmdb(form); + saveTvdb(form); + saveFanart(form); + + // Disable default form submission + return false; + } + + $(document).on('pageinitdepends', "#advancedMetadataConfigurationPage", function () { var page = this; @@ -174,7 +190,10 @@ }); }); - }).on('pageshow', "#advancedMetadataConfigurationPage", function () { + $('.advancedMetadataConfigurationForm').on('submit', onSubmit).on('submit', onSubmit); + + + }).on('pageshowready', "#advancedMetadataConfigurationPage", function () { var page = this; @@ -270,7 +289,7 @@ } function saveMetadata(form) { - + ApiClient.getNamedConfiguration("metadata").done(function (config) { config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() == '1'; @@ -307,24 +326,5 @@ }); } - window.AdvancedMetadataConfigurationPage = { - - onSubmit: function () { - var form = this; - - Dashboard.showLoadingMsg(); - - saveAdvancedConfig(form); - saveChapters(form); - saveMetadata(form); - saveTmdb(form); - saveTvdb(form); - saveFanart(form); - - // Disable default form submission - return false; - } - }; - })(window, jQuery); diff --git a/dashboard-ui/scripts/moviecollections.js b/dashboard-ui/scripts/moviecollections.js index 4845953c68..7ff4d0976b 100644 --- a/dashboard-ui/scripts/moviecollections.js +++ b/dashboard-ui/scripts/moviecollections.js @@ -173,7 +173,7 @@ $('#selectPageSize', page).val(query.Limit).selectmenu('refresh'); } - $(document).on('pageinit', "#boxsetsPage", function () { + $(document).on('pageinitdepends', "#boxsetsPage", function () { var page = this; @@ -257,7 +257,7 @@ reloadItems(page); }); - }).on('pagebeforeshow', "#boxsetsPage", function () { + }).on('pagebeforeshowready', "#boxsetsPage", function () { var page = this; @@ -296,7 +296,7 @@ } }); - }).on('pageshow', "#boxsetsPage", function () { + }).on('pageshowready', "#boxsetsPage", function () { updateFilterControls(this); @@ -417,7 +417,7 @@ }); } - $(document).on('pageinit', ".collectionEditorPage", function () { + $(document).on('pageinitdepends', ".collectionEditorPage", function () { var page = this; diff --git a/dashboard-ui/scripts/moviegenres.js b/dashboard-ui/scripts/moviegenres.js index 45e30b36aa..57e2f094d1 100644 --- a/dashboard-ui/scripts/moviegenres.js +++ b/dashboard-ui/scripts/moviegenres.js @@ -154,7 +154,7 @@ LibraryBrowser.saveViewSetting(getSavedQueryKey(), view); }); - }).on('pageshown', "#movieGenresPage", function () { + }).on('pageshowready', "#movieGenresPage", function () { var page = this; query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/moviepeople.js b/dashboard-ui/scripts/moviepeople.js index 7d1733c7f1..36176ce991 100644 --- a/dashboard-ui/scripts/moviepeople.js +++ b/dashboard-ui/scripts/moviepeople.js @@ -140,7 +140,7 @@ reloadItems(page); }); - }).on('pageshown', "#moviePeoplePage", function () { + }).on('pageshowready', "#moviePeoplePage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js index 7069bf5a4c..962a2d521c 100644 --- a/dashboard-ui/scripts/movies.js +++ b/dashboard-ui/scripts/movies.js @@ -399,7 +399,7 @@ reloadItems(page); }); - }).on('pageshown', "#moviesPage", function () { + }).on('pageshowready', "#moviesPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js index 72c96f182a..53017d22d2 100644 --- a/dashboard-ui/scripts/moviesrecommended.js +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -234,7 +234,7 @@ $('.recommendations', page).createCardMenus(); - }).on('pageshown', "#moviesRecommendedPage", function () { + }).on('pageshowready', "#moviesRecommendedPage", function () { var parentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/moviestudios.js b/dashboard-ui/scripts/moviestudios.js index 52c72f1c95..e973ba517b 100644 --- a/dashboard-ui/scripts/moviestudios.js +++ b/dashboard-ui/scripts/moviestudios.js @@ -99,7 +99,7 @@ reloadItems(page); }); - }).on('pageshown', "#movieStudiosPage", function () { + }).on('pageshowready', "#movieStudiosPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/movietrailers.js b/dashboard-ui/scripts/movietrailers.js index d545053f05..d99113c8ad 100644 --- a/dashboard-ui/scripts/movietrailers.js +++ b/dashboard-ui/scripts/movietrailers.js @@ -215,7 +215,7 @@ $('.popupTrailerReelForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#movieTrailersPage", function () { + }).on('pageshowready', "#movieTrailersPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/musicalbumartists.js b/dashboard-ui/scripts/musicalbumartists.js index 7ee412c358..b34b9cd684 100644 --- a/dashboard-ui/scripts/musicalbumartists.js +++ b/dashboard-ui/scripts/musicalbumartists.js @@ -190,7 +190,7 @@ reloadItems(page); }); - }).on('pageshown', "#musicAlbumArtistsPage", function () { + }).on('pageshowready', "#musicAlbumArtistsPage", function () { var page = this; query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/musicalbums.js b/dashboard-ui/scripts/musicalbums.js index 248621d3a3..d94abeb3cb 100644 --- a/dashboard-ui/scripts/musicalbums.js +++ b/dashboard-ui/scripts/musicalbums.js @@ -242,7 +242,7 @@ reloadItems(page); }); - }).on('pageshown', "#musicAlbumsPage", function () { + }).on('pageshowready', "#musicAlbumsPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/musicartists.js b/dashboard-ui/scripts/musicartists.js index 9b88edc4d4..a4214a9fed 100644 --- a/dashboard-ui/scripts/musicartists.js +++ b/dashboard-ui/scripts/musicartists.js @@ -191,7 +191,7 @@ reloadItems(page); }); - }).on('pageshown', "#musicArtistsPage", function () { + }).on('pageshowready', "#musicArtistsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/musicgenres.js b/dashboard-ui/scripts/musicgenres.js index fe23e45445..a70904e19e 100644 --- a/dashboard-ui/scripts/musicgenres.js +++ b/dashboard-ui/scripts/musicgenres.js @@ -115,7 +115,7 @@ reloadItems(page); }); - }).on('pageshown', "#musicGenresPage", function () { + }).on('pageshowready', "#musicGenresPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/musicrecommended.js b/dashboard-ui/scripts/musicrecommended.js index b79a86fdea..61d4c36d4d 100644 --- a/dashboard-ui/scripts/musicrecommended.js +++ b/dashboard-ui/scripts/musicrecommended.js @@ -165,7 +165,7 @@ }); } - $(document).on('pageshown', "#musicRecommendedPage", function () { + $(document).on('pageshowready', "#musicRecommendedPage", function () { var parentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/musicvideos.js b/dashboard-ui/scripts/musicvideos.js index 0cea101144..a3a9503a3a 100644 --- a/dashboard-ui/scripts/musicvideos.js +++ b/dashboard-ui/scripts/musicvideos.js @@ -183,7 +183,7 @@ reloadItems(page); }); - }).on('pageshown', "#musicVideosPage", function () { + }).on('pageshowready', "#musicVideosPage", function () { var page = this; diff --git a/dashboard-ui/scripts/notifications.js b/dashboard-ui/scripts/notifications.js index 49e6dc6097..42059d0025 100644 --- a/dashboard-ui/scripts/notifications.js +++ b/dashboard-ui/scripts/notifications.js @@ -226,23 +226,28 @@ } }); - function initializeApiClient(apiClient) { - $(apiClient).on("websocketmessage", function (e, msg) { + function onWebSocketMessage(e, msg) { + if (msg.MessageType === "NotificationUpdated" || msg.MessageType === "NotificationAdded" || msg.MessageType === "NotificationsMarkedRead") { + Notifications.getNotificationsSummaryPromise = null; - if (msg.MessageType === "NotificationUpdated" || msg.MessageType === "NotificationAdded" || msg.MessageType === "NotificationsMarkedRead") { - - Notifications.getNotificationsSummaryPromise = null; - - Notifications.updateNotificationCount(); - } - - }); + Notifications.updateNotificationCount(); + } } - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + function initializeApiClient(apiClient) { + $(apiClient).off("websocketmessage", onWebSocketMessage).on("websocketmessage", onWebSocketMessage); + } - initializeApiClient(apiClient); + Dashboard.ready(function () { + + if (window.ApiClient) { + initializeApiClient(window.ApiClient); + } + + $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + initializeApiClient(apiClient); + }); }); })(jQuery, document, Dashboard, LibraryBrowser); \ No newline at end of file diff --git a/dashboard-ui/scripts/nowplayingbar.js b/dashboard-ui/scripts/nowplayingbar.js index 7b10ba9f40..5dd5b6b52f 100644 --- a/dashboard-ui/scripts/nowplayingbar.js +++ b/dashboard-ui/scripts/nowplayingbar.js @@ -442,7 +442,7 @@ .on('positionchange.nowplayingbar', onStateChanged); } - $(function () { + Dashboard.ready(function () { $(MediaController).on('playerchange', function () { diff --git a/dashboard-ui/scripts/photos.js b/dashboard-ui/scripts/photos.js index d6cfe094d4..b70f8da90f 100644 --- a/dashboard-ui/scripts/photos.js +++ b/dashboard-ui/scripts/photos.js @@ -277,7 +277,7 @@ reloadItems(page); }); - }).on('pageshown', "#photosPage", function () { + }).on('pageshowready', "#photosPage", function () { var page = this; diff --git a/dashboard-ui/scripts/remotecontrol.js b/dashboard-ui/scripts/remotecontrol.js index c5973906b0..af1a10264a 100644 --- a/dashboard-ui/scripts/remotecontrol.js +++ b/dashboard-ui/scripts/remotecontrol.js @@ -355,9 +355,15 @@ $(apiClient).on("websocketmessage", onWebSocketMessageReceived).on("websocketopen", onWebSocketConnectionChange); } - $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + Dashboard.ready(function () { - initializeApiClient(apiClient); + if (window.ApiClient) { + initializeApiClient(window.ApiClient); + } + + $(ConnectionManager).on('apiclientcreated', function (e, apiClient) { + initializeApiClient(apiClient); + }); }); })(window, document, jQuery); \ No newline at end of file diff --git a/dashboard-ui/scripts/reports.js b/dashboard-ui/scripts/reports.js index e68b1276d9..bd136ac2d7 100644 --- a/dashboard-ui/scripts/reports.js +++ b/dashboard-ui/scripts/reports.js @@ -478,7 +478,7 @@ } - $(document).on('pageinit', "#libraryReportManagerPage", function () { + $(document).on('pageinitdepends', "#libraryReportManagerPage", function () { var page = this; @@ -781,7 +781,7 @@ reloadItems(page); }); }) - .on('pagebeforeshow', "#libraryReportManagerPage", function () { + .on('pageshowready', "#libraryReportManagerPage", function () { query.UserId = Dashboard.getCurrentUserId(); var page = this; @@ -791,11 +791,6 @@ QueryReportColumns.onPageShow(page, query); $('#selectView', page).val(query.IncludeItemTypes).selectmenu('refresh').trigger('change'); - }) - .on('pageshow', "#libraryReportManagerPage", function () { - - var page = this; - updateFilterControls(page); filtersLoaded = false; diff --git a/dashboard-ui/scripts/selectserver.js b/dashboard-ui/scripts/selectserver.js index 71f91e5ee3..96b256c596 100644 --- a/dashboard-ui/scripts/selectserver.js +++ b/dashboard-ui/scripts/selectserver.js @@ -62,7 +62,7 @@ html += '
'; - var href = "#"; + var href = server.href || "#"; html += ''; var imgUrl = server.Id == 'connect' ? 'css/images/logo536.png' : ''; @@ -84,20 +84,22 @@ // cardScalable html += "
"; - html += '
'; + html += '
'; if (server.showOptions !== false) { html += '
'; - - html += ''; - + html += ''; html += "
"; } - html += '
'; + html += '
'; html += server.Name; html += "
"; + html += '
'; + html += ' '; + html += "
"; + // cardFooter html += "
"; @@ -128,21 +130,15 @@ var id = this.getAttribute('data-serverid'); - if (id == 'new') { - Dashboard.navigate('connectlogin.html?mode=manualserver'); - return; + if (id != 'new' && id != 'connect') { + + var server = servers.filter(function (s) { + return s.Id == id; + })[0]; + + connectToServer(page, server); } - if (id == 'connect') { - Dashboard.navigate('connectlogin.html?mode=connect'); - return; - } - - var server = servers.filter(function (s) { - return s.Id == id; - })[0]; - - connectToServer(page, server); }); $('.btnServerMenu', elem).on('click', function () { @@ -312,17 +308,20 @@ // cardScalable html += "
"; - html += '
'; + html += '
'; html += '
'; - - html += ''; + html += ''; html += "
"; - html += '
'; + html += '
'; html += invite.Name; html += "
"; + html += '
'; + html += ' '; + html += "
"; + // cardFooter html += "
"; @@ -383,15 +382,8 @@ servers.push({ Name: Globalize.translate('ButtonNewServer'), Id: 'new', - showOptions: false - }); - } - - if (!ConnectionManager.isLoggedIntoConnect()) { - servers.push({ - Name: Globalize.translate('ButtonSignInWithConnect'), - Id: 'connect', - showOptions: false + showOptions: false, + href: 'connectlogin.html?mode=manualserver' }); } @@ -401,10 +393,16 @@ }); loadInvitations(page); + + if (ConnectionManager.isLoggedIntoConnect()) { + $('.connectLogin', page).hide(); + } else { + $('.connectLogin', page).show(); + } } function updatePageStyle(page) { - + if (ConnectionManager.isLoggedIntoConnect()) { $(page).addClass('libraryPage').addClass('noSecondaryNavPage').removeClass('standalonePage'); } else { @@ -412,12 +410,12 @@ } } - $(document).on('pagebeforecreate pageinit pagebeforeshow', "#selectServerPage", function () { + $(document).on('pageinitdepends pagebeforeshowready', "#selectServerPage", function () { var page = this; updatePageStyle(page); - }).on('pagebeforeshow', "#selectServerPage", function () { + }).on('pageshowready', "#selectServerPage", function () { var page = this; @@ -425,21 +423,4 @@ }); - window.SelectServerPage = { - - onServerAddressEntrySubmit: function () { - - Dashboard.showLoadingMsg(); - - var form = this; - var page = $(form).parents('.page'); - - - // Disable default form submission - return false; - - } - - }; - })(); \ No newline at end of file diff --git a/dashboard-ui/scripts/serversecurity.js b/dashboard-ui/scripts/serversecurity.js index 1899fe9fe1..255ead936a 100644 --- a/dashboard-ui/scripts/serversecurity.js +++ b/dashboard-ui/scripts/serversecurity.js @@ -133,7 +133,7 @@ $('.newKeyForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#serverSecurityPage", function () { + }).on('pageshowready', "#serverSecurityPage", function () { var page = this; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 9c591f5390..847a6a33a7 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -106,7 +106,9 @@ var Dashboard = { onApiClientServerAddressChanged: function () { - Dashboard.serverAddress(ApiClient.serverAddress()); + var apiClient = this; + + Dashboard.serverAddress(apiClient.serverAddress()); }, getCurrentUser: function () { @@ -200,7 +202,7 @@ var Dashboard = { Dashboard.getUserPromise = null; }, - logout: function (logoutWithServer) { + logout: function (logoutWithServer, forceReload) { store.removeItem("userId"); store.removeItem("token"); @@ -208,16 +210,20 @@ var Dashboard = { function onLogoutDone() { - var loginPage = 'login.html'; + var loginPage; if (Dashboard.isConnectMode()) { loginPage = 'connectlogin.html'; window.ApiClient = null; } else { - + loginPage = 'login.html'; } - Dashboard.navigate(loginPage); + if (forceReload) { + window.location.href = loginPage; + } else { + Dashboard.navigate(loginPage); + } } if (logoutWithServer === false) { @@ -697,14 +703,23 @@ var Dashboard = { getPluginSecurityInfo: function () { + var apiClient = ApiClient; + + if (!apiClient) { + + var deferred = $.Deferred(); + deferred.reject(); + return deferred.promise(); + } + if (!Dashboard.getPluginSecurityInfoPromise) { var deferred = $.Deferred(); // Don't let this blow up the dashboard when it fails - ApiClient.ajax({ + apiClient.ajax({ type: "GET", - url: ApiClient.getUrl("Plugins/SecurityInfo"), + url: apiClient.getUrl("Plugins/SecurityInfo"), dataType: 'json', error: function () { @@ -1393,7 +1408,7 @@ var Dashboard = { } else { - quality -= 50; + quality -= 40; } } @@ -1413,7 +1428,7 @@ var Dashboard = { } }, - getAppInfo: function () { + getAppInfo: function (appName, deviceId, deviceName) { function generateDeviceName() { @@ -1446,29 +1461,13 @@ var Dashboard = { } var appVersion = window.dashboardVersion; - var appName = "Emby Web Client"; - - var deviceName; - var deviceId; - - if (Dashboard.isRunningInCordova()) { - - appName = "Emby Mobile"; - - deviceName = store.getItem('cordovaDeviceName'); - deviceId = store.getItem('cordovaDeviceId'); - } + appName = appName || "Emby Web Client"; deviceName = deviceName || generateDeviceName(); var seed = []; var keyName = 'randomId'; - if (Dashboard.isRunningInCordova()) { - seed.push('cordova'); - keyName = 'cordovaDeviceId'; - } - deviceId = deviceId || MediaBrowser.generateDeviceId(keyName, seed.join(',')); return { @@ -1501,6 +1500,23 @@ var Dashboard = { } Dashboard.setCurrentUser(userId, accessToken); + }, + + ready: function(fn) { + + if (Dashboard.initPromiseDone) { + fn(); + return; + } + + Dashboard.initPromise.done(fn); + }, + + firePageEvent: function (page, name) { + + Dashboard.ready(function () { + $(page).trigger(name); + }); } }; @@ -1516,7 +1532,7 @@ var AppInfo = {}; function setAppInfo() { - if (isTouchDevice() && $.browser.mobile) { + if (isTouchDevice()) { AppInfo.isTouchPreferred = true; } @@ -1561,7 +1577,6 @@ var AppInfo = {}; AppInfo.enablePeopleTabs = true; AppInfo.enableTvEpisodesTab = true; AppInfo.enableMusicArtistsTab = true; - AppInfo.enableHomeLatestTab = true; AppInfo.enableMovieTrailersTab = true; } @@ -1582,9 +1597,7 @@ var AppInfo = {}; .on('serveraddresschanged.dashboard', Dashboard.onApiClientServerAddressChanged); } - function createConnectionManager() { - - var appInfo = Dashboard.getAppInfo(); + function createConnectionManager(appInfo) { var credentialProvider = new MediaBrowser.CredentialProvider(); @@ -1653,7 +1666,7 @@ var AppInfo = {}; } - function onReady() { + function onDocumentReady() { if (AppInfo.isTouchPreferred) { $(document.body).addClass('touch'); @@ -1691,10 +1704,6 @@ var AppInfo = {}; $(document.body).addClass('musicArtistsTabDisabled'); } - if (!AppInfo.enableHomeLatestTab) { - $(document.body).addClass('homeLatestTabDisabled'); - } - if (!AppInfo.enableMovieTrailersTab) { $(document.body).addClass('movieTrailersTabDisabled'); } @@ -1818,7 +1827,7 @@ var AppInfo = {}; }); if (Dashboard.isRunningInCordova()) { - requirejs(['thirdparty/cordova/connectsdk']); + requirejs(['thirdparty/cordova/connectsdk', 'thirdparty/cordova/remotecontrols']); } else { if ($.browser.chrome) { requirejs(['scripts/chromecast']); @@ -1826,38 +1835,64 @@ var AppInfo = {}; } } - requirejs.config({ - map: { - '*': { - 'css': 'thirdparty/requirecss' // or whatever the path to require-css is - } - }, - urlArgs: "v=" + window.dashboardVersion - }); + function init(deferred, appName, deviceId, deviceName) { - // Required since jQuery is loaded before requireJs - define('jquery', [], function () { - return jQuery; - }); + requirejs.config({ + map: { + '*': { + 'css': 'thirdparty/requirecss' // or whatever the path to require-css is + } + }, + urlArgs: "v=" + window.dashboardVersion + }); - setAppInfo(); - createConnectionManager(); + // Required since jQuery is loaded before requireJs + define('jquery', [], function () { + return jQuery; + }); - if (Dashboard.isRunningInCordova()) { + setAppInfo(); + + var appInfo = Dashboard.getAppInfo(appName, deviceId, deviceName); + + createConnectionManager(appInfo); + + Dashboard.initPromiseDone = true; + deferred.resolve(); + $(onDocumentReady); + } + + function initCordovaWithDeviceId(deferred, deviceId) { + if ($.browser.safari) { + requirejs(['thirdparty/cordova/imagestore.js']); + } + + init(deferred, "Emby Mobile", deviceId, device.model); + } + + function initCordova(deferred) { document.addEventListener("deviceready", function () { - if ($.browser.safari) { - requirejs(['thirdparty/cordova/imagestore.js']); - } + window.plugins.uniqueDeviceID.get(function (uuid) { - $(onReady); + initCordovaWithDeviceId(deferred, uuid); + }, function () { + + // Failure. Use cordova uuid + initCordovaWithDeviceId(deferred, device.uuid); + }); }, false); + } + var initDeferred = $.Deferred(); + Dashboard.initPromise = initDeferred.promise(); + + if (Dashboard.isRunningInCordova()) { + initCordova(initDeferred); } else { - - $(onReady); + init(initDeferred); } })(); @@ -1903,10 +1938,10 @@ $(document).on('pagecreate', ".page", function () { if (require) { requirejs(require.split(','), function () { - $(page).trigger('pageinitdepends'); + Dashboard.firePageEvent(page, 'pageinitdepends'); }); } else { - $(page).trigger('pageinitdepends'); + Dashboard.firePageEvent(page, 'pageinitdepends'); } $('.localnav a, .libraryViewNav a').attr('data-transition', 'none'); @@ -1914,16 +1949,29 @@ $(document).on('pagecreate', ".page", function () { }).on('pageshow', ".page", function () { var page = this; - var require = this.getAttribute('data-require'); if (require) { requirejs(require.split(','), function () { - $(page).trigger('pageshown'); + Dashboard.firePageEvent(page, 'pageshowready'); }); } else { - $(page).trigger('pageshown'); + Dashboard.firePageEvent(page, 'pageshowready'); + } + +}).on('pagebeforeshow', ".page", function () { + + var page = this; + var require = this.getAttribute('data-require'); + + if (require) { + requirejs(require.split(','), function () { + + Dashboard.firePageEvent(page, 'pagebeforeshowready'); + }); + } else { + Dashboard.firePageEvent(page, 'pagebeforeshowready'); } }).on('pagebeforeshow', ".page", function () { @@ -1961,7 +2009,7 @@ $(document).on('pagecreate', ".page", function () { if (isConnectMode) { if (!Dashboard.isServerlessPage()) { - Dashboard.logout(); + Dashboard.logout(true, true); return; } } @@ -1969,7 +2017,7 @@ $(document).on('pagecreate', ".page", function () { if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) { console.log('Not logged into server. Redirecting to login.'); - Dashboard.logout(); + Dashboard.logout(true, true); return; } diff --git a/dashboard-ui/scripts/songs.js b/dashboard-ui/scripts/songs.js index ff9af83ede..89183596c4 100644 --- a/dashboard-ui/scripts/songs.js +++ b/dashboard-ui/scripts/songs.js @@ -174,7 +174,7 @@ reloadItems(page); }); - }).on('pageshown', "#songsPage", function () { + }).on('pageshowready', "#songsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/streamingsettings.js b/dashboard-ui/scripts/streamingsettings.js index 2c05789519..bdb2217a7b 100644 --- a/dashboard-ui/scripts/streamingsettings.js +++ b/dashboard-ui/scripts/streamingsettings.js @@ -49,7 +49,7 @@ $('.streamingSettingsForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#streamingSettingsPage", function () { + }).on('pageshowready', "#streamingSettingsPage", function () { Dashboard.showLoadingMsg(); diff --git a/dashboard-ui/scripts/supporterpage.js b/dashboard-ui/scripts/supporterpage.js index 48a32696ee..f6513152ab 100644 --- a/dashboard-ui/scripts/supporterpage.js +++ b/dashboard-ui/scripts/supporterpage.js @@ -176,7 +176,7 @@ $('.supporterForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#supporterPage", function () { + }).on('pageshowready', "#supporterPage", function () { var page = this; diff --git a/dashboard-ui/scripts/tvgenres.js b/dashboard-ui/scripts/tvgenres.js index ef55d3a9f5..bb0e98c8ce 100644 --- a/dashboard-ui/scripts/tvgenres.js +++ b/dashboard-ui/scripts/tvgenres.js @@ -169,7 +169,7 @@ LibraryBrowser.saveViewSetting(getSavedQueryKey(), view); }); - }).on('pageshown', "#tvGenresPage", function () { + }).on('pageshowready', "#tvGenresPage", function () { query.ParentId = LibraryMenu.getTopParentId(); var page = this; diff --git a/dashboard-ui/scripts/tvlatest.js b/dashboard-ui/scripts/tvlatest.js index a48a01e6b9..4bb3c7b5ca 100644 --- a/dashboard-ui/scripts/tvlatest.js +++ b/dashboard-ui/scripts/tvlatest.js @@ -9,7 +9,7 @@ return 'Thumb'; } - $(document).on('pageshown', "#tvNextUpPage", function () { + $(document).on('pageshowready', "#tvNextUpPage", function () { var userId = Dashboard.getCurrentUserId(); diff --git a/dashboard-ui/scripts/tvpeople.js b/dashboard-ui/scripts/tvpeople.js index c26a242f1a..f846e679f9 100644 --- a/dashboard-ui/scripts/tvpeople.js +++ b/dashboard-ui/scripts/tvpeople.js @@ -147,7 +147,7 @@ reloadItems(page); }); - }).on('pageshown', "#tvPeoplePage", function () { + }).on('pageshowready', "#tvPeoplePage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index 9c3e03983d..3fda9532ef 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -182,7 +182,7 @@ }); } - $(document).on('pageshown', "#tvRecommendedPage", function () { + $(document).on('pageshowready', "#tvRecommendedPage", function () { var page = this; diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index 33ec3a8eb4..1a32df1f96 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -360,7 +360,7 @@ reloadItems(page); }); - }).on('pageshown', "#tvShowsPage", function () { + }).on('pageshowready', "#tvShowsPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/tvstudios.js b/dashboard-ui/scripts/tvstudios.js index d252ff76af..1fea2042de 100644 --- a/dashboard-ui/scripts/tvstudios.js +++ b/dashboard-ui/scripts/tvstudios.js @@ -108,7 +108,7 @@ reloadItems(page); }); - }).on('pageshown', "#tvStudiosPage", function () { + }).on('pageshowready', "#tvStudiosPage", function () { query.ParentId = LibraryMenu.getTopParentId(); diff --git a/dashboard-ui/scripts/tvupcoming.js b/dashboard-ui/scripts/tvupcoming.js index 55aa397256..810217b598 100644 --- a/dashboard-ui/scripts/tvupcoming.js +++ b/dashboard-ui/scripts/tvupcoming.js @@ -1,6 +1,6 @@ (function ($, document) { - $(document).on('pageshown', "#tvUpcomingPage", function () { + $(document).on('pageshowready', "#tvUpcomingPage", function () { var page = this; diff --git a/dashboard-ui/scripts/usernew.js b/dashboard-ui/scripts/usernew.js index 8350273979..b55215e6b4 100644 --- a/dashboard-ui/scripts/usernew.js +++ b/dashboard-ui/scripts/usernew.js @@ -151,7 +151,7 @@ $('.newUserProfileForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#newUserPage", function () { + }).on('pageshowready', "#newUserPage", function () { var page = this; diff --git a/dashboard-ui/scripts/wizardsettings.js b/dashboard-ui/scripts/wizardsettings.js index 37115d56a6..f3d184a6df 100644 --- a/dashboard-ui/scripts/wizardsettings.js +++ b/dashboard-ui/scripts/wizardsettings.js @@ -84,7 +84,7 @@ $('.wizardSettingsForm', page).off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#wizardSettingsPage", function () { + }).on('pageshowready', "#wizardSettingsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/wizarduserpage.js b/dashboard-ui/scripts/wizarduserpage.js index 76fa74d886..23d1ef1346 100644 --- a/dashboard-ui/scripts/wizarduserpage.js +++ b/dashboard-ui/scripts/wizarduserpage.js @@ -60,7 +60,7 @@ $('.wizardUserForm').off('submit', onSubmit).on('submit', onSubmit); - }).on('pageshown', "#wizardUserPage", function () { + }).on('pageshowready', "#wizardUserPage", function () { Dashboard.showLoadingMsg(); diff --git a/dashboard-ui/selectserver.html b/dashboard-ui/selectserver.html index 710c2d7435..77cb46cbd2 100644 --- a/dashboard-ui/selectserver.html +++ b/dashboard-ui/selectserver.html @@ -4,7 +4,7 @@ Emby -
+
@@ -24,6 +24,15 @@ ${MessageNoServersAvailableToConnect}
+
+