From 1a00f7fecd240871caa219bb45460b43c652c604 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Tue, 29 Oct 2013 11:11:19 -0700 Subject: [PATCH] fix 'next' links to disable them when at the end of a list. Also remove the "next class" link at the end of training. Change-Id: I1d81919a0498d57b451741a7a0c12f011921f2cb --- tools/droiddoc/templates-sdk/assets/js/docs.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index 1659cc673..f779c30a7 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -241,7 +241,7 @@ false; // navigate across topic boundaries only in design docs var training = $(".next-class-link").length; // decides whether to provide "next class" link var isCrossingBoundary = false; - if ($selListItem.hasClass('nav-section')) { + if ($selListItem.hasClass('nav-section') && $selListItem.children('div.empty').length == 0) { // we're on an index page, jump to the first topic $nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)'); @@ -262,12 +262,17 @@ false; // navigate across topic boundaries only in design docs } else { // jump to the next topic in this section (if it exists) $nextLink = $selListItem.next('li').find('a:eq(0)'); - if (!$nextLink.length) { + if ($nextLink.length == 0) { isCrossingBoundary = true; // no more topics in this section, jump to the first topic in the next section $nextLink = $selListItem.parents('li:eq(0)').next('li.nav-section').find('a:eq(0)'); if (!$nextLink.length) { // Go up another layer to look for next page (lesson > class > course) $nextLink = $selListItem.parents('li:eq(1)').next('li.nav-section').find('a:eq(0)'); + if ($nextLink.length == 0) { + // if that doesn't work, we're at the end of the list, so disable NEXT link + $('.next-page-link').attr('href','').addClass("disabled") + .click(function() { return false; }); + } } } } @@ -285,10 +290,11 @@ false; // navigate across topic boundaries only in design docs $('.next-page-link').attr('href','') .removeClass("hide").addClass("disabled") .click(function() { return false; }); - - $('.next-class-link').attr('href',$nextLink.attr('href')) - .removeClass("hide").append($nextLink.html()); - $('.next-class-link').find('.new').empty(); + if ($nextLink.length) { + $('.next-class-link').attr('href',$nextLink.attr('href')) + .removeClass("hide").append($nextLink.html()); + $('.next-class-link').find('.new').empty(); + } } else { $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide"); } -- 2.11.0