jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/listview/listview.js

1 line
9.2 KiB
JavaScript
Raw Normal View History

2017-07-05 11:24:45 -07:00
define(["itemHelper","mediaInfo","indicators","connectionManager","layoutManager","globalize","datetime","apphost","css!./listview","emby-ratingbutton"],function(itemHelper,mediaInfo,indicators,connectionManager,layoutManager,globalize,datetime,appHost){"use strict";function getIndex(item,options){if("disc"===options.index)return null==item.ParentIndexNumber?"":globalize.translate("sharedcomponents#ValueDiscNumber",item.ParentIndexNumber);var code,name,sortBy=(options.sortBy||"").toLowerCase();return 0===sortBy.indexOf("sortname")?"Episode"===item.Type?"":(name=(item.SortName||item.Name||"?")[0].toUpperCase(),code=name.charCodeAt(0),code<65||code>90?"#":name.toUpperCase()):0===sortBy.indexOf("officialrating")?item.OfficialRating||globalize.translate("sharedcomponents#Unrated"):0===sortBy.indexOf("communityrating")?null==item.CommunityRating?globalize.translate("sharedcomponents#Unrated"):Math.floor(item.CommunityRating):0===sortBy.indexOf("criticrating")?null==item.CriticRating?globalize.translate("sharedcomponents#Unrated"):Math.floor(item.CriticRating):0===sortBy.indexOf("albumartist")&&item.AlbumArtist?(name=item.AlbumArtist[0].toUpperCase(),code=name.charCodeAt(0),code<65||code>90?"#":name.toUpperCase()):""}function getImageUrl(item,width){var apiClient=connectionManager.getApiClient(item.ServerId),options={width:width,type:"Primary"};return item.ImageTags&&item.ImageTags.Primary?(options.tag=item.ImageTags.Primary,apiClient.getScaledImageUrl(item.Id,options)):item.AlbumId&&item.AlbumPrimaryImageTag?(options.tag=item.AlbumPrimaryImageTag,apiClient.getScaledImageUrl(item.AlbumId,options)):item.SeriesId&&item.SeriesPrimaryImageTag?(options.tag=item.SeriesPrimaryImageTag,apiClient.getScaledImageUrl(item.SeriesId,options)):item.ParentPrimaryImageTag?(options.tag=item.ParentPrimaryImageTag,apiClient.getScaledImageUrl(item.ParentPrimaryImageItemId,options)):null}function getTextLinesHtml(textlines,isLargeStyle){for(var html="",largeTitleTagName=layoutManager.tv?"h2":"div",i=0,length=textlines.length;i<length;i++){var text=textlines[i];text&&(html+=0===i?isLargeStyle?"<"+largeTitleTagName+' class="listItemBodyText">':'<div class="listItemBodyText">':'<div class="secondary listItemBodyText">',html+=textlines[i]||"&nbsp;",html+=0===i&&isLargeStyle?"</"+largeTitleTagName+">":"</div>")}return html}function getRightButtonsHtml(options){for(var html="",i=0,length=options.rightButtons.length;i<length;i++){var button=options.rightButtons[i];html+='<button is="paper-icon-button-light" class="listItemButton itemAction" data-action="custom" data-customaction="'+button.id+'" title="'+button.title+'"><i class="md-icon">'+button.icon+"</i></button>"}return html}function getListViewHtml(options){for(var items=options.items,groupTitle="",action=options.action||"link",isLargeStyle="large"===options.imageSize,enableOverview=options.enableOverview,clickEntireItem=!!layoutManager.tv,outerTagName=clickEntireItem?"button":"div",enableSideMediaInfo=null==options.enableSideMediaInfo||options.enableSideMediaInfo,outerHtml="",i=0,length=items.length;i<length;i++){var item=items[i],html="";if(options.showIndex){var itemGroupTitle=getIndex(item,options);itemGroupTitle!==groupTitle&&(html&&(html+="</div>"),html+=0===i?'<h1 class="listGroupHeader listGroupHeader-first">':'<h1 class="listGroupHeader">',html+=itemGroupTitle,html+="</h1>",html+="<div>",groupTitle=itemGroupTitle)}var cssClass="listItem";options.highlight!==!1&&(cssClass+=" listItem-shaded"),clickEntireItem&&(cssClass+=" itemAction listItem-button"),layoutManager.tv&&(cssClass+=" listItem-focusscale");var downloadWidth=80;isLargeStyle&&(cssClass+=" listItem-largeImage",downloadWidth=500);var playlistItemId=item.PlaylistItemId?' data-playlistitemid="'+item.PlaylistItemId+'"':"",positionTicksData=item.UserData&&item.UserData.PlaybackPositionTicks?' data-positionticks="'+item.UserData.PlaybackPositionTicks+'"':"",collectionIdData=options.collectionId?' data-collectionid="'+options.collectionId+'"':"",playlistIdData=options.playlistId?' data-playlistid="'+options.playlistId+'"':"",mediaTypeData