2017-01-27 18:05:04 -05:00
|
|
|
|
define(['layoutManager', 'viewManager', 'libraryBrowser', 'embyRouter', 'playbackManager', 'paper-icon-button-light', 'material-icons', 'scrollStyles'], function (layoutManager, viewManager, libraryBrowser, embyRouter, playbackManager) {
|
2016-10-23 01:11:46 -04:00
|
|
|
|
'use strict';
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
var enableBottomTabs = AppInfo.isNativeApp;
|
|
|
|
|
var enableLibraryNavDrawer = !enableBottomTabs;
|
|
|
|
|
|
|
|
|
|
var navDrawerElement;
|
|
|
|
|
var navDrawerScrollContainer;
|
2016-06-21 12:38:29 -04:00
|
|
|
|
var navDrawerInstance;
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
var mainDrawerButton;
|
|
|
|
|
|
2015-05-22 11:59:17 -04:00
|
|
|
|
function renderHeader() {
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2015-09-07 21:00:46 -04:00
|
|
|
|
var html = '';
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
html += '<div class="primaryIcons">';
|
2016-07-07 23:24:22 -04:00
|
|
|
|
var backIcon = browserInfo.safari ? 'chevron_left' : '';
|
2015-07-08 20:20:01 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonLeft headerBackButton hide"><i class="md-icon">' + backIcon + '</i></button>';
|
2015-04-25 23:25:07 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft hide"><i class="md-icon">menu</i></button>';
|
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerAppsButton barsMenuButton headerButtonLeft"><i class="md-icon">home</i></button>';
|
2016-03-29 13:28:14 -04:00
|
|
|
|
|
2016-11-05 15:34:03 -04:00
|
|
|
|
html += '<h3 class="libraryMenuButtonText headerButton">' + Globalize.translate('ButtonHome') + '</h3>';
|
2015-01-21 01:26:16 -05:00
|
|
|
|
|
2013-12-27 16:10:06 -05:00
|
|
|
|
html += '<div class="viewMenuSecondary">';
|
|
|
|
|
|
2015-06-24 00:38:46 -04:00
|
|
|
|
html += '<span class="headerSelectedPlayer"></span>';
|
2016-12-29 02:14:59 -05:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="btnCast headerButton-btnCast headerButton headerButtonRight hide autoSize"><i class="md-icon">cast</i></button>';
|
2014-05-11 01:11:53 -04:00
|
|
|
|
|
2016-09-01 12:36:11 -04:00
|
|
|
|
html += '<button type="button" is="paper-icon-button-light" class="headerButton headerButtonRight headerSearchButton hide autoSize"><i class="md-icon">search</i></button>';
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
2016-06-19 01:26:52 -04:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerVoiceButton hide autoSize"><i class="md-icon">mic</i></button>';
|
2015-06-02 01:46:06 -04:00
|
|
|
|
|
2016-06-09 12:13:25 -04:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight btnNotifications"><div class="btnNotificationsInner">0</div></button>';
|
2015-09-21 21:05:33 -04:00
|
|
|
|
|
2016-06-19 01:26:52 -04:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerUserButton autoSize"><i class="md-icon">person</i></button>';
|
2015-06-04 00:50:10 -04:00
|
|
|
|
|
2017-01-03 01:51:36 -05:00
|
|
|
|
if (!browserInfo.mobile) {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight dashboardEntryHeaderButton autoSize" onclick="return LibraryMenu.onSettingsClicked(event);"><i class="md-icon">settings</i></button>';
|
2015-06-02 01:46:06 -04:00
|
|
|
|
}
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2016-07-05 14:11:34 -04:00
|
|
|
|
html += '<div class="viewMenuBarTabs">';
|
2015-05-22 11:59:17 -04:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-09-07 21:00:46 -04:00
|
|
|
|
var viewMenuBar = document.createElement('div');
|
|
|
|
|
viewMenuBar.classList.add('viewMenuBar');
|
|
|
|
|
viewMenuBar.innerHTML = html;
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
document.querySelector('.skinHeader').appendChild(viewMenuBar);
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
2016-11-25 01:58:38 -05:00
|
|
|
|
lazyLoadViewMenuBarImages();
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
|
|
|
|
bindMenuEvents();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 01:58:38 -05:00
|
|
|
|
function lazyLoadViewMenuBarImages() {
|
|
|
|
|
require(['imageLoader'], function (imageLoader) {
|
|
|
|
|
imageLoader.lazyChildren(document.querySelector('.viewMenuBar'));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 17:32:20 -04:00
|
|
|
|
function onBackClick() {
|
2015-06-17 21:41:22 -04:00
|
|
|
|
|
2016-10-15 18:12:16 -04:00
|
|
|
|
embyRouter.back();
|
2015-06-08 17:32:20 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-25 21:28:35 -05:00
|
|
|
|
function updateUserInHeader(user) {
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var header = document.querySelector('.viewMenuBar');
|
2016-05-10 01:15:06 -04:00
|
|
|
|
if (!header) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-05-22 11:59:17 -04:00
|
|
|
|
|
2015-12-24 13:14:12 -05:00
|
|
|
|
var headerUserButton = header.querySelector('.headerUserButton');
|
|
|
|
|
var hasImage;
|
2015-12-25 21:28:35 -05:00
|
|
|
|
|
|
|
|
|
if (user && user.name) {
|
2016-02-26 12:15:06 -05:00
|
|
|
|
if (user.imageUrl) {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
|
|
|
|
var userButtonHeight = 26;
|
|
|
|
|
|
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
|
|
|
|
|
if (user.supportsImageParams) {
|
2016-04-23 14:48:57 -04:00
|
|
|
|
url += "&height=" + Math.round((userButtonHeight * Math.max(window.devicePixelRatio || 1, 2)));
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headerUserButton) {
|
2016-06-19 12:53:53 -04:00
|
|
|
|
updateHeaderUserButton(headerUserButton, url);
|
2015-12-24 13:14:12 -05:00
|
|
|
|
hasImage = true;
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-23 12:16:06 -04:00
|
|
|
|
|
2015-12-25 21:28:35 -05:00
|
|
|
|
if (headerUserButton && !hasImage) {
|
|
|
|
|
|
2016-06-19 12:53:53 -04:00
|
|
|
|
updateHeaderUserButton(headerUserButton, null);
|
2015-12-25 21:28:35 -05:00
|
|
|
|
}
|
|
|
|
|
if (user) {
|
|
|
|
|
updateLocalUser(user.localUser);
|
2015-12-24 13:14:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
requiresUserRefresh = false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-19 12:53:53 -04:00
|
|
|
|
function updateHeaderUserButton(headerUserButton, src) {
|
2016-03-14 14:05:45 -04:00
|
|
|
|
|
|
|
|
|
if (src) {
|
|
|
|
|
headerUserButton.classList.add('headerUserButtonRound');
|
2016-06-19 01:26:52 -04:00
|
|
|
|
headerUserButton.classList.remove('autoSize');
|
2016-05-06 13:49:58 -04:00
|
|
|
|
headerUserButton.innerHTML = '<img src="' + src + '" />';
|
2016-03-14 14:05:45 -04:00
|
|
|
|
} else {
|
|
|
|
|
headerUserButton.classList.remove('headerUserButtonRound');
|
2016-06-19 12:53:53 -04:00
|
|
|
|
headerUserButton.classList.add('autoSize');
|
|
|
|
|
headerUserButton.innerHTML = '<i class="md-icon">person</i>';
|
2016-03-14 14:05:45 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
function updateLocalUser(user) {
|
|
|
|
|
|
|
|
|
|
var header = document.querySelector('.viewMenuBar');
|
|
|
|
|
|
|
|
|
|
var headerSearchButton = header.querySelector('.headerSearchButton');
|
|
|
|
|
var btnCast = header.querySelector('.btnCast');
|
|
|
|
|
var dashboardEntryHeaderButton = header.querySelector('.dashboardEntryHeaderButton');
|
|
|
|
|
|
|
|
|
|
if (user) {
|
|
|
|
|
btnCast.classList.remove('hide');
|
2015-09-23 12:16:06 -04:00
|
|
|
|
|
|
|
|
|
if (headerSearchButton) {
|
|
|
|
|
headerSearchButton.classList.remove('hide');
|
|
|
|
|
}
|
2015-06-02 01:46:06 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
if (dashboardEntryHeaderButton) {
|
|
|
|
|
if (user.Policy.IsAdministrator) {
|
|
|
|
|
dashboardEntryHeaderButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
dashboardEntryHeaderButton.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-06 15:25:58 -04:00
|
|
|
|
require(['apphost'], function (apphost) {
|
|
|
|
|
if (apphost.supports('voiceinput')) {
|
2016-12-02 03:03:38 -05:00
|
|
|
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
2015-06-02 01:46:06 -04:00
|
|
|
|
} else {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
2015-06-02 01:46:06 -04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-22 11:59:17 -04:00
|
|
|
|
} else {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
btnCast.classList.add('hide');
|
|
|
|
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
2015-09-23 12:16:06 -04:00
|
|
|
|
if (headerSearchButton) {
|
|
|
|
|
headerSearchButton.classList.add('hide');
|
|
|
|
|
}
|
2015-05-14 01:42:55 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
if (dashboardEntryHeaderButton) {
|
2015-07-09 01:52:25 -04:00
|
|
|
|
dashboardEntryHeaderButton.classList.add('hide');
|
|
|
|
|
}
|
2014-10-25 14:32:58 -04:00
|
|
|
|
}
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}
|
2015-06-10 09:37:07 -04:00
|
|
|
|
|
2016-02-23 12:53:04 -05:00
|
|
|
|
function showVoice() {
|
2016-07-06 15:25:58 -04:00
|
|
|
|
require(['voiceDialog'], function (voiceDialog) {
|
|
|
|
|
voiceDialog.showDialog();
|
2016-02-23 12:53:04 -05:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 13:28:36 -04:00
|
|
|
|
function showSearch() {
|
|
|
|
|
Dashboard.navigate('search.html');
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 14:05:45 -04:00
|
|
|
|
function onHeaderUserButtonClick(e) {
|
|
|
|
|
Dashboard.showUserFlyout(e.target);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 13:28:14 -04:00
|
|
|
|
function onHeaderAppsButtonClick() {
|
|
|
|
|
|
2016-07-22 13:30:39 -04:00
|
|
|
|
Dashboard.navigate('home.html');
|
2016-03-29 13:28:14 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-25 23:25:07 -04:00
|
|
|
|
function bindMenuEvents() {
|
2014-05-29 15:34:20 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
mainDrawerButton = document.querySelector('.mainDrawerButton');
|
2015-09-07 21:00:46 -04:00
|
|
|
|
|
|
|
|
|
if (mainDrawerButton) {
|
2016-03-06 13:09:20 -05:00
|
|
|
|
mainDrawerButton.addEventListener('click', toggleMainDrawer);
|
2015-04-25 23:25:07 -04:00
|
|
|
|
}
|
2015-05-04 10:35:38 -04:00
|
|
|
|
|
2015-09-07 21:00:46 -04:00
|
|
|
|
var headerBackButton = document.querySelector('.headerBackButton');
|
|
|
|
|
if (headerBackButton) {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
headerBackButton.addEventListener('click', onBackClick);
|
2015-09-07 21:00:46 -04:00
|
|
|
|
}
|
2015-06-08 17:32:20 -04:00
|
|
|
|
|
2016-02-23 12:53:04 -05:00
|
|
|
|
var headerVoiceButton = document.querySelector('.headerVoiceButton');
|
|
|
|
|
if (headerVoiceButton) {
|
|
|
|
|
headerVoiceButton.addEventListener('click', showVoice);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-27 13:28:36 -04:00
|
|
|
|
var headerSearchButton = document.querySelector('.headerSearchButton');
|
|
|
|
|
if (headerSearchButton) {
|
|
|
|
|
headerSearchButton.addEventListener('click', showSearch);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 14:05:45 -04:00
|
|
|
|
var headerUserButton = document.querySelector('.headerUserButton');
|
|
|
|
|
if (headerUserButton) {
|
|
|
|
|
headerUserButton.addEventListener('click', onHeaderUserButtonClick);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 13:28:14 -04:00
|
|
|
|
var headerAppsButton = document.querySelector('.headerAppsButton');
|
|
|
|
|
if (headerAppsButton) {
|
|
|
|
|
headerAppsButton.addEventListener('click', onHeaderAppsButtonClick);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 21:00:46 -04:00
|
|
|
|
var viewMenuBar = document.querySelector(".viewMenuBar");
|
2015-05-06 23:11:51 -04:00
|
|
|
|
initHeadRoom(viewMenuBar);
|
2015-05-08 12:58:27 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
viewMenuBar.querySelector('.btnNotifications').addEventListener('click', function () {
|
|
|
|
|
Dashboard.navigate('notificationlist.html');
|
|
|
|
|
});
|
2017-01-19 15:09:04 -05:00
|
|
|
|
|
|
|
|
|
var btnCast = document.querySelector('.headerButton-btnCast');
|
|
|
|
|
|
|
|
|
|
if (btnCast) {
|
|
|
|
|
btnCast.addEventListener('click', onCastButtonClicked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onCastButtonClicked() {
|
|
|
|
|
|
|
|
|
|
var btn = this;
|
|
|
|
|
|
|
|
|
|
require(['playerSelectionMenu'], function (playerSelectionMenu) {
|
|
|
|
|
playerSelectionMenu.show(btn);
|
|
|
|
|
});
|
2015-06-17 21:41:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 12:51:39 -04:00
|
|
|
|
function getItemHref(item, context) {
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2016-07-18 23:57:55 -04:00
|
|
|
|
return libraryBrowser.getHref(item, context);
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
2014-05-11 01:11:53 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
var requiresUserRefresh = true;
|
2015-06-23 18:13:06 -04:00
|
|
|
|
var lastOpenTime = new Date().getTime();
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-06 13:09:20 -05:00
|
|
|
|
function toggleMainDrawer() {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
if (navDrawerInstance.isVisible) {
|
|
|
|
|
closeMainDrawer();
|
2016-03-06 13:09:20 -05:00
|
|
|
|
} else {
|
2016-06-21 12:38:29 -04:00
|
|
|
|
openMainDrawer();
|
2016-03-06 13:09:20 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
function openMainDrawer() {
|
2016-03-06 13:09:20 -05:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
navDrawerInstance.open();
|
2015-06-23 18:13:06 -04:00
|
|
|
|
lastOpenTime = new Date().getTime();
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
function onMainDrawerOpened() {
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
if (browserInfo.mobile) {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
document.body.classList.add('bodyWithPopupOpen');
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-21 12:38:29 -04:00
|
|
|
|
function closeMainDrawer() {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
navDrawerInstance.close();
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
2015-12-14 10:43:03 -05:00
|
|
|
|
function onMainDrawerSelect(e) {
|
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
if (!navDrawerInstance.isVisible) {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
document.body.classList.remove('bodyWithPopupOpen');
|
|
|
|
|
} else {
|
|
|
|
|
onMainDrawerOpened();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function refreshLibraryInfoInDrawer(user, drawer) {
|
2014-05-11 01:11:53 -04:00
|
|
|
|
|
2014-05-01 22:54:33 -04:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2016-03-31 02:33:37 -04:00
|
|
|
|
html += '<div style="height:.5em;"></div>';
|
|
|
|
|
|
2016-03-16 01:33:31 -04:00
|
|
|
|
var homeHref = window.ApiClient ? 'home.html' : 'selectserver.html?showuser=1';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" href="' + homeHref + '" onclick="return LibraryMenu.onLinkClicked(event, this);"><span class="sidebarLinkText">' + Globalize.translate('ButtonHome') + '</span></a>';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="remote" href="nowplaying.html" onclick="return LibraryMenu.onLinkClicked(event, this);"><span class="sidebarLinkText">' + Globalize.translate('ButtonRemote') + '</span></a>';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
2015-06-28 10:45:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
html += '<div class="libraryMenuOptions">';
|
|
|
|
|
html += '</div>';
|
2016-01-20 20:05:14 -05:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
var localUser = user.localUser;
|
|
|
|
|
if (localUser && localUser.Policy.IsAdministrator) {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
html += '<div class="adminMenuOptions">';
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
html += '<div class="sidebarHeader">';
|
|
|
|
|
html += Globalize.translate('HeaderAdmin');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkManageServer" data-itemid="dashboard" href="#"><span class="sidebarLinkText">' + Globalize.translate('ButtonManageServer') + '</span></a>';
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" onclick="return LibraryMenu.onLinkClicked(event, this);" href="edititemmetadata.html"><span class="sidebarLinkText">' + Globalize.translate('MetadataManager') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
|
|
|
|
if (!browserInfo.mobile) {
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="reports" onclick="return LibraryMenu.onLinkClicked(event, this);" href="reports.html"><span class="sidebarLinkText">' + Globalize.translate('ButtonReports') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="userMenuOptions">';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
if (user.localUser && (AppInfo.isNativeApp && browserInfo.android)) {
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkMySettings" onclick="return LibraryMenu.onLinkClicked(event, this);" href="mypreferencesmenu.html"><span class="sidebarLinkText">' + Globalize.translate('ButtonSettings') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkManageOffline" data-itemid="manageoffline" onclick="return LibraryMenu.onLinkClicked(event, this);" href="mysync.html?mode=offline"><span class="sidebarLinkText">' + Globalize.translate('ManageOfflineDownloads') + '</span></a>';
|
2016-08-16 14:54:08 -04:00
|
|
|
|
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkSyncToOtherDevices" data-itemid="syncotherdevices" onclick="return LibraryMenu.onLinkClicked(event, this);" href="mysync.html"><span class="sidebarLinkText">' + Globalize.translate('SyncToOtherDevices') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
|
|
|
|
if (Dashboard.isConnectMode()) {
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="selectserver" onclick="return LibraryMenu.onLinkClicked(event, this);" href="selectserver.html?showuser=1"><span class="sidebarLinkText">' + Globalize.translate('ButtonSelectServer') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (user.localUser) {
|
2017-01-27 18:05:04 -05:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="logout" onclick="return LibraryMenu.onLogoutClicked(this);" href="#"><span class="sidebarLinkText">' + Globalize.translate('ButtonSignOut') + '</span></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 16:20:19 -04:00
|
|
|
|
html += '</div>';
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
navDrawerScrollContainer.innerHTML = html;
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
var lnkManageServer = navDrawerScrollContainer.querySelector('.lnkManageServer');
|
2016-03-27 23:37:33 -04:00
|
|
|
|
if (lnkManageServer) {
|
|
|
|
|
lnkManageServer.addEventListener('click', onManageServerClicked);
|
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function refreshDashboardInfoInDrawer(page, user) {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
loadNavDrawer().then(function () {
|
|
|
|
|
if (!navDrawerScrollContainer.querySelector('.adminDrawerLogo')) {
|
|
|
|
|
createDashboardMenu(page);
|
|
|
|
|
} else {
|
|
|
|
|
updateDashboardMenuSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function updateDashboardMenuSelectedItem() {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
var links = navDrawerScrollContainer.querySelectorAll('.sidebarLink');
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
for (var i = 0, length = links.length; i < length; i++) {
|
|
|
|
|
var link = links[i];
|
2014-12-30 14:16:01 -05:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
var selected = false;
|
2015-05-29 19:51:33 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
var pageIds = link.getAttribute('data-pageids');
|
|
|
|
|
if (pageIds) {
|
2016-06-02 13:08:25 -04:00
|
|
|
|
selected = pageIds.split(',').indexOf(viewManager.currentView().id) != -1
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
2015-06-04 16:27:46 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
if (selected) {
|
|
|
|
|
link.classList.add('selectedSidebarLink');
|
2015-05-29 19:51:33 -04:00
|
|
|
|
|
2016-03-28 13:49:30 -04:00
|
|
|
|
var title = '';
|
|
|
|
|
|
2016-06-19 01:26:52 -04:00
|
|
|
|
link = link.querySelector('span') || link;
|
2016-03-29 23:10:01 -04:00
|
|
|
|
var secondaryTitle = (link.innerText || link.textContent).trim();
|
|
|
|
|
title += secondaryTitle;
|
|
|
|
|
|
2016-09-03 13:16:36 -04:00
|
|
|
|
LibraryMenu.setTitle(title);
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
link.classList.remove('selectedSidebarLink');
|
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function createDashboardMenu() {
|
2016-04-13 01:28:45 -04:00
|
|
|
|
var html = '';
|
2015-05-29 19:51:33 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
html += '<a class="adminDrawerLogo clearLink" href="home.html">'
|
|
|
|
|
html += '<img src="css/images/logo.png" />';
|
|
|
|
|
html += '</a>';
|
2015-06-10 09:37:07 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
html += Dashboard.getToolsMenuHtml();
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
html = html.split('href=').join('onclick="return LibraryMenu.onLinkClicked(event, this);" href=');
|
2015-05-29 19:51:33 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
navDrawerScrollContainer.innerHTML = html;
|
2014-05-03 19:38:23 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
updateDashboardMenuSelectedItem();
|
2014-05-14 16:20:19 -04:00
|
|
|
|
}
|
2014-03-18 13:05:57 -04:00
|
|
|
|
|
2015-06-29 14:45:42 -04:00
|
|
|
|
function onSidebarLinkClick() {
|
|
|
|
|
var section = this.getElementsByClassName('sectionName')[0];
|
|
|
|
|
var text = section ? section.innerHTML : this.innerHTML;
|
|
|
|
|
|
2015-07-09 23:00:03 -04:00
|
|
|
|
LibraryMenu.setTitle(text);
|
2015-06-29 14:45:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 11:02:22 -04:00
|
|
|
|
function getUserViews(apiClient, userId) {
|
|
|
|
|
|
2015-12-30 15:25:17 -05:00
|
|
|
|
return apiClient.getUserViews({}, userId).then(function (result) {
|
2015-08-28 11:02:22 -04:00
|
|
|
|
|
2016-11-02 13:08:20 -04:00
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
|
|
|
|
var list = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = items.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var view = items[i];
|
|
|
|
|
|
|
|
|
|
list.push(view);
|
|
|
|
|
|
|
|
|
|
if (view.CollectionType == 'livetv') {
|
|
|
|
|
|
|
|
|
|
view.ImageTags = {};
|
|
|
|
|
view.icon = 'live_tv';
|
|
|
|
|
view.onclick = "LibraryBrowser.showTab('livetv.html', 0);";
|
|
|
|
|
|
|
|
|
|
var guideView = Object.assign({}, view);
|
|
|
|
|
guideView.Name = Globalize.translate('ButtonGuide');
|
|
|
|
|
guideView.ImageTags = {};
|
|
|
|
|
guideView.icon = 'dvr';
|
|
|
|
|
guideView.url = 'livetv.html?tab=1';
|
|
|
|
|
guideView.onclick = "LibraryBrowser.showTab('livetv.html', 1);";
|
|
|
|
|
list.push(guideView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
2015-08-28 11:02:22 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 16:38:01 -04:00
|
|
|
|
function showBySelector(selector, show) {
|
|
|
|
|
var elem = document.querySelector(selector);
|
|
|
|
|
|
|
|
|
|
if (elem) {
|
|
|
|
|
if (show) {
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
function updateLibraryMenu(user) {
|
2014-03-13 05:00:47 -04:00
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
if (!user) {
|
2014-06-22 01:52:31 -04:00
|
|
|
|
|
2016-08-16 14:54:08 -04:00
|
|
|
|
showBySelector('.lnkManageOffline', false);
|
|
|
|
|
showBySelector('.lnkSyncToOtherDevices', false);
|
2016-03-16 16:38:01 -04:00
|
|
|
|
showBySelector('.userMenuOptions', false);
|
2014-10-25 14:32:58 -04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 15:41:52 -04:00
|
|
|
|
if (user.Policy.EnableSync) {
|
2016-08-16 14:54:08 -04:00
|
|
|
|
showBySelector('.lnkSyncToOtherDevices', true);
|
|
|
|
|
} else {
|
|
|
|
|
showBySelector('.lnkSyncToOtherDevices', false);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 01:58:38 -05:00
|
|
|
|
require(['apphost'], function (appHost) {
|
|
|
|
|
if (user.Policy.EnableSync && appHost.supports('sync')) {
|
|
|
|
|
showBySelector('.lnkManageOffline', true);
|
|
|
|
|
} else {
|
|
|
|
|
showBySelector('.lnkManageOffline', false);
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-03-31 15:41:52 -04:00
|
|
|
|
|
2014-05-14 16:20:19 -04:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-05-03 19:38:23 -04:00
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
var apiClient = window.ApiClient;
|
|
|
|
|
|
2016-03-31 15:41:52 -04:00
|
|
|
|
var libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
|
|
|
|
|
|
|
|
|
if (!libraryMenuOptions) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
getUserViews(apiClient, userId).then(function (result) {
|
2014-05-14 16:20:19 -04:00
|
|
|
|
|
2015-08-28 11:02:22 -04:00
|
|
|
|
var items = result;
|
2014-05-14 16:20:19 -04:00
|
|
|
|
|
2015-05-29 19:51:33 -04:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<div class="sidebarHeader">';
|
2015-05-31 14:22:51 -04:00
|
|
|
|
html += Globalize.translate('HeaderMedia');
|
2015-05-29 19:51:33 -04:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += items.map(function (i) {
|
2014-05-14 16:20:19 -04:00
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
var icon = 'folder';
|
|
|
|
|
var color = 'inherit';
|
2014-06-07 15:46:24 -04:00
|
|
|
|
var itemId = i.Id;
|
2014-06-22 01:52:31 -04:00
|
|
|
|
|
2014-06-07 15:46:24 -04:00
|
|
|
|
if (i.CollectionType == "channels") {
|
|
|
|
|
itemId = "channels";
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "livetv") {
|
|
|
|
|
itemId = "livetv";
|
|
|
|
|
}
|
2014-10-25 14:32:58 -04:00
|
|
|
|
|
2014-12-30 14:16:01 -05:00
|
|
|
|
if (i.CollectionType == "photos") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'photo_library';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = "#009688";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "music" || i.CollectionType == "musicvideos") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'library_music';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = '#FB8521';
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "books") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'library_books';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = "#1AA1E1";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "playlists") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'view_list';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = "#795548";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "games") {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
icon = 'games';
|
|
|
|
|
color = "#F44336";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "movies") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'video_library';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = '#CE5043';
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "channels" || i.Type == 'Channel') {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
icon = 'videocam';
|
|
|
|
|
color = '#E91E63';
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
else if (i.CollectionType == "tvshows") {
|
|
|
|
|
icon = 'tv';
|
|
|
|
|
color = "#4CAF50";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
else if (i.CollectionType == "livetv") {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
icon = 'live_tv';
|
2015-06-21 17:31:21 -04:00
|
|
|
|
color = "#293AAE";
|
2014-12-30 14:16:01 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 11:02:22 -04:00
|
|
|
|
icon = i.icon || icon;
|
|
|
|
|
|
|
|
|
|
var onclick = i.onclick ? ' function(){' + i.onclick + '}' : 'null';
|
2017-01-27 18:05:04 -05:00
|
|
|
|
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder sidebarLink" onclick="return LibraryMenu.onLinkClicked(event, this, ' + onclick + ');" href="' + getItemHref(i, i.CollectionType) + '"><span class="sectionName">' + i.Name + '</span></a>';
|
2014-05-14 16:20:19 -04:00
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
libraryMenuOptions.innerHTML = html;
|
|
|
|
|
var elem = libraryMenuOptions;
|
2014-05-21 23:35:18 -04:00
|
|
|
|
|
2016-03-16 16:38:01 -04:00
|
|
|
|
var sidebarLinks = elem.querySelectorAll('.sidebarLink');
|
|
|
|
|
for (var i = 0, length = sidebarLinks.length; i < length; i++) {
|
|
|
|
|
sidebarLinks[i].removeEventListener('click', onSidebarLinkClick);
|
|
|
|
|
sidebarLinks[i].addEventListener('click', onSidebarLinkClick);
|
|
|
|
|
}
|
2014-05-14 16:20:19 -04:00
|
|
|
|
});
|
2013-12-27 16:10:06 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-07 17:21:30 -04:00
|
|
|
|
function onManageServerClicked() {
|
|
|
|
|
|
2015-06-22 11:43:19 -04:00
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
2015-10-02 02:14:04 -04:00
|
|
|
|
Dashboard.navigate('dashboard.html');
|
2015-06-07 17:21:30 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 22:54:33 -04:00
|
|
|
|
function getTopParentId() {
|
|
|
|
|
|
2015-05-20 13:29:26 -04:00
|
|
|
|
return getParameterByName('topParentId') || null;
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-22 00:39:47 -04:00
|
|
|
|
function getNavigateDelay() {
|
|
|
|
|
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
|
|
|
|
return browserInfo.mobile ? 320 : 200;;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 05:00:47 -04:00
|
|
|
|
window.LibraryMenu = {
|
2014-05-23 21:16:53 -04:00
|
|
|
|
getTopParentId: getTopParentId,
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2015-08-28 11:02:22 -04:00
|
|
|
|
onLinkClicked: function (event, link, action) {
|
2015-07-08 20:20:01 -04:00
|
|
|
|
|
|
|
|
|
if (event.which != 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-06-22 11:43:19 -04:00
|
|
|
|
|
2015-06-23 18:13:06 -04:00
|
|
|
|
// There doesn't seem to be a way to detect if the drawer is in the process of opening, so try to handle that here
|
|
|
|
|
if ((new Date().getTime() - lastOpenTime) > 200) {
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
2015-06-27 23:29:50 -04:00
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
2015-06-27 23:29:50 -04:00
|
|
|
|
setTimeout(function () {
|
2015-08-28 11:02:22 -04:00
|
|
|
|
if (action) {
|
|
|
|
|
action();
|
|
|
|
|
} else {
|
|
|
|
|
Dashboard.navigate(link.href);
|
|
|
|
|
}
|
2016-06-22 00:39:47 -04:00
|
|
|
|
}, getNavigateDelay());
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
2015-06-27 23:29:50 -04:00
|
|
|
|
}, 50);
|
2015-06-23 18:13:06 -04:00
|
|
|
|
}
|
2015-06-22 11:43:19 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
2015-06-24 00:38:46 -04:00
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onLogoutClicked: function () {
|
|
|
|
|
// There doesn't seem to be a way to detect if the drawer is in the process of opening, so try to handle that here
|
|
|
|
|
if ((new Date().getTime() - lastOpenTime) > 200) {
|
|
|
|
|
|
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
Dashboard.logout();
|
2016-06-22 00:39:47 -04:00
|
|
|
|
}, getNavigateDelay());
|
2015-06-24 00:38:46 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-23 18:13:06 -04:00
|
|
|
|
return false;
|
2015-07-08 12:10:34 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onHardwareMenuButtonClick: function () {
|
2016-03-06 13:09:20 -05:00
|
|
|
|
toggleMainDrawer();
|
2015-07-08 20:20:01 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onSettingsClicked: function (event) {
|
|
|
|
|
|
|
|
|
|
if (event.which != 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// There doesn't seem to be a way to detect if the drawer is in the process of opening, so try to handle that here
|
|
|
|
|
Dashboard.navigate('dashboard.html');
|
|
|
|
|
return false;
|
2015-07-09 23:00:03 -04:00
|
|
|
|
},
|
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
setTabs: function (type, selectedIndex, builder) {
|
|
|
|
|
|
|
|
|
|
var viewMenuBarTabs;
|
|
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
|
if (LibraryMenu.tabType) {
|
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
document.body.classList.remove('withTallToolbar');
|
2016-04-13 01:28:45 -04:00
|
|
|
|
viewMenuBarTabs = document.querySelector('.viewMenuBarTabs');
|
2016-04-15 15:20:04 -04:00
|
|
|
|
viewMenuBarTabs.innerHTML = '';
|
|
|
|
|
viewMenuBarTabs.classList.add('hide');
|
2016-04-13 01:28:45 -04:00
|
|
|
|
LibraryMenu.tabType = null;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viewMenuBarTabs = document.querySelector('.viewMenuBarTabs');
|
|
|
|
|
|
2016-04-15 15:20:04 -04:00
|
|
|
|
if (!LibraryMenu.tabType) {
|
|
|
|
|
viewMenuBarTabs.classList.remove('hide');
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
require(['emby-tabs', 'emby-button'], function () {
|
|
|
|
|
if (LibraryMenu.tabType != type) {
|
2016-04-13 01:28:45 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
var index = 0;
|
2016-04-13 01:28:45 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
viewMenuBarTabs.innerHTML = '<div is="emby-tabs"><div class="emby-tabs-slider">' + builder().map(function (t) {
|
2016-04-14 12:30:37 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
var tabClass = selectedIndex == index ? 'emby-tab-button emby-tab-button-active' : 'emby-tab-button';
|
2016-04-13 01:28:45 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
var tabHtml = '<button onclick="Dashboard.navigate(this.getAttribute(\'data-href\'));" data-href="' + t.href + '" is="emby-button" class="' + tabClass + '" data-index="' + index + '"><div class="emby-button-foreground">' + t.name + '</div></button>';
|
|
|
|
|
index++;
|
|
|
|
|
return tabHtml;
|
2016-04-13 01:28:45 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
}).join('') + '</div></div>';
|
2016-07-05 14:11:34 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
document.body.classList.add('withTallToolbar');
|
|
|
|
|
LibraryMenu.tabType = type;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-04-15 15:20:04 -04:00
|
|
|
|
|
2016-08-17 16:32:39 -04:00
|
|
|
|
viewMenuBarTabs.querySelector('[is="emby-tabs"]').selectedIndex(selectedIndex);
|
2016-08-15 14:18:05 -04:00
|
|
|
|
|
2016-08-14 15:58:13 -04:00
|
|
|
|
LibraryMenu.tabType = type;
|
|
|
|
|
});
|
2016-04-13 01:28:45 -04:00
|
|
|
|
},
|
|
|
|
|
|
2015-07-09 23:00:03 -04:00
|
|
|
|
setTitle: function (title) {
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-03-29 13:28:14 -04:00
|
|
|
|
var html = title;
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-06-02 13:08:25 -04:00
|
|
|
|
var page = viewManager.currentView();
|
|
|
|
|
if (page) {
|
|
|
|
|
var helpUrl = page.getAttribute('data-helpurl');
|
2016-05-16 14:20:08 -04:00
|
|
|
|
|
2016-06-02 13:08:25 -04:00
|
|
|
|
if (helpUrl) {
|
2016-09-15 14:28:46 -04:00
|
|
|
|
html += '<a href="' + helpUrl + '" target="_blank" class="clearLink" style="margin-left:2em;" title="' + Globalize.translate('ButtonHelp') + '"><button is="emby-button" type="button" class="button-accent-flat button-flat" style="margin:0;font-weight:normal;font-size:14px;padding:.25em;display:block;align-items:center;"><i class="md-icon">info</i><span>' + Globalize.translate('ButtonHelp') + '</span></button></a>';
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 13:27:51 -04:00
|
|
|
|
var libraryMenuButtonText = document.querySelector('.libraryMenuButtonText');
|
|
|
|
|
if (libraryMenuButtonText) {
|
|
|
|
|
libraryMenuButtonText.innerHTML = html;
|
|
|
|
|
}
|
2015-07-18 14:07:03 -04:00
|
|
|
|
|
2016-09-03 13:16:36 -04:00
|
|
|
|
document.title = title || 'Emby';
|
2015-07-18 14:07:03 -04:00
|
|
|
|
},
|
|
|
|
|
|
2015-08-18 13:54:29 -04:00
|
|
|
|
setTransparentMenu: function (transparent) {
|
|
|
|
|
|
|
|
|
|
var viewMenuBar = document.querySelector('.viewMenuBar');
|
|
|
|
|
|
|
|
|
|
if (viewMenuBar) {
|
|
|
|
|
if (transparent) {
|
|
|
|
|
viewMenuBar.classList.add('semiTransparent');
|
|
|
|
|
} else {
|
|
|
|
|
viewMenuBar.classList.remove('semiTransparent');
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-22 11:43:19 -04:00
|
|
|
|
}
|
2014-03-13 05:00:47 -04:00
|
|
|
|
};
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2014-03-29 14:20:42 -04:00
|
|
|
|
function updateCastIcon() {
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2016-02-09 13:05:12 -05:00
|
|
|
|
var context = document;
|
|
|
|
|
|
|
|
|
|
var btnCast = context.querySelector('.btnCast');
|
|
|
|
|
|
2016-05-12 15:21:43 -04:00
|
|
|
|
if (!btnCast) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-03 01:51:36 -05:00
|
|
|
|
var info = playbackManager.getPlayerInfo();
|
2014-03-29 14:20:42 -04:00
|
|
|
|
|
2017-01-03 01:51:36 -05:00
|
|
|
|
if (info && !info.isLocalPlayer) {
|
2014-03-29 14:20:42 -04:00
|
|
|
|
|
2017-01-03 01:51:36 -05:00
|
|
|
|
btnCast.querySelector('i').icon = 'cast_connected';
|
|
|
|
|
btnCast.classList.add('btnActiveCast');
|
|
|
|
|
context.querySelector('.headerSelectedPlayer').innerHTML = info.deviceName || info.name;
|
|
|
|
|
|
|
|
|
|
} else {
|
2016-06-19 01:26:52 -04:00
|
|
|
|
btnCast.querySelector('i').innerHTML = 'cast';
|
2016-02-09 13:05:12 -05:00
|
|
|
|
btnCast.classList.remove('btnActiveCast');
|
2014-03-29 14:20:42 -04:00
|
|
|
|
|
2016-02-09 13:05:12 -05:00
|
|
|
|
context.querySelector('.headerSelectedPlayer').innerHTML = '';
|
2014-03-29 14:20:42 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2014-05-12 14:04:25 -04:00
|
|
|
|
function updateLibraryNavLinks(page) {
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var isLiveTvPage = page.classList.contains('liveTvPage');
|
|
|
|
|
var isChannelsPage = page.classList.contains('channelsPage');
|
|
|
|
|
var isEditorPage = page.classList.contains('metadataEditorPage');
|
|
|
|
|
var isReportsPage = page.classList.contains('reportsPage');
|
|
|
|
|
var isMySyncPage = page.classList.contains('mySyncPage');
|
2014-05-03 19:38:23 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var id = isLiveTvPage || isChannelsPage || isEditorPage || isReportsPage || isMySyncPage || page.classList.contains('allLibraryPage') ?
|
2014-05-01 22:54:33 -04:00
|
|
|
|
'' :
|
|
|
|
|
getTopParentId() || '';
|
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
var i, length;
|
|
|
|
|
var elems = document.getElementsByClassName('lnkMediaFolder');
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var lnkMediaFolder = elems[i];
|
|
|
|
|
var itemId = lnkMediaFolder.getAttribute('data-itemid');
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2014-05-03 00:20:04 -04:00
|
|
|
|
if (isChannelsPage && itemId == 'channels') {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-03 00:20:04 -04:00
|
|
|
|
}
|
|
|
|
|
else if (isLiveTvPage && itemId == 'livetv') {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
2014-05-12 14:04:25 -04:00
|
|
|
|
else if (isEditorPage && itemId == 'editor') {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-12 14:04:25 -04:00
|
|
|
|
}
|
|
|
|
|
else if (isReportsPage && itemId == 'reports') {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-12 14:04:25 -04:00
|
|
|
|
}
|
2016-08-17 15:28:43 -04:00
|
|
|
|
else if (isMySyncPage && itemId == 'manageoffline' && window.location.href.toString().indexOf('mode=offline') != -1) {
|
2016-08-16 14:54:08 -04:00
|
|
|
|
|
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
|
|
|
|
}
|
2016-08-17 15:28:43 -04:00
|
|
|
|
else if (isMySyncPage && itemId == 'syncotherdevices' && window.location.href.toString().indexOf('mode=offline') == -1) {
|
2016-08-16 14:54:08 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-12-31 01:24:49 -05:00
|
|
|
|
}
|
2014-05-01 22:54:33 -04:00
|
|
|
|
else if (id && itemId == id) {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
lnkMediaFolder.classList.remove('selectedMediaFolder');
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
2015-06-28 10:45:21 -04:00
|
|
|
|
}
|
2015-09-21 11:43:10 -04:00
|
|
|
|
}
|
2014-05-01 22:54:33 -04:00
|
|
|
|
|
2014-06-22 01:52:31 -04:00
|
|
|
|
function onWebSocketMessage(e, data) {
|
|
|
|
|
|
|
|
|
|
var msg = data;
|
|
|
|
|
|
|
|
|
|
if (msg.MessageType === "UserConfigurationUpdated") {
|
|
|
|
|
|
|
|
|
|
if (msg.Data.Id == Dashboard.getCurrentUserId()) {
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
// refresh library menu
|
2014-06-22 01:52:31 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
function updateViewMenuBar(page) {
|
2013-12-27 16:10:06 -05:00
|
|
|
|
|
2015-07-09 01:52:25 -04:00
|
|
|
|
var viewMenuBar = document.querySelector('.viewMenuBar');
|
|
|
|
|
|
2016-05-09 15:27:38 -04:00
|
|
|
|
if (viewMenuBar) {
|
|
|
|
|
if (page.classList.contains('standalonePage')) {
|
|
|
|
|
viewMenuBar.classList.add('hide');
|
|
|
|
|
} else {
|
|
|
|
|
viewMenuBar.classList.remove('hide');
|
|
|
|
|
}
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
2016-05-09 15:27:38 -04:00
|
|
|
|
if (page.classList.contains('type-interior') && !layoutManager.mobile) {
|
|
|
|
|
viewMenuBar.classList.add('headroomDisabled');
|
|
|
|
|
} else {
|
|
|
|
|
viewMenuBar.classList.remove('headroomDisabled');
|
|
|
|
|
}
|
2016-04-13 01:28:45 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
if (requiresUserRefresh) {
|
2015-12-25 21:28:35 -05:00
|
|
|
|
ConnectionManager.user(window.ApiClient).then(updateUserInHeader);
|
2014-05-01 22:54:33 -04:00
|
|
|
|
}
|
2015-05-20 12:28:55 -04:00
|
|
|
|
}
|
2014-10-25 14:32:58 -04:00
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
pageClassOn('pagebeforeshow', 'page', function (e) {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
if (!page.classList.contains('withTabs')) {
|
|
|
|
|
LibraryMenu.setTabs(null);
|
2017-01-27 18:05:04 -05:00
|
|
|
|
|
|
|
|
|
if (page.classList.contains('pageWithAbsoluteTabs')) {
|
|
|
|
|
document.body.classList.add('withTallToolbar');
|
|
|
|
|
} else {
|
|
|
|
|
document.body.classList.remove('withTallToolbar');
|
|
|
|
|
}
|
2016-04-13 01:28:45 -04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
pageClassOn('pageshow', 'page', function (e) {
|
2015-05-25 13:32:22 -04:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
var isDashboardPage = page.classList.contains('type-interior');
|
|
|
|
|
|
|
|
|
|
if (isDashboardPage) {
|
2016-08-31 15:17:11 -04:00
|
|
|
|
if (mainDrawerButton) {
|
|
|
|
|
mainDrawerButton.classList.remove('hide');
|
|
|
|
|
}
|
2016-03-27 23:37:33 -04:00
|
|
|
|
refreshDashboardInfoInDrawer(page);
|
|
|
|
|
} else {
|
2016-08-31 15:17:11 -04:00
|
|
|
|
|
|
|
|
|
if (mainDrawerButton) {
|
|
|
|
|
if (enableLibraryNavDrawer) {
|
|
|
|
|
mainDrawerButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
mainDrawerButton.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((navDrawerElement && navDrawerElement.classList.contains('adminDrawer')) || (!navDrawerElement && enableLibraryNavDrawer)) {
|
2016-03-27 23:37:33 -04:00
|
|
|
|
refreshLibraryDrawer();
|
|
|
|
|
}
|
2015-09-21 11:43:10 -04:00
|
|
|
|
}
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
setDrawerClass(page);
|
|
|
|
|
|
2016-04-13 01:28:45 -04:00
|
|
|
|
updateViewMenuBar(page);
|
2015-05-25 13:32:22 -04:00
|
|
|
|
|
2016-03-16 01:33:31 -04:00
|
|
|
|
if (!e.detail.isRestored) {
|
2015-12-14 10:43:03 -05:00
|
|
|
|
// Scroll back up so in case vertical scroll was messed with
|
2016-05-17 16:04:20 -04:00
|
|
|
|
window.scrollTo(0, 0);
|
2015-07-09 01:52:25 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
updateTitle(page);
|
|
|
|
|
updateBackButton(page);
|
2015-08-18 00:22:45 -04:00
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
if (page.classList.contains('libraryPage')) {
|
2015-06-21 17:31:21 -04:00
|
|
|
|
|
2015-06-28 10:45:21 -04:00
|
|
|
|
document.body.classList.add('libraryDocument');
|
|
|
|
|
document.body.classList.remove('dashboardDocument');
|
|
|
|
|
document.body.classList.remove('hideMainDrawer');
|
2015-05-20 12:28:55 -04:00
|
|
|
|
}
|
2016-03-27 23:37:33 -04:00
|
|
|
|
else if (isDashboardPage) {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
|
|
|
|
|
document.body.classList.remove('libraryDocument');
|
|
|
|
|
document.body.classList.add('dashboardDocument');
|
|
|
|
|
document.body.classList.remove('hideMainDrawer');
|
|
|
|
|
|
2015-06-21 17:31:21 -04:00
|
|
|
|
} else {
|
2015-06-28 10:45:21 -04:00
|
|
|
|
|
|
|
|
|
document.body.classList.remove('libraryDocument');
|
|
|
|
|
document.body.classList.remove('dashboardDocument');
|
|
|
|
|
document.body.classList.add('hideMainDrawer');
|
2015-06-21 17:31:21 -04:00
|
|
|
|
}
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
|
|
|
|
updateLibraryNavLinks(page);
|
2015-12-14 10:43:03 -05:00
|
|
|
|
});
|
2015-06-17 21:41:22 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
function updateTitle(page) {
|
|
|
|
|
|
2016-09-02 00:11:10 -04:00
|
|
|
|
var title = page.getAttribute('data-title');
|
2015-12-14 10:43:03 -05:00
|
|
|
|
|
|
|
|
|
if (title) {
|
|
|
|
|
LibraryMenu.setTitle(title);
|
|
|
|
|
}
|
2015-06-17 21:41:22 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBackButton(page) {
|
|
|
|
|
|
2015-07-09 01:52:25 -04:00
|
|
|
|
var backButton = document.querySelector('.headerBackButton');
|
|
|
|
|
|
2015-07-11 01:03:05 -04:00
|
|
|
|
if (backButton) {
|
2016-10-15 18:12:16 -04:00
|
|
|
|
if (page.getAttribute('data-backbutton') == 'true' && embyRouter.canGoBack()) {
|
2015-07-11 01:03:05 -04:00
|
|
|
|
backButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
backButton.classList.add('hide');
|
|
|
|
|
}
|
2015-07-09 01:52:25 -04:00
|
|
|
|
}
|
2015-05-25 13:32:22 -04:00
|
|
|
|
}
|
2014-05-23 10:09:58 -04:00
|
|
|
|
|
2015-05-06 23:11:51 -04:00
|
|
|
|
function initHeadRoom(elem) {
|
|
|
|
|
|
2016-08-15 22:40:29 -04:00
|
|
|
|
require(["headroom-window"], function (headroom) {
|
2015-05-08 23:48:43 -04:00
|
|
|
|
|
2016-08-15 22:40:29 -04:00
|
|
|
|
headroom.add(elem);
|
2015-05-08 23:48:43 -04:00
|
|
|
|
});
|
2015-05-06 23:11:51 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-25 14:32:58 -04:00
|
|
|
|
function initializeApiClient(apiClient) {
|
2014-10-31 00:57:24 -04:00
|
|
|
|
|
2015-06-29 14:45:42 -04:00
|
|
|
|
Events.off(apiClient, 'websocketmessage', onWebSocketMessage);
|
2015-06-28 10:45:21 -04:00
|
|
|
|
|
2015-06-29 14:45:42 -04:00
|
|
|
|
Events.on(apiClient, 'websocketmessage', onWebSocketMessage);
|
2014-10-25 14:32:58 -04:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
if (window.ApiClient) {
|
|
|
|
|
initializeApiClient(window.ApiClient);
|
2014-06-03 23:34:36 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function setDrawerClass(page) {
|
|
|
|
|
|
|
|
|
|
var admin = false;
|
|
|
|
|
|
|
|
|
|
if (!page) {
|
2016-06-02 13:08:25 -04:00
|
|
|
|
page = viewManager.currentView();
|
2016-03-27 23:37:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (page && page.classList.contains('type-interior')) {
|
|
|
|
|
admin = true;
|
|
|
|
|
}
|
2016-01-27 14:39:20 -05:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
var enableNavDrawer = admin || enableLibraryNavDrawer;
|
|
|
|
|
if (enableNavDrawer) {
|
|
|
|
|
loadNavDrawer().then(function () {
|
|
|
|
|
if (admin) {
|
|
|
|
|
navDrawerElement.classList.add('adminDrawer');
|
|
|
|
|
navDrawerElement.classList.remove('darkDrawer');
|
|
|
|
|
} else {
|
|
|
|
|
navDrawerElement.classList.add('darkDrawer');
|
|
|
|
|
navDrawerElement.classList.remove('adminDrawer');
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-01-27 14:39:20 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 23:37:33 -04:00
|
|
|
|
function refreshLibraryDrawer(user) {
|
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
if (!enableLibraryNavDrawer) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadNavDrawer().then(function () {
|
|
|
|
|
var promise = user ? Promise.resolve(user) : ConnectionManager.user(window.ApiClient);
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
promise.then(function (user) {
|
|
|
|
|
refreshLibraryInfoInDrawer(user);
|
2016-03-27 23:37:33 -04:00
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
updateLibraryMenu(user.localUser);
|
|
|
|
|
});
|
2016-03-27 23:37:33 -04:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
function getNavDrawerOptions() {
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
var drawerWidth = screen.availWidth - 50;
|
|
|
|
|
// At least 240
|
|
|
|
|
drawerWidth = Math.max(drawerWidth, 240);
|
2016-08-16 01:34:36 -04:00
|
|
|
|
// But not exceeding 280
|
2016-10-10 14:18:28 -04:00
|
|
|
|
drawerWidth = Math.min(drawerWidth, 260);
|
2016-04-23 14:48:57 -04:00
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
var disableEdgeSwipe = false;
|
|
|
|
|
|
|
|
|
|
if (browserInfo.safari) {
|
|
|
|
|
disableEdgeSwipe = true;
|
2016-04-23 14:48:57 -04:00
|
|
|
|
}
|
2016-06-21 12:38:29 -04:00
|
|
|
|
|
|
|
|
|
// Default is 600px
|
|
|
|
|
//drawer.responsiveWidth = '640px';
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
target: navDrawerElement,
|
|
|
|
|
onChange: onMainDrawerSelect,
|
|
|
|
|
width: drawerWidth,
|
2016-08-16 00:12:12 -04:00
|
|
|
|
disableEdgeSwipe: disableEdgeSwipe
|
2016-06-21 12:38:29 -04:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
function loadNavDrawer() {
|
|
|
|
|
|
|
|
|
|
if (navDrawerInstance) {
|
|
|
|
|
return Promise.resolve(navDrawerInstance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
|
|
navDrawerElement = document.querySelector('.mainDrawer');
|
|
|
|
|
navDrawerScrollContainer = navDrawerElement.querySelector('.scrollContainer');
|
|
|
|
|
|
|
|
|
|
require(['navdrawer'], function (navdrawer) {
|
|
|
|
|
navDrawerInstance = new navdrawer(getNavDrawerOptions());
|
|
|
|
|
navDrawerElement.classList.remove('hide');
|
|
|
|
|
resolve(navDrawerInstance);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-21 12:38:29 -04:00
|
|
|
|
renderHeader();
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
Events.on(ConnectionManager, 'apiclientcreated', function (e, apiClient) {
|
|
|
|
|
initializeApiClient(apiClient);
|
|
|
|
|
});
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
Events.on(ConnectionManager, 'localusersignedin', function (e, user) {
|
2016-01-27 14:39:20 -05:00
|
|
|
|
setDrawerClass();
|
2016-03-27 23:37:33 -04:00
|
|
|
|
ConnectionManager.user(ConnectionManager.getApiClient(user.ServerId)).then(function (user) {
|
|
|
|
|
refreshLibraryDrawer(user);
|
2016-06-21 12:38:29 -04:00
|
|
|
|
updateUserInHeader(user);
|
2016-03-27 23:37:33 -04:00
|
|
|
|
});
|
2015-12-14 10:43:03 -05:00
|
|
|
|
});
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2016-04-15 15:20:04 -04:00
|
|
|
|
Events.on(ConnectionManager, 'localusersignedout', updateUserInHeader);
|
2017-01-03 01:51:36 -05:00
|
|
|
|
Events.on(playbackManager, 'playerchange', updateCastIcon);
|
2014-06-03 23:34:36 -04:00
|
|
|
|
|
2016-01-27 14:39:20 -05:00
|
|
|
|
setDrawerClass();
|
|
|
|
|
|
2016-08-31 15:17:11 -04:00
|
|
|
|
if (enableBottomTabs) {
|
|
|
|
|
require(['appfooter-shared', 'dockedtabs'], function (footer, dockedtabs) {
|
|
|
|
|
new dockedtabs({
|
|
|
|
|
appFooter: footer
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-11-27 00:00:20 -05:00
|
|
|
|
|
|
|
|
|
return LibraryMenu;
|
2016-03-16 01:33:31 -04:00
|
|
|
|
});
|