2017-03-28 22:38:10 -07:00
|
|
|
define(["loading","embyRouter","layoutManager","connectionManager","cardBuilder","datetime","mediaInfo","backdrop","listView","itemContextMenu","itemHelper","userdataButtons","dom","indicators","apphost","imageLoader","libraryMenu","globalize","browser","events","scrollHelper","playbackManager","scrollStyles","emby-itemscontainer","emby-checkbox"],function(loading,embyRouter,layoutManager,connectionManager,cardBuilder,datetime,mediaInfo,backdrop,listView,itemContextMenu,itemHelper,userdataButtons,dom,indicators,appHost,imageLoader,libraryMenu,globalize,browser,events,scrollHelper,playbackManager){"use strict";function getPromise(params){var id=params.id;if(id)return ApiClient.getItem(Dashboard.getCurrentUserId(),id);if(params.seriesTimerId)return ApiClient.getLiveTvSeriesTimer(params.seriesTimerId);var name=params.genre;if(name)return ApiClient.getGenre(name,Dashboard.getCurrentUserId());if(name=params.musicgenre)return ApiClient.getMusicGenre(name,Dashboard.getCurrentUserId());if(name=params.gamegenre)return ApiClient.getGameGenre(name,Dashboard.getCurrentUserId());if(name=params.musicartist)return ApiClient.getArtist(name,Dashboard.getCurrentUserId());throw new Error("Invalid request")}function reload(page,params){loading.show(),getPromise(params).then(function(item){reloadFromItem(page,params,item)})}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};return appHost.supports("sync")&&(options.syncLocal=!1),options}function renderSyncLocalContainer(page,params,user,item){return page.syncToggleInstance?void page.syncToggleInstance.refresh(item):void require(["syncToggle"],function(syncToggle){page.syncToggleInstance=new syncToggle({user:user,item:item,container:page.querySelector(".syncLocalContainer")}),events.on(page.syncToggleInstance,"sync",function(){reload(page,params)})})}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:!1,showProgramDateTime:!0,showChannel:!0,mediaInfo:!1,action:"none",moreButton:!1,recordButton:!1}),html+="</div>"}function renderSeriesTimerSchedule(page,seriesTimerId){ApiClient.getLiveTvTimers({UserId:ApiClient.getCurrentUserId(),ImageTypeLimit:1,EnableImageTypes:"Primary,Backdrop,Thumb",SortBy:"StartDate",EnableTotalRecordCount:!1,EnableUserData:!1,SeriesTimerId:seriesTimerId,Fields:"ChannelInfo"}).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 renderSeriesTimerEditor(page,item,user){if("SeriesTimer"===item.Type){if(!user.Policy.EnableLiveTvManagement)return page.querySelector(".seriesTimerScheduleSection").classList.add("hide"),void page.querySelector(".btnCancelSeriesTimer").classList.add("hide");require(["seriesRecordingEditor"],function(seriesRecordingEditor){seriesRecordingEditor.embed(item,ApiClient.serverId(),{context:page.querySelector(".seriesRecordingEditor")})}),page.querySelector(".seriesTimerScheduleSection").classList.remove("hide"),page.querySelector(".btnCancelSeriesTimer").classList.remove("hide"),renderSeriesTimerSchedule(page,item.Id)}}function reloadPlayButtons(page,item){var canPlay=!1;if("Program"==item.Type){var now=new Date;now>=datetime.parseISO8601Date(item.StartDate,!0)&&now<datetime.parseISO8601Date(item.EndDate,!0)?(hideAll(page,"btnPlay",!0),canPlay=!0):hideAll(page,"btnPlay"),hideAll(page,"btnResume"),hideAll(page,"btnInstantMix"),hideAll(
|
|
|
|
var shape="MusicAlbum"==type.type?getSquareShape(!1):getPortraitShape(!1);html+=cardBuilder.getCardsHtml({items:items,shape:shape,showTitle:!0,centerText:!0,lazy:!0,showDetailsMenu:!0,overlayMoreButton:!0,showAddToCollection:!1,showRemoveFromCollection:!0,collectionId:parentItem.Id}),html+="</div>",html+="</div>";var collectionItems=page.querySelector(".collectionItems");collectionItems.insertAdjacentHTML("beforeend",html),imageLoader.lazyChildren(collectionItems),collectionItems.querySelector(".btnAddToCollection").addEventListener("click",function(){require(["alert"],function(alert){alert({text:globalize.translate("AddItemToCollectionHelp"),html:globalize.translate("AddItemToCollectionHelp")+'<br/><br/><a target="_blank" href="https://github.com/MediaBrowser/Wiki/wiki/Collections">'+globalize.translate("ButtonLearnMore")+"</a>"})})})}function renderUserDataIcons(page,item){for(var userDataIcons=page.querySelectorAll(".userDataIcons"),i=0,length=userDataIcons.length;i<length;i++)"Program"==item.Type||"SeriesTimer"==item.Type?userDataIcons[i].classList.add("hide"):userDataIcons[i].classList.remove("hide"),userdataButtons.fill({item:item,style:"fab-mini",element:userDataIcons[i]})}function renderCriticReviews(page,item,limit){if("Movie"!=item.Type&&"Trailer"!=item.Type&&"MusicVideo"!=item.Type)return void page.querySelector("#criticReviewsCollapsible").classList.add("hide");var options={};limit&&(options.limit=limit),ApiClient.getCriticReviews(item.Id,options).then(function(result){result.TotalRecordCount||item.CriticRatingSummary||item.AwardSummary?(page.querySelector("#criticReviewsCollapsible").classList.remove("hide"),renderCriticReviewsContent(page,result,limit)):page.querySelector("#criticReviewsCollapsible").classList.add("hide")})}function renderCriticReviewsContent(page,result,limit){for(var html="",reviews=result.Items,i=0,length=reviews.length;i<length;i++){var review=reviews[i];html+='<div class="paperList criticReviewPaperList">',html+='<div class="listItem">',null!=review.Score||null!=review.Likes&&(html+=review.Likes?"<div style=\"flex-shrink:0;background-color:transparent;background-image:url('css/images/fresh.png');background-repeat:no-repeat;background-position:center center;background-size: cover;width:40px;height:40px;\"></div>":"<div style=\"flex-shrink:0;background-color:transparent;background-image:url('css/images/rotten.png');background-repeat:no-repeat;background-position:center center;background-size: cover;width:40px;height:40px;\"></div>"),html+='<div class="listItemBody two-line">',html+='<h3 class="listItemBodyText" style="white-space:normal;">'+review.Caption+"</h3>";var vals=[];if(review.ReviewerName&&vals.push(review.ReviewerName),review.Publisher&&vals.push(review.Publisher),html+='<div class="secondary listItemBodyText">'+vals.join(", ")+".",review.Date)try{var date=datetime.toLocaleDateString(datetime.parseISO8601Date(review.Date,!0));html+='<span class="reviewDate">'+date+"</span>"}catch(error){}html+="</div>",review.Url&&(html+='<div class="secondary listItemBodyText"><a class="textlink" href="'+review.Url+'" target="_blank">'+globalize.translate("ButtonFullReview")+"</a></div>"),html+="</div>",html+="</div>",html+="</div>"}limit&&result.TotalRecordCount>limit&&(html+='<p style="margin: 0;"><button is="emby-button" type="button" class="raised more moreCriticReviews">'+globalize.translate("ButtonMore")+"</button></p>");var criticReviewsContent=page.querySelector("#criticReviewsContent");criticReviewsContent.innerHTML=html,enableScrollX()?criticReviewsContent.classList.add("hiddenScrollX"):criticReviewsContent.classList.remove("hiddenScrollX")}function renderThemeMedia(page,item){"SeriesTimer"!==item.Type&&"Timer"!==item.Type&&"Genre"!==item.Type&&"MusicGenre"!==item.Type&&"GameGenre"!==item.Type&&"Studio"!==item.Type&&"Person"!==item.Type&&ApiClient.getThemeMedia(Dashboard.getCurrentUserId(),item.Id,!0).then(function(result){var themeSongs=result.ThemeSongsResult.OwnerId==item.Id?result.ThemeSongsResult.Items:[],themeVideos=result.ThemeVideosResult.OwnerId==item.Id?result.ThemeVideosR
|