2015-05-06 20:11:51 -07:00
|
|
|
|
(function (window, document, $, devicePixelRatio) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
var backStack = [];
|
|
|
|
|
var addNextToBackStack = true;
|
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
function renderHeader() {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2013-12-28 00:09:05 -07:00
|
|
|
|
var html = '<div class="viewMenuBar ui-bar-b">';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-17 08:39:46 -07:00
|
|
|
|
if (AppInfo.enableBackButton) {
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="chevron-left" class="headerButton headerButtonLeft headerBackButton"></paper-icon-button>';
|
2015-06-17 08:39:46 -07:00
|
|
|
|
}
|
2015-04-25 20:25:07 -07:00
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="menu" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft"></paper-icon-button>';
|
2014-10-25 11:32:58 -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-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="search" class="headerButton headerButtonRight headerSearchButton hide" onclick="Search.showSearchPanel();"></paper-icon-button>';
|
2015-05-25 10:32:22 -07:00
|
|
|
|
html += '<div class="viewMenuSearch hide">';
|
|
|
|
|
html += '<form class="viewMenuSearchForm">';
|
2015-05-22 08:59:17 -07:00
|
|
|
|
html += '<input type="text" data-role="none" data-type="search" class="headerSearchInput" autocomplete="off" spellcheck="off" />';
|
|
|
|
|
html += '<div class="searchInputIcon fa fa-search"></div>';
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="close" class="btnCloseSearch"></paper-icon-button>';
|
2015-05-25 10:32:22 -07:00
|
|
|
|
html += '</form>';
|
|
|
|
|
html += '</div>';
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="mic" class="headerButton headerButtonRight headerVoiceButton hide" onclick="VoiceInputManager.startListening();"></paper-icon-button>';
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-06-10 06:37:07 -07:00
|
|
|
|
if (!showUserAtTop()) {
|
|
|
|
|
html += '<button class="headerButton headerButtonRight headerUserButton" type="button" data-role="none" onclick="Dashboard.showUserFlyout(this);">';
|
|
|
|
|
html += '<div class="fa fa-user"></div>';
|
|
|
|
|
html += '</button>';
|
|
|
|
|
}
|
2015-06-03 21:50:10 -07:00
|
|
|
|
|
2015-06-07 14:21:30 -07:00
|
|
|
|
if (!$.browser.mobile && !AppInfo.isNativeApp) {
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html += '<paper-icon-button icon="settings" class="headerButton headerButtonRight dashboardEntryHeaderButton hide" onclick="Dashboard.navigate(\'dashboard.html\');"></paper-icon-button>';
|
2015-06-01 22:46:06 -07:00
|
|
|
|
}
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
$(document.body).append(html);
|
2015-06-28 07:45:21 -07:00
|
|
|
|
ImageLoader.lazyChildren(document.querySelector('.viewMenuBar'));
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.trigger(document, '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 {
|
2015-06-17 18:41:22 -07:00
|
|
|
|
addNextToBackStack = false;
|
|
|
|
|
|
|
|
|
|
backStack.length = Math.max(0, backStack.length - 1);
|
2015-06-08 14:32:20 -07:00
|
|
|
|
history.back();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
function addUserToHeader(user) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var header = document.querySelector('.viewMenuBar');
|
2015-05-22 08:59:17 -07:00
|
|
|
|
|
2015-05-08 09:58:27 -07:00
|
|
|
|
if (user.localUser) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.btnCast', header).visible(true);
|
|
|
|
|
$('.headerSearchButton', header).visible(true);
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
2015-06-02 10:46:44 -07:00
|
|
|
|
requirejs(['voice/voice'], function () {
|
2015-06-01 22:46:06 -07:00
|
|
|
|
|
|
|
|
|
if (VoiceInputManager.isSupported()) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.headerVoiceButton', header).visible(true);
|
2015-06-01 22:46:06 -07:00
|
|
|
|
} else {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.headerVoiceButton', header).visible(false);
|
2015-06-01 22:46:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
} else {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.btnCast', header).visible(false);
|
|
|
|
|
$('.headerVoiceButton', header).visible(false);
|
|
|
|
|
$('.headerSearchButton', header).visible(false);
|
2015-05-22 08:59:17 -07:00
|
|
|
|
}
|
2015-05-13 22:42:55 -07:00
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
if (user.canManageServer) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.dashboardEntryHeaderButton', header).visible(true);
|
2015-05-22 08:59:17 -07:00
|
|
|
|
} else {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.dashboardEntryHeaderButton', header).visible(false);
|
2014-10-25 11:32:58 -07:00
|
|
|
|
}
|
2015-06-10 06:37:07 -07:00
|
|
|
|
|
|
|
|
|
var userButtonHtml = '';
|
|
|
|
|
if (user.name) {
|
|
|
|
|
|
|
|
|
|
if (user.imageUrl && AppInfo.enableUserImage) {
|
|
|
|
|
|
|
|
|
|
var userButtonHeight = 26;
|
|
|
|
|
|
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
|
|
|
|
|
if (user.supportsImageParams) {
|
|
|
|
|
url += "&height=" + (userButtonHeight * Math.max(devicePixelRatio || 1, 2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userButtonHtml += '<div class="lazy headerUserImage" data-src="' + url + '" style="width:' + userButtonHeight + 'px;height:' + userButtonHeight + 'px;"></div>';
|
|
|
|
|
} else {
|
|
|
|
|
userButtonHtml += '<div class="fa fa-user"></div>';
|
|
|
|
|
}
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
|
|
|
|
var headerUserButton = header.querySelector('.headerUserButton');
|
|
|
|
|
if (headerUserButton) {
|
|
|
|
|
headerUserButton.innerHTML = userButtonHtml;
|
|
|
|
|
ImageLoader.lazyChildren(headerUserButton);
|
|
|
|
|
}
|
2015-06-10 06:37:07 -07:00
|
|
|
|
}
|
2015-04-25 20:25:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindMenuEvents() {
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
if (AppInfo.isTouchPreferred) {
|
2015-04-25 20:25:07 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$('.mainDrawerButton').on('touchend', openMainDrawer).on('click', openMainDrawer);
|
2015-04-25 20:25:07 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.mainDrawerButton').createHoverTouch().on('hovertouch', openMainDrawer);
|
2015-04-25 20:25:07 -07:00
|
|
|
|
}
|
2015-05-04 07:35:38 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
$('.headerBackButton').on('click', onBackClick);
|
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
// Have to wait for document ready here because otherwise
|
|
|
|
|
// we may see the jQM redirect back and forth problem
|
|
|
|
|
$(initViewMenuBarHeadroom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initViewMenuBarHeadroom() {
|
|
|
|
|
|
2015-05-04 07:35:38 -07:00
|
|
|
|
// grab an element
|
|
|
|
|
var viewMenuBar = document.getElementsByClassName("viewMenuBar")[0];
|
2015-05-06 20:11:51 -07:00
|
|
|
|
initHeadRoom(viewMenuBar);
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-05-07 15:27:01 -07:00
|
|
|
|
function updateViewMenuBarHeadroom(page, viewMenuBar) {
|
2015-05-08 09:58:27 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (page.classList.contains('libraryPage')) {
|
2015-06-17 18:41:22 -07:00
|
|
|
|
// Don't like this timeout at all but if headroom is activated during the page events it will jump and flicker on us
|
|
|
|
|
setTimeout(reEnableHeadroom, 700);
|
2015-05-07 15:27:01 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
viewMenuBar.classList.add('headroomDisabled');
|
2015-05-07 15:27:01 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
function reEnableHeadroom() {
|
|
|
|
|
$('.headroomDisabled').removeClass('headroomDisabled');
|
|
|
|
|
}
|
|
|
|
|
|
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-06-21 14:31:21 -07:00
|
|
|
|
var requiresDrawerRefresh = true;
|
|
|
|
|
var requiresDashboardDrawerRefresh = true;
|
2015-06-23 15:13:06 -07:00
|
|
|
|
var lastOpenTime = new Date().getTime();
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
|
|
|
|
function openMainDrawer() {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var 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
|
|
|
|
}
|
|
|
|
|
function onMainDrawerOpened() {
|
|
|
|
|
|
|
|
|
|
if ($.browser.mobile) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.body.classList.add('bodyWithPopupOpen');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var drawer = document.querySelector('.mainDrawerPanel .mainDrawer');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
|
|
|
|
ConnectionManager.user(window.ApiClient).done(function (user) {
|
|
|
|
|
|
|
|
|
|
if (requiresDrawerRefresh) {
|
|
|
|
|
ensureDrawerStructure(drawer);
|
|
|
|
|
|
|
|
|
|
refreshUserInfoInDrawer(user, drawer);
|
|
|
|
|
refreshLibraryInfoInDrawer(user, drawer);
|
|
|
|
|
refreshBottomUserInfoInDrawer(user, drawer);
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.trigger(document, 'libraryMenuCreated');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
updateLibraryMenu(user.localUser);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var pageElem = $($.mobile.activePage)[0];
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
if (requiresDrawerRefresh || requiresDashboardDrawerRefresh) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
refreshDashboardInfoInDrawer(pageElem, user, drawer);
|
2015-06-21 14:31:21 -07:00
|
|
|
|
requiresDashboardDrawerRefresh = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
requiresDrawerRefresh = false;
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
updateLibraryNavLinks(pageElem);
|
2015-06-21 14:31:21 -07:00
|
|
|
|
});
|
2015-06-25 14:50:56 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.querySelector('.mainDrawerPanel #drawer').classList.add('verticalScrollingDrawer');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
function onMainDrawerClosed() {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.body.classList.remove('bodyWithPopupOpen');
|
|
|
|
|
document.querySelector('.mainDrawerPanel #drawer').classList.remove('verticalScrollingDrawer');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
function closeMainDrawer() {
|
|
|
|
|
|
2015-06-27 20:29:50 -07:00
|
|
|
|
document.getElementsByClassName('mainDrawerPanel')[0].closeDrawer();
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ensureDrawerStructure(drawer) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (drawer.querySelector('.mainDrawerContent')) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '<div class="mainDrawerContent">';
|
|
|
|
|
|
|
|
|
|
html += '<div class="userheader">';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="libraryDrawerContent">';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="dashboardDrawerContent">';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="userFooter">';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
drawer.innerHTML = html;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function refreshUserInfoInDrawer(user, drawer) {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
var userAtTop = showUserAtTop();
|
|
|
|
|
|
|
|
|
|
var homeHref = window.ApiClient ? 'index.html' : 'selectserver.html';
|
|
|
|
|
|
|
|
|
|
var hasUserImage = user.imageUrl && AppInfo.enableUserImage;
|
|
|
|
|
|
|
|
|
|
if (userAtTop) {
|
|
|
|
|
|
|
|
|
|
html += '<div class="drawerUserPanel">';
|
|
|
|
|
html += '<div class="drawerUserPanelInner">';
|
|
|
|
|
html += '<div class="drawerUserPanelContent">';
|
|
|
|
|
|
|
|
|
|
var imgWidth = 60;
|
|
|
|
|
|
|
|
|
|
if (hasUserImage) {
|
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
if (user.supportsImageParams) {
|
|
|
|
|
url += "&width=" + (imgWidth * Math.max(devicePixelRatio || 1, 2));
|
|
|
|
|
html += '<div class="lazy drawerUserPanelUserImage" data-src="' + url + '" style="width:' + imgWidth + 'px;height:' + imgWidth + 'px;"></div>';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div class="fa fa-user drawerUserPanelUserImage" style="font-size:' + imgWidth + 'px;"></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<div class="drawerUserPanelUserName">';
|
|
|
|
|
html += user.name;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="remote" href="index.html" onclick="return LibraryMenu.onLinkClicked(this);"><iron-icon icon="home" class="sidebarLinkIcon" style="color:#2196F3;"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonHome') + '</span></a>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
html += '<div style="margin-top:5px;"></div>';
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="lnkMediaFolder sidebarLink" href="' + homeHref + '" onclick="return LibraryMenu.onLinkClicked(this);">';
|
2015-06-27 20:29:50 -07:00
|
|
|
|
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>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
html += Globalize.translate('ButtonHome');
|
|
|
|
|
html += '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="remote" href="nowplaying.html" onclick="return LibraryMenu.onLinkClicked(this);"><iron-icon icon="tablet-android" class="sidebarLinkIcon" style="color:#673AB7;"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonRemote') + '</span></a>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var userHeader = drawer.querySelector('.userheader');
|
|
|
|
|
|
|
|
|
|
userHeader.innerHTML = html;
|
|
|
|
|
|
|
|
|
|
ImageLoader.fillImages(userHeader.getElementsByClassName('lazy'));
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function refreshLibraryInfoInDrawer(user, drawer) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<div class="libraryMenuOptions">';
|
|
|
|
|
html += '</div>';
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
drawer.querySelector('.libraryDrawerContent').innerHTML = html;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function refreshDashboardInfoInDrawer(page, user, drawer) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
|
|
|
|
|
|
|
|
|
html += Dashboard.getToolsMenuHtml(page);
|
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
html = html.split('href=').join('onclick="return LibraryMenu.onLinkClicked(this);" href=');
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
drawer.querySelector('.dashboardDrawerContent').innerHTML = html;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
function replaceAll(string, find, replace) {
|
|
|
|
|
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
function refreshBottomUserInfoInDrawer(user, drawer) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-12-30 23:24:49 -07:00
|
|
|
|
html += '<div class="adminMenuOptions">';
|
2015-06-05 07:27:01 -07:00
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
2014-12-30 12:16:01 -07:00
|
|
|
|
|
2015-05-29 16:51:33 -07:00
|
|
|
|
html += '<div class="sidebarHeader">';
|
|
|
|
|
html += Globalize.translate('HeaderAdmin');
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
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>';
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" onclick="return LibraryMenu.onLinkClicked(this);" href="edititemmetadata.html"><iron-icon icon="mode-edit" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonMetadataManager') + '</span></a>';
|
2015-06-04 13:27:46 -07:00
|
|
|
|
|
|
|
|
|
if (!$.browser.mobile && !AppInfo.isTouchPreferred) {
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="reports" onclick="return LibraryMenu.onLinkClicked(this);" href="reports.html"><iron-icon icon="insert-chart" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonReports') + '</span></a>';
|
2015-06-04 13:27:46 -07:00
|
|
|
|
}
|
2015-05-29 16:51:33 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="userMenuOptions">';
|
2015-06-05 07:27:01 -07:00
|
|
|
|
html += '<div class="sidebarDivider"></div>';
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="inbox" onclick="return LibraryMenu.onLinkClicked(this);" href="notificationlist.html"><iron-icon icon="inbox" class="sidebarLinkIcon"></iron-icon>';
|
2015-06-05 07:27:01 -07:00
|
|
|
|
html += Globalize.translate('ButtonInbox');
|
|
|
|
|
html += '<div class="btnNotifications"><div class="btnNotificationsInner">0</div></div>';
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
if (user.localUser && showUserAtTop()) {
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkMySettings" onclick="return LibraryMenu.onLinkClicked(this);" data-itemid="mysync" href="mypreferencesdisplay.html?userId=' + user.localUser.Id + '"><iron-icon icon="settings" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSettings') + '</span></a>';
|
2015-06-21 14:31:21 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder lnkMySync" data-itemid="mysync" onclick="return LibraryMenu.onLinkClicked(this);" href="mysync.html"><iron-icon icon="refresh" class="sidebarLinkIcon"></iron-icon><span class="sidebarLinkText">' + Globalize.translate('ButtonSync') + '</span></a>';
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
|
|
|
|
if (Dashboard.isConnectMode()) {
|
2015-06-23 15:13:06 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="selectserver" onclick="return LibraryMenu.onLinkClicked(this);" href="selectserver.html"><span class="fa fa-globe sidebarLinkIcon"></span><span class="sidebarLinkText">' + Globalize.translate('ButtonSelectServer') + '</span></a>';
|
2015-05-29 16:51:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-10 06:37:07 -07:00
|
|
|
|
if (showUserAtTop()) {
|
2015-06-23 21:38:46 -07:00
|
|
|
|
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>';
|
2015-06-10 06:37:07 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '</div>';
|
2015-05-29 16:51:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
drawer.querySelector('.userFooter').innerHTML = html;
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.on(drawer.querySelector('.lnkManageServer'), 'click', onManageServerClicked);
|
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;
|
|
|
|
|
|
|
|
|
|
document.querySelector('.libraryMenuButtonText').innerHTML = text;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.adminMenuOptions').visible(false);
|
|
|
|
|
$('.lnkMySync').visible(false);
|
|
|
|
|
$('.userMenuOptions').visible(false);
|
2014-10-25 11:32:58 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
apiClient.getUserViews(userId).done(function (result) {
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
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-06-30 19:29:27 -07:00
|
|
|
|
if (i.Type == 'Channel') {
|
|
|
|
|
}
|
2014-06-07 12:46:24 -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-06-23 15:13:06 -07:00
|
|
|
|
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder sidebarLink" onclick="return LibraryMenu.onLinkClicked(this);" 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
|
|
|
|
var libraryMenuOptions = document.querySelector('.libraryMenuOptions');
|
|
|
|
|
libraryMenuOptions.innerHTML = html;
|
|
|
|
|
var elem = libraryMenuOptions;
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
$('.sidebarLink', elem).off('click', onSidebarLinkClick).on('click', onSidebarLinkClick);
|
2014-05-14 13:20:19 -07:00
|
|
|
|
});
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
if (user.Policy.IsAdministrator) {
|
|
|
|
|
$('.adminMenuOptions').visible(true);
|
|
|
|
|
} else {
|
|
|
|
|
$('.adminMenuOptions').visible(false);
|
|
|
|
|
}
|
2015-01-17 22:45:10 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
if (user.Policy.EnableSync) {
|
|
|
|
|
$('.lnkMySync').visible(true);
|
|
|
|
|
} else {
|
|
|
|
|
$('.lnkMySync').visible(false);
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 07:27:01 -07:00
|
|
|
|
function showUserAtTop() {
|
2015-06-29 18:56:25 -07:00
|
|
|
|
return AppInfo.isNativeApp;
|
2015-06-05 07:27:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var requiresLibraryMenuRefresh = false;
|
2015-05-20 09:28:55 -07:00
|
|
|
|
var requiresViewMenuRefresh = false;
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
2015-06-07 14:21:30 -07:00
|
|
|
|
function onManageServerClicked() {
|
|
|
|
|
|
2015-06-22 08:43:19 -07:00
|
|
|
|
closeMainDrawer();
|
|
|
|
|
|
2015-06-07 14:21:30 -07:00
|
|
|
|
requirejs(["scripts/registrationservices"], function () {
|
|
|
|
|
|
|
|
|
|
RegistrationServices.validateFeature('manageserver').done(function () {
|
|
|
|
|
Dashboard.navigate('dashboard.html');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 18:16:53 -07:00
|
|
|
|
function setLibraryMenuText(text) {
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.querySelector('.libraryMenuButtonText').innerHTML = '<span>' + text + '</span>';
|
2014-05-23 18:16:53 -07:00
|
|
|
|
}
|
2013-12-27 14:10:06 -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-06-22 08:43:19 -07:00
|
|
|
|
setText: setLibraryMenuText,
|
|
|
|
|
|
|
|
|
|
onLinkClicked: function (link) {
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
Dashboard.navigate(link.href);
|
|
|
|
|
}, 350);
|
|
|
|
|
}, 50);
|
2015-06-23 15:13:06 -07:00
|
|
|
|
}
|
2015-06-22 08:43:19 -07:00
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
Dashboard.logout();
|
2015-06-27 20:29:50 -07:00
|
|
|
|
}, 350);
|
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 () {
|
|
|
|
|
openMainDrawer();
|
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
|
|
|
|
|
2014-03-29 11:20:42 -07:00
|
|
|
|
var info = MediaController.getPlayerInfo();
|
|
|
|
|
|
|
|
|
|
if (info.isLocalPlayer) {
|
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
$('.btnCast').removeClass('btnActiveCast').each(function () {
|
|
|
|
|
this.icon = 'cast';
|
|
|
|
|
});
|
2015-06-26 08:53:49 -07:00
|
|
|
|
$('.nowPlayingSelectedPlayer').html('');
|
2014-03-29 11:20:42 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
2015-06-23 21:38:46 -07:00
|
|
|
|
$('.btnCast').addClass('btnActiveCast').each(function () {
|
|
|
|
|
this.icon = 'cast-connected';
|
|
|
|
|
});
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
2015-06-26 08:53:49 -07:00
|
|
|
|
$('.nowPlayingSelectedPlayer').html((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
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
var context = getParameterByName('context');
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (context !== 'playlists') {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
elems = page.querySelectorAll('.scopedLibraryViewNav a');
|
|
|
|
|
|
|
|
|
|
for (i = 0, length = elems.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var lnk = elems[i];
|
|
|
|
|
var src = lnk.href;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (src.indexOf('#') != -1) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
continue;
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
src = replaceQueryString(src, 'topParentId', id);
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
lnk.href = src;
|
|
|
|
|
}
|
2014-08-02 19:16:37 -07:00
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
function updateContextText(page) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var name = page.getAttribute('data-contextname');
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.querySelector('.libraryMenuButtonText').innerHTML = '<span>' + name + '</span>';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
|
|
|
|
}
|
2015-06-28 07:45:21 -07:00
|
|
|
|
else if (page.classList.contains('allLibraryPage') || page.classList.contains('type-interior')) {
|
|
|
|
|
document.querySelector('.libraryMenuButtonText').innerHTML = Globalize.translate('ButtonHome');
|
2014-05-21 20:35:18 -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()) {
|
|
|
|
|
|
|
|
|
|
requiresLibraryMenuRefresh = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-20 09:28:55 -07:00
|
|
|
|
function buildViewMenuBar(page) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (page.classList.contains('standalonePage')) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
$('.viewMenuBar').visible(false);
|
2015-05-20 09:28:55 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var viewMenuBar = document.querySelector('.viewMenuBar');
|
|
|
|
|
|
2015-05-20 09:28:55 -07:00
|
|
|
|
if (requiresViewMenuRefresh) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (viewMenuBar) {
|
|
|
|
|
$(viewMenuBar).remove();
|
|
|
|
|
viewMenuBar = null;
|
|
|
|
|
}
|
2015-05-20 09:28:55 -07:00
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (!viewMenuBar) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
renderHeader();
|
2015-06-28 07:45:21 -07:00
|
|
|
|
updateViewMenuBarHeadroom(page, document.querySelector('.viewMenuBar'));
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
updateCastIcon();
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-05-22 08:59:17 -07:00
|
|
|
|
updateLibraryNavLinks(page);
|
|
|
|
|
updateContextText(page);
|
|
|
|
|
requiresViewMenuRefresh = false;
|
|
|
|
|
|
|
|
|
|
ConnectionManager.user(window.ApiClient).done(addUserToHeader);
|
2014-05-14 11:04:26 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
$(viewMenuBar).visible(true);
|
2014-05-21 20:35:18 -07:00
|
|
|
|
updateContextText(page);
|
|
|
|
|
updateLibraryNavLinks(page);
|
2015-05-07 15:27:01 -07:00
|
|
|
|
updateViewMenuBarHeadroom(page, viewMenuBar);
|
2015-05-20 09:28:55 -07:00
|
|
|
|
requiresViewMenuRefresh = false;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2015-05-20 09:28:55 -07:00
|
|
|
|
}
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
$(document).on('pagebeforeshowready', ".page", function () {
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
requiresDashboardDrawerRefresh = true;
|
|
|
|
|
|
2015-06-29 22:45:20 -07:00
|
|
|
|
onPageBeforeShowDocumentReady(page);
|
2015-05-25 10:32:22 -07:00
|
|
|
|
|
|
|
|
|
}).on('pageshowready', ".page", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
onPageShowDocumentReady(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', ".page", function () {
|
2015-05-20 09:28:55 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
if (addNextToBackStack) {
|
|
|
|
|
var text = $('.libraryMenuButtonText').text() || document.title;
|
2015-05-20 09:28:55 -07:00
|
|
|
|
|
2015-06-17 18:41:22 -07:00
|
|
|
|
backStack.push(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addNextToBackStack = true;
|
|
|
|
|
|
|
|
|
|
$('.headroomEnabled').addClass('headroomDisabled');
|
|
|
|
|
});
|
2015-05-20 09:28:55 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
function onPageBeforeShowDocumentReady(page) {
|
2014-05-23 07:09:58 -07:00
|
|
|
|
|
2015-05-20 09:28:55 -07:00
|
|
|
|
buildViewMenuBar(page);
|
2014-05-23 07:09:58 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var isLibraryPage = page.classList.contains('libraryPage');
|
2015-06-21 14:31:21 -07:00
|
|
|
|
var darkDrawer = false;
|
2015-05-08 20:48:43 -07:00
|
|
|
|
|
2015-05-20 09:28:55 -07:00
|
|
|
|
if (isLibraryPage) {
|
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-08 20:48:43 -07:00
|
|
|
|
|
2015-05-20 09:28:55 -07:00
|
|
|
|
if (AppInfo.enableBottomTabs) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.classList.add('noSecondaryNavPage');
|
2015-05-08 09:58:27 -07:00
|
|
|
|
|
2015-06-29 22:45:20 -07:00
|
|
|
|
document.querySelector('.footer').classList.add('footerOverBottomTabs');
|
2015-05-20 09:28:55 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.libraryViewNav', page).each(function () {
|
|
|
|
|
|
|
|
|
|
initHeadRoom(this);
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-06-21 14:31:21 -07:00
|
|
|
|
|
2015-06-29 18:56:25 -07:00
|
|
|
|
if (!AppInfo.isNativeApp) {
|
2015-06-21 14:31:21 -07:00
|
|
|
|
darkDrawer = true;
|
|
|
|
|
}
|
2015-05-20 09:28:55 -07:00
|
|
|
|
}
|
2015-06-28 07:45:21 -07:00
|
|
|
|
else if (page.classList.contains('type-interior')) {
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (darkDrawer) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.querySelector('.mainDrawerPanel #drawer').classList.add('darkDrawer');
|
2015-05-20 09:28:55 -07:00
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
document.querySelector('.mainDrawerPanel #drawer').classList.remove('darkDrawer');
|
2014-05-23 07:09:58 -07:00
|
|
|
|
}
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
2015-06-21 14:31:21 -07:00
|
|
|
|
if (AppInfo.enableBackButton) {
|
2015-06-17 18:41:22 -07:00
|
|
|
|
updateBackButton(page);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateBackButton(page) {
|
|
|
|
|
|
2015-06-28 19:05:46 -07:00
|
|
|
|
var canGoBack = backStack.length > 0 && !page.classList.contains('homePage');
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
|
|
|
|
$('.headerBackButton').visible(canGoBack);
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.off(page, 'swiperight', onPageSwipeLeft);
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
|
|
|
|
if (canGoBack) {
|
2015-06-29 11:45:42 -07:00
|
|
|
|
//Events.on(page, 'swiperight', onPageSwipeLeft);
|
2015-06-17 18:41:22 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onPageSwipeLeft(e) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var target = e.target;
|
2015-06-17 18:41:22 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
if (!target.classList.contains('hiddenScrollX') && !$(target).parents('.hiddenScrollX').length) {
|
2015-06-17 18:41:22 -07:00
|
|
|
|
history.back();
|
|
|
|
|
}
|
2015-05-25 10:32:22 -07:00
|
|
|
|
}
|
2014-05-23 07:09:58 -07:00
|
|
|
|
|
2015-05-25 10:32:22 -07:00
|
|
|
|
function onPageShowDocumentReady(page) {
|
2014-03-14 21:14:07 -07:00
|
|
|
|
|
2015-06-29 19:52:23 -07:00
|
|
|
|
if (!NavHelper.isBack()) {
|
|
|
|
|
var elems = page.querySelectorAll('.libraryViewNav .ui-btn-active');
|
|
|
|
|
elems = $(elems).filter(':visible');
|
2015-06-28 07:45:21 -07:00
|
|
|
|
|
2015-06-29 19:52:23 -07:00
|
|
|
|
if (elems.length) {
|
|
|
|
|
elems[0].scrollIntoView();
|
2014-03-16 09:15:10 -07:00
|
|
|
|
|
2015-06-29 19:52:23 -07:00
|
|
|
|
// Scroll back up so in case vertical scroll was messed with
|
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
|
}
|
2014-03-14 21:14:07 -07:00
|
|
|
|
}
|
2015-05-25 10:32:22 -07:00
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
function initHeadRoom(elem) {
|
|
|
|
|
|
|
|
|
|
if (!AppInfo.enableHeadRoom) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-08 20:48:43 -07:00
|
|
|
|
requirejs(["thirdparty/headroom"], function () {
|
|
|
|
|
|
|
|
|
|
// 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-06-28 07:45:21 -07:00
|
|
|
|
elem.classList.add('headroomEnabled');
|
2015-05-08 20:48:43 -07:00
|
|
|
|
});
|
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-05-19 12:15:40 -07:00
|
|
|
|
requiresLibraryMenuRefresh = true;
|
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-05-19 12:15:40 -07:00
|
|
|
|
Dashboard.ready(function () {
|
2015-05-18 15:23:03 -07:00
|
|
|
|
|
2015-05-19 12:15:40 -07:00
|
|
|
|
if (window.ApiClient) {
|
|
|
|
|
initializeApiClient(window.ApiClient);
|
|
|
|
|
}
|
2015-05-18 18:46:31 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.on(ConnectionManager, 'apiclientcreated', function (e, apiClient) {
|
2015-05-19 12:15:40 -07:00
|
|
|
|
initializeApiClient(apiClient);
|
2015-05-18 18:46:31 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-29 11:45:42 -07:00
|
|
|
|
Events.on(ConnectionManager, 'localusersignedin', function () {
|
|
|
|
|
requiresLibraryMenuRefresh = true;
|
|
|
|
|
requiresViewMenuRefresh = true;
|
|
|
|
|
requiresDrawerRefresh = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Events.on(ConnectionManager, 'localusersignedout', function () {
|
2015-05-19 12:15:40 -07:00
|
|
|
|
requiresLibraryMenuRefresh = true;
|
2015-05-20 09:28:55 -07:00
|
|
|
|
requiresViewMenuRefresh = true;
|
2015-06-21 14:31:21 -07:00
|
|
|
|
requiresDrawerRefresh = true;
|
2015-05-19 12:15:40 -07:00
|
|
|
|
});
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.on(MediaController, 'playerchange', function () {
|
2014-03-29 11:20:42 -07:00
|
|
|
|
updateCastIcon();
|
2014-03-29 09:58:49 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var mainDrawerPanel = document.querySelector('.mainDrawerPanel');
|
|
|
|
|
Events.on(mainDrawerPanel, 'paper-drawer-panel-open', onMainDrawerOpened);
|
|
|
|
|
Events.on(mainDrawerPanel, 'paper-drawer-panel-close', onMainDrawerClosed);
|
2014-03-29 09:58:49 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-05-06 20:11:51 -07:00
|
|
|
|
})(window, document, jQuery, window.devicePixelRatio);
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
|
|
|
|
$.fn.createHoverTouch = function () {
|
|
|
|
|
|
|
|
|
|
var preventHover = false;
|
|
|
|
|
var timerId;
|
|
|
|
|
|
|
|
|
|
function startTimer(elem) {
|
|
|
|
|
|
|
|
|
|
stopTimer();
|
|
|
|
|
|
|
|
|
|
timerId = setTimeout(function () {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.trigger(elem, 'hovertouch');
|
2014-06-07 14:06:01 -07:00
|
|
|
|
}, 300);
|
2014-06-03 20:34:36 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stopTimer(elem) {
|
|
|
|
|
|
|
|
|
|
if (timerId) {
|
|
|
|
|
clearTimeout(timerId);
|
|
|
|
|
timerId = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $(this).on('mouseenter', function () {
|
|
|
|
|
|
|
|
|
|
if (preventHover === true) {
|
2014-06-07 12:46:24 -07:00
|
|
|
|
preventHover = false;
|
2014-06-03 20:34:36 -07:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startTimer(this);
|
|
|
|
|
|
|
|
|
|
}).on('mouseleave', function () {
|
|
|
|
|
|
|
|
|
|
stopTimer(this);
|
|
|
|
|
|
|
|
|
|
}).on('touchstart', function () {
|
|
|
|
|
|
|
|
|
|
preventHover = true;
|
|
|
|
|
|
|
|
|
|
}).on('click', function () {
|
|
|
|
|
|
|
|
|
|
preventHover = true;
|
|
|
|
|
|
|
|
|
|
if (preventHover) {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
Events.trigger(this, 'hovertouch');
|
2014-06-24 14:45:21 -07:00
|
|
|
|
stopTimer(this);
|
|
|
|
|
preventHover = false;
|
2014-06-03 20:34:36 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-29 19:52:23 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
|
|
var backUrl;
|
|
|
|
|
|
|
|
|
|
$(document).on('pagebeforeshow', ".page", function () {
|
2015-07-08 09:10:34 -07:00
|
|
|
|
|
2015-06-29 19:52:23 -07:00
|
|
|
|
if (getWindowUrl() != backUrl) {
|
|
|
|
|
backUrl = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(window).on("popstate", function () {
|
|
|
|
|
backUrl = getWindowUrl();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function isBack() {
|
|
|
|
|
|
|
|
|
|
return backUrl == getWindowUrl();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.NavHelper = {
|
|
|
|
|
isBack: isBack
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})();
|