2017-08-27 10:34:42 -07:00
|
|
|
define(["layoutManager","loading","libraryBrowser","mainTabsManager","cardBuilder","apphost","imageLoader","scrollStyles","emby-itemscontainer","emby-tabs","emby-button"],function(layoutManager,loading,libraryBrowser,mainTabsManager,cardBuilder,appHost,imageLoader){"use strict";function enableScrollX(){return!layoutManager.desktop}function getBackdropShape(){return enableScrollX()?"overflowBackdrop":"backdrop"}function getPortraitShape(){return enableScrollX()?"overflowPortrait":"portrait"}function getLimit(){return enableScrollX()?12:8}function loadRecommendedPrograms(page){loading.show();var limit=getLimit();enableScrollX()&&(limit*=2),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),IsAiring:!0,limit:limit,ImageTypeLimit:1,EnableImageTypes:"Primary,Thumb,Backdrop",EnableTotalRecordCount:!1,Fields:"ChannelInfo,PrimaryImageAspectRatio"}).then(function(result){renderItems(page,result.Items,"activeProgramItems","play",{showAirDateTime:!1,showAirEndTime:!0}),loading.hide()})}function reload(page,enableFullRender){enableFullRender&&(loadRecommendedPrograms(page),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),HasAired:!1,limit:getLimit(),IsMovie:!1,IsSports:!1,IsKids:!1,IsNews:!1,IsSeries:!0,EnableTotalRecordCount:!1,Fields:"ChannelInfo,PrimaryImageAspectRatio",EnableImageTypes:"Primary,Thumb"}).then(function(result){renderItems(page,result.Items,"upcomingEpisodeItems")}),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),HasAired:!1,limit:getLimit(),IsMovie:!0,EnableTotalRecordCount:!1,Fields:"ChannelInfo",EnableImageTypes:"Primary,Thumb"}).then(function(result){renderItems(page,result.Items,"upcomingTvMovieItems",null,{shape:getPortraitShape(),preferThumb:null,showParentTitle:!1})}),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),HasAired:!1,limit:getLimit(),IsSports:!0,EnableTotalRecordCount:!1,Fields:"ChannelInfo,PrimaryImageAspectRatio",EnableImageTypes:"Primary,Thumb"}).then(function(result){renderItems(page,result.Items,"upcomingSportsItems")}),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),HasAired:!1,limit:getLimit(),IsKids:!0,EnableTotalRecordCount:!1,Fields:"ChannelInfo,PrimaryImageAspectRatio",EnableImageTypes:"Primary,Thumb"}).then(function(result){renderItems(page,result.Items,"upcomingKidsItems")}),ApiClient.getLiveTvRecommendedPrograms({userId:Dashboard.getCurrentUserId(),HasAired:!1,limit:getLimit(),IsNews:!0,EnableTotalRecordCount:!1,Fields:"ChannelInfo,PrimaryImageAspectRatio",EnableImageTypes:"Primary,Thumb"}).then(function(result){renderItems(page,result.Items,"upcomingNewsItems",null,{showParentTitleOrTitle:!0,showTitle:!1,showParentTitle:!1})}))}function renderItems(page,items,sectionClass,overlayButton,cardOptions){var html=cardBuilder.getCardsHtml(Object.assign({items:items,preferThumb:"auto",inheritThumb:!1,shape:enableScrollX()?"autooverflow":"auto",defaultShape:getBackdropShape(),showParentTitle:!0,showTitle:!0,centerText:!0,coverImage:!0,overlayText:!1,lazy:!0,overlayPlayButton:"play"===overlayButton,overlayMoreButton:"more"===overlayButton,overlayInfoButton:"info"===overlayButton,allowBottomPadding:!enableScrollX(),showAirTime:!0,showAirDateTime:!0},cardOptions||{})),elem=page.querySelector("."+sectionClass);elem.innerHTML=html,imageLoader.lazyChildren(elem)}function getTabs(){return[{name:Globalize.translate("Programs")},{name:Globalize.translate("TabGuide")},{name:Globalize.translate("TabChannels")},{name:Globalize.translate("TabRecordings")},{name:Globalize.translate("HeaderSchedule")},{name:Globalize.translate("TabSeries")},{name:Globalize.translate("ButtonSearch")}]}return function(view,params){function enableFullRender(){return(new Date).getTime()-lastFullRender>3e5}function onBeforeTabChange(e){preLoadTab(view,parseInt(e.detail.selectedTabIndex))}function onTabChange(e){var previousTabController=tabControllers[parseInt(e.detail.previousIndex)];previousTabController&&previousTabController.onHide&&previousTabController.onHide(),loadTab(view,parseInt(e.de
|