am 07e13f7c
: am f614554d
: 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.
* commit '07e13f7c25d22ac30a59b10feebf92a3d2df6e02': 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.
This commit is contained in:
commit
70174c6783
2 changed files with 42 additions and 18 deletions
|
@ -6,6 +6,7 @@ var NAV_PREF_TREE = "tree";
|
|||
var NAV_PREF_PANELS = "panels";
|
||||
var nav_pref;
|
||||
var isMobile = false; // true if mobile, so we can adjust some layout
|
||||
var mPagePath; // initialized in ready() function
|
||||
|
||||
var basePath = getBaseUri(location.pathname);
|
||||
var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
|
||||
|
@ -200,21 +201,16 @@ $(document).ready(function() {
|
|||
$("#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 $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();
|
||||
});
|
||||
|
||||
// set up prev links
|
||||
var $prevLink = [];
|
||||
|
@ -592,6 +588,24 @@ false; // navigate across topic boundaries only in design docs
|
|||
// 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) {
|
||||
var delay = 20;
|
||||
|
@ -2386,7 +2400,6 @@ function init_google_navtree(navtree_id, toroot, root_nodes)
|
|||
me.node.depth = 0;
|
||||
|
||||
get_google_node(me, me.node);
|
||||
|
||||
}
|
||||
|
||||
function new_google_node(me, mom, text, link, children_data, api_level)
|
||||
|
@ -2458,15 +2471,30 @@ function get_google_node(me, mom)
|
|||
function showGoogleRefTree() {
|
||||
init_default_google_navtree(toRoot);
|
||||
init_default_gcm_navtree(toRoot);
|
||||
resizeNav();
|
||||
}
|
||||
|
||||
function init_default_google_navtree(toroot) {
|
||||
init_google_navtree("gms-tree-list", toroot, GMS_NAVTREE_DATA);
|
||||
// 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);
|
||||
highlightSidenav();
|
||||
resizeNav();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init_default_gcm_navtree(toroot) {
|
||||
init_google_navtree("gcm-tree-list", toroot, GCM_NAVTREE_DATA);
|
||||
// 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);
|
||||
highlightSidenav();
|
||||
resizeNav();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* TOGGLE INHERITED MEMBERS */
|
||||
|
|
|
@ -47,10 +47,6 @@ else
|
|||
var devsite = <?cs if:devsite ?>true<?cs else ?>false<?cs /if ?>;
|
||||
</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">
|
||||
var _gaq = _gaq || [];
|
||||
|
|
Loading…
Reference in a new issue