From ad08f07cf2ece7a3711eafa382cf741134c69083 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Tue, 20 Aug 2013 16:49:57 -0700 Subject: [PATCH] new version of script to build sidenav lists dynamically. This is currently used only by the samples nav, but we'll later update to handle the Google reference nav as well Change-Id: I907ea8cb096148ba50808623ed872c8defc9a135 --- .../droiddoc/templates-sdk/assets/css/default.css | 2 + tools/droiddoc/templates-sdk/assets/js/docs.js | 115 ++++++++++++++++----- 2 files changed, 89 insertions(+), 28 deletions(-) diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css index d5a940d43..3f192865d 100644 --- a/tools/droiddoc/templates-sdk/assets/css/default.css +++ b/tools/droiddoc/templates-sdk/assets/css/default.css @@ -305,6 +305,8 @@ video.with-shadow { position: absolute; top: 0; right: 0; } + #nav .nav-section-header.empty { + padding:0; } #nav .nav-section-header.empty:after { display: none; } /* nested nav headers */ diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index 86b7aa1d2..2e0a6728a 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -353,35 +353,9 @@ false; // navigate across topic boundaries only in design docs $('.jd-descr').append($olClasses); } - - - // Set up expand/collapse behavior - $('#nav li.nav-section .nav-section-header').click(function() { - var section = $(this).closest('li.nav-section'); - if (section.hasClass('expanded')) { - /* hide me */ - // if (section.hasClass('selected') || section.find('li').hasClass('selected')) { - // /* but not if myself or my descendents are selected */ - // return; - // } - section.children('ul').slideUp(250, function() { - section.closest('li').removeClass('expanded'); - resizeNav(); - }); - } else { - /* show me */ - // first hide all other siblings - var $others = $('li.nav-section.expanded', $(this).closest('ul')); - $others.removeClass('expanded').children('ul').slideUp(250); + initExpandableNavItems("#nav"); - // now expand me - section.closest('li').addClass('expanded'); - section.children('ul').slideDown(250, function() { - resizeNav(); - }); - } - }); $(".scroll-pane").scroll(function(event) { event.preventDefault(); @@ -586,6 +560,30 @@ false; // navigate across topic boundaries only in design docs // END of the onload event +function initExpandableNavItems(rootTag) { + $(rootTag + ' li.nav-section .nav-section-header').click(function() { + var section = $(this).closest('li.nav-section'); + if (section.hasClass('expanded')) { + /* hide me */ + section.children('ul').slideUp(250, function() { + section.closest('li').removeClass('expanded'); + resizeNav(); + }); + } else { + /* show me */ + // first hide all other siblings + var $others = $('li.nav-section.expanded', $(this).closest('ul')); + $others.removeClass('expanded').children('ul').slideUp(250); + + // now expand me + section.closest('li').addClass('expanded'); + section.children('ul').slideDown(250, function() { + resizeNav(); + }); + } + }); +} + function highlightSidenav() { // select current page in sidenav and header, and set up prev/next links if they exist var $selNavLink = $('#nav').find('a[href="' + mPagePath + '"]'); @@ -2664,6 +2662,67 @@ function get_google_node(me, mom) node_data[2], node_data[3]); } } + + + + + + +/****** NEW version of script to build google and sample navs dynamically ******/ +// TODO: update Google reference docs to tolerate this new implementation + +function init_google_navtree2(navtree_id, data) +{ + var $containerUl = $("#"+navtree_id); + var linkText; + for (var i in data) { + var node_data = data[i]; + $containerUl.append(new_google_node2(node_data)); + } + + initExpandableNavItems("#"+navtree_id); +} + +function new_google_node2(node_data) +{ + var linkText = node_data[0]; + if(linkText.match("^"+"com.google.android")=="com.google.android"){ + linkText = linkText.substr(19, linkText.length); + } + var $li = $('
  • '); + var $a; + if (node_data[1] != null) { + $a = $('' + linkText + ''); + } else { + $a = $('' + linkText + '/'); + } + var $childUl = $('