2017-01-27 16:07:14 -07:00
|
|
|
define(["playbackManager","inputManager","connectionManager","embyRouter","globalize","loading","dom","recordingHelper"],function(playbackManager,inputManager,connectionManager,embyRouter,globalize,loading,dom,recordingHelper){"use strict";function playAllFromHere(card,serverId,queue){for(var parent=card.parentNode,className=card.classList.length?"."+card.classList[0]:"",cards=parent.querySelectorAll(className+"[data-id]"),ids=[],foundCard=!1,i=0,length=cards.length;i<length;i++)cards[i]===card&&(foundCard=!0),foundCard&&ids.push(cards[i].getAttribute("data-id"));ids.length&&(queue?playbackManager.queue({ids:ids,serverId:serverId}):playbackManager.play({ids:ids,serverId:serverId}))}function showSlideshow(startItemId,serverId){var apiClient=connectionManager.getApiClient(serverId),userId=apiClient.getCurrentUserId();return apiClient.getItem(userId,startItemId).then(function(item){return apiClient.getItems(userId,{MediaTypes:"Photo",Filters:"IsNotFolder",ParentId:item.ParentId,SortBy:"SortName"}).then(function(result){var items=result.Items,index=items.map(function(i){return i.Id}).indexOf(startItemId);index===-1&&(index=0),require(["slideshow"],function(slideshow){var newSlideShow=new slideshow({showTitle:!1,cover:!1,items:items,startIndex:index,interval:8e3,interactive:!0});newSlideShow.show()})})})}function showItem(item,options){return"Photo"===item.Type?void showSlideshow(item.Id,item.ServerId):void embyRouter.showItem(item,options)}function showProgramDialog(item){require(["recordingCreator"],function(recordingCreator){recordingCreator.show(item.Id,item.ServerId)})}function getItem(button){button=dom.parentWithAttribute(button,"data-id");var serverId=button.getAttribute("data-serverid"),id=button.getAttribute("data-id"),type=button.getAttribute("data-type"),apiClient=connectionManager.getApiClient(serverId);return"Timer"===type?apiClient.getLiveTvTimer(id):"SeriesTimer"===type?apiClient.getLiveTvSeriesTimer(id):apiClient.getItem(apiClient.getCurrentUserId(),id)}function showContextMenu(card,options){getItem(card).then(function(item){var playlistId=card.getAttribute("data-playlistid"),collectionId=card.getAttribute("data-collectionid");if(playlistId){var elem=dom.parentWithAttribute(card,"data-playlistitemid");item.PlaylistItemId=elem?elem.getAttribute("data-playlistitemid"):null}require(["itemContextMenu"],function(itemContextMenu){itemContextMenu.show(Object.assign({item:item,play:!0,queue:!0,playAllFromHere:!item.IsFolder,queueAllFromHere:!item.IsFolder,playlistId:playlistId,collectionId:collectionId},options||{})).then(function(result){var itemsContainer;"playallfromhere"===result.command||"queueallfromhere"===result.command?executeAction(card,options.positionTo,result.command):"removefromplaylist"===result.command||"removefromcollection"===result.command?(itemsContainer=options.itemsContainer||dom.parentWithAttribute(card,"is","emby-itemscontainer"),itemsContainer&&itemsContainer.dispatchEvent(new CustomEvent("needsrefresh",{detail:{},cancelable:!1,bubbles:!0}))):"canceltimer"===result.command&&(itemsContainer=options.itemsContainer||dom.parentWithAttribute(card,"is","emby-itemscontainer"),itemsContainer&&itemsContainer.dispatchEvent(new CustomEvent("timercancelled",{detail:{},cancelable:!1,bubbles:!0})))})})})}function getItemInfoFromCard(card){return{Type:card.getAttribute("data-type"),Id:card.getAttribute("data-id"),TimerId:card.getAttribute("data-timerid"),CollectionType:card.getAttribute("data-collectiontype"),ChannelId:card.getAttribute("data-channelid"),SeriesId:card.getAttribute("data-seriesid"),ServerId:card.getAttribute("data-serverid"),MediaType:card.getAttribute("data-mediatype"),IsFolder:"true"===card.getAttribute("data-isfolder"),UserData:{PlaybackPositionTicks:parseInt(card.getAttribute("data-positionticks")||"0")}}}function showPlayMenu(card,target){var item=getItemInfoFromCard(card);require(["playMenu"],function(playMenu){playMenu.show({item:item,positionTo:target})})}function sendToast(text){require(["toast"],function(toast){toast(text)})}function executeAction(card,target,action){target=target
|