(function (window, document, $) { var itemCountsPromise; var liveTvServicesPromise; function ensurePromises() { itemCountsPromise = itemCountsPromise || ApiClient.getItemCounts(Dashboard.getCurrentUserId()); liveTvServicesPromise = liveTvServicesPromise || ApiClient.getLiveTvServices(); } function renderHeader(page, user) { var html = '
'; $(page).prepend(html); $('.viewMenuBar', page).trigger('create'); } function insertViews(page, user, counts, liveTvServices) { 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 (liveTvServices.length) { 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, liveTvServicesPromise).done(function (response1, response2) { var counts = response1[0]; var liveTvServices = response2[0]; var panel = getLibraryMenu(page, counts, liveTvServices); $(panel).panel('toggle'); }); } function getLibraryMenu(page, counts, liveTvServices) { var panel = $('#libraryPanel', page); if (!panel.length) { var html = ''; html += '