diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index 1996daca4..6630bf936 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -23,7 +23,7 @@ var navBarIsFixed = false; $(document).ready(function() { // load json file for JD doc search suggestions - $.getScript(toRoot + 'reference/jd_lists.js'); + $.getScript(toRoot + 'jd_lists_unified.js'); // load json file for Android API search suggestions $.getScript(toRoot + 'reference/lists.js'); // load json files for Google services API suggestions @@ -1539,6 +1539,13 @@ function set_item_values(toroot, $li, match) $link.attr('href',toroot + match.link); } +function set_item_values_jd(toroot, $li, match) +{ + var $link = $('a',$li); + $link.html(match.title); + $link.attr('href',toroot + match.url); +} + function new_suggestion($list) { var $li = $("
  • "); $list.append($li); @@ -1615,6 +1622,9 @@ function sync_selection_table(toroot) $(".search_filtered_wrapper.docs li").remove(); // determine google results to show + // NOTE: The order of the conditions below for the sugg.type MUST BE SPECIFIC: + // The order must match the reverse order that each section appears as a card in + // the suggestion UI... this may be only for the "develop" grouped items though. gDocsListLength = gDocsMatches.length < ROW_COUNT_DOCS ? gDocsMatches.length : ROW_COUNT_DOCS; for (i=0; iTraining:"); $(".child-card.training li").appendTo(".suggest-card.develop ul"); } + if ($(".child-card.samples li").length > 0) { + $(".child-card.samples").prepend("
  • Samples:
  • "); + $(".child-card.samples li").appendTo(".suggest-card.develop ul"); + } if ($(".suggest-card.develop li").length > 0) { $(".suggest-card.develop").show(300); @@ -1681,6 +1698,7 @@ function sync_selection_table(toroot) */ function search_changed(e, kd, toroot) { + var currentLang = getLangPref(); var search = document.getElementById("search_autocomplete"); var text = search.value.replace(/(^ +)|( +$)/g, ''); // get the ul hosting the currently selected item @@ -1794,8 +1812,8 @@ function search_changed(e, kd, toroot) } } - // if key-up event and not arrow down/up, - // read the search query and add suggestsions to gMatches + // if key-up event and not arrow down/up/left/right, + // read the search query and add suggestions to gMatches else if (!kd && (e.keyCode != 40) && (e.keyCode != 38) && (e.keyCode != 37) @@ -1841,31 +1859,35 @@ function search_changed(e, kd, toroot) - // Search for JD docs + // Search for matching JD docs if (text.length >= 3) { - for (var i=0; i= 0; j--) { + for (var j = s.keywords.length - 1; j >= 0; j--) { // it matches a tag - if (s.tags[j].toLowerCase().match(textRegex)) { + if (s.keywords[j].toLowerCase().match(textRegex)) { matched = true; s.matched_tag = j + 1; // add 1 to index position } } - // Don't consider doc title for lessons (only for class landing pages) - // ...it is not a training lesson (or is but has matched a tag) - if (!(s.type == "training" && s.link.indexOf("index.html") == -1) || matched) { + // Don't consider doc title for lessons (only for class landing pages), + // unless the lesson has a tag that already matches + if ((s.lang == currentLang) && + (!(s.type == "training" && s.url.indexOf("index.html") == -1) || matched)) { // it matches the doc title - if (s.label.toLowerCase().match(textRegex)) { + if (s.title.toLowerCase().match(textRegex)) { matched = true; s.matched_title = 1; } @@ -1875,6 +1897,231 @@ function search_changed(e, kd, toroot) matchedCountDocs++; } } + + + // Search for API Guides + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for Tools Guides + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for About docs + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for Design guides + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for Distribute guides + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for Google guides + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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().match(textRegex)) { + matched = true; + s.matched_title = 1; + } + } + if (matched) { + gDocsMatches[matchedCountDocs] = s; + matchedCountDocs++; + } + } + + + // Search for Samples + for (var i=0; i= 0; j--) { + // it matches a tag + if (s.keywords[j].toLowerCase().match(textRegex)) { + 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.t + if (s.title.toLowerCase().match(textRegex)) { + 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 f3eb4014a..a4198fb33 100644 --- a/tools/droiddoc/templates-sdk/components/masthead.cs +++ b/tools/droiddoc/templates-sdk/components/masthead.cs @@ -122,6 +122,8 @@ onkeyup="return search_changed(event, false, '')" />
    +
    +