/* This file is part of Natural Docs, which is Copyright © 2003-2022 Code Clear LLC. Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL). Refer to License.txt or www.naturaldocs.org for the complete details. This file may be distributed with documentation files generated by Natural Docs. Such documentation is not covered by Natural Docs' copyright and licensing, and may have its own copyright and distribution terms as decided by its author. */ "use strict";var NDMenu=new function(){this.Start=function(){this.menuSections=[];this.firstUnusedMenuSection=0;var menuContainer=document.getElementById("NDMenu");var menuTabBar=document.createElement("div");menuTabBar.id="MTabBar";menuContainer.appendChild(menuTabBar);var menuContent=document.createElement("div");menuContent.id="MContent";menuContainer.appendChild(menuContent);NDCore.LoadJavaScript("menu/tabs.js","NDMenuTabsLoader");};this.OnLocationChange=function(oldLocation,newLocation){if(newLocation.type=="Home"&&this.tabs!=undefined&&this.tabs.length==1){this.GoToOffsets([0]);return;}if(oldLocation==undefined||oldLocation.type!=newLocation.type){this.UpdateTabs(newLocation.type);}if(oldLocation==undefined||oldLocation.type!=newLocation.type||oldLocation.path!=newLocation.path){this.Build(new NDMenuHashPath(newLocation.type,newLocation.path));}};this.GoToOffsets=function(offsets){if(this.tabs!=undefined){var newSelectedTab;if(offsets.length>=1){newSelectedTab=this.tabs[offsets[0]][0];if(newSelectedTab!=this.selectedTabType){this.UpdateTabs(newSelectedTab);}}}this.Build(new NDMenuOffsetPath(offsets));};this.Build=function(path){if(path!=undefined){this.pathBeingBuilt=path;}else if(this.pathBeingBuilt==undefined){return;}this.firstUnusedMenuSection=0;var newMenuContent=document.createElement("div");newMenuContent.id="MContent";var result;if(this.tabs!=undefined){result=this.BuildEntries(newMenuContent,this.pathBeingBuilt);}else{result={completed:false};}if(!result.completed){var htmlEntry=document.createElement("div");htmlEntry.className="MLoadingNotice";newMenuContent.appendChild(htmlEntry);}var oldMenuContent=document.getElementById("MContent");var menuContainer=oldMenuContent.parentNode;menuContainer.replaceChild(newMenuContent,oldMenuContent);if(result.completed){if(result.selectedFile){if(result.selectedFile.offsetTop+result.selectedFile.offsetHeight>menuContainer.scrollTop+menuContainer.clientHeight){result.selectedFile.scrollIntoView(false);}else if(result.selectedFile.offsetTop"+""+""+tabTitle+"";htmlMenu.appendChild(htmlEntry);}}else{for(var i=0;i";if(typeof(member[1])=="object"){title+=member[1][0];}else{title+=member[1];}var targetPath=(pathSoFar.length==0?i:pathSoFar.join(",")+","+i);var htmlEntry=document.createElement("a");htmlEntry.className="MEntry MFolder Child"+(hasParentFolders?"":" TopLevel");htmlEntry.setAttribute("href","javascript:NDMenu.GoToOffsets(["+targetPath+"])");htmlEntry.innerHTML=title;htmlMenu.appendChild(htmlEntry);}}}result.completed=true;if(selectedTab!=undefined){selectedTab[6]=pathSoFar;}return result;};this.MenuSection=function(file){for(var i=0;i=this.firstUnusedMenuSection){if(i>this.firstUnusedMenuSection){this.menuSections.splice(i,1);this.menuSections.splice(this.firstUnusedMenuSection,0,section);}this.firstUnusedMenuSection++;}if(section.ready==true){return section.contents;}else{return undefined;}}}return undefined;};this.LoadMenuSection=function(file){for(var i=0;i10){for(var i=this.menuSections.length-1;i>=this.firstUnusedMenuSection&&this.menuSections.length>10;i--){if(this.menuSections[i].ready==false){break;}this.menuSections.pop();}}};this.OnTabsLoaded=function(tabs){this.tabs=tabs;NDCore.RemoveScriptElement("NDMenuTabsLoader");var tabBar=document.getElementById("MTabBar");for(var i=0;i"+tabTitle+"";tab.style.position="absolute";tab.style.visibility="hidden";tabBar.appendChild(tab);tabs[i][4]=tab.offsetWidth;tab.className="MTab Narrow";tabs[i][5]=tab.offsetWidth;if(tabs[i][0]==this.selectedTabType){tab.className+=" Selected";}}this.ResizeTabs();if(this.ShouldTabsShow()==false){tabBar.style.display="none";}for(var i=0;i=this.pathObject.path.length){return;}else if(this.currentContainer==undefined){this.pathIndex++;}else{var currentEntry=this.currentContainer[this.pathObject.path[this.pathIndex]];this.currentContainer=undefined;this.currentContainerHashPath=undefined;this.needToLoad=undefined;if(this.pathIndex==0){this.currentContainerHashPath=currentEntry[2];this.needToLoad=currentEntry[3];}else if(currentEntry[0]==2){this.currentContainerHashPath=currentEntry[2];if(typeof currentEntry[3]=="string"){this.needToLoad=currentEntry[3];}else{this.currentContainer=currentEntry[3];}}this.pathIndex++;if(this.needToLoad!=undefined){this.currentContainer=NDMenu.MenuSection(this.needToLoad);if(this.currentContainer!=undefined){this.needToLoad=undefined;}}}};this.NavigationType=function(){if(this.currentContainer==undefined){return 9;}if(this.pathIndex>=this.pathObject.path.length){return-1;}var currentEntry=this.currentContainer[this.pathObject.path[this.pathIndex]];if(this.InTabs()==false&¤tEntry[0]==1){return 3;}if(this.pathIndex==this.pathObject.path.length-1){return 2;}if(this.pathIndex+2<=this.pathObject.path.length-1){return 1;}var lookahead=this.Duplicate();lookahead.Next();if(lookahead.NavigationType()==9){this.needToLoad=lookahead.NeedToLoad();return 9;}else if(lookahead.CurrentEntry()[0]==2){return 1;}else{return 2;}};this.Duplicate=function(){var newObject=new NDMenuOffsetPathIterator(this.pathObject);newObject.pathIndex=this.pathIndex;newObject.currentContainer=this.currentContainer;newObject.needToLoad=this.needToLoad;return newObject;};this.CurrentEntry=function(){if(this.currentContainer!=undefined&&this.pathIndex