Make nav accord to 1 item only, per @digitalcraftsman

This commit is contained in:
Ryan Watters
2017-03-08 15:18:45 -06:00
parent 7bedd4e294
commit 3839a0f98d
6 changed files with 44 additions and 47 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ wip: true
## What is a List Page Template?
A list page template is a template used to render multiple pieces of content in a single HTML page (with the exception of the homepage, which has a [dedicated template][homepage]).
A list page template is a template used to render multiple pieces of content in a single HTML page. The exception to this rule is the homepage, which is still a list but has its own [dedicated template][homepage]).
Hugo uses the term *list* in its truest sense; i.e. a sequential arrangement of material, especially in alphabetical or numerical order. Hugo uses list templates on any output HTML page where content is traditionally listed:
+1 -1
View File
@@ -12,7 +12,7 @@
{{$.Scratch.Set "url" .URL }}
{{range $item, $params := sort ($.Site.Data.sitenavigation) "order"}}
{{$section := $params.url}}
<li class="top-menu-item"><a class="list-icon top-menu-item-link {{$params.haschildren}}{{if eq ($.Scratch.Get "currentsection") $section }} active-section{{end}}" href="{{if $params.haschildren}}#{{else}}/{{$params.url}}{{end}}">{{$params.title}}</a>
<li class="top-menu-item"><a class="list-icon top-menu-item-link {{if $params.haschildren}}has-children{{end}}{{if eq ($.Scratch.Get "currentsection") $section }} active-section open{{end}}" href="{{if $params.haschildren}}#{{else}}/{{$params.url}}{{end}}">{{$params.title}}</a>
{{if $params.haschildren}}
<ul class="submenu">
{{- if eq $params.sortsubpagesby "title"}}
-12
View File
@@ -1,12 +0,0 @@
// (function() {
// var allSubMenuItems = document.querySelectorAll('.submenu-item'),
// href = window.location.href,
// path = href.replace(/^https?\:/i, "");
// for (var i = 0; i < allSubMenuItems.length; i++) {
// var datapath = allSubMenuItems[i].dataset.pagelink;
// console.log(`${path} and ${href}`)
// if (datapath === path) {
// allSubMenuItems[i].classList.add('active-page');
// }
// }
// })();
@@ -1,24 +1,26 @@
(function imageClasses() {
// var allImgs = document.getElementsByTagName('img');
var allImgs = document.querySelectorAll('.body-copy img');
if (allImgs.length < 1) {
return;
} else {
applyAltClassesAndIds(allImgs);
}
function applyAltClassesAndIds(images) {
for (var i = 0; i < images.length; i++) {
if (images[i].alt.indexOf('class=') > 0) {
var justText = images[i].alt.split('class=')[0];
var newClass = images[i].alt.split('class=')[1];
images[i].setAttribute('alt', justText);
images[i].classList.add(newClass);
} else if (images[i].alt.indexOf('id=') > 0) {
var justText = images[i].alt.split('id=')[0];
var newId = images[i].alt.split('id=')[1];
images[i].setAttribute('alt', justText);
images[i].id = newId;
}
}
}
})();
///this script *can* be used to add classes to images in markdown that append class= or id= to alt text)
//not currently being used in the Hugo docs
// (function imageClasses() {
// // var allImgs = document.getElementsByTagName('img');
// var allImgs = document.querySelectorAll('.body-copy img');
// if (allImgs.length < 1) {
// return;
// } else {
// applyAltClassesAndIds(allImgs);
// }
// function applyAltClassesAndIds(images) {
// for (var i = 0; i < images.length; i++) {
// if (images[i].alt.indexOf('class=') > 0) {
// var justText = images[i].alt.split('class=')[0];
// var newClass = images[i].alt.split('class=')[1];
// images[i].setAttribute('alt', justText);
// images[i].classList.add(newClass);
// } else if (images[i].alt.indexOf('id=') > 0) {
// var justText = images[i].alt.split('id=')[0];
// var newId = images[i].alt.split('id=')[1];
// images[i].setAttribute('alt', justText);
// images[i].id = newId;
// }
// }
// }
// })();
+12 -5
View File
@@ -1,16 +1,23 @@
$('.top-menu-item-link.true').on('click', function(evt) {
$('.top-menu-item-link.has-children').on('click', function(evt) {
evt.preventDefault();
evt.stopPropagation();
var allTopLinks = $('.top-menu-item-link.true:not(.active-section)').next('ul'),
$ul = $(this).next('ul'),
isOpen = $ul.is(':visible'),
var $ul = $(this).next('ul'),
siblingLinks = $('.top-menu-item-link.has-children.open').next('ul');
siblingLinks.velocity('slideUp', { easing: 'easeOut', duration: 200 });
var isOpen = $(this).hasClass('open'),
slideDir = isOpen ? 'slideUp' : 'slideDown',
dur = isOpen ? 200 : 400;
$ul.velocity(slideDir, {
easing: 'easeOut',
duration: dur
});
console.log(allTopLinks);
siblingLinks.velocity('slideUp', { easing: 'easeOut', duration: 200 });
if (isOpen) {
$(this).removeClass('open');
} else {
$(this).addClass('open');
}
console.log(siblingLinks);
});
//toggle off-canvas navigation for M- screens
+4 -4
View File
File diff suppressed because one or more lines are too long