Skip to content

Commit 3b60a86

Browse files
author
rakeshAlgo
committed
Merge branch 'master' of https://github.com/couchbase/docs-ui-sandbox into ui-bug-fixes
2 parents 811b53c + ae984ea commit 3b60a86

File tree

3 files changed

+54
-38
lines changed

3 files changed

+54
-38
lines changed

src/css/body.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ main {
2121
nav.nav {
2222
/* NOTE reserve no space in layout by default */
2323
flex: 0 0 0%;
24-
visibility: hidden;
2524
/* NOTE width must be set in order for fixed child to inherit */
2625
width: var(--width-nav);
2726
}
@@ -59,6 +58,6 @@ aside.toc.sidebar {
5958

6059
@media screen and (max-width: 767px) {
6160
div.body {
62-
margin-top: 5rem;
61+
margin-top: 3.9rem;
6362
}
6463
}

src/js/01-nav.js

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict'
33

44
var nav = document.querySelector('nav.nav')
5+
var menuExpandToggle = document.querySelector('.menu-expand-toggle')
56
var navMenu = {}
67
if (!(navMenu.element = nav && nav.querySelector('.nav-menu'))) return
78
var navControl
@@ -29,41 +30,41 @@
2930
}
3031
})
3132

32-
fitNavMenuInit({})
33-
window.addEventListener('load', fitNavMenuInit)
34-
window.addEventListener('resize', fitNavMenuInit)
33+
// fitNavMenuInit({})
34+
// window.addEventListener('load', fitNavMenuInit)
35+
// window.addEventListener('resize', fitNavMenuInit)
3536

3637
if ((navControl = document.querySelector('main .nav-control'))) navControl.addEventListener('click', revealNav)
3738

38-
function scrollItemToMiddle (el, parentEl) {
39-
var adjustment = (el.getBoundingClientRect().height - parentEl.getBoundingClientRect().height) * 0.5 + el.offsetTop
40-
if (adjustment > 0) parentEl.scrollTop = adjustment
41-
}
42-
43-
function fitNavMenuInit (e) {
44-
window.removeEventListener('scroll', fitNavMenuOnScroll)
45-
navMenu.element.style.height = ''
46-
if ((navMenu.preferredHeight = navMenu.element.getBoundingClientRect().height) > 0) {
47-
// QUESTION should we check if x value > 0 instead?
48-
if (window.getComputedStyle(nav).visibility === 'visible') {
49-
if (!navMenu.encroachingElement) navMenu.encroachingElement = document.querySelector('footer.footer')
50-
fitNavMenu(navMenu.preferredHeight, (navMenu.viewHeight = window.innerHeight), navMenu.encroachingElement)
51-
window.addEventListener('scroll', fitNavMenuOnScroll)
52-
}
53-
if (currentPageItem && e.type !== 'resize') {
54-
scrollItemToMiddle(currentPageItem.querySelector('.nav-link'), navMenu.element)
55-
}
56-
}
57-
}
58-
59-
function fitNavMenuOnScroll () {
60-
fitNavMenu(navMenu.preferredHeight, navMenu.viewHeight, navMenu.encroachingElement)
61-
}
62-
63-
function fitNavMenu (preferredHeight, availableHeight, encroachingElement) {
64-
var reclaimedHeight = availableHeight - encroachingElement.getBoundingClientRect().top
65-
navMenu.element.style.height = reclaimedHeight > 0 ? Math.max(0, preferredHeight - reclaimedHeight) + 'px' : ''
66-
}
39+
// function scrollItemToMiddle (el, parentEl) {
40+
// var adjustment = (el.getBoundingClientRect().height - parentEl.getBoundingClientRect().height) * 0.5 + el.offsetTop
41+
// if (adjustment > 0) parentEl.scrollTop = adjustment
42+
// }
43+
44+
// function fitNavMenuInit (e) {
45+
// window.removeEventListener('scroll', fitNavMenuOnScroll)
46+
// navMenu.element.style.height = ''
47+
// if ((navMenu.preferredHeight = navMenu.element.getBoundingClientRect().height) > 0) {
48+
// // QUESTION should we check if x value > 0 instead?
49+
// if (window.getComputedStyle(nav).visibility === 'visible') {
50+
// if (!navMenu.encroachingElement) navMenu.encroachingElement = document.querySelector('footer.footer')
51+
// fitNavMenu(navMenu.preferredHeight, (navMenu.viewHeight = window.innerHeight), navMenu.encroachingElement)
52+
// window.addEventListener('scroll', fitNavMenuOnScroll)
53+
// }
54+
// if (currentPageItem && e.type !== 'resize') {
55+
// scrollItemToMiddle(currentPageItem.querySelector('.nav-link'), navMenu.element)
56+
// }
57+
// }
58+
// }
59+
60+
// function fitNavMenuOnScroll () {
61+
// fitNavMenu(navMenu.preferredHeight, navMenu.viewHeight, navMenu.encroachingElement)
62+
// }
63+
64+
// function fitNavMenu (preferredHeight, availableHeight, encroachingElement) {
65+
// var reclaimedHeight = availableHeight - encroachingElement.getBoundingClientRect().top
66+
// navMenu.element.style.height = reclaimedHeight > 0 ? Math.max(0, preferredHeight - reclaimedHeight) + 'px' : ''
67+
// }
6768

6869
var navMenuControl
6970
if (document.querySelector('.main-nav-parent')) {
@@ -137,7 +138,20 @@
137138
} else {
138139
nav.classList.add('show-nav')
139140
}
140-
}, 2000)
141+
142+
menuExpandToggle.addEventListener('click', function(e) {
143+
e.preventDefault()
144+
// var navBarHeight = nav.querySelector('.nav-menu')
145+
// navBarHeight.style.height = '100vh'
146+
// console.log(navBarHeight.style.height)
147+
if (nav.classList.contains('collapse-menu')) {
148+
nav.classList.remove('collapse-menu')
149+
} else {
150+
nav.classList.add('collapse-menu')
151+
}
152+
153+
})
154+
}, 500)
141155
// has children in li
142156
// $('ul.nav-list li.nav-item ul.nav-list .nav-item').has('ul.nav-list').addClass('has-children')
143157
function concealEvent (e) {

src/js/05-tabset.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ function find (selector, from) {
9898
return Array.prototype.slice.call((from || document).querySelectorAll(selector))
9999
}
100100
setTimeout(function () {
101-
document.querySelector(' .dropddown-btn').addEventListener('click', function (e) {
102-
e.preventDefault()
103-
})
101+
if (document.querySelector(' .dropddown-btn')) {
102+
document.querySelector(' .dropddown-btn').addEventListener('click', function (e) {
103+
e.preventDefault()
104+
})
105+
}
106+
104107
}, 1000)
105108

106109
function getPane (id, tabset) {

0 commit comments

Comments
 (0)