2013-12-27 14:10:06 -07:00
|
|
|
|
(function (window, document, $) {
|
|
|
|
|
|
2014-05-03 16:38:23 -07:00
|
|
|
|
function renderHeader(page, 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-05-10 22:11:53 -07:00
|
|
|
|
html += '<button type="button" data-role="none" title="Menu" onclick="LibraryMenu.showLibraryMenu();" class="headerButton libraryMenuButton headerButtonLeft"><img src="css/images/menu.png" /></button>';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
html += '<a class="desktopHomeLink headerButton headerButtonLeft" href="index.html"><span>MEDIA</span><span class="mediaBrowserAccent">BROWSER</span></a>';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
html += '<div class="viewMenuSecondary">';
|
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
html += '<a href="nowplaying.html" class="headerButton headerButtonRight headerRemoteButton"><img src="css/images/remote.png" /></a>';
|
2014-02-23 10:29:02 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none"><div class="btnCastImage"></div></button>';
|
|
|
|
|
|
|
|
|
|
html += '<button onclick="Search.showSearchPanel($.mobile.activePage);" type="button" data-role="none" class="headerButton headerButtonRight headerSearchButton"><img src="css/images/headersearch.png" /></button>';
|
|
|
|
|
|
|
|
|
|
if (user.Configuration.IsAdministrator) {
|
|
|
|
|
html += '<a href="dashboard.html" class="headerButton headerButtonRight headerSettingsButton"><img src="css/images/items/folders/settings.png" /></a>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<a class="headerButton headerButtonRight" href="#" onclick="Dashboard.showUserFlyout(this);">';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
if (user.PrimaryImageTag) {
|
|
|
|
|
|
|
|
|
|
var url = ApiClient.getUserImageUrl(user.Id, {
|
2014-05-10 22:11:53 -07:00
|
|
|
|
height: 18,
|
2013-12-27 14:10:06 -07:00
|
|
|
|
tag: user.PrimaryImageTag,
|
|
|
|
|
type: "Primary"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
html += '<img src="' + url + '" />';
|
|
|
|
|
} else {
|
|
|
|
|
html += '<img src="css/images/currentuserdefaultwhite.png" />';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2014-05-03 16:38:23 -07:00
|
|
|
|
var $page = $(page);
|
|
|
|
|
|
|
|
|
|
$page.prepend(html);
|
2014-02-23 13:35:58 -07:00
|
|
|
|
|
2014-05-03 16:38:23 -07:00
|
|
|
|
$page.trigger('headercreated');
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getItemHref(item) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-06 19:28:19 -07:00
|
|
|
|
return LibraryBrowser.getHref(item);
|
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 secondaryDivider" style="display:none;"></div>';
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder channelsViewMenu channelsMenuOption" style="display:none;" data-itemid="channels" href="channels.html">Channels</a>';
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder tvshowsViewMenu liveTvMenuOption" style="display:none;" data-itemid="livetv" href="livetvsuggested.html">Live TV</a>';
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
html += '<div class="adminMenuOptions">';
|
|
|
|
|
html += '<div class="libraryMenuDivider"></div>';
|
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder dashboardViewMenu" data-itemid="dashboard" href="dashboard.html">Dashboard</a>';
|
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html">Metadata Manager</a>';
|
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder reportsViewMenu" data-itemid="reports" href="reports.html">Reports</a>';
|
|
|
|
|
html += '</div>';
|
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-05-14 13:20:19 -07:00
|
|
|
|
var userId = Dashboard.getCurrentUserId();
|
2014-05-03 16:38:23 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
ApiClient.getItems(userId, {
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
SortBy: "SortName"
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
}).done(function (result) {
|
|
|
|
|
|
|
|
|
|
var items = result.Items;
|
|
|
|
|
|
|
|
|
|
var html = items.map(function (i) {
|
|
|
|
|
|
|
|
|
|
var viewMenuCssClass = (i.CollectionType || 'general') + 'ViewMenu';
|
|
|
|
|
|
|
|
|
|
return '<a data-itemid="' + i.Id + '" class="lnkMediaFolder viewMenuLink viewMenuTextLink ' + viewMenuCssClass + '" href="' + getItemHref(i) + '">' + i.Name + '</a>';
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
$('.libraryMenuOptions').html(html);
|
|
|
|
|
});
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
var page = $.mobile.activePage;
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
var panel = getLibraryMenu();
|
2014-05-10 10:28:03 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
updateLibraryNavLinks(page);
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
$(panel).panel('toggle');
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
ApiClient.getLiveTvInfo().done(function (liveTvInfo) {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
var showLiveTv = liveTvInfo.EnabledUsers.indexOf(userId) != -1;
|
|
|
|
|
|
|
|
|
|
if (showLiveTv) {
|
|
|
|
|
$('.liveTvMenuOption').show();
|
|
|
|
|
$('.secondaryDivider').show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$.getJSON(ApiClient.getUrl("Channels", {
|
|
|
|
|
userId: userId,
|
|
|
|
|
|
|
|
|
|
// We just want the total record count
|
|
|
|
|
limit: 0
|
|
|
|
|
|
|
|
|
|
})).done(function (response) {
|
|
|
|
|
|
|
|
|
|
if (response.TotalRecordCount) {
|
|
|
|
|
$('.channelsMenuOption').show();
|
|
|
|
|
$('.secondaryDivider').show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
2014-05-14 11:04:26 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-14 13:20:19 -07:00
|
|
|
|
if (user.Configuration.IsAdministrator) {
|
|
|
|
|
$('.adminMenuOptions').show();
|
|
|
|
|
} else {
|
|
|
|
|
$('.adminMenuOptions').hide();
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-14 11:04:26 -07:00
|
|
|
|
function getLibraryMenu(user, channelCount, items, liveTvInfo) {
|
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">';
|
|
|
|
|
|
|
|
|
|
html += '<p class="libraryPanelHeader"><a href="index.html" class="imageLink"><img src="css/images/mblogoicon.png" /><span>MEDIA</span><span class="mediaBrowserAccent">BROWSER</span></a></p>';
|
|
|
|
|
|
2014-05-09 12:43:06 -07:00
|
|
|
|
html += '<div style="margin: 0 -1em;">';
|
2014-05-14 11:04:26 -07:00
|
|
|
|
html += getViewsHtml(user, channelCount, items, liveTvInfo);
|
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');
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-01 19:54:33 -07:00
|
|
|
|
function getTopParentId() {
|
|
|
|
|
|
|
|
|
|
return getParameterByName('topParentId') || sessionStorage.getItem('topParentId') || null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
window.LibraryMenu = {
|
2014-05-01 19:54:33 -07:00
|
|
|
|
showLibraryMenu: showLibraryMenu,
|
|
|
|
|
|
|
|
|
|
getTopParentId: getTopParentId
|
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');
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
$('.btnCast').removeClass('btnDefaultCast').addClass('btnActiveCast');
|
|
|
|
|
}
|
|
|
|
|
}
|
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-05-03 16:38:23 -07:00
|
|
|
|
|
2014-05-12 11:04:25 -07:00
|
|
|
|
var id = isLiveTvPage || isChannelsPage || isEditorPage || isReportsPage || page.hasClass('allLibraryPage') ?
|
2014-05-01 19:54:33 -07:00
|
|
|
|
'' :
|
|
|
|
|
getTopParentId() || '';
|
|
|
|
|
|
|
|
|
|
sessionStorage.setItem('topParentId', id);
|
|
|
|
|
|
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-05-01 19:54:33 -07:00
|
|
|
|
else if (id && itemId == id) {
|
|
|
|
|
$(this).addClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$(this).removeClass('selectedMediaFolder');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.scopedLibraryViewNav a', page).each(function () {
|
|
|
|
|
|
|
|
|
|
var src = this.href;
|
|
|
|
|
|
|
|
|
|
if (src.indexOf('#') != -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
src = replaceQueryString(src, 'topParentId', id);
|
|
|
|
|
|
|
|
|
|
this.href = src;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-13 02:00:47 -07:00
|
|
|
|
$(document).on('pageinit', ".libraryPage", 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-05-10 22:11:53 -07:00
|
|
|
|
}).on('pagebeforeshow', ".libraryPage", function () {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
updateLibraryNavLinks(page);
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
if (!$('.viewMenuBar', page).length) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-05-10 22:11:53 -07:00
|
|
|
|
renderHeader(page, 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-01 19:54:33 -07:00
|
|
|
|
}
|
2014-03-29 11:20:42 -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
|
|
|
|
}
|
2014-05-01 19:54:33 -07:00
|
|
|
|
|
2013-12-27 14:10:06 -07:00
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-12-27 14:10:06 -07:00
|
|
|
|
})(window, document, jQuery);
|