mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-19 03:48:18 -07:00
153 lines
4.8 KiB
JavaScript
153 lines
4.8 KiB
JavaScript
(function () {
|
|
|
|
var initComplete = false;
|
|
var ignoreNextSelection = false;
|
|
|
|
function onTabSelected(name) {
|
|
|
|
if (ignoreNextSelection) {
|
|
ignoreNextSelection = false;
|
|
return;
|
|
}
|
|
|
|
switch (name) {
|
|
case 'Favorites':
|
|
Dashboard.navigate('favorites.html');
|
|
break;
|
|
case 'Library':
|
|
Dashboard.navigate('index.html');
|
|
break;
|
|
case 'Search':
|
|
Dashboard.navigate('search.html');
|
|
break;
|
|
case 'NowPlaying':
|
|
Dashboard.navigate('nowplaying.html');
|
|
break;
|
|
case 'Sync':
|
|
Dashboard.navigate('mysync.html');
|
|
break;
|
|
case 'Settings':
|
|
Dashboard.navigate('mypreferencesmenu.html?userId=' + Dashboard.getCurrentUserId());
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
function init() {
|
|
|
|
// Use system defined items for this demo
|
|
// If an image is passed, label is not used
|
|
|
|
/**
|
|
* Create a new tab bar item for use on a previously created tab bar. Use ::showTabBarItems to show the new item on the tab bar.
|
|
*
|
|
* If the supplied image name is one of the labels listed below, then this method will construct a tab button
|
|
* using the standard system buttons. Note that if you use one of the system images, that the \c title you supply will be ignored.
|
|
* - <b>Tab Buttons</b>
|
|
* - tabButton:More
|
|
* - tabButton:Favorites
|
|
* - tabButton:Featured
|
|
* - tabButton:TopRated
|
|
* - tabButton:Recents
|
|
* - tabButton:Contacts
|
|
* - tabButton:History
|
|
* - tabButton:Bookmarks
|
|
* - tabButton:Search
|
|
* - tabButton:Downloads
|
|
* - tabButton:MostRecent
|
|
* - tabButton:MostViewed
|
|
* @brief create a tab bar item
|
|
* @param arguments Parameters used to create the tab bar
|
|
* -# \c name internal name to refer to this tab by
|
|
* -# \c title title text to show on the tab, or null if no text should be shown
|
|
* -# \c image image filename or internal identifier to show, or null if now image should be shown
|
|
* -# \c tag unique number to be used as an internal reference to this button
|
|
* @param options Options for customizing the individual tab item
|
|
* - \c badge value to display in the optional circular badge on the item; if nil or unspecified, the badge will be hidden
|
|
*/
|
|
|
|
var items = [
|
|
{ name: 'Library', label: Globalize.translate('ButtonLibrary'), image: 'tabbar/tab-library.png', options: {} },
|
|
{ name: 'Favorites', label: Globalize.translate('ButtonFavorites'), image: 'tabButton:Favorites', options: {} },
|
|
{ name: 'Search', label: Globalize.translate('ButtonSearch'), image: 'tabButton:Search', options: {} },
|
|
{ name: 'NowPlaying', label: Globalize.translate('ButtonNowPlaying'), image: 'tabbar/tab-nowplaying.png', options: {} },
|
|
{ name: 'Sync', label: Globalize.translate('ButtonSync'), image: 'tabbar/tab-sync.png', options: {} },
|
|
{ name: 'Settings', label: Globalize.translate('ButtonSettings'), image: 'tabbar/tab-settings.png', options: {} }
|
|
];
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
var item = items[i];
|
|
TabBar.createItem(item.name, item.label, item.image, onTabSelected, item.options);
|
|
};
|
|
|
|
TabBar.showItems();
|
|
initComplete = true;
|
|
showTabs();
|
|
|
|
ignoreNextSelection = true;
|
|
TabBar.selectItem('Library');
|
|
}
|
|
|
|
function showTabs() {
|
|
|
|
if (!initComplete) {
|
|
return;
|
|
}
|
|
|
|
TabBar.show();
|
|
}
|
|
|
|
var isFirstHide = true;
|
|
function hideTabs() {
|
|
|
|
if (!initComplete) {
|
|
return;
|
|
}
|
|
|
|
var hide = function () { TabBar.hide(); };
|
|
if (isFirstHide) {
|
|
isFirstHide = false;
|
|
setTimeout(hide, 1000);
|
|
} else {
|
|
hide();
|
|
}
|
|
}
|
|
|
|
Dashboard.ready(function () {
|
|
|
|
init();
|
|
|
|
Events.on(ConnectionManager, 'localusersignedin', showTabs);
|
|
Events.on(ConnectionManager, 'localusersignedout', hideTabs);
|
|
Events.on(MediaController, 'beforeplaybackstart', onPlaybackStart);
|
|
Events.on(MediaController, 'playbackstop', onPlaybackStop);
|
|
});
|
|
|
|
pageClassOn('pageshow', "page", function () {
|
|
|
|
var page = this;
|
|
|
|
if (page.classList.contains('libraryPage')) {
|
|
showTabs();
|
|
}
|
|
else {
|
|
hideTabs();
|
|
}
|
|
});
|
|
|
|
function onPlaybackStart(e, state, player) {
|
|
|
|
if (state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video' && player.isLocalPlayer) {
|
|
hideTabs();
|
|
}
|
|
}
|
|
|
|
function onPlaybackStop(e, state, player) {
|
|
|
|
if (state.NowPlayingItem && state.NowPlayingItem.MediaType == 'Video' && player.isLocalPlayer) {
|
|
showTabs();
|
|
}
|
|
}
|
|
|
|
})(); |