am f0093857: fix a couple bugs in sidenav for samples. Previously, clicking a link still invoked the expand collapse behavior. Previously, collapsing a parent item did not also collapse its children.

* commit 'f009385738c8201e8a964a567acb59ee14fc2116':
  fix a couple bugs in sidenav for samples. Previously, clicking a link still invoked the expand collapse behavior. Previously, collapsing a parent item did not also collapse its children.
This commit is contained in:
Scott Main 2013-08-22 16:23:47 -07:00 committed by Android Git Automerger
commit 2b9846d9d1
1 changed files with 12 additions and 9 deletions

View File

@ -449,13 +449,6 @@ false; // navigate across topic boundaries only in design docs
} }
// Stop expand/collapse behavior when clicking on nav section links (since we're navigating away
// from the page)
$('.nav-section-header').find('a:eq(0)').click(function(evt) {
window.location.href = $(this).attr('href');
return false;
});
// Set up play-on-hover <video> tags. // Set up play-on-hover <video> tags.
$('video.play-on-hover').bind('click', function(){ $('video.play-on-hover').bind('click', function(){
$(this).get(0).load(); // in case the video isn't seekable $(this).get(0).load(); // in case the video isn't seekable
@ -564,9 +557,11 @@ function initExpandableNavItems(rootTag) {
$(rootTag + ' li.nav-section .nav-section-header').click(function() { $(rootTag + ' li.nav-section .nav-section-header').click(function() {
var section = $(this).closest('li.nav-section'); var section = $(this).closest('li.nav-section');
if (section.hasClass('expanded')) { if (section.hasClass('expanded')) {
/* hide me */ /* hide me and descendants */
section.children('ul').slideUp(250, function() { section.find('ul').slideUp(250, function() {
// remove 'expanded' class from my section and any children
section.closest('li').removeClass('expanded'); section.closest('li').removeClass('expanded');
$('li.nav-section', section).removeClass('expanded');
resizeNav(); resizeNav();
}); });
} else { } else {
@ -582,6 +577,14 @@ function initExpandableNavItems(rootTag) {
}); });
} }
}); });
// Stop expand/collapse behavior when clicking on nav section links
// (since we're navigating away from the page)
// This selector captures the first instance of <a>, but not those with "#" as the href.
$('.nav-section-header').find('a:eq(0)').not('a[href="#"]').click(function(evt) {
window.location.href = $(this).attr('href');
return false;
});
} }
function highlightSidenav() { function highlightSidenav() {