From 8612002d89f5158a9bc4b049a1572e4b316dd6b6 Mon Sep 17 00:00:00 2001 From: Dirk Dougherty Date: Tue, 9 Feb 2016 18:00:05 -0800 Subject: [PATCH] Add Preview to templates-sdk develop nav and global nav in templates-sdk-dev. Remove dependence on -includePreview. Change-Id: I1456c3c94522f58c7d1c899ff96dd95cdc6ada7c --- .../templates-sdk-dev/assets/js/docs.js | 2 ++ .../templates-sdk-dev/components/masthead.cs | 3 ++ .../templates-sdk-dev/customizations.cs | 2 ++ tools/droiddoc/templates-sdk-dev/docpage.cs | 1 + .../droiddoc/templates-sdk/assets/js/docs.js | 33 +++++++++++++++++++ .../templates-sdk/components/masthead.cs | 4 ++- .../droiddoc/templates-sdk/customizations.cs | 19 +++++++++++ tools/droiddoc/templates-sdk/docpage.cs | 3 +- 8 files changed, 65 insertions(+), 2 deletions(-) diff --git a/tools/droiddoc/templates-sdk-dev/assets/js/docs.js b/tools/droiddoc/templates-sdk-dev/assets/js/docs.js index c634a3b943..6c19b4db7d 100644 --- a/tools/droiddoc/templates-sdk-dev/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk-dev/assets/js/docs.js @@ -4447,6 +4447,8 @@ $.fn.scrollIntoView = function(target) { } else { selected = parentNavEl.removeClass('has-subnav').addClass('selected'); } + } else if (body.hasClass('preview')) { + selected = navEl.find('> li.preview > a').addClass('selected'); } return $(selected); }; diff --git a/tools/droiddoc/templates-sdk-dev/components/masthead.cs b/tools/droiddoc/templates-sdk-dev/components/masthead.cs index d857ffb9ab..b105b52912 100644 --- a/tools/droiddoc/templates-sdk-dev/components/masthead.cs +++ b/tools/droiddoc/templates-sdk-dev/components/masthead.cs @@ -261,6 +261,9 @@ +
  • + Preview +
  • diff --git a/tools/droiddoc/templates-sdk-dev/customizations.cs b/tools/droiddoc/templates-sdk-dev/customizations.cs index d36e79feb9..15e8490f1e 100644 --- a/tools/droiddoc/templates-sdk-dev/customizations.cs +++ b/tools/droiddoc/templates-sdk-dev/customizations.cs @@ -196,6 +196,8 @@ elif:samples ?> + + diff --git a/tools/droiddoc/templates-sdk-dev/docpage.cs b/tools/droiddoc/templates-sdk-dev/docpage.cs index 7f53e6f7e7..ab5fb402c9 100644 --- a/tools/droiddoc/templates-sdk-dev/docpage.cs +++ b/tools/droiddoc/templates-sdk-dev/docpage.cs @@ -36,6 +36,7 @@ if:wear ?> wear tv auto preview trainingcourse" itemscope itemtype="http://schema.org/Article"> a").addClass("selected"); } else if ($("body").hasClass("samples")) { subNavEl.find("li.samples > a").addClass("selected"); + } else if ($("body").hasClass("preview")) { + subNavEl.find("li.preview > a").addClass("selected"); } else { parentNavEl.removeClass('has-subnav').addClass("selected"); } @@ -2359,6 +2361,37 @@ function search_changed(e, kd, toroot) } } + // Search for Preview Guides + for (var i=0; i<_RESOURCES.length; i++) { + // current search comparison, with counters for tag and title, + // used later to improve ranking + var s = _RESOURCES[i]; + s.matched_tag = 0; + s.matched_title = 0; + var matched = false; + + // Check if query matches any tags; work backwards toward 1 to assist ranking + for (var j = s.keywords.length - 1; j >= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().indexOf(queryStr) == 0) { + matched = true; + s.matched_tag = j + 1; // add 1 to index position + } + } + // Check if query matches the doc title, but only for current language + if (s.lang == currentLang) { + // if query matches the doc title + if (s.title.toLowerCase().indexOf(queryStr) == 0) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + // Rank/sort all the matched pages rank_autocomplete_doc_results(text, gDocsMatches); } diff --git a/tools/droiddoc/templates-sdk/components/masthead.cs b/tools/droiddoc/templates-sdk/components/masthead.cs index fc39cf7dfd..04fee654bd 100644 --- a/tools/droiddoc/templates-sdk/components/masthead.cs +++ b/tools/droiddoc/templates-sdk/components/masthead.cs @@ -228,8 +228,10 @@
  • Samples +
  • +
  • + Preview
  • -
  • diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs index cf9534e0e3..16469ac735 100644 --- a/tools/droiddoc/templates-sdk/customizations.cs +++ b/tools/droiddoc/templates-sdk/customizations.cs @@ -79,6 +79,23 @@ def:googleplay_nav() ?> +
    +
    + +
    +
    + +
    +
    +
    + +
    @@ -533,6 +550,8 @@ def:custom_left_nav() ?> reference downloadsdevelopdevelop guide samples previewdistribute googleplay essentials