jellyfin-web/dashboard-ui/scripts/librarymenu.js

1 line
24 KiB
JavaScript
Raw Normal View History

define(["layoutManager","viewManager","libraryBrowser","embyRouter","playbackManager","browser","paper-icon-button-light","material-icons","scrollStyles"],function(layoutManager,viewManager,libraryBrowser,embyRouter,playbackManager,browser){"use strict";function renderHeader(){var html="";html+='<div class="primaryIcons">';var backIcon=browser.safari?"chevron_left":"&#xE5C4;";html+='<button type="button" is="paper-icon-button-light" class="headerButton headerButtonLeft headerBackButton hide"><i class="md-icon">'+backIcon+"</i></button>",html+='<button type="button" is="paper-icon-button-light" class="headerButton mainDrawerButton barsMenuButton headerButtonLeft hide"><i class="md-icon">menu</i></button>',html+='<button type="button" is="paper-icon-button-light" class="headerButton headerAppsButton barsMenuButton headerButtonLeft"><i class="md-icon">home</i></button>',html+='<h3 class="libraryMenuButtonText headerButton">'+Globalize.translate("ButtonHome")+"</h3>",html+='<div class="viewMenuSecondary">',html+='<span class="headerSelectedPlayer"></span>',html+='<button is="paper-icon-button-light" class="btnCast headerButton-btnCast headerButton headerButtonRight hide autoSize"><i class="md-icon">cast</i></button>',html+='<button type="button" is="paper-icon-button-light" class="headerButton headerButtonRight headerSearchButton hide autoSize"><i class="md-icon">search</i></button>',html+='<button is="paper-icon-button-light" class="headerButton headerButtonRight headerVoiceButton hide autoSize"><i class="md-icon">mic</i></button>',html+='<button is="paper-icon-button-light" class="headerButton headerButtonRight btnNotifications"><div class="btnNotificationsInner">0</div></button>',html+='<button is="paper-icon-button-light" class="headerButton headerButtonRight headerUserButton autoSize"><i class="md-icon">person</i></button>',browser.mobile||(html+='<button is="paper-icon-button-light" class="headerButton headerButtonRight dashboardEntryHeaderButton autoSize" onclick="return LibraryMenu.onSettingsClicked(event);"><i class="md-icon">settings</i></button>'),html+="</div>",html+="</div>",html+='<div class="viewMenuBarTabs">',html+="</div>";var viewMenuBar=document.createElement("div");viewMenuBar.classList.add("viewMenuBar"),viewMenuBar.innerHTML=html,document.querySelector(".skinHeader").appendChild(viewMenuBar),lazyLoadViewMenuBarImages(),bindMenuEvents()}function lazyLoadViewMenuBarImages(){require(["imageLoader"],function(imageLoader){imageLoader.lazyChildren(document.querySelector(".viewMenuBar"))})}function onBackClick(){embyRouter.back()}function updateUserInHeader(user){var header=document.querySelector(".viewMenuBar");if(header){var hasImage,headerUserButton=header.querySelector(".headerUserButton");if(user&&user.name&&user.imageUrl){var userButtonHeight=26,url=user.imageUrl;user.supportsImageParams&&(url+="&height="+Math.round(userButtonHeight*Math.max(window.devicePixelRatio||1,2))),headerUserButton&&(updateHeaderUserButton(headerUserButton,url),hasImage=!0)}headerUserButton&&!hasImage&&updateHeaderUserButton(headerUserButton,null),user&&updateLocalUser(user.localUser),requiresUserRefresh=!1}}function updateHeaderUserButton(headerUserButton,src){src?(headerUserButton.classList.add("headerUserButtonRound"),headerUserButton.classList.remove("autoSize"),headerUserButton.innerHTML='<img src="'+src+'" />'):(headerUserButton.classList.remove("headerUserButtonRound"),headerUserButton.classList.add("autoSize"),headerUserButton.innerHTML='<i class="md-icon">person</i>')}function updateLocalUser(user){var header=document.querySelector(".viewMenuBar"),headerSearchButton=header.querySelector(".headerSearchButton"),btnCast=header.querySelector(".btnCast"),dashboardEntryHeaderButton=header.querySelector(".dashboardEntryHeaderButton");user?(btnCast.classList.remove("hide"),headerSearchButton&&headerSearchButton.classList.remove("hide"),dashboardEntryHeaderButton&&(user.Policy.IsAdministrator?dashboardEntryHeaderButton.classList.remove("hide"):dashboardEntryHeaderButton.classList.add("hide")),require(["apphost"],function(apphost