Skip to content

Commit

Permalink
reposition left menu (docs ToC) & make sure it doesn't overlap with o…
Browse files Browse the repository at this point in the history
…ther components (kubernetes-retired#2574)

* reposition left menu (docs ToC)

* remove commented lines
  • Loading branch information
arief-hidayat authored and yangweiwei committed May 10, 2019
1 parent 40edf7a commit ed0d8dd
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions docsite/js/script.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
//modal close button
(function(){
//π.modalCloseButton = function(closingFunction){
// return π.button('pi-modal-close-button', null, null, closingFunction);
//};
})();

// globals
var body;

Expand Down Expand Up @@ -92,7 +85,7 @@ function px(n){

var kub = (function () {
var HEADER_HEIGHT;
var html, header, mainNav, quickstartButton, hero, encyclopedia, footer, headlineWrapper;
var html, header, mainNav, quickstartButton, hero, encyclopedia, footer, headlineWrapper, docsToc;

$(document).ready(function () {
html = $('html');
Expand All @@ -104,6 +97,7 @@ var kub = (function () {
encyclopedia = $('#encyclopedia');
footer = $('footer');
headlineWrapper = $('#headlineWrapper');
docsToc = $('#docsToc');
HEADER_HEIGHT = header.outerHeight();

resetTheView();
Expand Down Expand Up @@ -167,6 +161,22 @@ var kub = (function () {
if (html[0].id == 'home') {
setHomeHeaderStyles();
}
if (html[0].id == 'docs') {
repositionDocsToc();
}
}

function repositionDocsToc() {
var headerBottom = header[0].getBoundingClientRect().bottom;
var heroBottom = hero[0].getBoundingClientRect().bottom;
var offsetForDocsTocTop = 10;
var docsTocTop = Math.max(headerBottom, heroBottom) + offsetForDocsTocTop;

var footerTop = footer[0].getBoundingClientRect().top;
var windowHeight = window.innerHeight;
var maxHeight = Math.min(footerTop, windowHeight) - docsTocTop;

docsToc.css({ 'top': docsTocTop + 'px', 'max-height': maxHeight + 'px', 'overflow' : 'scroll' });
}

function setHomeHeaderStyles() {
Expand Down

0 comments on commit ed0d8dd

Please sign in to comment.