am 83cd28b3: am 9efb6b09: am be264b6d: am 5a1123ef: add script to generate list of classes for each training course landing page

* commit '83cd28b354e222e5ca78b17229fa456e40d8c900':
  add script to generate list of classes for each training course landing page
This commit is contained in:
Scott Main 2012-11-14 17:42:20 -08:00 committed by Android Git Automerger
commit 2dc85a0fe0
3 changed files with 170 additions and 64 deletions

View file

@ -454,15 +454,17 @@ video.with-shadow {
width:123px; width:123px;
} }
.paging-links a.disabled,
.training-nav-top a.disabled, .training-nav-top a.disabled,
.content-footer a.disabled { .content-footer a.disabled {
color:#999; color:#bbb;
} }
.paging-links a.disabled:hover,
.training-nav-top a.disabled:hover, .training-nav-top a.disabled:hover,
.content-footer a.disabled:hover { .content-footer a.disabled:hover {
cursor:default; cursor:default;
color:#999 !important; color:#bbb !important;
} }
.training-nav-top a.start-class-link, .training-nav-top a.start-class-link,
@ -470,6 +472,78 @@ video.with-shadow {
width:262px; width:262px;
} }
/* list of classes on course landing page */
ol.class-list {
list-style:none;
margin-left:0;
}
ol.class-list>li {
margin:0 0 15px;
padding:5px 0 0;
overflow:hidden;
border-top:1px solid #ccc;
}
ol.class-list li a.title {
font-size:16px;
margin:0;
clear:left;
display:block;
height:32px;
padding:0 4px;
}
ol.class-list li a.title h2 {
color:inherit;
margin:0 0 10px;
display:block;
float:left;
width:675px;
}
ol.class-list li a.title span {
display:none;
float:left;
font-size:18px;
font-weight:bold;
background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
width: 10px;
height: 32px;
}
ol.class-list li a.title:hover {
background:#ddd;
color:#258AAF !important;
}
ol.class-list li a.title:hover span {
display:block;
}
#jd-content
ol.class-list li img {
float:left;
clear:left;
width:64px;
margin:0 20px 0 0;
}
ol.class-list li p.description {
float:left;
display:block;
width:250px;
margin:0;
}
ol.class-list li p.description.article {
width: 550px;
}
ol.class-list ol {
float:left;
width:320px;
margin:0 0 0 30px;
list-style:none;
margin:0 0 0 20px;
}
ol.class-list div.lessons li {
margin:0 0 6px;
line-height:16px;
}
.hide { .hide {
display:none !important; display:none !important;
} }

View file

@ -135,6 +135,7 @@ $(document).ready(function() {
// select current page in sidenav and set up prev/next links if they exist // select current page in sidenav and set up prev/next links if they exist
var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]'); var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]');
var $selListItem;
if ($selNavLink.length) { if ($selNavLink.length) {
$selListItem = $selNavLink.closest('li'); $selListItem = $selNavLink.closest('li');
@ -156,11 +157,9 @@ $(document).ready(function() {
false; // navigate across topic boundaries only in design docs false; // navigate across topic boundaries only in design docs
if ($prevListItem.length) { if ($prevListItem.length) {
if ($prevListItem.hasClass('nav-section')) { if ($prevListItem.hasClass('nav-section')) {
if (crossBoundaries) {
// jump to last topic of previous section // jump to last topic of previous section
$prevLink = $prevListItem.find('a:last'); $prevLink = $prevListItem.find('a:last');
} } else if (!$selListItem.hasClass('nav-section')) {
} else {
// jump to previous topic in this section // jump to previous topic in this section
$prevLink = $prevListItem.find('a:eq(0)'); $prevLink = $prevListItem.find('a:eq(0)');
} }
@ -177,18 +176,8 @@ false; // navigate across topic boundaries only in design docs
} }
} }
if ($prevLink.length) {
var prevHref = $prevLink.attr('href');
if (prevHref == SITE_ROOT + 'index.html') {
// Don't show Previous when it leads to the homepage
} else {
$('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
}
}
// set up next links // set up next links
var $nextLink = []; var $nextLink = [];
var startCourse = false;
var startClass = false; var startClass = false;
var training = $(".next-class-link").length; // decides whether to provide "next class" link var training = $(".next-class-link").length; // decides whether to provide "next class" link
var isCrossingBoundary = false; var isCrossingBoundary = false;
@ -206,39 +195,33 @@ false; // navigate across topic boundaries only in design docs
$('.topic-start-link').text($nextLink.text().toUpperCase()); $('.topic-start-link').text($nextLink.text().toUpperCase());
} }
// Handle some Training specialties // If the selected page has a description, then it's a class or article homepage
if ($selListItem.parent().is("#nav") && $(".start-course-link").length) { if ($selListItem.find('a[description]').length) {
// this means we're at the very top of the TOC hierarchy // this means we're on a class landing page
startCourse = true;
} else if ($(".start-class-link").length) {
// this means this page has children but is not at the top (it's a class, not a course)
startClass = true; startClass = true;
} }
} else { } else {
// jump to the next topic in this section (if it exists) // jump to the next topic in this section (if it exists)
$nextLink = $selListItem.next('li').find('a:eq(0)'); $nextLink = $selListItem.next('li').find('a:eq(0)');
if (!$nextLink.length) { if (!$nextLink.length) {
if (crossBoundaries || training) { isCrossingBoundary = true;
// no more topics in this section, jump to the first topic in the next section // 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)'); $nextLink = $selListItem.parents('li:eq(0)').next('li.nav-section').find('a:eq(0)');
isCrossingBoundary = true; 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) {
if (startCourse || startClass) { if (startClass) {
if (startCourse) {
$('.start-course-link').attr('href', $nextLink.attr('href')).removeClass("hide");
} else {
$('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide"); $('.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 // then we need to add a bottom border to button
if (!$("#tb").length) { if (!$("#tb").length) {
$('.start-course-link').css({'border-bottom':'1px solid #DADADA'});
$('.start-class-link').css({'border-bottom':'1px solid #DADADA'}); $('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
} }
} else if (training && isCrossingBoundary) { } else if (isCrossingBoundary && !$('body.design').length) { // Design always crosses boundaries
$('.content-footer.next-class').show(); $('.content-footer.next-class').show();
$('.next-page-link').attr('href','') $('.next-page-link').attr('href','')
.removeClass("hide").addClass("disabled") .removeClass("hide").addClass("disabled")
@ -250,12 +233,68 @@ false; // navigate across topic boundaries only in design docs
} else { } else {
$('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide"); $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide");
} }
if (!startClass && $prevLink.length) {
var prevHref = $prevLink.attr('href');
if (prevHref == SITE_ROOT + 'index.html') {
// Don't show Previous when it leads to the homepage
} 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...
if (training && $selListItem.parents('ul').eq(1).is('[id="nav"]') &&
!$selListItem.find('li').length) {
$('.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 = $('<ol class="class-list"></ol>');
var $liClass;
var $imgIcon;
var $h2Title;
var $pSummary;
var $olLessons;
var $liLesson;
$classLinks.each(function(index) {
$liClass = $('<li></li>');
$h2Title = $('<a class="title" href="'+$(this).attr('href')+'"><h2>' + $(this).html()+'</h2><span></span></a>');
$pSummary = $('<p class="description">' + $(this).attr('description') + '</p>');
$olLessons = $('<ol class="lesson-list"></ol>');
$lessons = $(this).closest('li').find('ul li a');
if ($lessons.length) {
$imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" alt=""/>');
$lessons.each(function(index) {
$olLessons.append('<li><a href="'+$(this).attr('href')+'">' + $(this).html()+'</a></li>');
});
} else {
$imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" alt=""/>');
$pSummary.addClass('article');
}
$liClass.append($h2Title).append($imgIcon).append($pSummary).append($olLessons);
$olClasses.append($liClass);
});
$('.jd-descr').append($olClasses);
}
// Set up expand/collapse behavior // Set up expand/collapse behavior
$('#nav li.nav-section .nav-section-header').click(function() { $('#nav li.nav-section .nav-section-header').click(function() {
var section = $(this).closest('li.nav-section'); var section = $(this).closest('li.nav-section');

View file

@ -7,7 +7,8 @@
elif:about ?>about<?cs elif:about ?>about<?cs
elif:design ?>design<?cs elif:design ?>design<?cs
elif:distribute ?>distribute<?cs elif:distribute ?>distribute<?cs
/if ?>" itemscope itemtype="http://schema.org/Article"> /if ?><?cs
if:page.trainingcourse ?> trainingcourse<?cs /if ?>" itemscope itemtype="http://schema.org/Article">
<a name="top"></a> <a name="top"></a>
<?cs include:"header.cs" ?> <?cs include:"header.cs" ?>
@ -16,7 +17,7 @@
?>class="col-13" id="doc-col"<?cs else ?>class="col-13" id="doc-col"<?cs else
?>class="col-12" id="doc-col"<?cs /if ?> > ?>class="col-12" id="doc-col"<?cs /if ?> >
<?cs if:(design||training||walkthru) ?><?cs # header logic for docs that provide previous/next buttons ?> <?cs if:(design||training||walkthru) && !page.trainingcourse ?><?cs # header logic for docs that provide previous/next buttons ?>
<?cs if:header.hide ?> <?cs if:header.hide ?>
<?cs else ?> <?cs else ?>
<div class="layout-content-row content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>"> <div class="layout-content-row content-header <?cs if:header.justLinks ?>just-links<?cs /if ?>">
@ -51,16 +52,8 @@
ja-lang="開始する" ja-lang="開始する"
es-lang="Empezar" es-lang="Empezar"
>Get started</a> >Get started</a>
<a href="#" class="start-course-link hide"
zh-TW-lang="第一堂課"
zh-CN-lang="第一课"
ru-lang="Первый урок"
ko-lang="첫 번째 강의"
ja-lang="最初のクラス"
es-lang="Primera clase"
>First class</a>
</div> </div>
<?cs else ?> <?cs elif:!page.trainingcourse ?>
<div class="paging-links layout-content-col span-4" itemscope itemtype="http://schema.org/SiteNavigationElement"> <div class="paging-links layout-content-col span-4" itemscope itemtype="http://schema.org/SiteNavigationElement">
<a href="#" class="prev-page-link hide" <a href="#" class="prev-page-link hide"
zh-TW-lang="上一堂課" zh-TW-lang="上一堂課"
@ -138,7 +131,7 @@
</div> </div>
<?cs if:!fullscreen ?> <?cs if:!fullscreen ?>
<div class="paging-links layout-content-col col-4"> <div class="paging-links layout-content-col col-4">
<?cs if:(design||training||guide||walkthru) && !page.landing && !footer.hide ?> <?cs if:(design||training||guide||walkthru) && !page.landing && !page.trainingcourse && !footer.hide ?>
<a href="#" class="prev-page-link hide" <a href="#" class="prev-page-link hide"
zh-TW-lang="上一堂課" zh-TW-lang="上一堂課"
zh-CN-lang="上一课" zh-CN-lang="上一课"