2016-03-18 21:26:17 -07:00
|
|
|
|
define(['imageLoader', 'jQuery', 'paper-icon-button', 'paper-button', 'emby-icons'], function (imageLoader, $) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var mainDrawerPanel = document.querySelector('.mainDrawerPanel');
|
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
function renderHeader() {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
var html = '';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
html += '<div class="primaryIcons">';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var backIcon = browserInfo.safari ? 'chevron-left' : 'arrow-back';
|
2015-07-08 17:20:01 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
html += '<paper-icon-button icon="' + backIcon + '" class="headerButton headerButtonLeft headerBackButton hide"></paper-icon-button>';
|
2015-04-25 20:25:07 -07:00
|
|
|
|
|
2015-09-23 09:16:06 -07:00
|
|
|
|
if (AppInfo.enableNavDrawer) {
|
|
|
|
|
html += '<paper-icon-button icon="menu" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft"></paper-icon-button>';
|
|
|
|
|
}
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2016-03-29 10:29:36 -07:00
|
|
|
|
html += '<paper-icon-button icon="menu" class="headerButton headerAppsButton barsMenuButton headerButtonLeft"></paper-icon-button>';
|
2016-03-29 10:28:14 -07:00
|
|
|
|
|
2015-06-17 08:39:46 -07:00
|
|
|
|
html += '<div class="libraryMenuButtonText headerButton">' + Globalize.translate('ButtonHome') + '</div>';
|
2015-01-20 23:26:16 -07:00
|
|
|
|
|
2013-12-27 14:10:06 -07:00
|
|
|
|
html += '<div class="viewMenuSecondary">';
|
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<span class="headerSelectedPlayer"></span>';
|
|
|
|
|
html += '<paper-icon-button icon="cast" class="btnCast headerButton headerButtonRight hide"></paper-icon-button>';
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2015-09-23 09:16:06 -07:00
|
|
|
|
if (AppInfo.enableSearchInTopMenu) {
|
|
|
|
|
html += '<paper-icon-button icon="search" class="headerButton headerButtonRight headerSearchButton hide" onclick="Search.showSearchPanel();"></paper-icon-button>';
|
|
|
|
|
html += '<div class="viewMenuSearch hide">';
|
|
|
|
|
html += '<form class="viewMenuSearchForm">';
|
|
|
|
|
html += '<input type="text" data-role="none" data-type="search" class="headerSearchInput" autocomplete="off" spellcheck="off" />';
|
|
|
|
|
html += '<paper-icon-button icon="close" class="btnCloseSearch"></paper-icon-button>';
|
|
|
|
|
html += '</form>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
html += '<paper-icon-button icon="mic" class="headerButton headerButtonRight headerVoiceButton hide"></paper-icon-button>';
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-09-22 09:06:27 -07:00
|
|
|
|
html += '<paper-button class="headerButton headerButtonRight btnNotifications subdued" type="button" title="Notifications"><div class="btnNotificationsInner">0</div></paper-button>';
|
2015-09-21 18:05:33 -07:00
|
|
|
|
|
2016-03-14 11:05:45 -07:00
|
|
|
|
html += '<paper-icon-button icon="person" class="headerButton headerButtonRight headerUserButton"></paper-icon-button>';
|
2015-06-03 21:50:10 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (!browserInfo.mobile && !Dashboard.isConnectMode()) {
|
2015-09-21 18:05:33 -07:00
|
|
|
|
html += '<paper-icon-button icon="settings" class="headerButton headerButtonRight dashboardEntryHeaderButton" onclick="return LibraryMenu.onSettingsClicked(event);"></paper-icon-button>';
|
2015-06-01 22:46:06 -07:00
|
|
|
|
}
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="viewMenuBarTabs hiddenScrollX">';
|
2015-05-22 08:59:17 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
var viewMenuBar = document.createElement('div');
|
|
|
|
|
viewMenuBar.classList.add('viewMenuBar');
|
|
|
|
|
viewMenuBar.innerHTML = html;
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
document.querySelector('.skinHeader').appendChild(viewMenuBar);
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2016-03-06 11:09:20 -07:00
|
|
|
|
imageLoader.lazyChildren(document.querySelector('.viewMenuBar'));
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
document.dispatchEvent(new CustomEvent("headercreated", {}));
|
2015-05-22 08:59:17 -07:00
|
|
|
|
bindMenuEvents();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
function onBackClick() {
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
if (Dashboard.exitOnBack()) {
|
|
|
|
|
Dashboard.exit();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
history.back();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-25 19:28:35 -07:00
|
|
|
|
function updateUserInHeader(user) {
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var header = document.querySelector('.viewMenuBar');
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-12-24 11:14:12 -07:00
|
|
|
|
var headerUserButton = header.querySelector('.headerUserButton');
|
|
|
|
|
var hasImage;
|
2015-12-25 19:28:35 -07:00
|
|
|
|
|
|
|
|
|
if (user && user.name) {
|
2016-02-26 10:15:06 -07:00
|
|
|
|
if (user.imageUrl) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
|
|
|
|
var userButtonHeight = 26;
|
|
|
|
|
|
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
|
|
|
|
|
if (user.supportsImageParams) {
|
2016-03-06 11:09:20 -07:00
|
|
|
|
url += "&height=" + (userButtonHeight * Math.max(window.devicePixelRatio || 1, 2));
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headerUserButton) {
|
2016-03-14 11:05:45 -07:00
|
|
|
|
updateHeaderUserButton(headerUserButton, url, null);
|
2015-12-24 11:14:12 -07:00
|
|
|
|
hasImage = true;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-09-23 09:16:06 -07:00
|
|
|
|
|
2015-12-25 19:28:35 -07:00
|
|
|
|
if (headerUserButton && !hasImage) {
|
|
|
|
|
|
2016-03-14 11:05:45 -07:00
|
|
|
|
updateHeaderUserButton(headerUserButton, null, 'person');
|
2015-12-25 19:28:35 -07:00
|
|
|
|
}
|
|
|
|
|
if (user) {
|
|
|
|
|
updateLocalUser(user.localUser);
|
2015-12-24 11:14:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
requiresUserRefresh = false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 11:05:45 -07:00
|
|
|
|
function updateHeaderUserButton(headerUserButton, src, icon) {
|
|
|
|
|
|
|
|
|
|
var oldButton = headerUserButton;
|
|
|
|
|
|
|
|
|
|
// There seems to be a bug in paper-icon-button where it doesn't refresh it's display after switching between icon and src image
|
|
|
|
|
// So work around that by just replacing the element altogether
|
|
|
|
|
|
|
|
|
|
var headerUserButton = document.createElement('paper-icon-button');
|
|
|
|
|
headerUserButton.className = oldButton.className;
|
|
|
|
|
headerUserButton.addEventListener('click', onHeaderUserButtonClick);
|
|
|
|
|
|
|
|
|
|
if (src) {
|
|
|
|
|
headerUserButton.classList.add('headerUserButtonRound');
|
|
|
|
|
headerUserButton.src = src;
|
|
|
|
|
} else if (icon) {
|
|
|
|
|
headerUserButton.classList.remove('headerUserButtonRound');
|
2016-03-15 22:33:31 -07:00
|
|
|
|
headerUserButton.icon = icon;
|
2016-03-14 11:05:45 -07:00
|
|
|
|
} else {
|
|
|
|
|
headerUserButton.classList.remove('headerUserButtonRound');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oldButton.parentNode.replaceChild(headerUserButton, oldButton);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07: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 09:16:06 -07:00
|
|
|
|
|
|
|
|
|
if (headerSearchButton) {
|
|
|
|
|
headerSearchButton.classList.remove('hide');
|
|
|
|
|
}
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (dashboardEntryHeaderButton) {
|
|
|
|
|
if (user.Policy.IsAdministrator) {
|
|
|
|
|
dashboardEntryHeaderButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
dashboardEntryHeaderButton.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
require(['voice/voice'], function (voice) {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
if (voice.isSupported()) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
header.querySelector('.headerVoiceButton').classList.remove('hide');
|
2015-06-01 22:46:06 -07:00
|
|
|
|
} else {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
2015-06-01 22:46:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
} else {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
btnCast.classList.add('hide');
|
|
|
|
|
header.querySelector('.headerVoiceButton').classList.add('hide');
|
2015-09-23 09:16:06 -07:00
|
|
|
|
if (headerSearchButton) {
|
|
|
|
|
headerSearchButton.classList.add('hide');
|
|
|
|
|
}
|
2015-05-13 22:42:55 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (dashboardEntryHeaderButton) {
|
2015-07-08 22:52:25 -07:00
|
|
|
|
dashboardEntryHeaderButton.classList.add('hide');
|
|
|
|
|
}
|
2014-10-25 11:32:58 -07:00
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
2015-06-10 06:37:07 -07:00
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
function showVoice() {
|
|
|
|
|
require(['voice/voice'], function (voice) {
|
|
|
|
|
voice.startListening();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 11:05:45 -07:00
|
|
|
|
function onHeaderUserButtonClick(e) {
|
|
|
|
|
Dashboard.showUserFlyout(e.target);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 10:28:14 -07:00
|
|
|
|
function onHeaderAppsButtonClick() {
|
|
|
|
|
|
2016-03-29 11:11:49 -07:00
|
|
|
|
require(['dialogHelper'], function (dialogHelper) {
|
|
|
|
|
|
|
|
|
|
var dlg = dialogHelper.createDialog({
|
|
|
|
|
removeOnClose: true,
|
|
|
|
|
modal: false,
|
|
|
|
|
autoFocus: false,
|
|
|
|
|
entryAnimationDuration: 160,
|
2016-04-08 19:30:22 -07:00
|
|
|
|
exitAnimationDuration: 160,
|
|
|
|
|
enableHistory: false
|
2016-03-29 11:11:49 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
dlg.classList.add('ui-body-a');
|
|
|
|
|
dlg.classList.add('background-theme-a');
|
|
|
|
|
dlg.classList.add('adminAppsMenu');
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="adminAppsMenuRow">';
|
|
|
|
|
|
|
|
|
|
html += '<a class="adminAppsButton" href="home.html">';
|
|
|
|
|
html += '<paper-icon-button icon="home"></paper-icon-button>';
|
|
|
|
|
html += '<div>' + Globalize.translate('ButtonHome') + '</div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="adminAppsMenuRow">';
|
|
|
|
|
|
|
|
|
|
html += '<a class="adminAppsButton" href="edititemmetadata.html">';
|
|
|
|
|
html += '<paper-icon-button icon="mode-edit"></paper-icon-button>';
|
|
|
|
|
html += '<div>' + Globalize.translate('ButtonMetadataManager') + '</div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '<a class="adminAppsButton" href="reports.html">';
|
|
|
|
|
html += '<paper-icon-button icon="insert-chart"></paper-icon-button>';
|
|
|
|
|
html += '<div>' + Globalize.translate('ButtonReports') + '</div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
dlg.innerHTML = html;
|
|
|
|
|
document.body.appendChild(dlg);
|
|
|
|
|
|
|
|
|
|
dlg.addEventListener('click', function (e) {
|
|
|
|
|
var link = parentWithTag(e.target, 'A');
|
|
|
|
|
if (link) {
|
|
|
|
|
dialogHelper.close(dlg);
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-04-08 19:30:22 -07:00
|
|
|
|
dialogHelper.open(dlg);
|
2016-03-29 11:11:49 -07:00
|
|
|
|
|
|
|
|
|
});
|
2016-03-29 10:28:14 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-25 20:25:07 -07:00
|
|
|
|
function bindMenuEvents() {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
var mainDrawerButton = document.querySelector('.mainDrawerButton');
|
|
|
|
|
|
|
|
|
|
if (mainDrawerButton) {
|
2016-03-06 11:09:20 -07:00
|
|
|
|
mainDrawerButton.addEventListener('click', toggleMainDrawer);
|
2015-04-25 20:25:07 -07:00
|
|
|
|
}
|
2015-05-04 07:35:38 -07:00
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
var headerBackButton = document.querySelector('.headerBackButton');
|
|
|
|
|
if (headerBackButton) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
headerBackButton.addEventListener('click', onBackClick);
|
2015-09-07 18:00:46 -07:00
|
|
|
|
}
|
2015-06-08 14:32:20 -07:00
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
var headerVoiceButton = document.querySelector('.headerVoiceButton');
|
|
|
|
|
if (headerVoiceButton) {
|
|
|
|
|
headerVoiceButton.addEventListener('click', showVoice);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-14 11:05:45 -07:00
|
|
|
|
var headerUserButton = document.querySelector('.headerUserButton');
|
|
|
|
|
if (headerUserButton) {
|
|
|
|
|
headerUserButton.addEventListener('click', onHeaderUserButtonClick);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-29 10:28:14 -07:00
|
|
|
|
var headerAppsButton = document.querySelector('.headerAppsButton');
|
|
|
|
|
if (headerAppsButton) {
|
|
|
|
|
headerAppsButton.addEventListener('click', onHeaderAppsButtonClick);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 18:00:46 -07:00
|
|
|
|
var viewMenuBar = document.querySelector(".viewMenuBar");
|
2015-05-06 20:11:51 -07:00
|
|
|
|
initHeadRoom(viewMenuBar);
|
2015-05-08 09:58:27 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
viewMenuBar.querySelector('.btnNotifications').addEventListener('click', function () {
|
|
|
|
|
Dashboard.navigate('notificationlist.html');
|
|
|
|
|
});
|
2015-06-17 18:41:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
function getItemHref(item, context) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-07-05 09:51:39 -07:00
|
|
|
|
return LibraryBrowser.getHref(item, context);
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var requiresUserRefresh = true;
|
2015-06-23 15:13:06 -07:00
|
|
|
|
var lastOpenTime = new Date().getTime();
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-06 11:09:20 -07:00
|
|
|
|
function toggleMainDrawer() {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (mainDrawerPanel.selected == 'drawer') {
|
|
|
|
|
closeMainDrawer(mainDrawerPanel);
|
2016-03-06 11:09:20 -07:00
|
|
|
|
} else {
|
2016-03-27 20:37:33 -07:00
|
|
|
|
openMainDrawer(mainDrawerPanel);
|
2016-03-06 11:09:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openMainDrawer(drawerPanel) {
|
|
|
|
|
|
|
|
|
|
drawerPanel = drawerPanel || document.querySelector('.mainDrawerPanel');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
drawerPanel.openDrawer();
|
2015-06-23 15:13:06 -07:00
|
|
|
|
lastOpenTime = new Date().getTime();
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
function onMainDrawerOpened() {
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (browserInfo.mobile) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.body.classList.add('bodyWithPopupOpen');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-06 11:09:20 -07:00
|
|
|
|
function closeMainDrawer(drawerPanel) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-06 11:09:20 -07:00
|
|
|
|
drawerPanel = drawerPanel || document.querySelector('.mainDrawerPanel');
|
|
|
|
|
drawerPanel.closeDrawer();
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
function onMainDrawerSelect(e) {
|
|
|
|
|
|
|
|
|
|
var drawer = e.target;
|
|
|
|
|
|
|
|
|
|
if (drawer.selected != 'drawer') {
|
|
|
|
|
document.body.classList.remove('bodyWithPopupOpen');
|
|
|
|
|
} else {
|
|
|
|
|
onMainDrawerOpened();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function refreshLibraryInfoInDrawer(user, drawer) {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2016-03-30 23:33:37 -07:00
|
|
|
|
html += '<div style="height:.5em;"></div>';
|
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
var homeHref = window.ApiClient ? 'home.html' : 'selectserver.html?showuser=1';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-02-26 22:43:12 -07:00
|
|
|
|
html += '<a class="lnkMediaFolder sidebarLink" href="' + homeHref + '" onclick="return LibraryMenu.onLinkClicked(event, this);">';
|
|
|
|
|
html += '<div style="background-image:url(\'css/images/mblogoicon.png\');width:' + 28 + 'px;height:' + 28 + 'px;background-size:contain;background-repeat:no-repeat;background-position:center center;border-radius:1000px;vertical-align:middle;margin:0 1.6em 0 1.5em;display:inline-block;"></div>';
|
|
|
|
|
html += Globalize.translate('ButtonHome');
|
|
|
|
|
html += '</a>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="remote" href="nowplaying.html" onclick="return LibraryMenu.onLinkClicked(event, this);"><iron-icon icon="tablet-android" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonRemote') + '</span></a>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
html += '<div class="libraryMenuOptions">';
|
|
|
|
|
html += '</div>';
|
2016-01-20 18:05:14 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var localUser = user.localUser;
|
|
|
|
|
if (localUser && localUser.Policy.IsAdministrator) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
html += '<div class="adminMenuOptions">';
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
html += '<div class="sidebarHeader">';
|
|
|
|
|
html += Globalize.translate('HeaderAdmin');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkManageServer" data-itemid="dashboard" href="#"><iron-icon icon="dashboard" class="sidebarLinkIcon"></iron-icon><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"><iron-icon icon="mode-edit" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonMetadataManager') + '</span></a>';
|
|
|
|
|
|
|
|
|
|
if (!browserInfo.mobile) {
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="reports" onclick="return LibraryMenu.onLinkClicked(event, this);" href="reports.html"><iron-icon icon="insert-chart" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonReports') + '</span></a>';
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="userMenuOptions">';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (user.localUser && (AppInfo.isNativeApp && browserInfo.android)) {
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkMySettings" onclick="return LibraryMenu.onLinkClicked(event, this);" href="mypreferencesmenu.html?userId=' + user.localUser.Id + '"><iron-icon icon="settings" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSettings') + '</span></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkMySync" data-itemid="mysync" onclick="return LibraryMenu.onLinkClicked(event, this);" href="mysync.html"><iron-icon icon="sync" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSync') + '</span></a>';
|
|
|
|
|
|
|
|
|
|
if (Dashboard.isConnectMode()) {
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="selectserver" onclick="return LibraryMenu.onLinkClicked(event, this);" href="selectserver.html?showuser=1"><iron-icon icon="wifi" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSelectServer') + '</span></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (user.localUser) {
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="logout" onclick="return LibraryMenu.onLogoutClicked(this);" href="#"><iron-icon icon="lock" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSignOut') + '</span></a>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '</div>';
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var drawer = mainDrawerPanel.querySelector('.mainDrawer');
|
|
|
|
|
|
|
|
|
|
drawer.innerHTML = html;
|
|
|
|
|
|
|
|
|
|
var lnkManageServer = drawer.querySelector('.lnkManageServer');
|
|
|
|
|
if (lnkManageServer) {
|
|
|
|
|
lnkManageServer.addEventListener('click', onManageServerClicked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require(['imageLoader'], function (imageLoader) {
|
|
|
|
|
imageLoader.fillImages(mainDrawerPanel.getElementsByClassName('lazy'));
|
|
|
|
|
});
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function refreshDashboardInfoInDrawer(page, user) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (!mainDrawerPanel.querySelector('.adminDrawerLogo')) {
|
|
|
|
|
createDashboardMenu(page);
|
|
|
|
|
} else {
|
|
|
|
|
updateDashboardMenuSelectedItem();
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function parentWithTag(elem, tagName) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
while (elem.tagName != tagName) {
|
|
|
|
|
elem = elem.parentNode;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (!elem) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-23 21:38:46 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
return elem;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function updateDashboardMenuSelectedItem() {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var links = mainDrawerPanel.querySelectorAll('.sidebarLink');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
for (var i = 0, length = links.length; i < length; i++) {
|
|
|
|
|
var link = links[i];
|
2014-12-30 12:16:01 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var selected = false;
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var pageIds = link.getAttribute('data-pageids');
|
|
|
|
|
if (pageIds) {
|
|
|
|
|
selected = pageIds.split(',').indexOf($.mobile.activePage.id) != -1
|
|
|
|
|
}
|
2015-06-04 13:27:46 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (selected) {
|
|
|
|
|
link.classList.add('selectedSidebarLink');
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
2016-03-28 10:49:30 -07:00
|
|
|
|
var title = '';
|
|
|
|
|
|
2016-03-29 20:10:01 -07:00
|
|
|
|
var secondaryTitle = (link.innerText || link.textContent).trim();
|
|
|
|
|
title += secondaryTitle;
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
var documentTitle = secondaryTitle;
|
2016-03-29 20:10:01 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.setPageTitle(title, documentTitle);
|
2016-03-27 20:37:33 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
link.classList.remove('selectedSidebarLink');
|
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
2016-03-27 20:37:33 -07:00
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function createDashboardMenu() {
|
2016-04-12 22:28:45 -07:00
|
|
|
|
var html = '';
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
//html += '<div class="userHeader">';
|
|
|
|
|
//html += '<div class="userHeaderActionMenu">';
|
|
|
|
|
//html += '<div>';
|
|
|
|
|
//html += localUser.Name;
|
|
|
|
|
//html += '</div>';
|
|
|
|
|
//html += '<paper-icon-button icon="expand-more"></paper-icon-button>';
|
|
|
|
|
//html += '</div>';
|
|
|
|
|
//html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<a class="adminDrawerLogo clearLink" href="home.html">'
|
|
|
|
|
html += '<img src="css/images/logo.png" />';
|
|
|
|
|
html += '</a>';
|
2015-06-10 06:37:07 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
html += Dashboard.getToolsMenuHtml();
|
2016-03-27 20:37:33 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
html = html.split('href=').join('onclick="return LibraryMenu.onLinkClicked(event, this);" href=');
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
mainDrawerPanel.querySelector('.mainDrawer').innerHTML = html;
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
updateDashboardMenuSelectedItem();
|
2014-05-14 13:20:19 -07:00
|
|
|
|
}
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
function onSidebarLinkClick() {
|
|
|
|
|
var section = this.getElementsByClassName('sectionName')[0];
|
|
|
|
|
var text = section ? section.innerHTML : this.innerHTML;
|
|
|
|
|
|
2015-07-09 20:00:03 -07:00
|
|
|
|
LibraryMenu.setTitle(text);
|
2015-06-29 11:45:42 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
function getUserViews(apiClient, userId) {
|
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
return apiClient.getUserViews({}, userId).then(function (result) {
|
2015-08-28 08:02:22 -07: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';
|
2015-08-28 10:39:52 -07:00
|
|
|
|
view.onclick = "LibraryBrowser.showTab('livetv.html', 0);";
|
2015-08-28 08:02:22 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
var guideView = Object.assign({}, view);
|
2015-08-28 08:02:22 -07:00
|
|
|
|
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);
|
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
var recordedTvView = Object.assign({}, view);
|
2015-08-28 08:02:22 -07:00
|
|
|
|
recordedTvView.Name = Globalize.translate('ButtonRecordedTv');
|
|
|
|
|
recordedTvView.ImageTags = {};
|
|
|
|
|
recordedTvView.icon = 'video-library';
|
|
|
|
|
recordedTvView.url = 'livetv.html?tab=3';
|
|
|
|
|
recordedTvView.onclick = "LibraryBrowser.showTab('livetv.html', 3);";
|
|
|
|
|
list.push(recordedTvView);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-30 13:25:17 -07:00
|
|
|
|
return list;
|
2015-08-28 08:02:22 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:38:01 -07: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 14:31:21 -07:00
|
|
|
|
function updateLibraryMenu(user) {
|
2014-03-13 02:00:47 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
if (!user) {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07:00
|
|
|
|
showBySelector('.lnkMySync', false);
|
|
|
|
|
showBySelector('.userMenuOptions', false);
|
2014-10-25 11:32:58 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-31 12:41:52 -07:00
|
|
|
|
if (user.Policy.EnableSync) {
|
|
|
|
|
showBySelector('.lnkMySync', true);
|
|
|
|
|
} else {
|
|
|
|
|
showBySelector('.lnkMySync', false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
var apiClient = window.ApiClient;
|
|
|
|
|
|
2016-03-31 12:41:52 -07:00
|
|
|
|
var libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
|
|
|
|
|
|
|
|
|
if (!libraryMenuOptions) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
getUserViews(apiClient, userId).then(function (result) {
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
var items = result;
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
2015-05-29 16:51:33 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
html += '<div class="sidebarHeader">';
|
2015-05-31 11:22:51 -07:00
|
|
|
|
html += Globalize.translate('HeaderMedia');
|
2015-05-29 16:51:33 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += items.map(function (i) {
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
var icon = 'folder';
|
|
|
|
|
var color = 'inherit';
|
2014-06-07 12:46:24 -07:00
|
|
|
|
var itemId = i.Id;
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2014-06-07 12:46:24 -07:00
|
|
|
|
if (i.CollectionType == "channels") {
|
|
|
|
|
itemId = "channels";
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "livetv") {
|
|
|
|
|
itemId = "livetv";
|
|
|
|
|
}
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2014-12-30 12:16:01 -07:00
|
|
|
|
if (i.CollectionType == "photos") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'photo-library';
|
|
|
|
|
color = "#009688";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "music" || i.CollectionType == "musicvideos") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'library-music';
|
|
|
|
|
color = '#FB8521';
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "books") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'library-books';
|
|
|
|
|
color = "#1AA1E1";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "playlists") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'view-list';
|
|
|
|
|
color = "#795548";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "games") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'games';
|
|
|
|
|
color = "#F44336";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "movies") {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'video-library';
|
|
|
|
|
color = '#CE5043';
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "channels" || i.Type == 'Channel') {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
icon = 'videocam';
|
|
|
|
|
color = '#E91E63';
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
else if (i.CollectionType == "tvshows") {
|
|
|
|
|
icon = 'tv';
|
|
|
|
|
color = "#4CAF50";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
else if (i.CollectionType == "livetv") {
|
|
|
|
|
icon = 'live-tv';
|
|
|
|
|
color = "#293AAE";
|
2014-12-30 12:16:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
icon = i.icon || icon;
|
|
|
|
|
|
|
|
|
|
var onclick = i.onclick ? ' function(){' + i.onclick + '}' : 'null';
|
|
|
|
|
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder sidebarLink" onclick="return LibraryMenu.onLinkClicked(event, this, ' + onclick + ');" href="' + getItemHref(i, i.CollectionType) + '"><iron-icon icon="' + icon + '" class="sidebarLinkIcon" style="color:' + color + '"></iron-icon><span class="sectionName">' + i.Name + '</span></a>';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
libraryMenuOptions.innerHTML = html;
|
|
|
|
|
var elem = libraryMenuOptions;
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
2016-03-16 13:38:01 -07: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 13:20:19 -07:00
|
|
|
|
});
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-07 14:21:30 -07:00
|
|
|
|
function onManageServerClicked() {
|
|
|
|
|
|
2015-06-22 08:43:19 -07:00
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
2015-10-01 23:14:04 -07:00
|
|
|
|
Dashboard.navigate('dashboard.html');
|
2015-06-07 14:21:30 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getTopParentId() {
|
|
|
|
|
|
2015-05-20 10:29:26 -07:00
|
|
|
|
return getParameterByName('topParentId') || null;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
window.LibraryMenu = {
|
2014-05-23 18:16:53 -07:00
|
|
|
|
getTopParentId: getTopParentId,
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-08-28 08:02:22 -07:00
|
|
|
|
onLinkClicked: function (event, link, action) {
|
2015-07-08 17:20:01 -07:00
|
|
|
|
|
|
|
|
|
if (event.which != 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2015-06-22 08:43:19 -07:00
|
|
|
|
|
2015-06-23 15:13:06 -07: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 20:29:50 -07:00
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
2015-12-14 15:54:11 -07:00
|
|
|
|
var delay = browserInfo.mobile ? 350 : 200;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2015-06-27 20:29:50 -07:00
|
|
|
|
setTimeout(function () {
|
2015-08-28 08:02:22 -07:00
|
|
|
|
if (action) {
|
|
|
|
|
action();
|
|
|
|
|
} else {
|
|
|
|
|
Dashboard.navigate(link.href);
|
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}, delay);
|
|
|
|
|
|
2015-06-27 20:29:50 -07:00
|
|
|
|
}, 50);
|
2015-06-23 15:13:06 -07:00
|
|
|
|
}
|
2015-06-22 08:43:19 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
2015-06-23 21:38:46 -07: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();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
2015-12-14 15:54:11 -07:00
|
|
|
|
var delay = browserInfo.mobile ? 350 : 200;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
Dashboard.logout();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}, delay);
|
2015-06-23 21:38:46 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
return false;
|
2015-07-08 09:10:34 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onHardwareMenuButtonClick: function () {
|
2016-03-06 11:09:20 -07:00
|
|
|
|
toggleMainDrawer();
|
2015-07-08 17:20:01 -07: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 20:00:03 -07:00
|
|
|
|
},
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
setTabs: function (type, selectedIndex, builder) {
|
|
|
|
|
|
|
|
|
|
var viewMenuBarTabs;
|
|
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
|
if (LibraryMenu.tabType) {
|
|
|
|
|
|
|
|
|
|
mainDrawerPanel.classList.remove('withTallToolbar');
|
|
|
|
|
viewMenuBarTabs = document.querySelector('.viewMenuBarTabs');
|
|
|
|
|
viewMenuBarTabs.innerHTML = '';
|
|
|
|
|
viewMenuBarTabs.classList.add('hide');
|
|
|
|
|
LibraryMenu.tabType = null;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viewMenuBarTabs = document.querySelector('.viewMenuBarTabs');
|
|
|
|
|
|
|
|
|
|
if (!LibraryMenu.tabType) {
|
|
|
|
|
viewMenuBarTabs.classList.remove('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (LibraryMenu.tabType != type) {
|
|
|
|
|
|
|
|
|
|
require(['paper-tabs'], function () {
|
|
|
|
|
|
2016-04-14 09:30:37 -07:00
|
|
|
|
var noInk = browserInfo.animate ? '' : ' noink';
|
|
|
|
|
|
|
|
|
|
viewMenuBarTabs.innerHTML = '<paper-tabs selected="' + selectedIndex + '" hidescrollbuttons ' + noInk + '>' + builder().map(function (t) {
|
2016-04-12 22:28:45 -07:00
|
|
|
|
|
|
|
|
|
return '<paper-tab link><a class="clearLink paperTabLink" href="' + t.href + '"><div>' + t.name + '</div></a></paper-tab>';
|
|
|
|
|
|
|
|
|
|
}).join('') + '</paper-tabs>';
|
|
|
|
|
mainDrawerPanel.classList.add('withTallToolbar');
|
|
|
|
|
LibraryMenu.tabType = type;
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
viewMenuBarTabs.querySelector('paper-tabs').selected = selectedIndex;
|
|
|
|
|
LibraryMenu.tabType = type;
|
|
|
|
|
},
|
|
|
|
|
|
2015-07-09 20:00:03 -07:00
|
|
|
|
setTitle: function (title) {
|
2016-03-27 20:37:33 -07:00
|
|
|
|
|
2016-03-29 10:28:14 -07:00
|
|
|
|
var html = title;
|
2016-03-27 20:37:33 -07:00
|
|
|
|
|
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
if (page) {
|
|
|
|
|
var helpUrl = page.getAttribute('data-helpurl');
|
|
|
|
|
|
|
|
|
|
if (helpUrl) {
|
|
|
|
|
html += '<a href="' + helpUrl + '" target="_blank" class="clearLink" style="margin-left:1em;" title="' + Globalize.translate('ButtonHelp') + '"><paper-icon-button icon="info"></paper-icon-button></a>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.querySelector('.libraryMenuButtonText').innerHTML = html;
|
2015-07-18 11:07:03 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setBackButtonVisible: function (visible) {
|
|
|
|
|
|
|
|
|
|
var backButton = document.querySelector('.headerBackButton');
|
|
|
|
|
|
|
|
|
|
if (backButton) {
|
|
|
|
|
if (visible) {
|
|
|
|
|
backButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
backButton.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setMenuButtonVisible: function (visible) {
|
|
|
|
|
|
|
|
|
|
var mainDrawerButton = document.querySelector('.mainDrawerButton');
|
|
|
|
|
|
|
|
|
|
if (mainDrawerButton) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (!visible && browserInfo.mobile) {
|
2015-08-18 08:25:57 -07:00
|
|
|
|
mainDrawerButton.classList.remove('hide');
|
2015-07-18 11:07:03 -07:00
|
|
|
|
} else {
|
|
|
|
|
mainDrawerButton.classList.remove('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-18 10:54:29 -07: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 08:43:19 -07:00
|
|
|
|
}
|
2014-03-13 02:00:47 -07:00
|
|
|
|
};
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
function updateCastIcon() {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2016-02-09 11:05:12 -07:00
|
|
|
|
var context = document;
|
|
|
|
|
|
|
|
|
|
var btnCast = context.querySelector('.btnCast');
|
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
var info = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
if (info.isLocalPlayer) {
|
|
|
|
|
|
2016-02-09 11:05:12 -07:00
|
|
|
|
btnCast.icon = 'cast';
|
|
|
|
|
btnCast.classList.remove('btnActiveCast');
|
2014-03-29 11:20:42 -07:00
|
|
|
|
|
2016-02-09 11:05:12 -07:00
|
|
|
|
context.querySelector('.headerSelectedPlayer').innerHTML = '';
|
2014-03-29 11:20:42 -07:00
|
|
|
|
|
2016-02-09 11:05:12 -07:00
|
|
|
|
} else {
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
2016-02-09 11:05:12 -07:00
|
|
|
|
btnCast.icon = 'cast-connected';
|
|
|
|
|
btnCast.classList.add('btnActiveCast');
|
|
|
|
|
context.querySelector('.headerSelectedPlayer').innerHTML = info.deviceName || info.name;
|
2014-03-29 11:20:42 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
function updateLibraryNavLinks(page) {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07: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 16:38:23 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var id = isLiveTvPage || isChannelsPage || isEditorPage || isReportsPage || isMySyncPage || page.classList.contains('allLibraryPage') ?
|
2014-05-01 19:54:33 -07:00
|
|
|
|
'' :
|
|
|
|
|
getTopParentId() || '';
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var i, length;
|
|
|
|
|
var elems = document.getElementsByClassName('lnkMediaFolder');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var lnkMediaFolder = elems[i];
|
|
|
|
|
var itemId = lnkMediaFolder.getAttribute('data-itemid');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-02 21:20:04 -07:00
|
|
|
|
if (isChannelsPage && itemId == 'channels') {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-02 21:20:04 -07:00
|
|
|
|
}
|
|
|
|
|
else if (isLiveTvPage && itemId == 'livetv') {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2014-05-12 11:04:25 -07:00
|
|
|
|
else if (isEditorPage && itemId == 'editor') {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
}
|
|
|
|
|
else if (isReportsPage && itemId == 'reports') {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
}
|
2014-12-30 23:24:49 -07:00
|
|
|
|
else if (isMySyncPage && itemId == 'mysync') {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-12-30 23:24:49 -07:00
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
else if (id && itemId == id) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.add('selectedMediaFolder');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnkMediaFolder.classList.remove('selectedMediaFolder');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2015-06-28 07:45:21 -07:00
|
|
|
|
}
|
2015-09-21 08:43:10 -07:00
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
function updateTabLinks(page) {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var elems = page.querySelectorAll('.scopedLibraryViewNav a');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var id = page.classList.contains('liveTvPage') || page.classList.contains('channelsPage') || page.classList.contains('metadataEditorPage') || page.classList.contains('reportsPage') || page.classList.contains('mySyncPage') || page.classList.contains('allLibraryPage') ?
|
|
|
|
|
'' :
|
|
|
|
|
getTopParentId() || '';
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
if (!id) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
var lnk = elems[i];
|
|
|
|
|
var src = lnk.href;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
|
2015-09-21 08:43:10 -07:00
|
|
|
|
if (src.indexOf('#') != -1) {
|
|
|
|
|
continue;
|
2015-06-28 07:45:21 -07:00
|
|
|
|
}
|
2015-09-21 08:43:10 -07:00
|
|
|
|
|
|
|
|
|
src = replaceQueryString(src, 'topParentId', id);
|
|
|
|
|
|
|
|
|
|
lnk.href = src;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
function onWebSocketMessage(e, data) {
|
|
|
|
|
|
|
|
|
|
var msg = data;
|
|
|
|
|
|
|
|
|
|
if (msg.MessageType === "UserConfigurationUpdated") {
|
|
|
|
|
|
|
|
|
|
if (msg.Data.Id == Dashboard.getCurrentUserId()) {
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
// refresh library menu
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
function updateViewMenuBar(page) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
var viewMenuBar = document.querySelector('.viewMenuBar');
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (page.classList.contains('standalonePage')) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
viewMenuBar.classList.add('hide');
|
2014-05-21 20:35:18 -07:00
|
|
|
|
} else {
|
2015-07-08 22:52:25 -07:00
|
|
|
|
viewMenuBar.classList.remove('hide');
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
if (page.classList.contains('type-interior')) {
|
|
|
|
|
viewMenuBar.classList.add('headroomDisabled');
|
|
|
|
|
} else {
|
|
|
|
|
viewMenuBar.classList.remove('headroomDisabled');
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (requiresUserRefresh) {
|
2015-12-25 19:28:35 -07:00
|
|
|
|
ConnectionManager.user(window.ApiClient).then(updateUserInHeader);
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2015-05-20 09:28:55 -07:00
|
|
|
|
}
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2016-02-09 10:13:50 -07:00
|
|
|
|
pageClassOn('pageinit', 'page', function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var isLibraryPage = page.classList.contains('libraryPage');
|
|
|
|
|
|
|
|
|
|
if (isLibraryPage) {
|
|
|
|
|
|
|
|
|
|
var navs = page.querySelectorAll('.libraryViewNav');
|
|
|
|
|
for (var i = 0, length = navs.length; i < length; i++) {
|
|
|
|
|
initHeadRoom(navs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
pageClassOn('pagebeforeshow', 'page', function (e) {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
if (!page.classList.contains('withTabs')) {
|
|
|
|
|
LibraryMenu.setTabs(null);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
pageClassOn('pageshow', 'page', function (e) {
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
var isDashboardPage = page.classList.contains('type-interior');
|
|
|
|
|
|
|
|
|
|
if (isDashboardPage) {
|
|
|
|
|
refreshDashboardInfoInDrawer(page);
|
|
|
|
|
mainDrawerPanel.forceNarrow = false;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (mainDrawerPanel.classList.contains('adminDrawerPanel')) {
|
|
|
|
|
refreshLibraryDrawer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainDrawerPanel.forceNarrow = true;
|
2015-09-21 08:43:10 -07:00
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
setDrawerClass(page);
|
|
|
|
|
|
2016-04-12 22:28:45 -07:00
|
|
|
|
updateViewMenuBar(page);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
updateTabLinks(page);
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
if (!e.detail.isRestored) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
// Scroll back up so in case vertical scroll was messed with
|
|
|
|
|
window.scrollTo(0, 0);
|
2015-07-08 22:52:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
updateTitle(page);
|
|
|
|
|
updateBackButton(page);
|
2015-08-17 21:22:45 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (page.classList.contains('libraryPage')) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.body.classList.add('libraryDocument');
|
|
|
|
|
document.body.classList.remove('dashboardDocument');
|
|
|
|
|
document.body.classList.remove('hideMainDrawer');
|
2015-05-20 09:28:55 -07:00
|
|
|
|
}
|
2016-03-27 20:37:33 -07:00
|
|
|
|
else if (isDashboardPage) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
|
|
|
|
document.body.classList.remove('libraryDocument');
|
|
|
|
|
document.body.classList.add('dashboardDocument');
|
|
|
|
|
document.body.classList.remove('hideMainDrawer');
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
|
|
|
|
document.body.classList.remove('libraryDocument');
|
|
|
|
|
document.body.classList.remove('dashboardDocument');
|
|
|
|
|
document.body.classList.add('hideMainDrawer');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
2016-03-27 20:37:33 -07:00
|
|
|
|
|
|
|
|
|
updateLibraryNavLinks(page);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
function updateTitle(page) {
|
|
|
|
|
var title = page.getAttribute('data-title') || page.getAttribute('data-contextname');
|
|
|
|
|
|
|
|
|
|
if (!title) {
|
|
|
|
|
var titleKey = getParameterByName('titlekey');
|
|
|
|
|
|
|
|
|
|
if (titleKey) {
|
|
|
|
|
title = Globalize.translate(titleKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (title) {
|
|
|
|
|
LibraryMenu.setTitle(title);
|
|
|
|
|
}
|
2015-06-17 18:41:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBackButton(page) {
|
|
|
|
|
|
2015-07-15 04:26:47 -07:00
|
|
|
|
var canGoBack = !page.classList.contains('homePage') && history.length > 0;
|
2015-07-08 22:52:25 -07:00
|
|
|
|
|
|
|
|
|
var backButton = document.querySelector('.headerBackButton');
|
|
|
|
|
|
|
|
|
|
var showBackButton = AppInfo.enableBackButton;
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
2015-07-08 22:52:25 -07:00
|
|
|
|
if (!showBackButton) {
|
|
|
|
|
showBackButton = page.getAttribute('data-backbutton') == 'true';
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-10 22:03:05 -07:00
|
|
|
|
if (backButton) {
|
|
|
|
|
if (canGoBack && showBackButton) {
|
|
|
|
|
backButton.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
backButton.classList.add('hide');
|
|
|
|
|
}
|
2015-07-08 22:52:25 -07:00
|
|
|
|
}
|
2015-05-25 10:32:22 -07:00
|
|
|
|
}
|
2014-05-23 07:09:58 -07:00
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
function initHeadRoom(elem) {
|
|
|
|
|
|
|
|
|
|
if (!AppInfo.enableHeadRoom) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-23 10:53:04 -07:00
|
|
|
|
require(["headroom"], function () {
|
2015-05-08 20:48:43 -07:00
|
|
|
|
|
|
|
|
|
// construct an instance of Headroom, passing the element
|
2015-06-21 14:31:21 -07:00
|
|
|
|
var headroom = new Headroom(elem, {
|
|
|
|
|
// or scroll tolerance per direction
|
|
|
|
|
tolerance: {
|
|
|
|
|
down: 40,
|
|
|
|
|
up: 0
|
|
|
|
|
}
|
|
|
|
|
});
|
2015-05-08 20:48:43 -07:00
|
|
|
|
// initialise
|
|
|
|
|
headroom.init();
|
|
|
|
|
});
|
2015-05-06 20:11:51 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
function initializeApiClient(apiClient) {
|
2014-10-30 21:57:24 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
Events.off(apiClient, 'websocketmessage', onWebSocketMessage);
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
Events.on(apiClient, 'websocketmessage', onWebSocketMessage);
|
2014-10-25 11:32:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
if (window.ApiClient) {
|
|
|
|
|
initializeApiClient(window.ApiClient);
|
2014-06-03 20:34:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function setDrawerClass(page) {
|
|
|
|
|
|
|
|
|
|
var admin = false;
|
|
|
|
|
|
|
|
|
|
if (!page) {
|
|
|
|
|
if (window.$ && window.$.mobile) {
|
|
|
|
|
page = $.mobile.activePage;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (page && page.classList.contains('type-interior')) {
|
|
|
|
|
admin = true;
|
|
|
|
|
}
|
2016-01-27 12:39:20 -07:00
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
if (admin) {
|
|
|
|
|
mainDrawerPanel.classList.add('adminDrawerPanel');
|
|
|
|
|
mainDrawerPanel.classList.remove('darkDrawerPanel');
|
|
|
|
|
} else {
|
|
|
|
|
mainDrawerPanel.classList.add('darkDrawerPanel');
|
|
|
|
|
mainDrawerPanel.classList.remove('adminDrawerPanel');
|
2016-01-27 12:39:20 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-27 20:37:33 -07:00
|
|
|
|
function refreshLibraryDrawer(user) {
|
|
|
|
|
|
|
|
|
|
var promise = user ? Promise.resolve(user) : ConnectionManager.user(window.ApiClient);
|
|
|
|
|
|
|
|
|
|
promise.then(function (user) {
|
|
|
|
|
refreshLibraryInfoInDrawer(user);
|
|
|
|
|
|
|
|
|
|
document.dispatchEvent(new CustomEvent("libraryMenuCreated", {}));
|
|
|
|
|
updateLibraryMenu(user.localUser);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
mainDrawerPanel.addEventListener('iron-select', onMainDrawerSelect);
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
renderHeader();
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Events.on(ConnectionManager, 'apiclientcreated', function (e, apiClient) {
|
|
|
|
|
initializeApiClient(apiClient);
|
|
|
|
|
});
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Events.on(ConnectionManager, 'localusersignedin', function (e, user) {
|
|
|
|
|
requiresDrawerRefresh = true;
|
2016-01-27 12:39:20 -07:00
|
|
|
|
setDrawerClass();
|
2016-04-07 11:21:01 -07:00
|
|
|
|
var apiClient = ConnectionManager.getApiClient(user.ServerId);
|
2016-03-27 20:37:33 -07:00
|
|
|
|
ConnectionManager.user(ConnectionManager.getApiClient(user.ServerId)).then(function (user) {
|
|
|
|
|
refreshLibraryDrawer(user);
|
|
|
|
|
updateUserInHeader(user);
|
|
|
|
|
});
|
2016-04-07 11:21:01 -07:00
|
|
|
|
|
|
|
|
|
if (!AppInfo.isNativeApp) {
|
|
|
|
|
require(['components/servertestermessage'], function (message) {
|
|
|
|
|
message.show(apiClient);
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Events.on(ConnectionManager, 'localusersignedout', function () {
|
|
|
|
|
requiresDrawerRefresh = true;
|
2015-12-25 19:28:35 -07:00
|
|
|
|
updateUserInHeader();
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
Events.on(MediaController, 'playerchange', function () {
|
|
|
|
|
updateCastIcon();
|
2014-06-03 20:34:36 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-01-27 12:39:20 -07:00
|
|
|
|
setDrawerClass();
|
|
|
|
|
|
2016-03-15 22:33:31 -07:00
|
|
|
|
});
|