load google API navtree ondemand (remove request from <head>).
Also move the code for highlighting the sidenav into a separate method that we can call at a later time, such as after the gms reference is loaded into nav. Change-Id: I924d68b2b9dbfed83f81d1fd418e06b6c79a9010
This commit is contained in:
@@ -6,6 +6,7 @@ var NAV_PREF_TREE = "tree";
|
|||||||
var NAV_PREF_PANELS = "panels";
|
var NAV_PREF_PANELS = "panels";
|
||||||
var nav_pref;
|
var nav_pref;
|
||||||
var isMobile = false; // true if mobile, so we can adjust some layout
|
var isMobile = false; // true if mobile, so we can adjust some layout
|
||||||
|
var mPagePath; // initialized in ready() function
|
||||||
|
|
||||||
var basePath = getBaseUri(location.pathname);
|
var basePath = getBaseUri(location.pathname);
|
||||||
var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
|
var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
|
||||||
@@ -200,21 +201,16 @@ $(document).ready(function() {
|
|||||||
$("#header li.distribute a").addClass("selected");
|
$("#header li.distribute a").addClass("selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set global variable so we can highlight the sidenav a bit later (such as for google reference)
|
||||||
|
// and highlight the sidenav
|
||||||
|
mPagePath = pagePath;
|
||||||
|
highlightSidenav();
|
||||||
|
|
||||||
// select current page in sidenav and header, and set up prev/next links if they exist
|
// set up prev/next links if they exist
|
||||||
var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
|
var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
|
||||||
var $selListItem;
|
var $selListItem;
|
||||||
if ($selNavLink.length) {
|
if ($selNavLink.length) {
|
||||||
|
|
||||||
// Find this page's <li> in sidenav and set selected
|
|
||||||
$selListItem = $selNavLink.closest('li');
|
$selListItem = $selNavLink.closest('li');
|
||||||
$selListItem.addClass('selected');
|
|
||||||
|
|
||||||
// Traverse up the tree and expand all parent nav-sections
|
|
||||||
$selNavLink.parents('li.nav-section').each(function() {
|
|
||||||
$(this).addClass('expanded');
|
|
||||||
$(this).children('ul').show();
|
|
||||||
});
|
|
||||||
|
|
||||||
// set up prev links
|
// set up prev links
|
||||||
var $prevLink = [];
|
var $prevLink = [];
|
||||||
@@ -592,6 +588,24 @@ false; // navigate across topic boundaries only in design docs
|
|||||||
// END of the onload event
|
// END of the onload event
|
||||||
|
|
||||||
|
|
||||||
|
function highlightSidenav() {
|
||||||
|
// select current page in sidenav and header, and set up prev/next links if they exist
|
||||||
|
var $selNavLink = $('#nav').find('a[href="' + mPagePath + '"]');
|
||||||
|
var $selListItem;
|
||||||
|
if ($selNavLink.length) {
|
||||||
|
|
||||||
|
// Find this page's <li> in sidenav and set selected
|
||||||
|
$selListItem = $selNavLink.closest('li');
|
||||||
|
$selListItem.addClass('selected');
|
||||||
|
|
||||||
|
// Traverse up the tree and expand all parent nav-sections
|
||||||
|
$selNavLink.parents('li.nav-section').each(function() {
|
||||||
|
$(this).addClass('expanded');
|
||||||
|
$(this).children('ul').show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggleFullscreen(enable) {
|
function toggleFullscreen(enable) {
|
||||||
var delay = 20;
|
var delay = 20;
|
||||||
@@ -2386,7 +2400,6 @@ function init_google_navtree(navtree_id, toroot, root_nodes)
|
|||||||
me.node.depth = 0;
|
me.node.depth = 0;
|
||||||
|
|
||||||
get_google_node(me, me.node);
|
get_google_node(me, me.node);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_google_node(me, mom, text, link, children_data, api_level)
|
function new_google_node(me, mom, text, link, children_data, api_level)
|
||||||
@@ -2458,15 +2471,30 @@ function get_google_node(me, mom)
|
|||||||
function showGoogleRefTree() {
|
function showGoogleRefTree() {
|
||||||
init_default_google_navtree(toRoot);
|
init_default_google_navtree(toRoot);
|
||||||
init_default_gcm_navtree(toRoot);
|
init_default_gcm_navtree(toRoot);
|
||||||
resizeNav();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_default_google_navtree(toroot) {
|
function init_default_google_navtree(toroot) {
|
||||||
|
// load json file for navtree data
|
||||||
|
$.getScript(toRoot + 'gms_navtree_data.js', function(data, textStatus, jqxhr) {
|
||||||
|
// when the file is loaded, initialize the tree
|
||||||
|
if(jqxhr.status === 200) {
|
||||||
init_google_navtree("gms-tree-list", toroot, GMS_NAVTREE_DATA);
|
init_google_navtree("gms-tree-list", toroot, GMS_NAVTREE_DATA);
|
||||||
|
highlightSidenav();
|
||||||
|
resizeNav();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_default_gcm_navtree(toroot) {
|
function init_default_gcm_navtree(toroot) {
|
||||||
|
// load json file for navtree data
|
||||||
|
$.getScript(toRoot + 'gcm_navtree_data.js', function(data, textStatus, jqxhr) {
|
||||||
|
// when the file is loaded, initialize the tree
|
||||||
|
if(jqxhr.status === 200) {
|
||||||
init_google_navtree("gcm-tree-list", toroot, GCM_NAVTREE_DATA);
|
init_google_navtree("gcm-tree-list", toroot, GCM_NAVTREE_DATA);
|
||||||
|
highlightSidenav();
|
||||||
|
resizeNav();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TOGGLE INHERITED MEMBERS */
|
/* TOGGLE INHERITED MEMBERS */
|
||||||
|
@@ -47,10 +47,6 @@ else
|
|||||||
var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
|
var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
|
||||||
</script>
|
</script>
|
||||||
<script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
|
<script src="<?cs var:toroot ?>assets/js/docs.js" type="text/javascript"></script>
|
||||||
<?cs if:reference.gms || reference.gcm || google?>
|
|
||||||
<script src="<?cs var:toroot ?>gms_navtree_data.js" async type="text/javascript"></script>
|
|
||||||
<script src="<?cs var:toroot ?>gcm_navtree_data.js" async type="text/javascript"></script>
|
|
||||||
<?cs /if ?>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
|
Reference in New Issue
Block a user