2013-12-27 14:10:06 -07:00
|
|
|
|
(function (window, document, $) {
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
function renderHeader(user) {
|
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
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '<button type="button" data-role="none" title="Menu" class="headerButton dashboardMenuButton barsMenuButton headerButtonLeft">';
|
2014-12-19 23:06:27 -07:00
|
|
|
|
html += '<div class="barMenuInner fa fa-bars">';
|
2014-07-27 15:01:29 -07:00
|
|
|
|
html += '</div>';
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '</button>';
|
|
|
|
|
|
|
|
|
|
html += '<button type="button" data-role="none" title="Menu" class="headerButton libraryMenuButton barsMenuButton headerButtonLeft">';
|
2014-12-19 23:06:27 -07:00
|
|
|
|
html += '<div class="barMenuInner fa fa-bars">';
|
2014-07-27 15:01:29 -07:00
|
|
|
|
html += '</div>';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += '</button>';
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2015-03-21 11:12:12 -07:00
|
|
|
|
html += '<div class="libraryMenuButtonText headerButton"><span>EMBY</span></div>';
|
2015-01-20 23:26:16 -07:00
|
|
|
|
|
2015-01-24 23:34:50 -07:00
|
|
|
|
if (user.localUser) {
|
2015-01-23 21:50:45 -07:00
|
|
|
|
|
2015-01-24 23:34:50 -07:00
|
|
|
|
html += '<div class="viewMenuSearch"><form class="viewMenuSearchForm">';
|
|
|
|
|
html += '<input type="text" data-role="none" data-type="search" class="headerSearchInput" autocomplete="off" spellcheck="off" />';
|
|
|
|
|
html += '<div class="searchInputIcon fa fa-search"></div>';
|
|
|
|
|
html += '<button data-role="none" type="button" data-iconpos="notext" class="imageButton btnCloseSearch" style="display:none;"><i class="fa fa-close"></i></button>';
|
|
|
|
|
html += '</form></div>';
|
|
|
|
|
}
|
2015-01-23 21:50:45 -07:00
|
|
|
|
|
2013-12-27 14:10:06 -07:00
|
|
|
|
html += '<div class="viewMenuSecondary">';
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
if (user.localUser) {
|
|
|
|
|
|
|
|
|
|
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
|
|
|
|
|
|
2014-12-20 18:23:56 -07:00
|
|
|
|
html += '<button onclick="Search.showSearchPanel($.mobile.activePage);" type="button" data-role="none" class="headerButton headerButtonRight headerSearchButton"><div class="fa fa-search" style="font-size:21px;"></div></button>';
|
2014-10-25 11:32:58 -07:00
|
|
|
|
} else {
|
|
|
|
|
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none" style="visibility:hidden;"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
}
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
if (user.imageUrl) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
var userButtonHeight = 26;
|
2014-12-19 23:06:27 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
|
|
|
|
|
if (user.supportsImageParams) {
|
2015-02-25 11:11:49 -07:00
|
|
|
|
url += "&height=" + userButtonHeight;
|
2014-10-25 11:32:58 -07:00
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-12-19 23:06:27 -07:00
|
|
|
|
html += '<img src="' + url + '" style="border-radius: 1000px; height:' + userButtonHeight + 'px;" />';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
} else {
|
2014-12-19 23:06:27 -07:00
|
|
|
|
html += '<div class="fa fa-user"></div>';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
if (user.canManageServer) {
|
2015-01-26 15:47:16 -07:00
|
|
|
|
html += '<a href="dashboard.html" class="headerButton headerButtonRight dashboardEntryHeaderButton"><div class="fa fa-cog"></div></a>';
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-27 14:10:06 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
$(document.body).prepend(html);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
$('.viewMenuBar').trigger('create');
|
2014-02-23 13:35:58 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
$(document).trigger('headercreated');
|
2014-05-29 12:34:20 -07:00
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
$('.libraryMenuButton').createHoverTouch().on('hovertouch', showLibraryMenu);
|
2014-06-21 22:52:31 -07:00
|
|
|
|
$('.dashboardMenuButton').createHoverTouch().on('hovertouch', showDashboardMenu);
|
2013-12-27 14:10:06 -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
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
function getViewsHtml() {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<div class="libraryMenuOptions">';
|
|
|
|
|
html += '</div>';
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<div class="libraryMenuDivider"></div>';
|
2014-12-30 23:24:49 -07:00
|
|
|
|
html += '<div class="adminMenuOptions">';
|
2014-12-30 12:16:01 -07:00
|
|
|
|
|
2015-01-26 15:47:16 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="dashboard" href="dashboard.html"><span class="fa fa-cog sidebarLinkIcon"></span>' + Globalize.translate('ButtonDashboard') + '</a>';
|
2015-01-23 21:50:45 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html"><span class="fa fa-edit sidebarLinkIcon"></span>' + Globalize.translate('ButtonMetadataManager') + '</a>';
|
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder" data-itemid="reports" href="reports.html"><span class="fa fa-bar-chart sidebarLinkIcon"></span>' + Globalize.translate('ButtonReports') + '</a>';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '</div>';
|
2015-01-23 21:50:45 -07:00
|
|
|
|
html += '<a class="sidebarLink lnkMediaFolder syncViewMenu" data-itemid="mysync" href="mysync.html"><span class="fa fa-cloud sidebarLinkIcon"></span>' + Globalize.translate('ButtonSync') + '</a>';
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
return html;
|
|
|
|
|
}
|
2014-03-18 10:05:57 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
function showLibraryMenu() {
|
2014-03-13 02:00:47 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
var panel;
|
|
|
|
|
|
|
|
|
|
panel = getLibraryMenu();
|
|
|
|
|
updateLibraryNavLinks(page);
|
|
|
|
|
|
|
|
|
|
$(panel).panel('toggle').off('mouseleave.librarymenu').on('mouseleave.librarymenu', function () {
|
|
|
|
|
|
|
|
|
|
$(this).panel("close");
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showDashboardMenu() {
|
2014-05-17 14:23:48 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
|
|
|
|
var panel = getDashboardMenu(page);
|
2014-05-17 14:23:48 -07:00
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
$(panel).panel('toggle').off('mouseleave.librarymenu').on('mouseleave.librarymenu', function () {
|
|
|
|
|
|
|
|
|
|
$(this).panel("close");
|
|
|
|
|
|
|
|
|
|
});
|
2014-05-17 14:23:48 -07:00
|
|
|
|
}
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
2014-05-17 14:23:48 -07:00
|
|
|
|
function updateLibraryMenu(panel) {
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
var apiClient = ConnectionManager.currentApiClient();
|
|
|
|
|
|
|
|
|
|
if (!apiClient) {
|
|
|
|
|
|
|
|
|
|
$('.adminMenuOptions').hide();
|
2014-12-30 23:24:49 -07:00
|
|
|
|
$('.syncViewMenu').hide();
|
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
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
var html = items.map(function (i) {
|
|
|
|
|
|
2014-12-30 12:16:01 -07:00
|
|
|
|
var iconCssClass = 'fa';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
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") {
|
|
|
|
|
iconCssClass += ' fa-photo';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "music" || i.CollectionType == "musicvideos") {
|
|
|
|
|
iconCssClass += ' fa-music';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "books") {
|
|
|
|
|
iconCssClass += ' fa-book';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "playlists") {
|
|
|
|
|
iconCssClass += ' fa-list';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "games") {
|
|
|
|
|
iconCssClass += ' fa-gamepad';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "movies") {
|
|
|
|
|
iconCssClass += ' fa-film';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "channels" || i.Type == 'Channel') {
|
|
|
|
|
iconCssClass += ' fa-globe';
|
|
|
|
|
}
|
|
|
|
|
else if (i.CollectionType == "tvshows" || i.CollectionType == "livetv") {
|
|
|
|
|
iconCssClass += ' fa-video-camera';
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
iconCssClass += ' fa-folder-open-o';
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-23 21:50:45 -07:00
|
|
|
|
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder sidebarLink" href="' + getItemHref(i, i.CollectionType) + '"><span class="' + iconCssClass + ' sidebarLinkIcon"></span><span class="sectionName">' + i.Name + '</span></a>';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
var elem = $('.libraryMenuOptions').html(html);
|
|
|
|
|
|
2015-01-23 21:50:45 -07:00
|
|
|
|
$('.sidebarLink', elem).on('click', function () {
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
2014-12-30 12:16:01 -07:00
|
|
|
|
var section = $('.sectionName', this)[0];
|
|
|
|
|
var text = section ? section.innerHTML : this.innerHTML;
|
|
|
|
|
|
|
|
|
|
$('.libraryMenuButtonText').html(text);
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
|
|
|
|
});
|
2014-05-14 13:20:19 -07:00
|
|
|
|
});
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-12-19 23:06:27 -07:00
|
|
|
|
if (user.Policy.IsAdministrator) {
|
2014-05-14 13:20:19 -07:00
|
|
|
|
$('.adminMenuOptions').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.adminMenuOptions').hide();
|
|
|
|
|
}
|
2015-01-17 22:45:10 -07:00
|
|
|
|
|
2014-12-30 23:24:49 -07:00
|
|
|
|
if (user.Policy.EnableSync) {
|
|
|
|
|
$('.syncViewMenu').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.syncViewMenu').hide();
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var requiresLibraryMenuRefresh = false;
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
function getLibraryMenu(user) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
var panel = $('#libraryPanel');
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
if (!panel.length) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div data-role="panel" id="libraryPanel" class="libraryPanel" data-position="left" data-display="overlay" data-position-fixed="true" data-theme="b">';
|
|
|
|
|
|
2015-01-23 21:50:45 -07:00
|
|
|
|
html += '<div class="sidebarLinks librarySidebarLinks" style="margin-top: 0;margin-left: -1em;margin-right: -1em;">';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
var homeHref = ConnectionManager.currentApiClient() ? 'index.html' : 'selectserver.html';
|
|
|
|
|
|
2015-01-23 21:50:45 -07:00
|
|
|
|
html += '<a class="lnkMediaFolder sidebarLink homeViewMenu" href="' + homeHref + '">' + Globalize.translate('ButtonHome') + '</a>';
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += '<div class="libraryMenuDivider"></div>';
|
|
|
|
|
|
2014-06-10 10:36:06 -07:00
|
|
|
|
html += getViewsHtml();
|
2014-05-09 12:43:06 -07:00
|
|
|
|
html += '</div>';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
$(document.body).append(html);
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
panel = $('#libraryPanel').panel({}).trigger('create');
|
2014-05-17 14:23:48 -07:00
|
|
|
|
|
|
|
|
|
updateLibraryMenu();
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
else if (requiresLibraryMenuRefresh) {
|
|
|
|
|
updateLibraryMenu();
|
|
|
|
|
requiresLibraryMenuRefresh = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDashboardMenu(page) {
|
|
|
|
|
|
|
|
|
|
var panel = $('#dashboardPanel', page);
|
|
|
|
|
|
|
|
|
|
if (!panel.length) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div data-role="panel" id="dashboardPanel" class="dashboardPanel" data-position="left" data-display="overlay" data-position-fixed="true" data-theme="b">';
|
|
|
|
|
|
|
|
|
|
html += '<div style="margin: 0 -1em;">';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
$(document.body).append(html);
|
|
|
|
|
panel = $('#dashboardPanel').panel({}).trigger('create');
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2014-05-23 18:16:53 -07:00
|
|
|
|
function setLibraryMenuText(text) {
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2014-05-23 18:16:53 -07:00
|
|
|
|
$('.libraryMenuButtonText').html('<span>' + text + '</span>');
|
|
|
|
|
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getTopParentId() {
|
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
return getParameterByName('topParentId') /*|| sessionStore.getItem('topParentId')*/ || null;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
window.LibraryMenu = {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
showLibraryMenu: showLibraryMenu,
|
|
|
|
|
|
2014-05-23 18:16:53 -07:00
|
|
|
|
getTopParentId: getTopParentId,
|
2014-06-03 20:34:36 -07:00
|
|
|
|
|
2014-05-23 18:16:53 -07:00
|
|
|
|
setText: setLibraryMenuText
|
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) {
|
|
|
|
|
|
|
|
|
|
$('.btnCast').addClass('btnDefaultCast').removeClass('btnActiveCast');
|
2014-06-21 22:52:31 -07:00
|
|
|
|
$('.headerSelectedPlayer').html('');
|
2014-03-29 11:20:42 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.btnCast').removeClass('btnDefaultCast').addClass('btnActiveCast');
|
2014-08-16 22:38:13 -07:00
|
|
|
|
|
|
|
|
|
$('.headerSelectedPlayer').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
|
|
|
|
|
|
|
|
|
page = $(page);
|
|
|
|
|
|
|
|
|
|
var isLiveTvPage = page.hasClass('liveTvPage');
|
2014-05-02 21:20:04 -07:00
|
|
|
|
var isChannelsPage = page.hasClass('channelsPage');
|
2014-05-12 11:04:25 -07:00
|
|
|
|
var isEditorPage = page.hasClass('metadataEditorPage');
|
|
|
|
|
var isReportsPage = page.hasClass('reportsPage');
|
2014-12-30 23:24:49 -07:00
|
|
|
|
var isMySyncPage = page.hasClass('mySyncPage');
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2014-12-30 23:24:49 -07:00
|
|
|
|
var id = isLiveTvPage || isChannelsPage || isEditorPage || isReportsPage || isMySyncPage || page.hasClass('allLibraryPage') ?
|
2014-05-01 19:54:33 -07:00
|
|
|
|
'' :
|
|
|
|
|
getTopParentId() || '';
|
|
|
|
|
|
2014-05-09 12:43:06 -07:00
|
|
|
|
$('.lnkMediaFolder').each(function () {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
|
|
|
|
var itemId = this.getAttribute('data-itemid');
|
|
|
|
|
|
2014-05-02 21:20:04 -07:00
|
|
|
|
if (isChannelsPage && itemId == 'channels') {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
else if (isLiveTvPage && itemId == 'livetv') {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
2014-05-12 11:04:25 -07:00
|
|
|
|
else if (isEditorPage && itemId == 'editor') {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
else if (isReportsPage && itemId == 'reports') {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
2014-12-30 23:24:49 -07:00
|
|
|
|
else if (isMySyncPage && itemId == 'mysync') {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
else if (id && itemId == id) {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$(this).removeClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
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') {
|
|
|
|
|
$('.scopedLibraryViewNav a', page).each(function () {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
var src = this.href;
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
if (src.indexOf('#') != -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-08-02 19:16:37 -07:00
|
|
|
|
src = replaceQueryString(src, 'topParentId', id);
|
|
|
|
|
|
|
|
|
|
this.href = src;
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
function updateContextText(page) {
|
|
|
|
|
|
|
|
|
|
var name = page.getAttribute('data-contextname');
|
|
|
|
|
|
|
|
|
|
if (name) {
|
|
|
|
|
|
|
|
|
|
$('.libraryMenuButtonText').html('<span>' + name + '</span>');
|
|
|
|
|
|
|
|
|
|
}
|
2014-06-21 22:52:31 -07:00
|
|
|
|
//else if ($(page).hasClass('type-interior')) {
|
|
|
|
|
|
|
|
|
|
// $('.libraryMenuButtonText').html('<span>' + 'Dashboard' + '</span>');
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
else if ($(page).hasClass('allLibraryPage') || $(page).hasClass('type-interior')) {
|
2015-03-21 11:12:12 -07:00
|
|
|
|
$('.libraryMenuButtonText').html('<span class="logoLibraryMenuButtonText">EMBY</span>');
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', ".page", function () {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
var page = this;
|
2013-12-28 09:58:13 -07:00
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
$('.libraryViewNav', page).wrapInner('<div class="libraryViewNavInner"></div>');
|
2014-01-23 14:09:00 -07:00
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
$('.libraryViewNav a', page).each(function () {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
this.innerHTML = '<span class="libraryViewNavLinkContent">' + this.innerHTML + '</span>';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
});
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
}).on('pagebeforeshow', ".page:not(.standalonePage)", function () {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
2014-05-21 20:35:18 -07:00
|
|
|
|
if (!$('.viewMenuBar').length) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
ConnectionManager.user().done(function (user) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
renderHeader(user);
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
updateCastIcon();
|
2014-05-14 11:04:26 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
updateLibraryNavLinks(page);
|
2014-05-21 20:35:18 -07:00
|
|
|
|
updateContextText(page);
|
2014-05-10 22:11:53 -07:00
|
|
|
|
});
|
2014-05-21 20:35:18 -07:00
|
|
|
|
} else {
|
|
|
|
|
updateContextText(page);
|
|
|
|
|
updateLibraryNavLinks(page);
|
2014-05-01 19:54:33 -07:00
|
|
|
|
}
|
2014-03-29 11:20:42 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
var jpage = $(page);
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
if (jpage.hasClass('libraryPage')) {
|
|
|
|
|
$(document.body).addClass('libraryDocument').removeClass('dashboardDocument');
|
|
|
|
|
}
|
|
|
|
|
else if (jpage.hasClass('type-interior')) {
|
|
|
|
|
$(document.body).addClass('dashboardDocument').removeClass('libraryDocument');
|
|
|
|
|
} else {
|
|
|
|
|
$(document.body).removeClass('dashboardDocument').removeClass('libraryDocument');
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-23 07:09:58 -07:00
|
|
|
|
}).on('pagebeforeshow', ".page", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
if ($(page).hasClass('standalonePage')) {
|
2014-05-23 07:09:58 -07:00
|
|
|
|
$('.viewMenuBar').hide();
|
2014-06-21 22:52:31 -07:00
|
|
|
|
} else {
|
|
|
|
|
$('.viewMenuBar').show();
|
2014-05-23 07:09:58 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 21:14:07 -07:00
|
|
|
|
}).on('pageshow', ".libraryPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var elem = $('.libraryViewNavInner .ui-btn-active:visible', page);
|
|
|
|
|
|
|
|
|
|
if (elem.length) {
|
|
|
|
|
elem[0].scrollIntoView();
|
2014-03-16 09:15:10 -07:00
|
|
|
|
|
|
|
|
|
// Scroll back up so in case vertical scroll was messed with
|
|
|
|
|
$(document).scrollTop(0);
|
2014-03-14 21:14:07 -07:00
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
function initializeApiClient(apiClient) {
|
2014-10-30 21:57:24 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
$(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 21:57:24 -07:00
|
|
|
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
|
|
|
|
|
|
|
|
|
initializeApiClient(apiClient);
|
|
|
|
|
});
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
$(function () {
|
|
|
|
|
|
2014-03-29 09:58:49 -07:00
|
|
|
|
$(MediaController).on('playerchange', function () {
|
2014-03-29 11:20:42 -07:00
|
|
|
|
updateCastIcon();
|
2014-03-29 09:58:49 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-06-03 20:34:36 -07:00
|
|
|
|
})(window, document, jQuery);
|
|
|
|
|
|
|
|
|
|
$.fn.createHoverTouch = function () {
|
|
|
|
|
|
|
|
|
|
var preventHover = false;
|
|
|
|
|
var timerId;
|
|
|
|
|
|
|
|
|
|
function startTimer(elem) {
|
|
|
|
|
|
|
|
|
|
stopTimer();
|
|
|
|
|
|
|
|
|
|
timerId = setTimeout(function () {
|
|
|
|
|
|
|
|
|
|
$(elem).trigger('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) {
|
|
|
|
|
$(this).trigger('hovertouch');
|
2014-06-24 14:45:21 -07:00
|
|
|
|
stopTimer(this);
|
|
|
|
|
preventHover = false;
|
2014-06-03 20:34:36 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
};
|