jellyfin-web/dashboard-ui/components/maintabsmanager.js
2017-03-21 13:31:40 -04:00

1 line
1.5 KiB
JavaScript

define(["emby-tabs","emby-button"],function(){"use strict";function setTabs(type,selectedIndex,builder){var viewMenuBarTabs;if(!type)return void(tabType&&(document.body.classList.remove("withTallToolbar"),viewMenuBarTabs=queryScope.querySelector(".viewMenuBarTabs"),viewMenuBarTabs.innerHTML="",viewMenuBarTabs.classList.add("hide"),tabType=null));if(viewMenuBarTabs=queryScope.querySelector(".viewMenuBarTabs"),tabType||viewMenuBarTabs.classList.remove("hide"),tabType!=type){var index=0,indexAttribute=null==selectedIndex?"":' data-index="'+selectedIndex+'"';return viewMenuBarTabs.innerHTML='<div is="emby-tabs"'+indexAttribute+' class="tabs-viewmenubar"><div class="emby-tabs-slider" style="white-space:nowrap;">'+builder().map(function(t){var tabHtml,tabClass="emby-tab-button";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>",document.body.classList.add("withTallToolbar"),tabType=type,!0}return viewMenuBarTabs.querySelector('[is="emby-tabs"]').selectedIndex(selectedIndex),tabType=type,!1}function getTabsElement(){return document.querySelector(".tabs-viewmenubar")}var tabType,queryScope=document.querySelector(".skinHeader");return{setTabs:setTabs,getTabsElement:getTabsElement}});