(function (window, document, $) { var itemCountsPromise; var liveTvInfoPromise; function ensurePromises() { itemCountsPromise = itemCountsPromise || ApiClient.getItemCounts(Dashboard.getCurrentUserId()); liveTvInfoPromise = liveTvInfoPromise || ApiClient.getLiveTvInfo(); } function renderHeader(page, user) { var html = '
'; $(page).prepend(html); $('.viewMenuBar', page).trigger('create'); } function insertViews(page, user, counts, liveTvInfo) { var html = ''; var selectedCssClass = ' selectedViewLink'; var selectedHtml = "▶"; var view = page.getAttribute('data-view') || getParameterByName('context'); if (counts.MovieCount) { html += '' + (view == 'movies' ? selectedHtml : '') + 'Movies'; } if (counts.SeriesCount) { html += '' + (view == 'tv' ? selectedHtml : '') + 'TV'; } if (liveTvInfo.ActiveServiceName) { html += '' + (view == 'livetv' ? selectedHtml : '') + 'Live TV'; } if (counts.SongCount || counts.MusicVideoCount) { html += '' + (view == 'music' ? selectedHtml : '') + 'Music'; } if (counts.GameCount) { html += '' + (view == 'games' ? selectedHtml : '') + 'Games'; } $('.viewMenuRemoteControlButton', page).before(html); } function showLibraryMenu(page) { ensurePromises(); $.when(itemCountsPromise, liveTvInfoPromise).done(function (response1, response2) { var counts = response1[0]; var liveTvInfo = response2[0]; var panel = getLibraryMenu(page, counts, liveTvInfo); $(panel).panel('toggle'); }); } function getLibraryMenu(page, counts, liveTvInfo) { var panel = $('#libraryPanel', page); if (!panel.length) { var html = ''; html += '