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-05-31 07:30:59 -07:00
|
|
|
|
//html += '<a href="index.html" class="headerButton headerButtonLeft headerHomeButton">';
|
|
|
|
|
//html += '<img src="css/images/items/folders/home.png" />';
|
|
|
|
|
//html += '</a>';
|
2014-06-21 22:52:31 -07:00
|
|
|
|
|
|
|
|
|
html += '<button type="button" data-role="none" title="Menu" class="headerButton dashboardMenuButton barsMenuButton headerButtonLeft">';
|
2014-07-27 15:01:29 -07:00
|
|
|
|
html += '<div class="barMenuInner">';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
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-07-27 15:01:29 -07:00
|
|
|
|
html += '<div class="barMenuInner">';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
html += '<span class="icon-bar"></span>';
|
|
|
|
|
html += '</div>';
|
2014-05-21 20:35:18 -07:00
|
|
|
|
html += '</button>';
|
2014-10-25 11:32:58 -07:00
|
|
|
|
|
2014-05-28 07:21:07 -07:00
|
|
|
|
html += '<div class="libraryMenuButtonText headerButton"><span>MEDIA</span><span class="mediaBrowserAccent">BROWSER</span></div>';
|
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>';
|
|
|
|
|
|
|
|
|
|
html += '<button onclick="Search.showSearchPanel($.mobile.activePage);" type="button" data-role="none" class="headerButton headerButtonRight headerSearchButton"><img src="css/images/headersearch.png" /></button>';
|
|
|
|
|
} 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-06-23 09:05:19 -07:00
|
|
|
|
var userButtonHeight = 21;
|
2014-10-25 11:32:58 -07:00
|
|
|
|
if (user.imageUrl) {
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
var url = user.imageUrl;
|
|
|
|
|
|
|
|
|
|
if (user.supportsImageParams) {
|
|
|
|
|
url += "height=" + userButtonHeight;
|
|
|
|
|
}
|
2013-12-27 14:10:06 -07:00
|
|
|
|
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '<img src="' + url + '" style="height:' + userButtonHeight + 'px;" />';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
} else {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '<img src="css/images/currentuserdefaultwhite.png" style="height:' + userButtonHeight + 'px;" />';
|
2013-12-27 14:10:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
if (user.canManageServer) {
|
2014-06-21 22:52:31 -07:00
|
|
|
|
html += '<a href="dashboard.html" class="headerButton headerButtonRight"><img src="css/images/items/folders/settings.png" /></a>';
|
|
|
|
|
}
|
|
|
|
|
|
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="adminMenuOptions">';
|
|
|
|
|
html += '<div class="libraryMenuDivider"></div>';
|
2014-07-02 11:34:08 -07:00
|
|
|
|
//html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder dashboardViewMenu" data-itemid="dashboard" href="dashboard.html">'+Globalize.translate('ButtonDashboard')+'</a>';
|
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder editorViewMenu" data-itemid="editor" href="edititemmetadata.html">' + Globalize.translate('ButtonMetadataManager') + '</a>';
|
|
|
|
|
html += '<a class="viewMenuLink viewMenuTextLink lnkMediaFolder reportsViewMenu" data-itemid="reports" href="reports.html">' + Globalize.translate('ButtonReports') + '</a>';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
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-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();
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
var viewMenuCssClass = (i.CollectionType || 'general') + 'ViewMenu';
|
|
|
|
|
|
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') {
|
|
|
|
|
viewMenuCssClass = 'channelsViewMenu';
|
|
|
|
|
}
|
2014-06-07 12:46:24 -07:00
|
|
|
|
|
2014-09-04 20:48:53 -07:00
|
|
|
|
return '<a data-itemid="' + itemId + '" class="lnkMediaFolder viewMenuLink viewMenuTextLink ' + viewMenuCssClass + '" href="' + getItemHref(i, i.CollectionType) + '">' + i.Name + '</a>';
|
2014-05-14 13:20:19 -07:00
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
2014-05-21 20:35:18 -07:00
|
|
|
|
var elem = $('.libraryMenuOptions').html(html);
|
|
|
|
|
|
|
|
|
|
$('.viewMenuTextLink', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
$('.libraryMenuButtonText').html(this.innerHTML);
|
|
|
|
|
|
|
|
|
|
});
|
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-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-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">';
|
|
|
|
|
|
2014-05-09 12:43:06 -07:00
|
|
|
|
html += '<div style="margin: 0 -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';
|
|
|
|
|
|
|
|
|
|
html += '<a class="lnkMediaFolder viewMenuLink viewMenuTextLink homeViewMenu" href="' + homeHref + '">' + Globalize.translate('ButtonHome') + '</a>';
|
|
|
|
|
|
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-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() || '';
|
|
|
|
|
|
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');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
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')) {
|
2014-09-15 20:33:30 -07:00
|
|
|
|
$('.libraryMenuButtonText').html('<span class="logoLibraryMenuButtonText">MEDIA</span><span class="logoLibraryMenuButtonText mediaBrowserAccent">BROWSER</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) {
|
|
|
|
|
$(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage);
|
|
|
|
|
}
|
|
|
|
|
|
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-10-25 11:32:58 -07:00
|
|
|
|
$(ConnectionManager).on('apiclientcreated', function (e, apiClient) {
|
|
|
|
|
|
|
|
|
|
initializeApiClient(apiClient);
|
|
|
|
|
});
|
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
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
};
|