diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css index f272241578..9f4edc6954 100644 --- a/tools/droiddoc/templates-sdk/assets/css/default.css +++ b/tools/droiddoc/templates-sdk/assets/css/default.css @@ -3184,18 +3184,6 @@ ul#search_filtered { padding: 0; } - -#search_filtered li{ - line-height:1.5em; - margin: 0 0 2px; - padding: 0; -} - -#search_filtered li a { - padding:0 5px; - color:#222 !important; -} - #search_filtered .jd-selected { background-color: #33B5E5; cursor:pointer; @@ -3209,15 +3197,31 @@ ul#search_filtered { display: none; } -.jd-autocomplete { - padding-left: 6px; - padding-right: 6px; - padding-top: 1px; - padding-bottom: 1px; +#search_filtered li.jd-autocomplete { font-size: 0.81em; border: none; - margin: 0; - line-height: 1.05em; + margin: 0 0 2px; + padding: 0; + line-height:1.5em; +} + +#search_filtered li a { + padding:0 5px; + color:#222 !important; +} + +#search_filtered li.header { + color:#aaa; + font-weight:bold; + font-size: 0.81em; + border: none; + margin: 8px 0 2px; + padding:1px 5px; + line-height:1.5em; +} + +#search_filtered li.header:first-child { + margin: 0 0 2px; } .show-item { diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index ded3eaf045..5a2f7c3857 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -9,12 +9,35 @@ var isMobile = false; // true if mobile, so we can adjust some layout var basePath = getBaseUri(location.pathname); var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1)); +var GOOGLE_DATA; // combined data for google service apis, used for search suggest /****** ON LOAD SET UP STUFF *********/ var navBarIsFixed = false; $(document).ready(function() { + + // load json file for Android API search suggestions + $.getScript(toRoot + 'reference/lists.js'); + // load json files for Google services API suggestions + $.getScript(toRoot + 'reference/gcm-lists.js', function(data, textStatus, jqxhr) { + // once the GCM json (GCM_DATA) is loaded, load the GMS json (GMS_DATA) and merge the data + if(jqxhr.status === 200) { + $.getScript(toRoot + 'reference/gms-lists.js', function(data, textStatus, jqxhr) { + if(jqxhr.status === 200) { + // combine GCM and GMS data + GOOGLE_DATA = GMS_DATA; + var start = GOOGLE_DATA.length; + for (var i=0; i"); + $list.append($li); + + $li.mousedown(function() { + window.location = this.firstChild.getAttribute("href"); + }); + $li.mouseover(function() { + $('#search_filtered li').removeClass('jd-selected'); + $(this).addClass('jd-selected'); + gSelectedIndex = $('#search_filtered li').index(this); + }); + $li.append(''); + $li.attr('class','show-item'); + return $li; +} + function sync_selection_table(toroot) { var $list = $("#search_filtered"); var $li; //list item jquery object var i; //list item iterator - gSelectedID = -1; - - //initialize the table; draw it for the first time (but not visible). - if (!gInitialized) { - for (i=0; i"); - $list.append($li); - - $li.mousedown(function() { - window.location = this.firstChild.getAttribute("href"); - }); - $li.mouseover(function() { - $('#search_filtered li').removeClass('jd-selected'); - $(this).addClass('jd-selected'); - gSelectedIndex = $('#search_filtered li').index(this); - }); - $li.append(''); - } - gInitialized = true; - } + // reset the list + $("li",$list).remove(); + //if we have results, make the table visible and initialize result info - if (gMatches.length > 0) { + if ((gMatches.length > 0) || (gGoogleMatches.length > 0)) { + // reveal suggestion list $('#search_filtered_div').removeClass('no-display'); - var N = gMatches.length < ROW_COUNT ? gMatches.length : ROW_COUNT; - for (i=0; i 0) { + + // determine android results to show + gListLength = gMatches.length < ROW_COUNT_FRAMEWORK ? + gMatches.length : ROW_COUNT_FRAMEWORK; + for (i=0; i 0) { + // show header for list + $list.append("
  • in Google Services:
  • "); + + // determine google results to show + gGoogleListLength = gGoogleMatches.length < ROW_COUNT_GOOGLE ? gGoogleMatches.length : ROW_COUNT_GOOGLE; + for (i=0; i ROW_COUNT) { - li = list.rows[ROW_COUNT]; - li.className = "show-item"; - c1 = li.cells[0]; - c1.innerHTML = "plus " + (gMatches.length-ROW_COUNT) + " more"; - } else { - list.rows[ROW_COUNT].className = "hide-item"; - }*/ + //if we have no results, hide the table } else { $('#search_filtered_div').addClass('no-display'); @@ -1580,8 +1607,8 @@ function search_changed(e, kd, toroot) if (e.keyCode == 13) { $('#search_filtered_div').addClass('no-display'); if (!$('#search_filtered_div').hasClass('no-display') || (gSelectedIndex < 0)) { - if ($("#searchResults").is(":hidden")) { - // if results aren't showing, return true to allow search to execute + if ($("#searchResults").is(":hidden") && (search.value != "")) { + // if results aren't showing (and text not empty), return true to allow search to execute return true; } else { // otherwise, results are already showing, so allow ajax to auto refresh the results @@ -1589,33 +1616,49 @@ function search_changed(e, kd, toroot) return false; } } else if (kd && gSelectedIndex >= 0) { - window.location = toroot + gMatches[gSelectedIndex].link; + window.location = $("a",$('#search_filtered li')[gSelectedIndex]).attr("href"); return false; } } // 38 -- arrow up else if (kd && (e.keyCode == 38)) { - if (gSelectedIndex >= 0) { - $('#search_filtered li').removeClass('jd-selected'); + if ($($("#search_filtered li")[gSelectedIndex-1]).hasClass("header")) { + $('#search_filtered_div li').removeClass('jd-selected'); gSelectedIndex--; - $('#search_filtered li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); + $('#search_filtered_div li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); + } + if (gSelectedIndex >= 0) { + $('#search_filtered_div li').removeClass('jd-selected'); + gSelectedIndex--; + $('#search_filtered_div li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); } return false; } // 40 -- arrow down else if (kd && (e.keyCode == 40)) { - if (gSelectedIndex < gMatches.length-1 - && gSelectedIndex < ROW_COUNT-1) { - $('#search_filtered li').removeClass('jd-selected'); + if ($($("#search_filtered li")[gSelectedIndex+1]).hasClass("header")) { + $('#search_filtered_div li').removeClass('jd-selected'); gSelectedIndex++; - $('#search_filtered li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); + $('#search_filtered_div li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); + } + if ((gSelectedIndex < $("ul#search_filtered li").length-1) || + ($($("#search_filtered li")[gSelectedIndex+1]).hasClass("header"))) { + $('#search_filtered_div li').removeClass('jd-selected'); + gSelectedIndex++; + $('#search_filtered_div li:nth-child('+(gSelectedIndex+1)+')').addClass('jd-selected'); } return false; } + // if key-up event and not arrow down/up, + // read the search query and add suggestsions to gMatches else if (!kd && (e.keyCode != 40) && (e.keyCode != 38)) { gMatches = new Array(); matchedCount = 0; + gGoogleMatches = new Array(); + matchedCountGoogle = 0; gSelectedIndex = -1; + + // Search for Android matches for (var i=0; i$1'); } + for (var i=0; i$1'); + } } function search_focus_changed(obj, focused) diff --git a/tools/droiddoc/templates-sdk/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs index 6f910c1d3e..d84a3be139 100644 --- a/tools/droiddoc/templates-sdk/head_tag.cs +++ b/tools/droiddoc/templates-sdk/head_tag.cs @@ -38,10 +38,10 @@ else - - - - + + + +