Turning off sticky navigation if navbar is taller than window

Conflicts:
	sass/_theme_layout.sass
	sphinx_rtd_theme/layout.html
This commit is contained in:
Eric Hough 2014-01-07 17:39:48 -05:00
parent bcf2276d5b
commit 30f5c683eb
4 changed files with 59 additions and 3 deletions

View File

@ -286,6 +286,6 @@ footer
.wy-nav-content-wrap .wy-nav-content-wrap
margin-left: 0 margin-left: 0
.stickynav nav.stickynav
position: fixed position: fixed
top: 0 top: 0

View File

@ -53,6 +53,15 @@
<script type="text/javascript" src="_static/js/theme.js"></script> <script type="text/javascript" src="_static/js/theme.js"></script>
{% endif %} {% endif %}
{# STICKY NAVIGATION #}
{% if theme_sticky_navigation %}
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
{% endif %}
{% for cssfile in css_files %} {% for cssfile in css_files %}
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" /> <link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
{% endfor %} {% endfor %}
@ -94,7 +103,7 @@
<div class="wy-grid-for-nav"> <div class="wy-grid-for-nav">
{# SIDE NAV, TOGGLES ON MOBILE #} {# SIDE NAV, TOGGLES ON MOBILE #}
<nav data-toggle="wy-nav-shift" class="wy-nav-side{% if theme_sticky_navigation %} stickynav{% endif %}"> <nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-nav-search"> <div class="wy-side-nav-search">
<a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}</a> <a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}</a>
{% include "searchbox.html" %} {% include "searchbox.html" %}

File diff suppressed because one or more lines are too long

View File

@ -14,3 +14,50 @@ $( document ).ready(function() {
}); });
$("table.docutils:not(.field-list").wrap("<div class='wy-table-responsive'></div>"); $("table.docutils:not(.field-list").wrap("<div class='wy-table-responsive'></div>");
}); });
window.SphinxRtdTheme = (function (jquery) {
var stickyNav = (function () {
var navBar,
win,
stickyNavCssClass = 'stickynav',
applyStickNav = function () {
if (navBar.height() <= win.height()) {
navBar.addClass(stickyNavCssClass);
} else {
navBar.removeClass(stickyNavCssClass);
}
},
enable = function () {
applyStickNav();
win.on('resize', applyStickNav);
},
init = function () {
navBar = jquery('nav.wy-nav-side:first');
win = jquery(window);
};
jquery(init);
return {
enable : enable
};
}());
return {
StickyNav : stickyNav
};
}($));