docs: switch templates to dynamic tab highlighting; prep for devsite template migration
Change-Id: I5785c63603d8da5dfa1118fe28a3106aa20835a6
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 394dbe4..ded3eaf 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -112,7 +112,7 @@
if (pagePath.indexOf("/intl/") == 0) {
pagePath = pagePath.substr(pagePath.indexOf("/",6)); // start after intl/ to get last /
}
-
+
if (pagePath.indexOf(SITE_ROOT) == 0) {
if (pagePath == '' || pagePath.charAt(pagePath.length - 1) == '/') {
pagePath += 'index.html';
@@ -138,12 +138,47 @@
// Otherwise the page path is already an absolute URL
}
- // select current page in sidenav and set up prev/next links if they exist
+ // Highlight the header tabs...
+ // highlight Design tab
+ if ($("body").hasClass("design")) {
+ $("#header li.design a").addClass("selected");
+
+ // highlight Develop tab
+ } else if ($("body").hasClass("develop") || $("body").hasClass("google")) {
+ $("#header li.develop a").addClass("selected");
+
+ // In Develop docs, also highlight appropriate sub-tab
+ var rootDir = pagePath.substring(1,pagePath.indexOf('/', 1));
+ if (rootDir == "training") {
+ $("#nav-x li.training a").addClass("selected");
+ } else if (rootDir == "guide") {
+ $("#nav-x li.guide a").addClass("selected");
+ } else if (rootDir == "reference") {
+ // If the root is reference, but page is also part of Google Services, select Google
+ if ($("body").hasClass("google")) {
+ $("#nav-x li.google a").addClass("selected");
+ } else {
+ $("#nav-x li.reference a").addClass("selected");
+ }
+ } else if ((rootDir == "tools") || (rootDir == "sdk")) {
+ $("#nav-x li.tools a").addClass("selected");
+ } else if ($("body").hasClass("google")) {
+ $("#nav-x li.google a").addClass("selected");
+ }
+
+ // highlight Distribute tab
+ } else if ($("body").hasClass("distribute")) {
+ $("#header li.distribute a").addClass("selected");
+ }
+
+
+ // select current page in sidenav and header, and set up prev/next links if they exist
var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
var $selListItem;
if ($selNavLink.length) {
- $selListItem = $selNavLink.closest('li');
+ // Find this page's <li> in sidenav and set selected
+ $selListItem = $selNavLink.closest('li');
$selListItem.addClass('selected');
// Traverse up the tree and expand all parent nav-sections
@@ -151,7 +186,6 @@
$(this).addClass('expanded');
$(this).children('ul').show();
});
-
// set up prev links
var $prevLink = [];
diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs
index fc16161..9f19906 100644
--- a/tools/droiddoc/templates-sdk/components/masthead.cs
+++ b/tools/droiddoc/templates-sdk/components/masthead.cs
@@ -13,8 +13,7 @@
</div>
<ul class="nav-x col-9">
<li class="design">
- <a href="<?cs var:toroot ?>design/index.html" <?cs
- if:design ?>class="selected"<?cs /if ?>
+ <a href="<?cs var:toroot ?>design/index.html"
zh-TW-lang="設計"
zh-CN-lang="设计"
ru-lang="Проектирование"
@@ -22,8 +21,7 @@
ja-lang="設計"
es-lang="Diseñar"
>Design</a></li>
- <li class="develop"><a href="<?cs var:toroot ?>develop/index.html" <?cs
- if:training || guide || reference || tools || develop || google ?>class="selected"<?cs /if ?>
+ <li class="develop"><a href="<?cs var:toroot ?>develop/index.html"
zh-TW-lang="開發"
zh-CN-lang="开发"
ru-lang="Разработка"
@@ -31,8 +29,7 @@
ja-lang="開発"
es-lang="Desarrollar"
>Develop</a></li>
- <li class="distribute last"><a href="<?cs var:toroot ?>distribute/index.html" <?cs
- if:distribute ?>class="selected"<?cs /if ?>
+ <li class="distribute last"><a href="<?cs var:toroot ?>distribute/index.html"
zh-TW-lang="發佈"
zh-CN-lang="分发"
ru-lang="Распространение"
@@ -203,8 +200,7 @@
<div id="nav-x">
<div class="wrap">
<ul class="nav-x col-9 develop" style="width:100%">
- <li><a href="<?cs var:toroot ?>training/index.html" <?cs
- if:training ?>class="selected"<?cs /if ?>
+ <li class="training"><a href="<?cs var:toroot ?>training/index.html"
zh-TW-lang="訓練課程"
zh-CN-lang="培训"
ru-lang="Курсы"
@@ -212,8 +208,7 @@
ja-lang="トレーニング"
es-lang="Capacitación"
>Training</a></li>
- <li><a href="<?cs var:toroot ?>guide/components/index.html" <?cs
- if:guide ?>class="selected"<?cs /if ?>
+ <li class="guide"><a href="<?cs var:toroot ?>guide/components/index.html"
zh-TW-lang="API 指南"
zh-CN-lang="API 指南"
ru-lang="Руководства по API"
@@ -221,8 +216,7 @@
ja-lang="API ガイド"
es-lang="Guías de la API"
>API Guides</a></li>
- <li><a href="<?cs var:toroot ?>reference/packages.html" <?cs
- if:reference && !(reference.gcm || reference.gms) ?>class="selected"<?cs /if ?>
+ <li class="reference"><a href="<?cs var:toroot ?>reference/packages.html"
zh-TW-lang="參考資源"
zh-CN-lang="参考"
ru-lang="Справочник"
@@ -230,8 +224,7 @@
ja-lang="リファレンス"
es-lang="Referencia"
>Reference</a></li>
- <li><a href="<?cs var:toroot ?>tools/index.html" <?cs
- if:tools ?>class="selected"<?cs /if ?>
+ <li class="tools"><a href="<?cs var:toroot ?>tools/index.html"
zh-TW-lang="相關工具"
zh-CN-lang="工具"
ru-lang="Инструменты"
@@ -239,8 +232,7 @@
ja-lang="ツール"
es-lang="Herramientas"
>Tools</a></li>
- <li><a href="<?cs var:toroot ?>google/index.html" <?cs
- if:google || reference.gcm || reference.gms?>class="selected"<?cs /if ?>
+ <li class="google"><a href="<?cs var:toroot ?>google/index.html"
>Google Services</a>
</li>
</ul>