am 79935f59
: am 015d616a
: docs: use devsite hdf bool as a javascript condition for managing the lang toggle. sync the sdk and ds templates so we can move toward one template set
# Via Android Git Automerger (1) and Scott Main (1) * commit '79935f593bc567517c95d0f09198a519f315b2ca': docs: use devsite hdf bool as a javascript condition for managing the lang toggle. sync the sdk and ds templates so we can move toward one template set
This commit is contained in:
commit
086e7f8b23
6 changed files with 80 additions and 47 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?>
|
||||
|
|
Loading…
Reference in a new issue