define(['itemHelper', 'mediaInfo', 'indicators', 'connectionManager', 'layoutManager', 'globalize', 'userdataButtons', 'apphost', 'css!./listview'], function (itemHelper, mediaInfo, indicators, connectionManager, layoutManager, globalize, userdataButtons, appHost) { function getIndex(item, options) { if (options.index == 'disc') { return item.ParentIndexNumber == null ? '' : globalize.translate('sharedcomponents#ValueDiscNumber', item.ParentIndexNumber); } var sortBy = (options.sortBy || '').toLowerCase(); var code, name; if (sortBy.indexOf('sortname') == 0) { if (item.Type == 'Episode') return ''; // SortName name = (item.SortName || item.Name || '?')[0].toUpperCase(); code = name.charCodeAt(0); if (code < 65 || code > 90) { return '#'; } return name.toUpperCase(); } if (sortBy.indexOf('officialrating') == 0) { return item.OfficialRating || globalize.translate('sharedcomponents#Unrated'); } if (sortBy.indexOf('communityrating') == 0) { if (item.CommunityRating == null) { return globalize.translate('sharedcomponents#Unrated'); } return Math.floor(item.CommunityRating); } if (sortBy.indexOf('criticrating') == 0) { if (item.CriticRating == null) { return globalize.translate('sharedcomponents#Unrated'); } return Math.floor(item.CriticRating); } if (sortBy.indexOf('metascore') == 0) { if (item.Metascore == null) { return globalize.translate('sharedcomponents#Unrated'); } return Math.floor(item.Metascore); } if (sortBy.indexOf('albumartist') == 0) { // SortName if (!item.AlbumArtist) return ''; name = item.AlbumArtist[0].toUpperCase(); code = name.charCodeAt(0); if (code < 65 || code > 90) { return '#'; } return name.toUpperCase(); } return ''; } function getImageUrl(item, width) { var apiClient = connectionManager.getApiClient(item.ServerId); var options = { width: width, type: "Primary" }; if (item.ImageTags && item.ImageTags['Primary']) { options.tag = item.ImageTags['Primary']; return apiClient.getScaledImageUrl(item.Id, options); } if (item.AlbumId && item.AlbumPrimaryImageTag) { options.tag = item.AlbumPrimaryImageTag; return apiClient.getScaledImageUrl(item.AlbumId, options); } else if (item.SeriesId && item.SeriesPrimaryImageTag) { options.tag = item.SeriesPrimaryImageTag; return apiClient.getScaledImageUrl(item.SeriesId, options); } else if (item.ParentPrimaryImageTag) { options.tag = item.ParentPrimaryImageTag; return apiClient.getScaledImageUrl(item.ParentPrimaryImageItemId, options); } return null; } function getListViewHtml(items, options) { if (arguments.length == 1) { options = items; items = options.items; } var index = 0; var groupTitle = ''; var action = options.action || 'link'; var isLargeStyle = options.imageSize == 'large'; var enableOverview = options.enableOverview; var clickEntireItem = layoutManager.tv ? true : false; var outerTagName = clickEntireItem ? 'button' : 'div'; var enableSideMediaInfo = options.enableSideMediaInfo != null ? options.enableSideMediaInfo : clickEntireItem; var outerHtml = ''; outerHtml += items.map(function (item) { var html = ''; if (options.showIndex) { var itemGroupTitle = getIndex(item, options); if (itemGroupTitle != groupTitle) { if (html) { html += ''; } if (index == 0) { html += '