jellyfin-web/dashboard-ui/components/maintabsmanager.js

1 line
2.4 KiB
JavaScript
Raw Normal View History

2017-06-06 21:56:15 -07:00
define(["appFooter-shared","emby-tabs","emby-button"],function(appFooter){"use strict";function enableTabsInFooter(){return!1}function ensureElements(enableInFooter){enableInFooter&&(footerTabsContainer||(footerTabsContainer=document.createElement("div"),footerTabsContainer.classList.add("footerTabs"),footerTabsContainer.classList.add("sectionTabs"),footerTabsContainer.classList.add("hide"),appFooter.add(footerTabsContainer))),headerTabsContainer||(headerTabsContainer=queryScope.querySelector(".headerTabs"))}function setTabs(view,selectedIndex,builder){var enableInFooter=enableTabsInFooter();if(!view)return void(tabOwnerView&&(headerTabsContainer||(headerTabsContainer=queryScope.querySelector(".headerTabs")),ensureElements(enableInFooter),document.body.classList.remove("withSectionTabs"),headerTabsContainer.innerHTML="",headerTabsContainer.classList.add("hide"),footerTabsContainer&&(footerTabsContainer.innerHTML="",footerTabsContainer.classList.add("hide")),tabOwnerView=null));ensureElements(enableInFooter);var tabsContainerElem=enableInFooter?footerTabsContainer:headerTabsContainer;if(tabOwnerView||tabsContainerElem.classList.remove("hide"),tabOwnerView!==view){var index=0,indexAttribute=null==selectedIndex?"":' data-index="'+selectedIndex+'"',tabsHtml='<div is="emby-tabs"'+indexAttribute+' class="tabs-viewmenubar"><div class="emby-tabs-slider" style="white-space:nowrap;">'+builder().map(function(t){var tabClass="emby-tab-button";t.enabled===!1&&(tabClass+=" hide");var tabHtml;return tabHtml=t.href?'<button onclick="Dashboard.navigate(this.getAttribute(\'data-href\'));" type="button" data-href="'+t.href+'" is="emby-button" class="'+tabClass+'" data-index="'+index+'"><div class="emby-button-foreground">'+t.name+"</div></button>":'<button type="button" is="emby-button" class="'+tabClass+'" data-index="'+index+'"><div class="emby-button-foreground">'+t.name+"</div></button>",index++,tabHtml}).join("")+"</div></div>";return tabsContainerElem.innerHTML=tabsHtml,document.body.classList.add("withSectionTabs"),tabOwnerView=view,!0}return tabsContainerElem.querySelector('[is="emby-tabs"]').selectedIndex(selectedIndex),tabOwnerView=view,!1}function getTabsElement(){return document.querySelector(".tabs-viewmenubar")}var tabOwnerView,footerTabsContainer,headerTabsContainer,queryScope=document.querySelector(".skinHeader");return{setTabs:setTabs,getTabsElement:getTabsElement}});