2019-02-27 22:26:23 +00:00
|
|
|
define(['layoutManager', 'globalize', 'require', 'events', 'connectionManager', 'cardBuilder', 'appRouter', 'emby-scroller', 'emby-itemscontainer', 'emby-button'], function (layoutManager, globalize, require, events, connectionManager, cardBuilder, appRouter) {
|
2019-01-10 15:39:37 +03:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function loadSuggestions(instance, context, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
SortBy: 'IsFavoriteOrLiked,Random',
|
|
|
|
IncludeItemTypes: 'Movie,Series,MusicArtist',
|
2018-10-23 01:05:09 +03:00
|
|
|
Limit: 20,
|
2019-01-10 15:39:37 +03:00
|
|
|
Recursive: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
ImageTypeLimit: 0,
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableImages: false,
|
2018-10-23 01:05:09 +03:00
|
|
|
ParentId: instance.options.parentId,
|
2019-01-10 15:39:37 +03:00
|
|
|
EnableTotalRecordCount: false
|
2018-10-23 01:05:09 +03:00
|
|
|
};
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
apiClient.getItems(apiClient.getCurrentUserId(), options).then(function (result) {
|
|
|
|
|
|
|
|
if (instance.mode !== 'suggestions') {
|
|
|
|
result.Items = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
var html = result.Items.map(function (i) {
|
|
|
|
|
|
|
|
var href = appRouter.getRouteUrl(i);
|
|
|
|
|
|
|
|
var itemHtml = '<div><a is="emby-linkbutton" class="button-link" style="display:inline-block;padding:.5em 1em;" href="' + href + '">';
|
|
|
|
itemHtml += i.Name;
|
|
|
|
itemHtml += '</a></div>';
|
|
|
|
return itemHtml;
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
var searchSuggestions = context.querySelector('.searchSuggestions');
|
|
|
|
searchSuggestions.querySelector('.searchSuggestionsList').innerHTML = html;
|
|
|
|
|
|
|
|
if (result.Items.length) {
|
|
|
|
searchSuggestions.classList.remove('hide');
|
|
|
|
}
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSearchHints(instance, apiClient, query) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (!query.searchTerm) {
|
|
|
|
return Promise.resolve({
|
|
|
|
SearchHints: []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var allowSearch = true;
|
|
|
|
|
|
|
|
var queryIncludeItemTypes = query.IncludeItemTypes;
|
|
|
|
|
|
|
|
if (instance.options.collectionType === 'tvshows') {
|
|
|
|
if (query.IncludeArtists) {
|
|
|
|
allowSearch = false;
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (queryIncludeItemTypes === 'Movie' ||
|
2019-01-10 15:39:37 +03:00
|
|
|
queryIncludeItemTypes === 'LiveTvProgram' ||
|
|
|
|
queryIncludeItemTypes === 'MusicAlbum' ||
|
|
|
|
queryIncludeItemTypes === 'Audio' ||
|
|
|
|
queryIncludeItemTypes === 'Book' ||
|
|
|
|
queryIncludeItemTypes === 'AudioBook' ||
|
|
|
|
queryIncludeItemTypes === 'Playlist' ||
|
|
|
|
queryIncludeItemTypes === 'PhotoAlbum' ||
|
|
|
|
query.MediaTypes === 'Video' ||
|
|
|
|
query.MediaTypes === 'Photo') {
|
|
|
|
allowSearch = false;
|
|
|
|
}
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (instance.options.collectionType === 'movies') {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (query.IncludeArtists) {
|
|
|
|
allowSearch = false;
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (queryIncludeItemTypes === 'Series' ||
|
2019-01-10 15:39:37 +03:00
|
|
|
queryIncludeItemTypes === 'Episode' ||
|
|
|
|
queryIncludeItemTypes === 'LiveTvProgram' ||
|
|
|
|
queryIncludeItemTypes === 'MusicAlbum' ||
|
|
|
|
queryIncludeItemTypes === 'Audio' ||
|
|
|
|
queryIncludeItemTypes === 'Book' ||
|
|
|
|
queryIncludeItemTypes === 'AudioBook' ||
|
|
|
|
queryIncludeItemTypes === 'Playlist' ||
|
|
|
|
queryIncludeItemTypes === 'PhotoAlbum' ||
|
|
|
|
query.MediaTypes === 'Video' ||
|
|
|
|
query.MediaTypes === 'Photo') {
|
|
|
|
allowSearch = false;
|
|
|
|
}
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (instance.options.collectionType === 'music') {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (query.People) {
|
|
|
|
allowSearch = false;
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (queryIncludeItemTypes === 'Series' ||
|
2019-01-10 15:39:37 +03:00
|
|
|
queryIncludeItemTypes === 'Episode' ||
|
|
|
|
queryIncludeItemTypes === 'LiveTvProgram' ||
|
|
|
|
queryIncludeItemTypes === 'Movie') {
|
|
|
|
allowSearch = false;
|
|
|
|
}
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (instance.options.collectionType === 'livetv') {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (query.IncludeArtists || query.IncludePeople) {
|
|
|
|
allowSearch = false;
|
2019-11-23 00:29:38 +09:00
|
|
|
} else if (queryIncludeItemTypes === 'Series' ||
|
2019-01-10 15:39:37 +03:00
|
|
|
queryIncludeItemTypes === 'Episode' ||
|
|
|
|
queryIncludeItemTypes === 'MusicAlbum' ||
|
|
|
|
queryIncludeItemTypes === 'Audio' ||
|
|
|
|
queryIncludeItemTypes === 'Book' ||
|
|
|
|
queryIncludeItemTypes === 'AudioBook' ||
|
|
|
|
queryIncludeItemTypes === 'PhotoAlbum' ||
|
|
|
|
queryIncludeItemTypes === 'Movie' ||
|
|
|
|
query.MediaTypes === 'Video' ||
|
|
|
|
query.MediaTypes === 'Photo') {
|
|
|
|
allowSearch = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (queryIncludeItemTypes === 'NullType') {
|
|
|
|
allowSearch = false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (!allowSearch) {
|
|
|
|
return Promise.resolve({
|
|
|
|
SearchHints: []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the search hint query to a regular item query
|
|
|
|
if (apiClient.isMinServerVersion('3.4.1.31')) {
|
|
|
|
|
|
|
|
query.Fields = 'PrimaryImageAspectRatio,CanDelete,BasicSyncInfo,MediaSourceCount';
|
|
|
|
query.Recursive = true;
|
|
|
|
query.EnableTotalRecordCount = false;
|
|
|
|
query.ImageTypeLimit = 1;
|
|
|
|
|
|
|
|
var methodName = 'getItems';
|
|
|
|
|
|
|
|
if (!query.IncludeMedia) {
|
|
|
|
if (query.IncludePeople) {
|
|
|
|
methodName = 'getPeople';
|
|
|
|
|
|
|
|
} else if (query.IncludeArtists) {
|
|
|
|
methodName = 'getArtists';
|
2019-11-23 00:29:38 +09:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return apiClient[methodName](apiClient.getCurrentUserId(), query);
|
|
|
|
}
|
|
|
|
|
|
|
|
query.UserId = apiClient.getCurrentUserId();
|
|
|
|
|
|
|
|
return apiClient.getSearchHints(query);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function search(instance, apiClient, context, value) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (value || layoutManager.tv) {
|
|
|
|
instance.mode = 'search';
|
|
|
|
context.querySelector('.searchSuggestions').classList.add('hide');
|
|
|
|
} else {
|
|
|
|
instance.mode = 'suggestions';
|
|
|
|
loadSuggestions(instance, context, apiClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instance.options.collectionType === 'livetv') {
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
|
|
|
searchTerm: value,
|
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'LiveTvProgram',
|
2019-01-10 15:39:37 +03:00
|
|
|
IsMovie: true,
|
|
|
|
IsKids: false,
|
|
|
|
IsNews: false
|
|
|
|
|
|
|
|
}, context, '.movieResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowPortrait' : 'portrait'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
} else {
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
|
|
|
searchTerm: value,
|
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Movie'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.movieResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
showYear: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Series'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.seriesResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
showYear: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
if (instance.options.collectionType === 'livetv') {
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
|
|
|
searchTerm: value,
|
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'LiveTvProgram',
|
2019-01-10 15:39:37 +03:00
|
|
|
IsSeries: true,
|
|
|
|
IsSports: false,
|
|
|
|
IsKids: false,
|
|
|
|
IsNews: false
|
|
|
|
|
|
|
|
}, context, '.episodeResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
|
|
|
searchTerm: value,
|
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Episode'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.episodeResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
coverImage: true,
|
|
|
|
showTitle: true,
|
|
|
|
showParentTitle: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
|
|
|
// NullType to hide
|
|
|
|
IncludeItemTypes: instance.options.collectionType === 'livetv' ? 'LiveTvProgram' : 'NullType',
|
|
|
|
IsSports: true
|
|
|
|
|
|
|
|
}, context, '.sportsResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
|
|
|
// NullType to hide
|
|
|
|
IncludeItemTypes: instance.options.collectionType === 'livetv' ? 'LiveTvProgram' : 'NullType',
|
|
|
|
IsKids: true
|
|
|
|
|
|
|
|
}, context, '.kidsResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
|
|
|
// NullType to hide
|
|
|
|
IncludeItemTypes: instance.options.collectionType === 'livetv' ? 'LiveTvProgram' : 'NullType',
|
|
|
|
IsNews: true
|
|
|
|
|
|
|
|
}, context, '.newsResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'LiveTvProgram',
|
2019-01-10 15:39:37 +03:00
|
|
|
IsMovie: instance.options.collectionType === 'livetv' ? false : null,
|
|
|
|
IsSeries: instance.options.collectionType === 'livetv' ? false : null,
|
|
|
|
IsSports: instance.options.collectionType === 'livetv' ? false : null,
|
|
|
|
IsKids: instance.options.collectionType === 'livetv' ? false : null,
|
|
|
|
IsNews: instance.options.collectionType === 'livetv' ? false : null
|
|
|
|
|
|
|
|
}, context, '.programResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
preferThumb: true,
|
|
|
|
inheritThumb: false,
|
|
|
|
shape: (enableScrollX() ? 'overflowBackdrop' : 'backdrop'),
|
|
|
|
showParentTitleOrTitle: true,
|
|
|
|
showTitle: false,
|
|
|
|
centerText: true,
|
|
|
|
coverImage: true,
|
|
|
|
overlayText: false,
|
|
|
|
overlayMoreButton: true,
|
|
|
|
showAirTime: true,
|
|
|
|
showAirDateTime: true,
|
|
|
|
showChannelName: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
MediaTypes: 'Video',
|
|
|
|
ExcludeItemTypes: 'Movie,Episode'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.videoResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showParentTitle: true,
|
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: true,
|
|
|
|
IncludeMedia: false,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false
|
|
|
|
|
|
|
|
}, context, '.peopleResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
coverImage: true,
|
|
|
|
showTitle: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: false,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: true
|
|
|
|
|
|
|
|
}, context, '.artistResults', {
|
2019-11-23 00:29:38 +09:00
|
|
|
coverImage: true,
|
|
|
|
showTitle: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'MusicAlbum'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.albumResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showParentTitle: true,
|
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Audio'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.songResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showParentTitle: true,
|
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
|
|
|
action: 'play'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
MediaTypes: 'Photo'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.photoResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showParentTitle: false,
|
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'PhotoAlbum'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.photoAlbumResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Book'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.bookResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'AudioBook'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.audioBookResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
searchType(instance, apiClient, {
|
2018-10-23 01:05:09 +03:00
|
|
|
searchTerm: value,
|
2019-01-10 15:39:37 +03:00
|
|
|
IncludePeople: false,
|
|
|
|
IncludeMedia: true,
|
|
|
|
IncludeGenres: false,
|
|
|
|
IncludeStudios: false,
|
|
|
|
IncludeArtists: false,
|
2020-05-04 12:44:12 +02:00
|
|
|
IncludeItemTypes: 'Playlist'
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, context, '.playlistResults', {
|
|
|
|
|
2019-11-23 00:29:38 +09:00
|
|
|
showTitle: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function searchType(instance, apiClient, query, context, section, cardOptions) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
query.Limit = enableScrollX() ? 24 : 16;
|
|
|
|
query.ParentId = instance.options.parentId;
|
|
|
|
|
|
|
|
getSearchHints(instance, apiClient, query).then(function (result) {
|
|
|
|
|
|
|
|
populateResults(result, context, section, cardOptions);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function populateResults(result, context, section, cardOptions) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
section = context.querySelector(section);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var items = result.Items || result.SearchHints;
|
|
|
|
|
|
|
|
var itemsContainer = section.querySelector('.itemsContainer');
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
cardBuilder.buildCards(items, Object.assign({
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
itemsContainer: itemsContainer,
|
|
|
|
parentContainer: section,
|
2019-01-10 15:39:37 +03:00
|
|
|
shape: enableScrollX() ? 'autooverflow' : 'auto',
|
|
|
|
scalable: true,
|
|
|
|
overlayText: false,
|
|
|
|
centerText: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
allowBottomPadding: !enableScrollX()
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}, cardOptions || {}));
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function enableScrollX() {
|
2019-01-10 15:39:37 +03:00
|
|
|
return true;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function replaceAll(originalString, strReplace, strWith) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var reg = new RegExp(strReplace, 'ig');
|
|
|
|
return originalString.replace(reg, strWith);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function embed(elem, instance, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
require(['text!./searchresults.template.html'], function (template) {
|
|
|
|
|
|
|
|
if (!enableScrollX()) {
|
|
|
|
template = replaceAll(template, 'data-horizontal="true"', 'data-horizontal="false"');
|
|
|
|
template = replaceAll(template, 'itemsContainer scrollSlider', 'itemsContainer scrollSlider vertical-wrap');
|
|
|
|
}
|
|
|
|
|
2020-07-18 09:21:15 +01:00
|
|
|
var html = globalize.translateHtml(template, 'core');
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
elem.innerHTML = html;
|
|
|
|
|
|
|
|
elem.classList.add('searchResults');
|
|
|
|
instance.search('');
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function SearchResults(options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
this.options = options;
|
|
|
|
embed(options.element, this, options);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
SearchResults.prototype.search = function (value) {
|
|
|
|
|
|
|
|
var apiClient = connectionManager.getApiClient(this.options.serverId);
|
|
|
|
|
|
|
|
search(this, apiClient, this.options.element, value);
|
|
|
|
};
|
|
|
|
|
|
|
|
SearchResults.prototype.destroy = function () {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var options = this.options;
|
2019-01-10 15:39:37 +03:00
|
|
|
if (options) {
|
|
|
|
options.element.classList.remove('searchFields');
|
|
|
|
}
|
|
|
|
this.options = null;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return SearchResults;
|
2019-12-02 22:48:14 +03:00
|
|
|
});
|