29 lines
42 KiB
JavaScript
29 lines
42 KiB
JavaScript
|
|
import browser from"./../../browser.js";import itemShortcuts from"./../../shortcuts.js";import connectionManager from"./../../emby-apiclient/connectionmanager.js";import serverNotifications from"./../../common/input/api.js";import events from"./../../emby-apiclient/events.js";import globalize from"./../../common/globalize.js";import dom from"./../../dom.js";import layoutManager from"./../../layoutmanager.js";import datetime from"./../../common/datetime.js";import focusManager from"./../../focusmanager.js";import loading from"./../../loading/loading.js";import mouseManager from"./../../input/mouse.js";import userSettings from"./../../common/usersettings/usersettings.js";import gridRowRenderer from"./gridrowrenderer.js";import"./../emby-button/emby-button.js";import"./../emby-scroller/emby-scroller.js";import"./../emby-button/paper-icon-button-light.js";import MethodTimer from"./../../common/methodtimer.js";import EmbyItemsContainer from"./../emby-itemscontainer/emby-itemscontainer.js";import inputManager from"./../../common/inputmanager.js";import playbackManager from"./../../common/playback/playbackmanager.js";require(["css!modules/emby-elements/guide/guide.css","programStyles","material-icons","flexStyles"]);let virtualChunkSize=25,cellCurationMinutes=30,cellDurationMs=60*cellCurationMinutes*1e3,msPerMinute=6e4,msPerHour=36e5,msPerDay=864e5,msPerPage=8*msPerHour,startId=Date.now();function showActionSheet(options){return Emby.importModule("./modules/actionsheet/actionsheet.js").then(function(ActionSheet){return ActionSheet.show(options)})}function normalizeDateToTimeslot(value,roundUp){var delta=value%cellDurationMs;return roundUp&&delta&&(value+=cellDurationMs),value-=delta}function onSettingsButtonClick(e){let instance=this;Emby.importModule("./modules/emby-elements/guide/guide-settings.js").then(function(guideSettingsDialog){guideSettingsDialog.show({categoryOptions:instance.categoryOptions,positionTo:e.target,positionY:"bottom",positionX:"after"},connectionManager.getApiClient(instance.options.serverId)).then(function(){instance.refresh()})})}function getDateMenuOptions(instance){var items=[];let start=new Date(instance._startDateMs);for(var end=new Date(instance._endDateMs),today=new Date,nowHours=today.getHours(),nowMinutes=30<=today.getMinutes()?30:0,nowHours=(start.setHours(nowHours,nowMinutes,0,0),end.setHours(0,0,0,0),start.getTime()>=end.getTime()&&end.setDate(start.getDate()+1),start=new Date(Math.max(today,start)),instance.scroller),nowMinutes=instance.scroller.getScrollWidth(),today=(nowMinutes-=getChannelCellWidth(instance),instance._startDateMs),instance=instance._endDateMs,nowHours=Math.abs(nowHours.getScrollLeft())/nowMinutes*(instance-today),date=(nowHours+=today,new Date(nowHours));start<=end;)items.push({name:datetime.toLocaleDateString(start,{weekday:"long",month:"short",day:"numeric"}),value:start.getTime().toString(),selected:date.getDate()===start.getDate()&&date.getMonth()===start.getMonth()&&date.getFullYear()===start.getFullYear()}),start.setDate(start.getDate()+1),start.setHours(0,0,0,0);return items}function onDateButtonClick(e){showActionSheet({items:getDateMenuOptions(this),positionTo:e.target,title:globalize.translate("Date"),positionY:"bottom",hasItemSelectionState:!0}).then(onSelectedDateValue.bind(this))}function scrollToTimeMs(instance,value,exactTime,autoFocus){value=parseInt(value);var startDate,endDate,date=new Date,value=(date.setTime(value),instance.scroller),scrollWidth=instance.scroller.getScrollWidth();scrollWidth&&(scrollWidth-=getChannelCellWidth(instance),startDate=instance._startDateMs,endDate=instance._endDateMs,exactTime||(exactTime=Math.abs(value.getScrollLeft())/scrollWidth*(endDate-startDate),exactTime+=startDate,exactTime=new Date(exactTime),date.setHours(exactTime.getHours(),exactTime.getMinutes()+1,0,0)),date.setTime(normalizeDateToTimeslot(date.getTime())),exactTime=Math.max(date.getTime()-startDate,0)/(endDate-startDate),value.scrollToPosition({left:exactTime*scrollWidth*value.getScrollLeftMultiplier(),behavior:"instant"}),onScroll.call(instance,{currentTarget:
|
||
|
|
.epgScrollSlider {
|
||
|
|
width: `+32*numCells+`ch;
|
||
|
|
}
|
||
|
|
|
||
|
|
@media all and (min-width: 80em) {
|
||
|
|
|
||
|
|
.epgScrollSlider {
|
||
|
|
width: `+40*numCells+`ch;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@media all and (min-width: 120em) {
|
||
|
|
|
||
|
|
.epgScrollSlider {
|
||
|
|
width: `+50*numCells+`ch;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@media all and (orientation: portrait) {
|
||
|
|
|
||
|
|
.epgScrollSlider {
|
||
|
|
width: calc(`+numCells+` * min(50ch, 34vw));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
.epgScrollSlider-tv {
|
||
|
|
width: `+19*numCells+`vw;
|
||
|
|
}
|
||
|
|
`,elem=(console.log("rendering guide width css"),html=html.replaceAll("epgScrollSlider",instance.scrollSliderUniqueClass),document.querySelector("."+instance.styleElementUniqueClass));elem?elem.innerHTML=html:((elem=document.createElement("style")).innerHTML=html,document.head.appendChild(elem))}function onGetGuideInfo(guideInfo){var guideInfo=Date.parse(guideInfo.EndDate),startDate=(loading.show(),this._startDateMs=normalizeDateToTimeslot(Date.now())),guideInfo=this._endDateMs=normalizeDateToTimeslot(guideInfo,!0),guideInfo=(renderWidthCss(this),this.scroller.notifyResized(),this.options.element.querySelector(".timeslotHeaders").innerHTML=getTimeslotHeadersHtml(startDate,guideInfo),this.currentPositionMs?null:startDate);return this.updateDateButtonText(guideInfo,Math.abs(this.scroller.getScrollLeft())),refreshTagFilters(this),this.itemsContainer.virtualScroller?.resetAll(),this.itemsContainer.resume({refresh:!0}).then(function(){loading.hide()})}let dateLocalOptions={weekday:"short",month:"short",day:"numeric"};function hideOrShow(elem,hide){!0===elem._showing?hide&&(elem.classList.add("hide"),elem._showing=!1):hide||(elem.classList.remove("hide"),elem._showing=!0)}function isInCurrentFocusScope(instance){return!focusManager.hasExclusiveFocusScope()}Guide.prototype.updateCurrentPositionIfNeeded=function(){var now,currentPositionMs=this.currentPositionMs;currentPositionMs&&(console.log("currentPositionMs: "+currentPositionMs),currentPositionMs=normalizeDateToTimeslot(currentPositionMs),console.log("currentPositionMs normalized: "+currentPositionMs),now=Date.now(),console.log("now: "+now),currentPositionMs<=now&&now<currentPositionMs+cellDurationMs?console.log("scrollToNow not needed"):isInCurrentFocusScope(this)&&this.scrollToNow())},Guide.prototype.scrollToNow=function(){var autoFocus=layoutManager.tv&&isInCurrentFocusScope(this);scrollToTimeMs(this,Date.now(),!0,autoFocus)},Guide.prototype.updateDateButtonText=function(currentPositionMs,scrollLeft,scrollWidth){if(!currentPositionMs){var startDate=this._startDateMs,endDate=this._endDateMs;if(!startDate||!endDate)return;if(0===scrollWidth)return;if(null==scrollWidth){var channelCellWidth=getChannelCellWidth(this);if(!channelCellWidth)return;if(!(scrollWidth=this.scroller.getScrollWidth()))return;scrollWidth-=channelCellWidth}if(scrollWidth<=0)return;currentPositionMs=scrollLeft/scrollWidth*(endDate-startDate),currentPositionMs=Math.floor(currentPositionMs),currentPositionMs+=startDate}this.currentPositionMs=currentPositionMs;channelCellWidth=new Date(currentPositionMs),scrollLeft=this.btnDateText||(this.btnDateText=this.options.element.querySelector(".btnDateText")),layoutManager.tv?scrollLeft.classList.remove("btnDateText-autosize"):scrollLeft.classList.add("btnDateText-autosize"),scrollLeft.innerHTML=datetime.toLocaleDateString(channelCellWidth,dateLocalOptions),scrollWidth=this.btnLiveGuide,!layoutManager.tv&&Math.abs(currentPositionMs-Date.now())>cellDurationMs?hideOrShow(scrollWidth,!1):hideOrShow(scrollWidth,!0),userSettings.guideChannelStyle();userSettings.showChannelNumberInGuide(),!1===this.options.dateButton?this.dateButtons[0].classList.add("hide"):this.dateButtons[0].classList.remove("hide")};let minIdleTime=6e4;function onCurrentTimeUpdate(){var dots=this.currentTimeIndicatorDots,startDateMs=this._startDateMs,endDate=this._endDateMs;let pct;var now=Date.now(),showIndicator=0<=(pct=startDateMs&&endDate?(now-startDateMs)/(endDate-startDateMs)*100:-100)&&pct<=100,displayTime=(pct=pct.toFixed(2)+"%",getDisplayTime(new Date(now)));for(let i=0,length=dots.length;i<length;i++){var dot=dots[i];dot.style[InsetInlineStartProp]=pct,dot.setAttribute("aria-label",displayTime),dot.title=displayTime,showIndicator?dot.classList.remove("hide"):dot.classList.add("hide")}inputManager.idleTime()<minIdleTime||now-mouseManager.lastMouseInputTime()<minIdleTime||this.updateCurrentPositionIfNeeded()}function scrollToIndex(instance,index,focus,scrollBehavior){focus&&instance.scroller.setFocusScroll("start"),instance.itemsContainer.scrollToIndex(index,{behavior:scrollBehavior},focus)
|