(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 = '
'; var $page = $(page); $page.prepend(html); $('.viewMenuBar', page).trigger('create'); $page.trigger('headercreated'); } 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.EnabledUsers.indexOf(user.Id) != -1) { html += '' + (view == 'livetv' ? selectedHtml : '') + 'Live TV'; } if (counts.SongCount || counts.MusicVideoCount) { html += '' + (view == 'music' ? selectedHtml : '') + 'Music'; } if (counts.GameCount) { html += '' + (view == 'games' ? selectedHtml : '') + 'Games'; } if (counts.ChannelCount) { html += '' + (view == 'channels' ? selectedHtml : '') + 'Channels'; } //if (counts.BoxSetCount) { html += '' + (view == 'boxsets' ? selectedHtml : '') + 'Collections'; //} $('.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 += '