X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=tools%2Fdroiddoc%2Ftemplates-sdk%2Fassets%2Fjs%2Fdocs.js;h=12221ebc14b90761f5f86aeccb5749bdb36421db;hb=36ea7a3d74c68d62a5d081401b887e848370f6d8;hp=ba65e44295ccce19bbcb1403eecf29d8e40d2837;hpb=d8d0c17e22f42597497e8f9f5c134621e399e22a;p=android-x86%2Fbuild.git
diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js
index ba65e4429..12221ebc1 100644
--- a/tools/droiddoc/templates-sdk/assets/js/docs.js
+++ b/tools/droiddoc/templates-sdk/assets/js/docs.js
@@ -11,7 +11,7 @@ var mPagePath; // initialized in ready() function
var basePath = getBaseUri(location.pathname);
var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
var GOOGLE_DATA; // combined data for google service apis, used for search suggest
-
+
// Ensure that all ajax getScript() requests allow caching
$.ajaxSetup({
cache: true
@@ -59,10 +59,10 @@ $(document).ready(function() {
toggleFullscreen(false);
}
});
-
+
// initialize the divs with custom scrollbars
$('.scroll-pane').jScrollPane( {verticalGutter:0} );
-
+
// add HRs below all H2s (except for a few other h2 variants)
$('h2').not('#qv h2').not('#tb h2').not('.sidebox h2').not('#devdoc-nav h2').not('h2.norule').css({marginBottom:0}).after('
');
@@ -78,7 +78,7 @@ $(document).ready(function() {
});
// Set up quicknav
- var quicknav_open = false;
+ var quicknav_open = false;
$("#btn-quicknav").click(function() {
if (quicknav_open) {
$(this).removeClass('active');
@@ -90,20 +90,20 @@ $(document).ready(function() {
expand();
}
})
-
+
var expand = function() {
$('#header-wrap').addClass('quicknav');
$('#quicknav').stop().show().animate({opacity:'1'});
}
-
+
var collapse = function() {
$('#quicknav').stop().animate({opacity:'0'}, 100, function() {
$(this).hide();
$('#header-wrap').removeClass('quicknav');
});
}
-
-
+
+
//Set up search
$("#search_autocomplete").focus(function() {
$("#search-container").addClass('active');
@@ -127,7 +127,7 @@ $(document).ready(function() {
}
})
-
+
// prep nav expandos
var pagePath = document.location.pathname;
// account for intl docs by removing the intl/*/ path
@@ -188,6 +188,8 @@ $(document).ready(function() {
$("#nav-x li.tools a").addClass("selected");
} else if ($("body").hasClass("google")) {
$("#nav-x li.google a").addClass("selected");
+ } else if ($("body").hasClass("samples")) {
+ $("#nav-x li.samples a").addClass("selected");
}
// highlight Distribute tab
@@ -209,7 +211,7 @@ $(document).ready(function() {
// set up prev links
var $prevLink = [];
var $prevListItem = $selListItem.prev('li');
-
+
var crossBoundaries = ($("body.design").length > 0) || ($("body.guide").length > 0) ? true :
false; // navigate across topic boundaries only in design docs
if ($prevListItem.length) {
@@ -224,10 +226,10 @@ false; // navigate across topic boundaries only in design docs
// jump to this section's index page (if it exists)
var $parentListItem = $selListItem.parents('li');
$prevLink = $selListItem.parents('li').find('a');
-
+
// except if cross boundaries aren't allowed, and we're at the top of a section already
// (and there's another parent)
- if (!crossBoundaries && $parentListItem.hasClass('nav-section')
+ if (!crossBoundaries && $parentListItem.hasClass('nav-section')
&& $selListItem.hasClass('nav-section')) {
$prevLink = [];
}
@@ -238,8 +240,8 @@ false; // navigate across topic boundaries only in design docs
var startClass = false;
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)');
@@ -251,7 +253,7 @@ false; // navigate across topic boundaries only in design docs
// then set the landing page "start link" text to be the first doc title
$('.topic-start-link').text($nextLink.text().toUpperCase());
}
-
+
// If the selected page has a description, then it's a class or article homepage
if ($selListItem.find('a[description]').length) {
// this means we're on a class landing page
@@ -260,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; });
+ }
}
}
}
@@ -273,7 +280,7 @@ false; // navigate across topic boundaries only in design docs
if (startClass) {
$('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
- // if there's no training bar (below the start button),
+ // if there's no training bar (below the start button),
// then we need to add a bottom border to button
if (!$("#tb").length) {
$('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
@@ -283,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");
}
@@ -298,7 +306,7 @@ false; // navigate across topic boundaries only in design docs
} else {
$('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
}
- }
+ }
// If this is a training 'article', there should be no prev/next nav
// ... if the grandparent is the "nav" ... and it has no child list items...
@@ -307,16 +315,16 @@ false; // navigate across topic boundaries only in design docs
$('.next-page-link,.prev-page-link').attr('href','').addClass("disabled")
.click(function() { return false; });
}
-
+
}
-
-
-
+
+
+
// Set up the course landing pages for Training with class names and descriptions
if ($('body.trainingcourse').length) {
var $classLinks = $selListItem.find('ul li a').not('#nav .nav-section .nav-section ul a');
var $classDescriptions = $classLinks.attr('description');
-
+
var $olClasses = $('
');
var $liClass;
var $imgIcon;
@@ -328,18 +336,20 @@ false; // navigate across topic boundaries only in design docs
$liClass = $('');
$h2Title = $('' + $(this).html()+'
');
$pSummary = $('' + $(this).attr('description') + '
');
-
+
$olLessons = $('
');
-
+
$lessons = $(this).closest('li').find('ul li a');
-
+
if ($lessons.length) {
- $imgIcon = $('
');
+ $imgIcon = $('
');
$lessons.each(function(index) {
$olLessons.append('' + $(this).html()+'');
});
} else {
- $imgIcon = $('
');
+ $imgIcon = $('
');
$pSummary.addClass('article');
}
@@ -349,36 +359,10 @@ false; // navigate across topic boundaries only in design docs
$('.jd-descr').append($olClasses);
}
+ // Set up expand/collapse behavior
+ initExpandableNavItems("#nav");
-
- // Set up expand/collapse behavior
- $('#nav li.nav-section .nav-section-header').click(function() {
- var section = $(this).closest('li.nav-section');
- if (section.hasClass('expanded')) {
- /* hide me */
- // if (section.hasClass('selected') || section.find('li').hasClass('selected')) {
- // /* but not if myself or my descendents are selected */
- // return;
- // }
- section.children('ul').slideUp(250, function() {
- section.closest('li').removeClass('expanded');
- resizeNav();
- });
- } else {
- /* show me */
- // first hide all other siblings
- var $others = $('li.nav-section.expanded', $(this).closest('ul'));
- $others.removeClass('expanded').children('ul').slideUp(250);
-
- // now expand me
- section.closest('li').addClass('expanded');
- section.children('ul').slideDown(250, function() {
- resizeNav();
- });
- }
- });
-
$(".scroll-pane").scroll(function(event) {
event.preventDefault();
return false;
@@ -410,10 +394,10 @@ false; // navigate across topic boundaries only in design docs
// from a scrollable div and so there's no need to make adjustments to our layout
return;
}
- var scrollTop = $(window).scrollTop();
+ var scrollTop = $(window).scrollTop();
var headerHeight = $('#header').outerHeight();
var subheaderHeight = $('#nav-x').outerHeight();
- var searchResultHeight = $('#searchResults').is(":visible") ?
+ var searchResultHeight = $('#searchResults').is(":visible") ?
$('#searchResults').outerHeight() : 0;
var totalHeaderHeight = headerHeight + subheaderHeight + searchResultHeight;
// we set the navbar fixed when the scroll position is beyond the height of the site header...
@@ -423,20 +407,20 @@ false; // navigate across topic boundaries only in design docs
if ($("#doc-col").height() < $("#side-nav").height()) {
navBarShouldBeFixed = false;
}
-
+
var scrollLeft = $(window).scrollLeft();
// When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
if (navBarIsFixed && (scrollLeft != prevScrollLeft)) {
updateSideNavPosition();
prevScrollLeft = scrollLeft;
}
-
- // Don't continue if the header is sufficently far away
+
+ // Don't continue if the header is sufficently far away
// (to avoid intensive resizing that slows scrolling)
if (navBarIsFixed && navBarShouldBeFixed) {
return;
}
-
+
if (navBarIsFixed != navBarShouldBeFixed) {
if (navBarShouldBeFixed) {
// make it fixed
@@ -447,7 +431,7 @@ false; // navigate across topic boundaries only in design docs
.prependTo('#body-content');
// add neato "back to top" button
$('#devdoc-nav a.totop').css({'display':'block','width':$("#nav").innerWidth()+'px'});
-
+
// update the sidenaav position for side scrolling
updateSideNavPosition();
} else {
@@ -459,25 +443,18 @@ false; // navigate across topic boundaries only in design docs
$('#devdoc-nav a.totop').hide();
}
navBarIsFixed = navBarShouldBeFixed;
- }
-
+ }
+
resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
});
-
+
var navBarLeftPos;
if ($('#devdoc-nav').length) {
setNavBarLeftPos();
}
- // 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