jellyfin-web/dashboard-ui/scripts/itemdetailpage.js

2 lines
52 KiB
JavaScript
Raw Normal View History

2017-11-01 11:35:02 -07:00
define(["loading","appRouter","layoutManager","connectionManager","cardBuilder","datetime","mediaInfo","backdrop","listView","itemContextMenu","itemHelper","dom","indicators","apphost","imageLoader","libraryMenu","globalize","browser","events","scrollHelper","playbackManager","libraryBrowser","scrollStyles","emby-itemscontainer","emby-checkbox","emby-linkbutton","emby-playstatebutton","emby-ratingbutton","emby-downloadbutton","emby-scroller"],function(loading,appRouter,layoutManager,connectionManager,cardBuilder,datetime,mediaInfo,backdrop,listView,itemContextMenu,itemHelper,dom,indicators,appHost,imageLoader,libraryMenu,globalize,browser,events,scrollHelper,playbackManager,libraryBrowser){"use strict";function getPromise(apiClient,params){var id=params.id;if(id)return apiClient.getItem(apiClient.getCurrentUserId(),id);if(params.seriesTimerId)return apiClient.getLiveTvSeriesTimer(params.seriesTimerId);var name=params.genre;if(name)return apiClient.getGenre(name,apiClient.getCurrentUserId());if(name=params.musicgenre)return apiClient.getMusicGenre(name,apiClient.getCurrentUserId());if(name=params.gamegenre)return apiClient.getGameGenre(name,apiClient.getCurrentUserId());if(name=params.musicartist)return apiClient.getArtist(name,apiClient.getCurrentUserId());throw new Error("Invalid request")}function hideAll(page,className,show){var i,length,elems=page.querySelectorAll("."+className);for(i=0,length=elems.length;i<length;i++)show?elems[i].classList.remove("hide"):elems[i].classList.add("hide")}function getContextMenuOptions(item,user,button){var options={item:item,open:!1,play:!1,playAllFromHere:!1,queueAllFromHere:!1,positionTo:button,cancelTimer:!1,record:!1,deleteItem:item.IsFolder===!0,shuffle:!1,instantMix:!1,user:user,share:!0};return appHost.supports("sync")&&(options.syncLocal=!1),options}function renderSyncLocalContainer(page,params,user,item){if(appHost.supports("sync"))for(var canSync=itemHelper.canSync(user,item),buttons=page.querySelectorAll(".btnSyncDownload"),i=0,length=buttons.length;i<length;i++)buttons[i].setItem(item),canSync?buttons[i].classList.remove("hide"):buttons[i].classList.add("hide")}function getProgramScheduleHtml(items,options){options=options||{};var html="";return html+='<div is="emby-itemscontainer" class="itemsContainer vertical-list" data-contextmenu="false">',html+=listView.getListViewHtml({items:items,enableUserDataButtons:!1,image:!0,imageSource:"channel",showProgramDateTime:!0,showChannel:!1,mediaInfo:!1,action:"none",moreButton:!1,recordButton:!1}),html+="</div>"}function renderSeriesTimerSchedule(page,apiClient,seriesTimerId){apiClient.getLiveTvTimers({UserId:apiClient.getCurrentUserId(),ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Thumb",SortBy:"StartDate",EnableTotalRecordCount:!1,EnableUserData:!1,SeriesTimerId:seriesTimerId,Fields:"ChannelInfo,ChannelImage"}).then(function(result){result.Items.length&&result.Items[0].SeriesTimerId!=seriesTimerId&&(result.Items=[]);var html=getProgramScheduleHtml(result.Items),scheduleTab=page.querySelector(".seriesTimerSchedule");scheduleTab.innerHTML=html,imageLoader.lazyChildren(scheduleTab)})}function renderTimerEditor(page,item,apiClient,user){return"Recording"===item.Type&&user.Policy.EnableLiveTvManagement&&item.TimerId&&"InProgress"===item.Status?void hideAll(page,"btnCancelTimer",!0):void hideAll(page,"btnCancelTimer")}function renderSeriesTimerEditor(page,item,apiClient,user){return"SeriesTimer"!==item.Type?void hideAll(page,"btnCancelSeriesTimer"):user.Policy.EnableLiveTvManagement?(require(["seriesRecordingEditor"],function(seriesRecordingEditor){seriesRecordingEditor.embed(item,apiClient.serverId(),{context:page.querySelector(".seriesRecordingEditor")})}),page.querySelector(".seriesTimerScheduleSection").classList.remove("hide"),hideAll(page,"btnCancelSeriesTimer",!0),void renderSeriesTimerSchedule(page,apiClient,item.Id)):(page.querySelector(".seriesTimerScheduleSection").classList.add("hide"),void hideAll(page,"btnCancelSeriesTimer"))}function reloadPlayButtons(page,item){var canPlay=!1;if("Program"==item.Type){var now=new
"MusicAlbum"==item.Type||"Season"==item.Type?page.querySelector(".childrenSectionHeader",page).classList.add("hide"):page.querySelector(".childrenSectionHeader",page).classList.remove("hide")}function renderItemsByName(page,item,user){require("scripts/itembynamedetailpage".split(","),function(){window.ItemsByName.renderItems(page,item)})}function renderPlaylistItems(page,item,user){require("scripts/playlistedit".split(","),function(){PlaylistViewer.render(page,item)})}function renderProgramsForChannel(page,result){for(var html="",currentItems=[],currentStartDate=null,i=0,length=result.Items.length;i<length;i++){var item=result.Items[i],itemStartDate=datetime.parseISO8601Date(item.StartDate);currentStartDate&&currentStartDate.toDateString()===itemStartDate.toDateString()||(currentItems.length&&(html+='<div class="verticalSection verticalDetailSection">',html+='<h2 class="sectionTitle padded-left">'+datetime.toLocaleDateString(currentStartDate,{weekday:"long",month:"long",day:"numeric"})+"</h2>",html+='<div is="emby-itemscontainer" class="vertical-list padded-left padded-right">'+listView.getListViewHtml({items:currentItems,enableUserDataButtons:!1,showParentTitle:!0,image:!1,showProgramTime:!0,mediaInfo:!1,parentTitleWithTitle:!0})+"</div></div>"),currentStartDate=itemStartDate,currentItems=[]),currentItems.push(item)}page.querySelector(".programGuide").innerHTML=html}function renderChannelGuide(page,apiClient,item){"TvChannel"===item.Type&&(page.querySelector(".programGuideSection").classList.remove("hide"),apiClient.getLiveTvPrograms({ChannelIds:item.Id,UserId:apiClient.getCurrentUserId(),HasAired:!1,SortBy:"StartDate",EnableTotalRecordCount:!1,EnableImages:!1,ImageTypeLimit:0,EnableUserData:!1}).then(function(result){renderProgramsForChannel(page,result)}))}function renderSeriesSchedule(page,item,user){return}function inferContext(item){return"Movie"===item.Type||"BoxSet"===item.Type?"movies":"Series"===item.Type||"Season"===item.Type||"Episode"===item.Type?"tvshows":"Game"===item.Type||"GameSystem"===item.Type?"games":"Game"===item.Type||"GameSystem"===item.Type?"games":"MusicArtist"===item.Type||"MusicAlbum"===item.Type?"music":null}function renderStudios(elem,item,isStatic){var context=inferContext(item);if(item.Studios&&item.Studios.length&&"Series"!=item.Type,1)elem.classList.add("hide");else{for(var html="",i=0,length=item.Studios.length;i<length;i++)if(i>0&&(html+="&nbsp;&nbsp;/&nbsp;&nbsp;"),isStatic)html+=item.Studios[i].Name;else{item.Studios[i].Type="Studio";var href=appRouter.getRouteUrl(item.Studios[0],{context:context,serverId:item.ServerId});html+='<a class="textlink button-link" is="emby-linkbutton" href="'+href+'">'+item.Studios[i].Name+"</a>"}var translationKey=item.Studios.length>1?"ValueStudios":"ValueStudio";html=globalize.translate(translationKey,html),elem.innerHTML=html,elem.classList.remove("hide")}}function filterItemsByCollectionItemType(items,typeInfo){return items.filter(function(item){return typeInfo.mediaType?item.MediaType==typeInfo.mediaType:item.Type==typeInfo.type})}function renderCollectionItems(page,parentItem,types,items){page.querySelector(".collectionItems").innerHTML="";var i,length;for(i=0,length=types.length;i<length;i++){var type=types[i],typeItems=filterItemsByCollectionItemType(items,type);typeItems.length&&renderCollectionItemType(page,parentItem,type,typeItems)}var otherType={name:globalize.translate("HeaderOtherItems")},otherTypeItems=items.filter(function(curr){return!types.filter(function(t){return filterItemsByCollectionItemType([curr],t).length>0}).length});otherTypeItems.length&&renderCollectionItemType(page,parentItem,otherType,otherTypeItems),items.length||renderCollectionItemType(page,parentItem,{name:globalize.translate("HeaderItems")},items)}function renderCollectionItemType(page,parentItem,type,items){var html="";html+='<div class="verticalSection">',html+='<div class="sectionTitleContainer padded-left">',html+='<h2 class="sectionTitle sectionTitle-cards">',html+="<span>"+type.name+"</span>",html+="</h2>",html+='<button class="btnAddToCollection sectionTitleB