diff --git a/dashboard-ui/channelitems.html b/dashboard-ui/channelitems.html index 4f90e05667..bb61eb997d 100644 --- a/dashboard-ui/channelitems.html +++ b/dashboard-ui/channelitems.html @@ -4,7 +4,7 @@ Emby -
+
@@ -14,29 +14,6 @@
- -
-
-
- -
-

- ${HeaderFilters} -

- -
- ${OptionPlayed} - ${OptionUnplayed} - ${OptionResumable} - ${OptionFavorite} - ${OptionLikes} - ${OptionDislikes} -
- -
-
-
-
diff --git a/dashboard-ui/components/filterdialog/filterdialog.js b/dashboard-ui/components/filterdialog/filterdialog.js new file mode 100644 index 0000000000..856afa572b --- /dev/null +++ b/dashboard-ui/components/filterdialog/filterdialog.js @@ -0,0 +1,85 @@ +define(['paperdialoghelper', 'events', 'paper-checkbox'], function (paperDialogHelper, events) { + + function updateFilterControls(context, query) { + + $('.chkStandardFilter', context).each(function () { + + var filters = "," + (query.Filters || ""); + var filterName = this.getAttribute('data-filter'); + + this.checked = filters.indexOf(',' + filterName) != -1; + + }); + } + + function triggerChange(instance) { + + events.trigger(instance, 'filterchange'); + } + + function bindEvents(instance, context, query) { + + $('.chkStandardFilter', context).on('change', function () { + + var filterName = this.getAttribute('data-filter'); + var filters = query.Filters || ""; + + filters = (',' + filters).replace(',' + filterName, '').substring(1); + + if (this.checked) { + filters = filters ? (filters + ',' + filterName) : filterName; + } + + query.StartIndex = 0; + query.Filters = filters; + triggerChange(instance); + }); + } + + return function (options) { + + var self = this; + + self.show = function () { + return new Promise(function (resolve, reject) { + + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/filterdialog/filterdialog.template.html', true); + + xhr.onload = function (e) { + + var template = this.response; + var dlg = paperDialogHelper.createDialog({ + removeOnClose: true, + modal: false, + enableHistory: false, + entryAnimationDuration: 160, + exitAnimationDuration: 200 + }); + + dlg.classList.add('ui-body-b'); + dlg.classList.add('background-theme-b'); + + dlg.classList.add('formDialog'); + + var html = ''; + + html += Globalize.translateDocument(template); + + dlg.innerHTML = html; + document.body.appendChild(dlg); + + paperDialogHelper.open(dlg); + + dlg.addEventListener('iron-overlay-closed', resolve); + + updateFilterControls(dlg, options.query); + bindEvents(self, dlg, options.query); + } + + xhr.send(); + }); + }; + + }; +}); \ No newline at end of file diff --git a/dashboard-ui/components/filterdialog/filterdialog.template.html b/dashboard-ui/components/filterdialog/filterdialog.template.html new file mode 100644 index 0000000000..dca574fb8a --- /dev/null +++ b/dashboard-ui/components/filterdialog/filterdialog.template.html @@ -0,0 +1,14 @@ +
+

+ ${HeaderFilters} +

+ +
+ ${OptionPlayed} + ${OptionUnplayed} + ${OptionResumable} + ${OptionFavorite} + ${OptionLikes} + ${OptionDislikes} +
+
\ No newline at end of file diff --git a/dashboard-ui/gamegenres.html b/dashboard-ui/gamegenres.html index a2fd9ab122..74a0ddcf6e 100644 --- a/dashboard-ui/gamegenres.html +++ b/dashboard-ui/gamegenres.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGames} @@ -20,41 +20,6 @@
-
-
- - - -
- -
- - -
- -
-
-
- - ${HeaderFilters} - - - - - - - - - -
- -
-
-
-
diff --git a/dashboard-ui/gamestudios.html b/dashboard-ui/gamestudios.html index f25d2045a9..f018a8ffb3 100644 --- a/dashboard-ui/gamestudios.html +++ b/dashboard-ui/gamestudios.html @@ -4,7 +4,7 @@ Emby -
+
${TabSuggestions} ${TabGames} @@ -19,41 +19,6 @@
- -
-
- - - -
- -
- - -
- -
-
-
- - ${HeaderFilters} - - - - - - - - - -
- -
-
-
diff --git a/dashboard-ui/scripts/channelitems.js b/dashboard-ui/scripts/channelitems.js index a2ce4557fa..642860333c 100644 --- a/dashboard-ui/scripts/channelitems.js +++ b/dashboard-ui/scripts/channelitems.js @@ -103,11 +103,10 @@ startIndex: query.StartIndex, limit: query.Limit, totalRecordCount: result.TotalRecordCount, - viewButton: true, showLimit: false, updatePageSizeSetting: false, - viewIcon: 'filter-list', - sortButton: true + sortButton: true, + filterButton: true }); page.querySelector('.listTopPaging').innerHTML = pagingHtml; @@ -140,6 +139,10 @@ reloadItems(page); }); + $('.btnFilter', page).on('click', function () { + showFilterMenu(page); + }); + // On callback make sure to set StartIndex = 0 $('.btnSort', page).on('click', function () { showSortMenu(page); @@ -153,6 +156,22 @@ }); } + function showFilterMenu(page) { + + require(['components/filterdialog/filterdialog'], function (filterDialogFactory) { + + var filterDialog = new filterDialogFactory({ + query: getQuery() + }); + + Events.on(filterDialog, 'filterchange', function () { + reloadItems(page); + }); + + filterDialog.show(); + }); + } + function showSortMenu(page) { var sortFields = getPageData().sortFields; @@ -213,15 +232,6 @@ function updateFilterControls(page) { var query = getQuery(); - $('.chkStandardFilter', page).each(function () { - - var filters = "," + (query.Filters || ""); - var filterName = this.getAttribute('data-filter'); - - this.checked = filters.indexOf(',' + filterName) != -1; - - }); - $('.alphabetPicker', page).alphaValue(query.NameStartsWith); } @@ -229,24 +239,6 @@ var page = this; - $('.chkStandardFilter', this).on('change', function () { - - var query = getQuery(); - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; - - filters = (',' + filters).replace(',' + filterName, '').substring(1); - - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } - - query.StartIndex = 0; - query.Filters = filters; - - reloadItems(page); - }); - $('.alphabetPicker', this).on('alphaselect', function (e, character) { var query = getQuery(); diff --git a/dashboard-ui/scripts/gamegenrepage.js b/dashboard-ui/scripts/gamegenrepage.js index 5b33d40b91..9c4f4b1fc1 100644 --- a/dashboard-ui/scripts/gamegenrepage.js +++ b/dashboard-ui/scripts/gamegenrepage.js @@ -30,12 +30,9 @@ startIndex: query.StartIndex, limit: query.Limit, totalRecordCount: result.TotalRecordCount, - viewButton: true, showLimit: false })); - updateFilterControls(page); - html = LibraryBrowser.getPosterViewHtml({ items: result.Items, shape: "backdrop", @@ -66,39 +63,7 @@ }); } - function updateFilterControls(page) { - - $('#selectPageSize', page).val(query.Limit); - } - - $(document).on('pageinit', "#gameGenresPage", function () { - - var page = this; - - $('.chkStandardFilter', this).on('change', function () { - - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; - - filters = (',' + filters).replace(',' + filterName, '').substring(1); - - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } - - query.StartIndex = 0; - query.Filters = filters; - - reloadItems(page); - }); - - $('#selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); - - }).on('pagebeforeshow', "#gameGenresPage", function () { + $(document).on('pagebeforeshow', "#gameGenresPage", function () { query.ParentId = LibraryMenu.getTopParentId(); @@ -113,8 +78,6 @@ LibraryBrowser.loadSavedQueryValues(getSavedQueryKey(), query); reloadItems(this); - - updateFilterControls(this); }); })(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/gamestudiospage.js b/dashboard-ui/scripts/gamestudiospage.js index f297413c97..779d5092ac 100644 --- a/dashboard-ui/scripts/gamestudiospage.js +++ b/dashboard-ui/scripts/gamestudiospage.js @@ -31,12 +31,9 @@ startIndex: query.StartIndex, limit: query.Limit, totalRecordCount: result.TotalRecordCount, - viewButton: true, showLimit: false })); - updateFilterControls(page); - html = LibraryBrowser.getPosterViewHtml({ items: result.Items, shape: "backdrop", @@ -45,7 +42,6 @@ showItemCounts: true, centerText: true, lazy: true - }); var elem = page.querySelector('#items'); @@ -68,39 +64,7 @@ }); } - function updateFilterControls(page) { - - $('#selectPageSize', page).val(query.Limit); - } - - $(document).on('pageinit', "#gameStudiosPage", function () { - - var page = this; - - $('.chkStandardFilter', this).on('change', function () { - - var filterName = this.getAttribute('data-filter'); - var filters = query.Filters || ""; - - filters = (',' + filters).replace(',' + filterName, '').substring(1); - - if (this.checked) { - filters = filters ? (filters + ',' + filterName) : filterName; - } - - query.StartIndex = 0; - query.Filters = filters; - - reloadItems(page); - }); - - $('#selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); - - }).on('pagebeforeshow', "#gameStudiosPage", function () { + $(document).on('pagebeforeshow', "#gameStudiosPage", function () { query.ParentId = LibraryMenu.getTopParentId(); @@ -115,8 +79,6 @@ LibraryBrowser.loadSavedQueryValues(getSavedQueryKey(), query); reloadItems(this); - - updateFilterControls(this); }); })(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 43d3c0d352..4f439e6855 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -2821,7 +2821,7 @@ html += ''; } - if (showControls || options.viewButton || options.sortButton || options.addLayoutButton) { + if (showControls || options.viewButton || options.filterButton || options.sortButton || options.addLayoutButton) { html += '
'; @@ -2849,6 +2849,11 @@ html += ''; } + if (options.filterButton) { + + html += ''; + } + html += '
'; if (showControls && options.showLimit) { diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 8078b4dd6d..05902d0e16 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -652,143 +652,142 @@ self.createStreamInfo = function (type, item, mediaSource, startPosition) { - var deferred = $.Deferred(); + return new Promise(function (resolve, reject) { - var mediaUrl; - var contentType; - var startTimeTicksOffset = 0; + var mediaUrl; + var contentType; + var startTimeTicksOffset = 0; - var startPositionInSeekParam = startPosition ? (startPosition / 10000000) : 0; - var seekParam = startPositionInSeekParam ? '#t=' + startPositionInSeekParam : ''; - var playMethod = 'Transcode'; + var startPositionInSeekParam = startPosition ? (startPosition / 10000000) : 0; + var seekParam = startPositionInSeekParam ? '#t=' + startPositionInSeekParam : ''; + var playMethod = 'Transcode'; - if (type == 'Video') { + if (type == 'Video') { - contentType = 'video/' + mediaSource.Container; + contentType = 'video/' + mediaSource.Container; - if (mediaSource.enableDirectPlay) { - mediaUrl = mediaSource.Path; + if (mediaSource.enableDirectPlay) { + mediaUrl = mediaSource.Path; - playMethod = 'DirectPlay'; + playMethod = 'DirectPlay'; - } else { + } else { - if (mediaSource.SupportsDirectStream) { + if (mediaSource.SupportsDirectStream) { - var directOptions = { - Static: true, - mediaSourceId: mediaSource.Id, - deviceId: ApiClient.deviceId(), - api_key: ApiClient.accessToken() - }; + var directOptions = { + Static: true, + mediaSourceId: mediaSource.Id, + deviceId: ApiClient.deviceId(), + api_key: ApiClient.accessToken() + }; - if (mediaSource.LiveStreamId) { - directOptions.LiveStreamId = mediaSource.LiveStreamId; - } - - mediaUrl = ApiClient.getUrl('Videos/' + item.Id + '/stream.' + mediaSource.Container, directOptions); - mediaUrl += seekParam; - - playMethod = 'DirectStream'; - } else if (mediaSource.SupportsTranscoding) { - - mediaUrl = ApiClient.getUrl(mediaSource.TranscodingUrl); - - if (mediaSource.TranscodingSubProtocol == 'hls') { - - mediaUrl += seekParam; - contentType = 'application/x-mpegURL'; - - } else { - - // Reports of stuttering with h264 stream copy in IE - if (mediaUrl.indexOf('.mkv') == -1) { - mediaUrl += '&EnableAutoStreamCopy=false'; + if (mediaSource.LiveStreamId) { + directOptions.LiveStreamId = mediaSource.LiveStreamId; } - startTimeTicksOffset = startPosition || 0; - contentType = 'video/' + mediaSource.TranscodingContainer; + mediaUrl = ApiClient.getUrl('Videos/' + item.Id + '/stream.' + mediaSource.Container, directOptions); + mediaUrl += seekParam; + + playMethod = 'DirectStream'; + } else if (mediaSource.SupportsTranscoding) { + + mediaUrl = ApiClient.getUrl(mediaSource.TranscodingUrl); + + if (mediaSource.TranscodingSubProtocol == 'hls') { + + mediaUrl += seekParam; + contentType = 'application/x-mpegURL'; + + } else { + + // Reports of stuttering with h264 stream copy in IE + if (mediaUrl.indexOf('.mkv') == -1) { + mediaUrl += '&EnableAutoStreamCopy=false'; + } + startTimeTicksOffset = startPosition || 0; + + contentType = 'video/' + mediaSource.TranscodingContainer; + } } } - } - - } else { - - contentType = 'audio/' + mediaSource.Container; - - if (mediaSource.enableDirectPlay) { - - mediaUrl = mediaSource.Path; - - playMethod = 'DirectPlay'; } else { - var isDirectStream = mediaSource.SupportsDirectStream; + contentType = 'audio/' + mediaSource.Container; - if (isDirectStream) { + if (mediaSource.enableDirectPlay) { - var outputContainer = (mediaSource.Container || '').toLowerCase(); + mediaUrl = mediaSource.Path; - var directOptions = { - Static: true, - mediaSourceId: mediaSource.Id, - deviceId: ApiClient.deviceId(), - api_key: ApiClient.accessToken() - }; + playMethod = 'DirectPlay'; - if (mediaSource.LiveStreamId) { - directOptions.LiveStreamId = mediaSource.LiveStreamId; - } + } else { - mediaUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.' + outputContainer, directOptions); - mediaUrl += seekParam; + var isDirectStream = mediaSource.SupportsDirectStream; - playMethod = 'DirectStream'; + if (isDirectStream) { - } else if (mediaSource.SupportsTranscoding) { + var outputContainer = (mediaSource.Container || '').toLowerCase(); - mediaUrl = ApiClient.getUrl(mediaSource.TranscodingUrl); + var directOptions = { + Static: true, + mediaSourceId: mediaSource.Id, + deviceId: ApiClient.deviceId(), + api_key: ApiClient.accessToken() + }; - if (mediaSource.TranscodingSubProtocol == 'hls') { + if (mediaSource.LiveStreamId) { + directOptions.LiveStreamId = mediaSource.LiveStreamId; + } + mediaUrl = ApiClient.getUrl('Audio/' + item.Id + '/stream.' + outputContainer, directOptions); mediaUrl += seekParam; - contentType = 'application/x-mpegURL'; - } else { - startTimeTicksOffset = startPosition || 0; - contentType = 'audio/' + mediaSource.TranscodingContainer; + playMethod = 'DirectStream'; + + } else if (mediaSource.SupportsTranscoding) { + + mediaUrl = ApiClient.getUrl(mediaSource.TranscodingUrl); + + if (mediaSource.TranscodingSubProtocol == 'hls') { + + mediaUrl += seekParam; + contentType = 'application/x-mpegURL'; + } else { + + startTimeTicksOffset = startPosition || 0; + contentType = 'audio/' + mediaSource.TranscodingContainer; + } } } } - } - var resultInfo = { - url: mediaUrl, - mimeType: contentType, - startTimeTicksOffset: startTimeTicksOffset, - startPositionInSeekParam: startPositionInSeekParam, - playMethod: playMethod - }; + var resultInfo = { + url: mediaUrl, + mimeType: contentType, + startTimeTicksOffset: startTimeTicksOffset, + startPositionInSeekParam: startPositionInSeekParam, + playMethod: playMethod + }; - if (playMethod == 'DirectPlay' && mediaSource.Protocol == 'File') { + if (playMethod == 'DirectPlay' && mediaSource.Protocol == 'File') { - require(['localassetmanager'], function () { + require(['localassetmanager'], function () { - LocalAssetManager.translateFilePath(resultInfo.url).then(function (path) { + LocalAssetManager.translateFilePath(resultInfo.url).then(function (path) { - resultInfo.url = path; - console.log('LocalAssetManager.translateFilePath: path: ' + resultInfo.url + ' result: ' + path); - deferred.resolveWith(null, [resultInfo]); + resultInfo.url = path; + console.log('LocalAssetManager.translateFilePath: path: ' + resultInfo.url + ' result: ' + path); + resolve(resultInfo); + }); }); - }); - } - else { - deferred.resolveWith(null, [resultInfo]); - } - - return deferred.promise(); + } + else { + resolve(resultInfo); + } + }); }; self.lastBitrateDetections = {}; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 579bdb6ed4..b4d2e4f371 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -2142,8 +2142,6 @@ var AppInfo = {}; deps.push('scripts/mediacontroller'); deps.push('scripts/globalize'); - deps.push('jQuery'); - deps.push('paper-drawer-panel'); require(deps, function (events) { @@ -2197,26 +2195,14 @@ var AppInfo = {}; MediaBrowser[i] = connectionManagerExports[i]; } - // TODO: This needs to be deprecated, but it's used heavily - $.fn.checked = function (value) { - if (value === true || value === false) { - // Set the value of the checkbox - return $(this).each(function () { - this.checked = value; - }); - } else { - // Return check state - return this.length && this[0].checked; - } - }; - var promises = []; deps = []; deps.push('scripts/mediaplayer'); deps.push('emby-icons'); deps.push('paper-icon-button'); deps.push('paper-button'); - deps.push('jqm'); + deps.push('jQuery'); + promises.push(getRequirePromise(deps)); promises.push(Globalize.ensure()); @@ -2256,6 +2242,19 @@ var AppInfo = {}; require(depends, function () { + // TODO: This needs to be deprecated, but it's used heavily + $.fn.checked = function (value) { + if (value === true || value === false) { + // Set the value of the checkbox + return $(this).each(function () { + this.checked = value; + }); + } else { + // Return check state + return this.length && this[0].checked; + } + }; + // Don't like having to use jQuery here, but it takes care of making sure that embedded script executes $(mainDrawerPanelContent).html(Globalize.translateDocument(newHtml, 'html')); onAppReady(); @@ -2317,6 +2316,7 @@ var AppInfo = {}; deps.push('scripts/backdrops'); deps.push('scripts/librarymenu'); deps.push('scripts/librarybrowser'); + deps.push('jqm'); deps.push('css!css/card.css'); diff --git a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.widget.js b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.widget.js index 83864e58ea..37a20e8715 100644 --- a/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.widget.js +++ b/dashboard-ui/thirdparty/jquerymobile-1.4.5/jqm.widget.js @@ -1,8 +1,4 @@ -(function () { - - if (jQuery.widget) { - return; - } +define(['jqm'], function () { /*! * jQuery UI Widget c0ab71056b936627e8a7821f03c044aec6280a40 @@ -498,7 +494,7 @@ (function ($, undefined) { - var originalWidget = $.widget + var originalWidget = $.widget; $.widget = (function (orig) { return function () { @@ -519,5 +515,4 @@ })(jQuery); - -})(); \ No newline at end of file +}); \ No newline at end of file