From 5a1123ef7a43c007ff4cfb6c04d3f9dc5436f1c6 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Wed, 26 Sep 2012 12:51:28 -0700 Subject: [PATCH] add script to generate list of classes for each training course landing page Change-Id: Ieac8a97a8d6fda41a3682241901150cfe16afc4d --- .../droiddoc/templates-sdk/assets/css/default.css | 80 +++++++++++- tools/droiddoc/templates-sdk/assets/js/docs.js | 135 +++++++++++++-------- tools/droiddoc/templates-sdk/docpage.cs | 17 +-- 3 files changed, 169 insertions(+), 63 deletions(-) diff --git a/tools/droiddoc/templates-sdk/assets/css/default.css b/tools/droiddoc/templates-sdk/assets/css/default.css index db5bd01e8..4f8c4243d 100644 --- a/tools/droiddoc/templates-sdk/assets/css/default.css +++ b/tools/droiddoc/templates-sdk/assets/css/default.css @@ -448,21 +448,23 @@ video.with-shadow { border:1px solid #DADADA; border-bottom:0; } - + .training-nav-top a.next-page-link { border-left:0; width:123px; } + .paging-links a.disabled, .training-nav-top a.disabled, .content-footer a.disabled { - color:#999; + color:#bbb; } + .paging-links a.disabled:hover, .training-nav-top a.disabled:hover, .content-footer a.disabled:hover { cursor:default; - color:#999 !important; + color:#bbb !important; } .training-nav-top a.start-class-link, @@ -470,6 +472,78 @@ video.with-shadow { 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 { display:none !important; } diff --git a/tools/droiddoc/templates-sdk/assets/js/docs.js b/tools/droiddoc/templates-sdk/assets/js/docs.js index 54e1fd4cd..0a5a4af9f 100644 --- a/tools/droiddoc/templates-sdk/assets/js/docs.js +++ b/tools/droiddoc/templates-sdk/assets/js/docs.js @@ -135,6 +135,7 @@ $(document).ready(function() { // select current page in sidenav and set up prev/next links if they exist var $selNavLink = $('#nav').find('a[href="' + pagePath + '"]'); + var $selListItem; if ($selNavLink.length) { $selListItem = $selNavLink.closest('li'); @@ -156,11 +157,9 @@ $(document).ready(function() { false; // navigate across topic boundaries only in design docs if ($prevListItem.length) { if ($prevListItem.hasClass('nav-section')) { - if (crossBoundaries) { - // jump to last topic of previous section - $prevLink = $prevListItem.find('a:last'); - } - } else { + // jump to last topic of previous section + $prevLink = $prevListItem.find('a:last'); + } else if (!$selListItem.hasClass('nav-section')) { // jump to previous topic in this section $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 var $nextLink = []; - var startCourse = false; var startClass = false; var training = $(".next-class-link").length; // decides whether to provide "next class" link var isCrossingBoundary = false; @@ -206,53 +195,103 @@ false; // navigate across topic boundaries only in design docs $('.topic-start-link').text($nextLink.text().toUpperCase()); } - // Handle some Training specialties - if ($selListItem.parent().is("#nav") && $(".start-course-link").length) { - // this means we're at the very top of the TOC hierarchy - 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) + // 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 startClass = true; } } else { // jump to the next topic in this section (if it exists) $nextLink = $selListItem.next('li').find('a:eq(0)'); if (!$nextLink.length) { - if (crossBoundaries || training) { - // 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)'); - isCrossingBoundary = true; + 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) { - if (startCourse || startClass) { - if (startCourse) { - $('.start-course-link').attr('href', $nextLink.attr('href')).removeClass("hide"); - } else { - $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide"); - } - // if there's no training bar (below the start button), - // then we need to add a bottom border to button - if (!$("#tb").length) { - $('.start-course-link').css({'border-bottom':'1px solid #DADADA'}); - $('.start-class-link').css({'border-bottom':'1px solid #DADADA'}); - } - } else if (training && isCrossingBoundary) { - $('.content-footer.next-class').show(); - $('.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 (startClass) { + $('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide"); + + // 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'}); + } + } else if (isCrossingBoundary && !$('body.design').length) { // Design always crosses boundaries + $('.content-footer.next-class').show(); + $('.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(); + } else { + $('.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 { - $('.next-page-link').attr('href', $nextLink.attr('href')).removeClass("hide"); + $('.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 = $('
    '); + var $liClass; + var $imgIcon; + var $h2Title; + var $pSummary; + var $olLessons; + var $liLesson; + $classLinks.each(function(index) { + $liClass = $('
  1. '); + $h2Title = $('

    ' + $(this).html()+'

    '); + $pSummary = $('

    ' + $(this).attr('description') + '

    '); + + $olLessons = $('
      '); + + $lessons = $(this).closest('li').find('ul li a'); + + if ($lessons.length) { + $imgIcon = $(''); + $lessons.each(function(index) { + $olLessons.append('
    1. ' + $(this).html()+'
    2. '); + }); + } else { + $imgIcon = $(''); + $pSummary.addClass('article'); + } + + $liClass.append($h2Title).append($imgIcon).append($pSummary).append($olLessons); + $olClasses.append($liClass); + }); + $('.jd-descr').append($olClasses); + } + diff --git a/tools/droiddoc/templates-sdk/docpage.cs b/tools/droiddoc/templates-sdk/docpage.cs index 63abceba4..00ca5e0f8 100644 --- a/tools/droiddoc/templates-sdk/docpage.cs +++ b/tools/droiddoc/templates-sdk/docpage.cs @@ -7,7 +7,8 @@ elif:about ?>aboutdesigndistribute" itemscope itemtype="http://schema.org/Article"> + /if ?> trainingcourse" itemscope itemtype="http://schema.org/Article"> @@ -16,7 +17,7 @@ ?>class="col-13" id="doc-col"class="col-12" id="doc-col" > - + - +