var previouslySelectedNode = null; function constructDesktopToc() { processlist($("ul.root")); } function expandOrCollapseClickHandler(e) { // expand / collapse child var siblingList = $(this).nextAll("ul"); expandOrCollapseNode(siblingList, true); } function clickHandler(e) { var element = $(this); selectNode(element); if (element.attr("href") != "#") { var webframe = window.parent.parent; webframe.postMessage("navigate|" + element.attr('href'), "*"); } // Don't collapse the nested list when clicking on a node (do expand it if it is collapsed) if (!$(this).prev("ins").hasClass("collapse")) { // expand /collapse child var siblingList = element.nextAll("ul"); expandOrCollapseNode(siblingList, true); } if (window.UpdateNavigationButtons != undefined) { UpdateNavigationButtons(); } e.preventDefault(); return false; } function selectNode(anchor) { // highlighting if (previouslySelectedNode != null) { previouslySelectedNode.removeClass("selected"); } anchor.removeClass("hover"); anchor.addClass("selected"); previouslySelectedNode = anchor; setSelectedNode(anchor); } function expandOrCollapseNode(ul, animate) { if (ul.length) { if (!ul.hasClass("visible")) { processlist(ul); } if (animate) { ul.slideToggle(200, function () { ul.toggleClass('visible'); ul.css('display', ''); }); } else { ul.toggleClass('visible'); } // Swap icons for open and closed books var icon = ul.prev("a").children("ins"); if (icon.hasClass("icon-1")) icon.removeClass("icon-1").addClass("icon-2"); else if (icon.hasClass("icon-2")) icon.removeClass("icon-2").addClass("icon-1"); else if (icon.hasClass("icon-3")) icon.removeClass("icon-3").addClass("icon-4"); else if (icon.hasClass("icon-4")) icon.removeClass("icon-4").addClass("icon-3"); ul.prevAll("ins").toggleClass("expand collapse"); } } function processlist(ul) { if (ul.hasClass("root")) { ul.addClass("visible"); } ul.children("li").each(function (index, element) { var hasNestedList = false; $(this).children("ul").each(function (index, element) { if ($(this).children().length > 0) { hasNestedList = true; } else { // Remove any empty