From 14a7a422568f3c7fa20e304facd654ad9f03ddd3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 13 Jan 2014 11:25:18 -0500 Subject: [PATCH] save web client view selection --- dashboard-ui/scripts/episodes.js | 2 -- dashboard-ui/scripts/gamespage.js | 2 -- dashboard-ui/scripts/itemlistpage.js | 18 +++++++++++++++--- dashboard-ui/scripts/librarybrowser.js | 14 ++++++++++++++ dashboard-ui/scripts/movies.js | 11 ++++++++++- dashboard-ui/scripts/movietrailers.js | 18 +++++++----------- dashboard-ui/scripts/musicalbums.js | 13 +++++++++++-- dashboard-ui/scripts/musicvideos.js | 2 -- dashboard-ui/scripts/tvshows.js | 11 ++++++++++- 9 files changed, 67 insertions(+), 24 deletions(-) diff --git a/dashboard-ui/scripts/episodes.js b/dashboard-ui/scripts/episodes.js index 6c56e8a44f..7c53ddb15e 100644 --- a/dashboard-ui/scripts/episodes.js +++ b/dashboard-ui/scripts/episodes.js @@ -1,7 +1,5 @@ (function ($, document) { - var view = "Poster"; - // The base query options var query = { diff --git a/dashboard-ui/scripts/gamespage.js b/dashboard-ui/scripts/gamespage.js index e86adbf3e5..6b8b78023d 100644 --- a/dashboard-ui/scripts/gamespage.js +++ b/dashboard-ui/scripts/gamespage.js @@ -1,8 +1,6 @@ (function ($, document) { - var view = "Poster"; - // The base query options var query = { diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js index 2040816f41..605b3624c0 100644 --- a/dashboard-ui/scripts/itemlistpage.js +++ b/dashboard-ui/scripts/itemlistpage.js @@ -178,6 +178,8 @@ view = this.value; reloadItems(page); + + LibraryBrowser.saveViewSetting(getParameterByName('parentId'), view); }); $('#btnEdit', page).on('click', function () { @@ -201,6 +203,8 @@ }).on('pageshow', "#itemListPage", function () { + var page = this; + query.Limit = LibraryBrowser.getDefaultPageSize(); query.ParentId = getParameterByName('parentId'); query.Filters = ""; @@ -209,11 +213,19 @@ query.StartIndex = 0; query.NameStartsWithOrGreater = ''; - LibraryBrowser.loadSavedQueryValues(getParameterByName('parentId'), query); + var key = getParameterByName('parentId'); + LibraryBrowser.loadSavedQueryValues(key, query); - reloadItems(this); + LibraryBrowser.getSavedViewSetting(key).done(function (val) { - updateFilterControls(this); + if (val) { + $('#selectView', page).val(val).selectmenu('refresh').trigger('change'); + } else { + reloadItems(page); + } + }); + + updateFilterControls(page); }).on('pagehide', "#itemListPage", function () { diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index b36ca3d368..fffb13b349 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -45,6 +45,20 @@ localStorage.setItem(key + '_' + Dashboard.getCurrentUserId(), JSON.stringify(values)); }, + + saveViewSetting: function(key, value) { + + localStorage.setItem(key + '_' + Dashboard.getCurrentUserId() + '_view', value); + }, + + getSavedViewSetting: function (key) { + + var deferred = $.Deferred(); + var val = localStorage.getItem(key + '_' + Dashboard.getCurrentUserId() + '_view'); + + deferred.resolveWith(null, [val]); + return deferred.promise(); + }, getDateParamValue: function (date) { diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js index 8f528a6c36..ac04a353b0 100644 --- a/dashboard-ui/scripts/movies.js +++ b/dashboard-ui/scripts/movies.js @@ -212,6 +212,7 @@ reloadItems(page); } + LibraryBrowser.saveViewSetting('movies', view); }); $('#chk3D', this).on('change', function () { @@ -346,6 +347,7 @@ }).on('pagebeforeshow', "#moviesPage", function () { + var page = this; var limit = LibraryBrowser.getDefaultPageSize(); // If the default page size has changed, the start index will have to be reset @@ -356,7 +358,14 @@ LibraryBrowser.loadSavedQueryValues('movies', query); - reloadItems(this); + LibraryBrowser.getSavedViewSetting('movies').done(function (val) { + + if (val) { + $('#selectView', page).val(val).selectmenu('refresh').trigger('change'); + } else { + reloadItems(page); + } + }); }).on('pageshow', "#moviesPage", function () { diff --git a/dashboard-ui/scripts/movietrailers.js b/dashboard-ui/scripts/movietrailers.js index d911b81fe4..0fb1f9d12a 100644 --- a/dashboard-ui/scripts/movietrailers.js +++ b/dashboard-ui/scripts/movietrailers.js @@ -1,7 +1,5 @@ (function ($, document) { - var view = "Poster"; - // The base query options var query = { @@ -31,15 +29,13 @@ var checkSortOption = $('.radioSortBy:checked', page); $('.viewSummary', page).html(LibraryBrowser.getViewSummaryHtml(query, checkSortOption)).trigger('create'); - if (view == "Poster") { - html = LibraryBrowser.getPosterViewHtml({ - items: result.Items, - shape: "portrait", - context: 'movies', - useAverageAspectRatio: true, - showTitle: true - }); - } + html = LibraryBrowser.getPosterViewHtml({ + items: result.Items, + shape: "portrait", + context: 'movies', + useAverageAspectRatio: true, + showTitle: true + }); html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); diff --git a/dashboard-ui/scripts/musicalbums.js b/dashboard-ui/scripts/musicalbums.js index 1cda3cbf7b..718474ef71 100644 --- a/dashboard-ui/scripts/musicalbums.js +++ b/dashboard-ui/scripts/musicalbums.js @@ -165,6 +165,7 @@ } else { reloadItems(page); } + LibraryBrowser.saveViewSetting('musicalbums', view); }); $('.alphabetPicker', page).on('alphaselect', function (e, character) { @@ -191,8 +192,9 @@ }).on('pagebeforeshow', "#musicAlbumsPage", function () { + var page = this; var limit = LibraryBrowser.getDefaultPageSize(); - + // If the default page size has changed, the start index will have to be reset if (limit != query.Limit) { query.Limit = limit; @@ -201,7 +203,14 @@ LibraryBrowser.loadSavedQueryValues('musicalbums', query); - reloadItems(this); + LibraryBrowser.getSavedViewSetting('musicalbums').done(function (val) { + + if (val) { + $('#selectView', page).val(val).selectmenu('refresh').trigger('change'); + } else { + reloadItems(page); + } + }); }).on('pageshow', "#musicAlbumsPage", function () { diff --git a/dashboard-ui/scripts/musicvideos.js b/dashboard-ui/scripts/musicvideos.js index ffb70c1bd9..abbe0427fe 100644 --- a/dashboard-ui/scripts/musicvideos.js +++ b/dashboard-ui/scripts/musicvideos.js @@ -1,7 +1,5 @@ (function ($, document) { - var view = "Poster"; - // The base query options var query = { diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index 9b6196c47f..7fb5ec78c4 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -233,6 +233,7 @@ } else { reloadItems(page); } + LibraryBrowser.saveViewSetting('tvshows', view); }); $('#chkTrailer', this).on('change', function () { @@ -335,6 +336,7 @@ }).on('pagebeforeshow', "#tvShowsPage", function () { + var page = this; var limit = LibraryBrowser.getDefaultPageSize(); // If the default page size has changed, the start index will have to be reset @@ -345,7 +347,14 @@ LibraryBrowser.loadSavedQueryValues('tvshows', query); - reloadItems(this); + LibraryBrowser.getSavedViewSetting('tvshows').done(function (val) { + + if (val) { + $('#selectView', page).val(val).selectmenu('refresh').trigger('change'); + } else { + reloadItems(page); + } + }); }).on('pageshow', "#tvShowsPage", function () {