(function () { function getTimersHtml(timers) { var html = ''; var index = ''; for (var i = 0, length = timers.length; i < length; i++) { var timer = timers[i]; var startDateText = LibraryBrowser.getFutureDateText(parseISO8601Date(timer.StartDate, { toLocal: true })); if (startDateText != index) { if (index) { html += ''; html += ''; } html += '
'; html += '

' + startDateText + '

'; html += '
'; index = startDateText; } html += ''; var program = timer.ProgramInfo || {}; var imgUrl; if (program.ImageTags && program.ImageTags.Primary) { imgUrl = ApiClient.getScaledImageUrl(program.Id, { height: 80, tag: program.ImageTags.Primary, type: "Primary" }); } if (imgUrl) { html += ''; } else if (program.IsKids) { html += ''; } else if (program.IsSports) { html += ''; } else if (program.IsMovie) { html += ''; } else if (program.IsNews) { html += ''; } else { html += ''; } html += ''; html += ''; html += '
'; html += timer.Name; html += '
'; html += '
'; html += LibraryBrowser.getDisplayTime(timer.StartDate); html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate); html += '
'; html += '
'; html += '
'; if (timer.SeriesTimerId) { html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; } html += ''; html += '
'; } if (timers.length) { html += '
'; html += '
'; } return html; } window.LiveTvHelpers = { getDaysOfWeek: function () { var days = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]; return days.map(function (d) { return { name: d, value: d }; }); }, renderOriginalAirDate: function (elem, item) { var airDate = item.PremiereDate; if (airDate && item.IsRepeat) { try { airDate = parseISO8601Date(airDate, { toLocal: true }).toLocaleDateString(); } catch (e) { Logger.log("Error parsing date: " + airDate); } elem.html(Globalize.translate('ValueOriginalAirDate').replace('{0}', airDate)).show(); } else { elem.hide(); } }, getTimersHtml: getTimersHtml }; })(); (function ($, document, window) { var showOverlayTimeout; var hideOverlayTimeout; var currentPosterItem; function onOverlayMouseOver() { if (hideOverlayTimeout) { clearTimeout(hideOverlayTimeout); hideOverlayTimeout = null; } } function onOverlayMouseOut() { startHideOverlayTimer(); } function getOverlayHtml(item) { var html = ''; html += '
'; if (item.EpisodeTitle) { html += '

'; html += item.EpisodeTitle; html += '

'; } html += '

'; html += '

'; html += ''; html += LibraryBrowser.getRatingHtml(item); html += ''; html += ''; html += LibraryBrowser.getUserDataIconsHtml(item); html += ''; html += '

'; html += '

'; html += '

'; html += (item.Overview || ''); html += '

'; html += '
'; var endDate; var startDate; var now = new Date().getTime(); try { endDate = parseISO8601Date(item.EndDate, { toLocal: true }); } catch (err) { endDate = now; } try { startDate = parseISO8601Date(item.StartDate, { toLocal: true }); } catch (err) { startDate = now; } if (now < endDate && now >= startDate) { html += '' + Globalize.translate('ButtonPlay') + ''; } if (!item.TimerId && !item.SeriesTimerId) { html += '' + Globalize.translate('ButtonRecord') + ''; } html += '
'; html += '
'; return html; } function onPlayClick() { hideOverlay(); MediaController.play({ ids: [this.getAttribute('data-id')] }); } function onRecordClick() { hideOverlay(); Dashboard.navigate('livetvnewrecording.html?programid=' + this.getAttribute('data-id')); } function showOverlay(elem, item) { require(['components/paperdialoghelper'], function () { var dlg = document.createElement('paper-dialog'); dlg.setAttribute('with-backdrop', 'with-backdrop'); dlg.setAttribute('role', 'alertdialog'); // seeing max call stack size exceeded in the debugger with this dlg.setAttribute('noAutoFocus', 'noAutoFocus'); dlg.entryAnimation = 'scale-up-animation'; dlg.exitAnimation = 'fade-out-animation'; dlg.classList.add('ui-body-b'); dlg.classList.add('background-theme-b'); dlg.classList.add('tvProgramOverlay'); var html = ''; html += '

'; html += item.Name; html += '

'; html += '
'; html += getOverlayHtml(item); html += '
'; dlg.innerHTML = html; document.body.appendChild(dlg); // Has to be assigned a z-index after the call to .open() $(dlg).on('iron-overlay-closed', function () { $(dlg).off('mouseenter', onOverlayMouseOver); $(dlg).off('mouseleave', onOverlayMouseOut); this.parentNode.removeChild(this); if (currentPosterItem) { currentPosterItem = null; } }); $('.btnPlay', dlg).on('click', onPlayClick); $('.btnRecord', dlg).on('click', onRecordClick); LibraryBrowser.renderGenres($('.itemGenres', dlg), item, 3); $('.miscTvProgramInfo', dlg).html(LibraryBrowser.getMiscInfoHtml(item)); PaperDialogHelper.positionTo(dlg, elem); dlg.open(); $(dlg).on('mouseenter', onOverlayMouseOver); $(dlg).on('mouseleave', onOverlayMouseOut); currentPosterItem = elem; }); } function onProgramClicked() { if (showOverlayTimeout) { clearTimeout(showOverlayTimeout); showOverlayTimeout = null; } if (hideOverlayTimeout) { clearTimeout(hideOverlayTimeout); hideOverlayTimeout = null; } hideOverlay(); } function hideOverlay() { var flyout = document.querySelector('.tvProgramOverlay'); if (flyout) { flyout.close(); } } function startHideOverlayTimer() { if (hideOverlayTimeout) { clearTimeout(hideOverlayTimeout); hideOverlayTimeout = null; } hideOverlayTimeout = setTimeout(hideOverlay, 200); } $.fn.createGuideHoverMenu = function (childSelector) { function onShowTimerExpired(elem) { var id = elem.getAttribute('data-programid'); ApiClient.getLiveTvProgram(id, Dashboard.getCurrentUserId()).done(function (item) { showOverlay(elem, item); }); } function onHoverOut() { if (showOverlayTimeout) { clearTimeout(showOverlayTimeout); showOverlayTimeout = null; } } function onHoverIn() { if (showOverlayTimeout) { clearTimeout(showOverlayTimeout); showOverlayTimeout = null; } if (hideOverlayTimeout) { clearTimeout(hideOverlayTimeout); hideOverlayTimeout = null; } var elem = this; if (currentPosterItem) { if (currentPosterItem && currentPosterItem == elem) { return; } else { hideOverlay(); } } showOverlayTimeout = setTimeout(function () { onShowTimerExpired(elem); }, 1000); } if (AppInfo.isTouchPreferred) { /* browser with either Touch Events of Pointer Events running on touch-capable device */ return this; } return this.on('mouseenter', childSelector, onHoverIn) .on('mouseleave', childSelector, onHoverOut) .on('click', childSelector, onProgramClicked); }; })(jQuery, document, window);