Code Review - Where will this .positionTop() function fail?
http://codereview.stackexchange.com/q/7785/9137
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AeroFS API Reference</title>
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/google-open-sans.css">
<link rel="stylesheet" href="css/aerofs.css">
<link rel="stylesheet" href="css/syntax.css">
<link rel="stylesheet" href="css/api.css">
</head>
<body data-spy="scroll" data-target="#left-nav" data-offset="800">
<div id="wrapper">
<div class="container-fluid" id="top-container">
<div class="row-fluid">
<div class="span12" id="top-nav-span">
<ul class="nav nav-pills top-nav">
<li><a href="https://www.aerofs.com">
<img src="img/logo_small.png"
width="144" height="40" alt="AeroFS"/>
</a>
</li>
<li class="pull-right"> <a class="btn" id="nav-btn-sign-up" href="https://www.aerofs.com/private-cloud-signup">
Sign up for Private Cloud</a>
</li>
<li class="pull-right"><a href="https://www.aerofs.com/developers">
Documentation
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container-fluid" style="padding-right: 0">
<div class="row-fluid">
<div id="left-nav" data-spy="affix" data-offset-top="60">
<ul id="left-nav-list" class="nav nav-list">
<li class="nav-node"><a...
JavaScript
$(document).ready(adjustLeftNavHeight);
$(window).resize(adjustLeftNavHeight);
// adjust the height of the left navigation panel according to the height of
// the browser
function adjustLeftNavHeight() {
$('#left-nav').css({
'height': $(window).height() - 82,
'overflow': 'scroll'
});
}
$(document).ready(function () {
var nav = $('#left-nav');
// ensures activated item is in view
$('#left-nav-list').on('activate', '.nav-node, .nav-subnode', function () {
nav.scrollTop(inRange(nav.scrollTop(),
this.offsetTop + this.offsetHeight - nav.height(),
this.offsetTop));
});
});
// returns val bounded by [atLeast, atMost]
function inRange(val, atLeast, atMost) {
return Math.min(Math.max(val, atLeast), atMost);
}