From 9b5fdb9c23f9301d1a963a6e9be4b46ad70922d7 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Tue, 27 Oct 2009 15:09:15 -0700 Subject: [PATCH] docs: add checkbox to toggle the api level filter on and off; this includes some function renaming for the related scripts. the checkbox will be unchecked by default, so any users that currently have an api level filter selected will now see all apis until they click the checkbox. the old api level cookie is still saved the same, but the selected value will only be applied if the checkbox is selected, which has its own cookie for on or off. --- tools/droiddoc/templates-sdk/customization.cs | 9 +- .../assets/android-developer-core.css | 3 +- .../assets/android-developer-docs.css | 3 + .../assets/android-developer-docs.js | 2 +- .../assets/android-developer-reference.js | 85 +++++++++++++------ 5 files changed, 68 insertions(+), 34 deletions(-) diff --git a/tools/droiddoc/templates-sdk/customization.cs b/tools/droiddoc/templates-sdk/customization.cs index 6bdb992066..6ae8446622 100644 --- a/tools/droiddoc/templates-sdk/customization.cs +++ b/tools/droiddoc/templates-sdk/customization.cs @@ -73,9 +73,10 @@ def:custom_masthead() ?> call:default_search_box() ?>
- - + +
diff --git a/tools/droiddoc/templates/assets/android-developer-core.css b/tools/droiddoc/templates/assets/android-developer-core.css index eb7e107239..954032b7dd 100644 --- a/tools/droiddoc/templates/assets/android-developer-core.css +++ b/tools/droiddoc/templates/assets/android-developer-core.css @@ -48,11 +48,12 @@ a:visited code { } input, select, -textarea, option { +textarea, option, label { font-family:inherit; font-size:inherit; padding:0; margin:0; + vertical-align:middle; } option { diff --git a/tools/droiddoc/templates/assets/android-developer-docs.css b/tools/droiddoc/templates/assets/android-developer-docs.css index e8dc20bbb5..d700c0ea35 100644 --- a/tools/droiddoc/templates/assets/android-developer-docs.css +++ b/tools/droiddoc/templates/assets/android-developer-docs.css @@ -341,6 +341,9 @@ links to summary tables) */ #api-level-toggle { padding:0 10px; font-size:11px; +} + +#api-level-toggle label.disabled { color:#999; } diff --git a/tools/droiddoc/templates/assets/android-developer-docs.js b/tools/droiddoc/templates/assets/android-developer-docs.js index 5f472f66a0..db5e64fc8a 100644 --- a/tools/droiddoc/templates/assets/android-developer-docs.js +++ b/tools/droiddoc/templates/assets/android-developer-docs.js @@ -99,7 +99,7 @@ function readCookie(cookie) { } function writeCookie(cookie, val, section, expiration) { - if (!val) return; + if (val==undefined) return; section = section == null ? "_" : "_"+section+"_"; if (expiration == null) { var date = new Date(); diff --git a/tools/droiddoc/templates/assets/android-developer-reference.js b/tools/droiddoc/templates/assets/android-developer-reference.js index 3080760f10..b96e1366c9 100644 --- a/tools/droiddoc/templates/assets/android-developer-reference.js +++ b/tools/droiddoc/templates/assets/android-developer-reference.js @@ -1,48 +1,77 @@ /* API LEVEL TOGGLE */ addLoadEvent(changeApiLevel); + +var API_LEVEL_ENABLED_COOKIE = "api_level_enabled"; var API_LEVEL_COOKIE = "api_level"; var minLevel = 1; -function buildApiLevelToggle() { - var maxLevel = SINCE_DATA.length; - var userApiLevel = readCookie(API_LEVEL_COOKIE); - - if (userApiLevel != 0) { - selectedLevel = userApiLevel; - } else { - selectedLevel = maxLevel; - } +function toggleApiLevelSelector(checkbox) { + var date = new Date(); + date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years + var expiration = date.toGMTString(); + if (checkbox.checked) { + $("#apiLevelSelector").removeAttr("disabled"); + $("#api-level-toggle label").removeClass("disabled"); + writeCookie(API_LEVEL_ENABLED_COOKIE, 1, null, expiration); + } else { + $("#apiLevelSelector").attr("disabled","disabled"); + $("#api-level-toggle label").addClass("disabled"); + writeCookie(API_LEVEL_ENABLED_COOKIE, 0, null, expiration); + } + changeApiLevel(); +} + +function buildApiLevelSelector() { + var maxLevel = SINCE_DATA.length; + var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE); + var userApiLevel = readCookie(API_LEVEL_COOKIE); + + if (userApiLevelEnabled == 0) { + $("#apiLevelSelector").attr("disabled","disabled"); + } else { + $("#apiLevelCheckbox").attr("checked","checked"); + $("#api-level-toggle label").removeClass("disabled"); + } minLevel = $("body").attr("class"); - var select = $("#apiLevelControl").html("").change(changeApiLevel); - for (var i = maxLevel-1; i >= 0; i--) { - var option = $("