diff --git a/dashboard-ui/scripts/boxsets.js b/dashboard-ui/scripts/boxsets.js index c8909a6f69..28c47f3dc6 100644 --- a/dashboard-ui/scripts/boxsets.js +++ b/dashboard-ui/scripts/boxsets.js @@ -60,8 +60,6 @@ var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); - $('.radioSortBy', this).on('click', function () { query.SortBy = this.getAttribute('data-sortby'); reloadItems(page); @@ -115,6 +113,14 @@ }).on('pagebeforeshow', "#boxsetsPage", function () { + 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; + query.StartIndex = 0; + } + reloadItems(this); }).on('pageshow', "#boxsetsPage", function () { diff --git a/dashboard-ui/scripts/gamegenrepage.js b/dashboard-ui/scripts/gamegenrepage.js index e973e926e8..9da9b25e5f 100644 --- a/dashboard-ui/scripts/gamegenrepage.js +++ b/dashboard-ui/scripts/gamegenrepage.js @@ -1,115 +1,121 @@ (function ($, document) { - // The base query options - var query = { + // The base query options + var query = { - SortBy: "SortName", - SortOrder: "Ascending", - MediaTypes: "Game", - Recursive: true, - Fields: "ItemCounts,DateCreated,UserData", - StartIndex: 0 - }; + SortBy: "SortName", + SortOrder: "Ascending", + MediaTypes: "Game", + Recursive: true, + Fields: "ItemCounts,DateCreated,UserData", + StartIndex: 0 + }; - function reloadItems(page) { + function reloadItems(page) { - Dashboard.showLoadingMsg(); + Dashboard.showLoadingMsg(); - ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { - var html = ''; + var html = ''; - $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); + $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); - html += LibraryBrowser.getPosterDetailViewHtml({ - items: result.Items, - countNameSingular: "Game", - countNamePlural: "Games", - context: "games" - }); + html += LibraryBrowser.getPosterDetailViewHtml({ + items: result.Items, + countNameSingular: "Game", + countNamePlural: "Games", + context: "games" + }); - html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); - $('#items', page).html(html).trigger('create'); + $('#items', page).html(html).trigger('create'); - $('.selectPage', page).on('change', function () { - query.StartIndex = (parseInt(this.value) - 1) * query.Limit; - reloadItems(page); - }); + $('.selectPage', page).on('change', function () { + query.StartIndex = (parseInt(this.value) - 1) * query.Limit; + reloadItems(page); + }); - $('.btnNextPage', page).on('click', function () { - query.StartIndex += query.Limit; - reloadItems(page); - }); + $('.btnNextPage', page).on('click', function () { + query.StartIndex += query.Limit; + reloadItems(page); + }); - $('.btnPreviousPage', page).on('click', function () { - query.StartIndex -= query.Limit; - reloadItems(page); - }); + $('.btnPreviousPage', page).on('click', function () { + query.StartIndex -= query.Limit; + reloadItems(page); + }); - $('.selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); + $('.selectPageSize', page).on('change', function () { + query.Limit = parseInt(this.value); + query.StartIndex = 0; + reloadItems(page); + }); - Dashboard.hideLoadingMsg(); - }); - } + Dashboard.hideLoadingMsg(); + }); + } - $(document).on('pageinit', "#gameGenresPage", function () { + $(document).on('pageinit', "#gameGenresPage", function () { - var page = this; + var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); + $('.radioSortBy', this).on('click', function () { + query.SortBy = this.getAttribute('data-sortby'); + query.StartIndex = 0; + reloadItems(page); + }); - $('.radioSortBy', this).on('click', function () { - query.SortBy = this.getAttribute('data-sortby'); - query.StartIndex = 0; - reloadItems(page); - }); + $('.radioSortOrder', this).on('click', function () { + query.SortOrder = this.getAttribute('data-sortorder'); + query.StartIndex = 0; + reloadItems(page); + }); - $('.radioSortOrder', this).on('click', function () { - query.SortOrder = this.getAttribute('data-sortorder'); - query.StartIndex = 0; - reloadItems(page); - }); + $('.chkStandardFilter', this).on('change', function () { - $('.chkStandardFilter', this).on('change', function () { + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; + filters = (',' + filters).replace(',' + filterName, '').substring(1); - filters = (',' + filters).replace(',' + filterName, '').substring(1); + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } + query.StartIndex = 0; + query.Filters = filters; - query.StartIndex = 0; - query.Filters = filters; + reloadItems(page); + }); - reloadItems(page); - }); + }).on('pagebeforeshow', "#gameGenresPage", function () { - }).on('pagebeforeshow', "#gameGenresPage", function () { + var limit = LibraryBrowser.getDefaultPageSize(); - reloadItems(this); + // If the default page size has changed, the start index will have to be reset + if (limit != query.Limit) { + query.Limit = limit; + query.StartIndex = 0; + } - }).on('pageshow', "#gameGenresPage", function () { + reloadItems(this); - // Reset form values using the last used query - $('.radioSortBy', this).each(function () { + }).on('pageshow', "#gameGenresPage", function () { - this.checked = query.SortBy == this.getAttribute('data-sortby'); + // Reset form values using the last used query + $('.radioSortBy', this).each(function () { - }).checkboxradio('refresh'); + this.checked = query.SortBy == this.getAttribute('data-sortby'); - $('.radioSortOrder', this).each(function () { + }).checkboxradio('refresh'); - this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + $('.radioSortOrder', this).each(function () { - }).checkboxradio('refresh'); - }); + this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + + }).checkboxradio('refresh'); + }); })(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/gamespage.js b/dashboard-ui/scripts/gamespage.js index ad5b195203..bde9a20713 100644 --- a/dashboard-ui/scripts/gamespage.js +++ b/dashboard-ui/scripts/gamespage.js @@ -84,8 +84,6 @@ var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); - $('.radioSortBy', this).on('click', function () { query.StartIndex = 0; query.SortBy = this.getAttribute('data-sortby'); @@ -156,6 +154,14 @@ }).on('pagebeforeshow', "#gamesPage", function () { + 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; + query.StartIndex = 0; + } + reloadItems(this); }).on('pageshow', "#gamesPage", function () { diff --git a/dashboard-ui/scripts/gamestudiospage.js b/dashboard-ui/scripts/gamestudiospage.js index 7b9ced7af1..7ee5c0de9a 100644 --- a/dashboard-ui/scripts/gamestudiospage.js +++ b/dashboard-ui/scripts/gamestudiospage.js @@ -1,116 +1,122 @@ (function ($, document) { - // The base query options - var query = { + // The base query options + var query = { - SortBy: "SortName", - SortOrder: "Ascending", - MediaTypes: "Game", - Recursive: true, - Fields: "ItemCounts,DateCreated,UserData", - StartIndex: 0 - }; + SortBy: "SortName", + SortOrder: "Ascending", + MediaTypes: "Game", + Recursive: true, + Fields: "ItemCounts,DateCreated,UserData", + StartIndex: 0 + }; - function reloadItems(page) { + function reloadItems(page) { - Dashboard.showLoadingMsg(); + Dashboard.showLoadingMsg(); - ApiClient.getStudios(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getStudios(Dashboard.getCurrentUserId(), query).done(function (result) { - var html = ''; + var html = ''; - $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); + $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); - html += LibraryBrowser.getPosterDetailViewHtml({ - items: result.Items, - countNameSingular: "Game", - countNamePlural: "Games", - context: "games" - }); + html += LibraryBrowser.getPosterDetailViewHtml({ + items: result.Items, + countNameSingular: "Game", + countNamePlural: "Games", + context: "games" + }); - html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); - $('#items', page).html(html).trigger('create'); + $('#items', page).html(html).trigger('create'); - $('.selectPage', page).on('change', function () { - query.StartIndex = (parseInt(this.value) - 1) * query.Limit; - reloadItems(page); - }); + $('.selectPage', page).on('change', function () { + query.StartIndex = (parseInt(this.value) - 1) * query.Limit; + reloadItems(page); + }); - $('.btnNextPage', page).on('click', function () { - query.StartIndex += query.Limit; - reloadItems(page); - }); + $('.btnNextPage', page).on('click', function () { + query.StartIndex += query.Limit; + reloadItems(page); + }); - $('.btnPreviousPage', page).on('click', function () { - query.StartIndex -= query.Limit; - reloadItems(page); - }); + $('.btnPreviousPage', page).on('click', function () { + query.StartIndex -= query.Limit; + reloadItems(page); + }); - $('.selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); + $('.selectPageSize', page).on('change', function () { + query.Limit = parseInt(this.value); + query.StartIndex = 0; + reloadItems(page); + }); - Dashboard.hideLoadingMsg(); - }); - } + Dashboard.hideLoadingMsg(); + }); + } - $(document).on('pageinit', "#gameStudiosPage", function () { + $(document).on('pageinit', "#gameStudiosPage", function () { - var page = this; + var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); + $('.radioSortBy', this).on('click', function () { + query.SortBy = this.getAttribute('data-sortby'); + query.StartIndex = 0; + reloadItems(page); + }); - $('.radioSortBy', this).on('click', function () { - query.SortBy = this.getAttribute('data-sortby'); - query.StartIndex = 0; - reloadItems(page); - }); + $('.radioSortOrder', this).on('click', function () { + query.SortOrder = this.getAttribute('data-sortorder'); + query.StartIndex = 0; + reloadItems(page); + }); - $('.radioSortOrder', this).on('click', function () { - query.SortOrder = this.getAttribute('data-sortorder'); - query.StartIndex = 0; - reloadItems(page); - }); + $('.chkStandardFilter', this).on('change', function () { - $('.chkStandardFilter', this).on('change', function () { + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; + filters = (',' + filters).replace(',' + filterName, '').substring(1); - filters = (',' + filters).replace(',' + filterName, '').substring(1); + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } + query.StartIndex = 0; + query.Filters = filters; - query.StartIndex = 0; - query.Filters = filters; + reloadItems(page); + }); - reloadItems(page); - }); + }).on('pagebeforeshow', "#gameStudiosPage", function () { - }).on('pagebeforeshow', "#gameStudiosPage", function () { + var limit = LibraryBrowser.getDefaultPageSize(); - reloadItems(this); + // If the default page size has changed, the start index will have to be reset + if (limit != query.Limit) { + query.Limit = limit; + query.StartIndex = 0; + } - }).on('pageshow', "#gameStudiosPage", function () { + reloadItems(this); - // Reset form values using the last used query - $('.radioSortBy', this).each(function () { + }).on('pageshow', "#gameStudiosPage", function () { - this.checked = query.SortBy == this.getAttribute('data-sortby'); + // Reset form values using the last used query + $('.radioSortBy', this).each(function () { - }).checkboxradio('refresh'); + this.checked = query.SortBy == this.getAttribute('data-sortby'); - $('.radioSortOrder', this).each(function () { + }).checkboxradio('refresh'); - this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + $('.radioSortOrder', this).each(function () { - }).checkboxradio('refresh'); + this.checked = query.SortOrder == this.getAttribute('data-sortorder'); - }); + }).checkboxradio('refresh'); + + }); })(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/gamesystemspage.js b/dashboard-ui/scripts/gamesystemspage.js index 098294a455..3917d2a5e5 100644 --- a/dashboard-ui/scripts/gamesystemspage.js +++ b/dashboard-ui/scripts/gamesystemspage.js @@ -1,122 +1,128 @@ (function ($, document) { - // The base query options - var query = { + // The base query options + var query = { - SortBy: "SortName", - SortOrder: "Ascending", - IncludeItemTypes: "GamePlatform", - Recursive: true, - Fields: "ItemCounts,ItemCounts,DateCreated,UserData", - StartIndex: 0 - }; + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "GamePlatform", + Recursive: true, + Fields: "ItemCounts,ItemCounts,DateCreated,UserData", + StartIndex: 0 + }; - function reloadItems(page) { + function reloadItems(page) { - Dashboard.showLoadingMsg(); + Dashboard.showLoadingMsg(); - ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { - var html = ''; + var html = ''; - $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); + $('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create'); - html += LibraryBrowser.getPosterDetailViewHtml({ - items: result.Items, - context: "games" - }); + html += LibraryBrowser.getPosterDetailViewHtml({ + items: result.Items, + context: "games" + }); - html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); - $('#items', page).html(html).trigger('create'); + $('#items', page).html(html).trigger('create'); - $('.selectPage', page).on('change', function () { - query.StartIndex = (parseInt(this.value) - 1) * query.Limit; - reloadItems(page); - }); + $('.selectPage', page).on('change', function () { + query.StartIndex = (parseInt(this.value) - 1) * query.Limit; + reloadItems(page); + }); - $('.btnNextPage', page).on('click', function () { - query.StartIndex += query.Limit; - reloadItems(page); - }); + $('.btnNextPage', page).on('click', function () { + query.StartIndex += query.Limit; + reloadItems(page); + }); - $('.btnPreviousPage', page).on('click', function () { - query.StartIndex -= query.Limit; - reloadItems(page); - }); + $('.btnPreviousPage', page).on('click', function () { + query.StartIndex -= query.Limit; + reloadItems(page); + }); - $('.selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); + $('.selectPageSize', page).on('change', function () { + query.Limit = parseInt(this.value); + query.StartIndex = 0; + reloadItems(page); + }); - Dashboard.hideLoadingMsg(); - }); - } + Dashboard.hideLoadingMsg(); + }); + } - $(document).on('pageinit', "#gamesystemsPage", function () { + $(document).on('pageinit', "#gamesystemsPage", function () { - var page = this; + var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); + $('.radioSortBy', this).on('click', function () { + query.SortBy = this.getAttribute('data-sortby'); + reloadItems(page); + }); - $('.radioSortBy', this).on('click', function () { - query.SortBy = this.getAttribute('data-sortby'); - reloadItems(page); - }); + $('.radioSortOrder', this).on('click', function () { + query.SortOrder = this.getAttribute('data-sortorder'); + reloadItems(page); + }); - $('.radioSortOrder', this).on('click', function () { - query.SortOrder = this.getAttribute('data-sortorder'); - reloadItems(page); - }); + $('.chkStandardFilter', this).on('change', function () { - $('.chkStandardFilter', this).on('change', function () { + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; + filters = (',' + filters).replace(',' + filterName, '').substring(1); - filters = (',' + filters).replace(',' + filterName, '').substring(1); + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } + query.StartIndex = 0; + query.Filters = filters; - query.StartIndex = 0; - query.Filters = filters; + reloadItems(page); + }); - reloadItems(page); - }); + }).on('pagebeforeshow', "#gamesystemsPage", function () { - }).on('pagebeforeshow', "#gamesystemsPage", function () { + var limit = LibraryBrowser.getDefaultPageSize(); - reloadItems(this); + // If the default page size has changed, the start index will have to be reset + if (limit != query.Limit) { + query.Limit = limit; + query.StartIndex = 0; + } - }).on('pageshow', "#gamesystemsPage", function () { + reloadItems(this); - // Reset form values using the last used query - $('.radioSortBy', this).each(function () { + }).on('pageshow', "#gamesystemsPage", function () { - this.checked = query.SortBy == this.getAttribute('data-sortby'); + // Reset form values using the last used query + $('.radioSortBy', this).each(function () { - }).checkboxradio('refresh'); + this.checked = query.SortBy == this.getAttribute('data-sortby'); - $('.radioSortOrder', this).each(function () { + }).checkboxradio('refresh'); - this.checked = query.SortOrder == this.getAttribute('data-sortorder'); + $('.radioSortOrder', this).each(function () { - }).checkboxradio('refresh'); + this.checked = query.SortOrder == this.getAttribute('data-sortorder'); - $('.chkStandardFilter', this).each(function () { + }).checkboxradio('refresh'); - var filters = "," + (query.Filters || ""); - var filterName = this.getAttribute('data-filter'); + $('.chkStandardFilter', this).each(function () { - this.checked = filters.indexOf(',' + filterName) != -1; + var filters = "," + (query.Filters || ""); + var filterName = this.getAttribute('data-filter'); - }).checkboxradio('refresh'); - }); + this.checked = filters.indexOf(',' + filterName) != -1; + + }).checkboxradio('refresh'); + }); })(jQuery, document); diff --git a/dashboard-ui/scripts/itemlistpage.js b/dashboard-ui/scripts/itemlistpage.js index 2414116571..297ebc7849 100644 --- a/dashboard-ui/scripts/itemlistpage.js +++ b/dashboard-ui/scripts/itemlistpage.js @@ -1,7 +1,7 @@ (function ($, document) { var view = "Poster"; - + // The base query options var query = { @@ -75,15 +75,15 @@ } $('#itemName', page).html(name); - + Dashboard.setPageTitle(name); - + if (ApiClient.isWebSocketOpen()) { ApiClient.sendWebSocketMessage("Context", [item.Type, item.Id].join('|')); } }); - + Dashboard.getCurrentUser().done(function (user) { if (user.Configuration.IsAdministrator) { @@ -99,8 +99,6 @@ var page = this; - query.Limit = LibraryBrowser.getDefaultPageSize(); - $('.radioSortBy', this).on('click', function () { query.StartIndex = 0; query.SortBy = this.getAttribute('data-sortby'); @@ -144,12 +142,13 @@ }).on('pageshow', "#itemListPage", function () { + query.Limit = LibraryBrowser.getDefaultPageSize(); query.ParentId = getParameterByName('parentId'); query.Filters = ""; query.SortBy = "SortName"; query.SortOrder = "Ascending"; query.StartIndex = 0; - + reloadItems(this); // Reset form values using the last used query diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index a9a0e14860..09e7ac49eb 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -796,7 +796,8 @@ var recordsEnd = Math.min(query.StartIndex + query.Limit, totalRecordCount); - var showControls = totalRecordCount > query.Limit; + // 20 is the minimum page size + var showControls = totalRecordCount > 20; html += '