summaryrefslogtreecommitdiffstats
path: root/tools/droiddoc
diff options
context:
space:
mode:
Diffstat (limited to 'tools/droiddoc')
-rw-r--r--tools/droiddoc/templates-ds/assets/js/docs.js22
-rw-r--r--tools/droiddoc/templates-ds/customizations.cs7
-rw-r--r--tools/droiddoc/templates-ds/head_tag.cs5
-rw-r--r--tools/droiddoc/templates-sdk/assets/js/docs.js81
-rw-r--r--tools/droiddoc/templates-sdk/customizations.cs7
-rw-r--r--tools/droiddoc/templates-sdk/head_tag.cs5
6 files changed, 80 insertions, 47 deletions
diff --git a/tools/droiddoc/templates-ds/assets/js/docs.js b/tools/droiddoc/templates-ds/assets/js/docs.js
index a7440c7..557a242 100644
--- a/tools/droiddoc/templates-ds/assets/js/docs.js
+++ b/tools/droiddoc/templates-ds/assets/js/docs.js
@@ -15,8 +15,10 @@ var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
var navBarIsFixed = false;
$(document).ready(function() {
- // move the lang selector into the overflow menu
- $("#moremenu .mid div.header:last").after($("#language").detach());
+ if (devsite) {
+ // move the lang selector into the overflow menu
+ $("#moremenu .mid div.header:last").after($("#language").detach());
+ }
// init the fullscreen toggle click event
$('#nav-swap .fullscreen').click(function(){
@@ -1051,8 +1053,20 @@ function changeLangPref(lang, submit) {
// keep this for 50 years
//alert("expires: " + expires)
writeCookie("pref_lang", lang, null, expires);
- if (submit) {
- $("#setlang").submit();
+
+ // ####### TODO: Remove this condition once we're stable on devsite #######
+ // This condition is only needed if we still need to support legacy GAE server
+ if (devsite) {
+ // Switch language when on Devsite server
+ if (submit) {
+ $("#setlang").submit();
+ }
+ } else {
+ // Switch language when on legacy GAE server
+ changeDocLang(lang);
+ if (submit) {
+ window.location = getBaseUri(location.pathname);
+ }
}
}
diff --git a/tools/droiddoc/templates-ds/customizations.cs b/tools/droiddoc/templates-ds/customizations.cs
index 342dd49..75559e6 100644
--- a/tools/droiddoc/templates-ds/customizations.cs
+++ b/tools/droiddoc/templates-ds/customizations.cs
@@ -330,12 +330,7 @@ def:custom_left_nav() ?><?cs
call:about_nav() ?><?cs
else ?><?cs
call:default_left_nav() ?> <?cs
- /if ?>
- <script>
- $(document).ready(function() {
- changeNavLang(getLangPref());
- });
- </script><?cs
+ /if ?><?cs
/def ?>
<?cs # appears at the bottom of every page ?><?cs
diff --git a/tools/droiddoc/templates-ds/head_tag.cs b/tools/droiddoc/templates-ds/head_tag.cs
index b704d44..cb22cc3 100644
--- a/tools/droiddoc/templates-ds/head_tag.cs
+++ b/tools/droiddoc/templates-ds/head_tag.cs
@@ -25,6 +25,11 @@ type="text/css">
<script src="//android-dot-devsite.googleplex.com/_static/js/android_3p-bundle.js" type="text/javascript"></script>
<script type="text/javascript">
var toRoot = "<?cs var:toroot ?>";
+ <?cs if:devsite ?>
+ var devsite = true;
+ <?cs else ?>
+ var devsite = false;
+ <?cs /if ?>
</script>
<script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
<?cs if:reference.gms || reference.gcm || google?>
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index 43bcb8f..557a242 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -15,6 +15,11 @@ var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
var navBarIsFixed = false;
$(document).ready(function() {
+ if (devsite) {
+ // move the lang selector into the overflow menu
+ $("#moremenu .mid div.header:last").after($("#language").detach());
+ }
+
// init the fullscreen toggle click event
$('#nav-swap .fullscreen').click(function(){
if ($(this).hasClass('disabled')) {
@@ -489,6 +494,36 @@ false; // navigate across topic boundaries only in design docs
resizeNav();
+ /* init the language selector based on user cookie for lang */
+ loadLangPref();
+ changeNavLang(getLangPref());
+
+ /* setup event handlers to ensure the overflow menu is visible while picking lang */
+ $("#language select")
+ .mousedown(function() {
+ $("div.morehover").addClass("hover"); })
+ .blur(function() {
+ $("div.morehover").removeClass("hover"); });
+
+ /* some global variable setup */
+ resizePackagesNav = $("#resize-packages-nav");
+ classesNav = $("#classes-nav");
+ devdocNav = $("#devdoc-nav");
+
+ var cookiePath = "";
+ if (location.href.indexOf("/reference/") != -1) {
+ cookiePath = "reference_";
+ } else if (location.href.indexOf("/guide/") != -1) {
+ cookiePath = "guide_";
+ } else if (location.href.indexOf("/tools/") != -1) {
+ cookiePath = "tools_";
+ } else if (location.href.indexOf("/training/") != -1) {
+ cookiePath = "training_";
+ } else if (location.href.indexOf("/design/") != -1) {
+ cookiePath = "design_";
+ } else if (location.href.indexOf("/distribute/") != -1) {
+ cookiePath = "distribute_";
+ }
});
@@ -576,28 +611,6 @@ addLoadEvent( function() {
prettyPrint();
} );
-function init() {
- //resizeNav();
-
- resizePackagesNav = $("#resize-packages-nav");
- classesNav = $("#classes-nav");
- devdocNav = $("#devdoc-nav");
-
- var cookiePath = "";
- if (location.href.indexOf("/reference/") != -1) {
- cookiePath = "reference_";
- } else if (location.href.indexOf("/guide/") != -1) {
- cookiePath = "guide_";
- } else if (location.href.indexOf("/tools/") != -1) {
- cookiePath = "tools_";
- } else if (location.href.indexOf("/training/") != -1) {
- cookiePath = "training_";
- } else if (location.href.indexOf("/design/") != -1) {
- cookiePath = "design_";
- } else if (location.href.indexOf("/distribute/") != -1) {
- cookiePath = "distribute_";
- }
-}
@@ -1034,20 +1047,26 @@ function changeNavLang(lang) {
});
}
-function changeDocLang(lang) {
- changeNavLang(lang);
-}
-
-function changeLangPref(lang, refresh) {
+function changeLangPref(lang, submit) {
var date = new Date();
expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000)));
// keep this for 50 years
//alert("expires: " + expires)
writeCookie("pref_lang", lang, null, expires);
- changeDocLang(lang);
- if (refresh) {
- l = getBaseUri(location.pathname);
- window.location = l;
+
+ // ####### TODO: Remove this condition once we're stable on devsite #######
+ // This condition is only needed if we still need to support legacy GAE server
+ if (devsite) {
+ // Switch language when on Devsite server
+ if (submit) {
+ $("#setlang").submit();
+ }
+ } else {
+ // Switch language when on legacy GAE server
+ changeDocLang(lang);
+ if (submit) {
+ window.location = getBaseUri(location.pathname);
+ }
}
}
diff --git a/tools/droiddoc/templates-sdk/customizations.cs b/tools/droiddoc/templates-sdk/customizations.cs
index a45e4ba..6aa8f4f 100644
--- a/tools/droiddoc/templates-sdk/customizations.cs
+++ b/tools/droiddoc/templates-sdk/customizations.cs
@@ -330,12 +330,7 @@ def:custom_left_nav() ?><?cs
call:about_nav() ?><?cs
else ?><?cs
call:default_left_nav() ?> <?cs
- /if ?>
- <script>
- $(document).ready(function() {
- changeDocLang(getLangPref());
- });
- </script><?cs
+ /if ?><?cs
/def ?>
<?cs # appears at the bottom of every page ?><?cs
diff --git a/tools/droiddoc/templates-sdk/head_tag.cs b/tools/droiddoc/templates-sdk/head_tag.cs
index 75e4cc6..f841c3b 100644
--- a/tools/droiddoc/templates-sdk/head_tag.cs
+++ b/tools/droiddoc/templates-sdk/head_tag.cs
@@ -25,6 +25,11 @@ type="text/css">
<script src="<?cs var:toroot ?>assets/js/global-libraries-combined.js" type="text/javascript"></script>
<script type="text/javascript">
var toRoot = "<?cs var:toroot ?>";
+ <?cs if:devsite ?>
+ var devsite = true;
+ <?cs else ?>
+ var devsite = false;
+ <?cs /if ?>
</script>
<script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
<?cs if:reference.gms || reference.gcm || google?>