[120958] trunk/doc-new/guide/resources
cal at macports.org
cal at macports.org
Thu Jun 12 11:08:47 PDT 2014
Revision: 120958
https://trac.macports.org/changeset/120958
Author: cal at macports.org
Date: 2014-06-12 11:08:47 -0700 (Thu, 12 Jun 2014)
Log Message:
-----------
guide: Fix pseudo-fixed sidebar in browsers that don't support CSS3's "vh" units, closes #43995
Modified Paths:
--------------
trunk/doc-new/guide/resources/docbook.css
trunk/doc-new/guide/resources/sticky-sidebar.js
trunk/doc-new/guide/resources/tabs.xsl
Modified: trunk/doc-new/guide/resources/docbook.css
===================================================================
--- trunk/doc-new/guide/resources/docbook.css 2014-06-12 17:59:36 UTC (rev 120957)
+++ trunk/doc-new/guide/resources/docbook.css 2014-06-12 18:08:47 UTC (rev 120958)
@@ -2,10 +2,6 @@
* MacPorts Guide Stylesheet
*/
-/*
- CSS design by Mark Duling
-*/
-
div.book {
max-width: 1000px;
margin: 0 auto;
@@ -111,7 +107,7 @@
background: url("https://www.macports.org/img/nav-footer.png") bottom no-repeat;
}
-body.singlepage div.toc > dl {
+body.singlepage.vh-supported div.toc > dl {
max-height: 90vh;
overflow: auto;
}
@@ -328,3 +324,10 @@
color: #fff;
text-decoration: none;
}
+
+div#vh-test {
+ width: 0;
+ float: left;
+ display: none;
+ height: 20px; /* some arbitrary value that's probably not == 100vh */
+}
Modified: trunk/doc-new/guide/resources/sticky-sidebar.js
===================================================================
--- trunk/doc-new/guide/resources/sticky-sidebar.js 2014-06-12 17:59:36 UTC (rev 120957)
+++ trunk/doc-new/guide/resources/sticky-sidebar.js 2014-06-12 18:08:47 UTC (rev 120958)
@@ -1,13 +1,26 @@
$(function() {
- var stickyTop = $('div.toc').offset().top;
+ var testElement = $('#vh-test');
+ testElement.css({ height: '100vh' });
+ if (testElement.height() == window.innerHeight) {
+ $('body').addClass('vh-supported');
- $(window).scroll(function() {
- var windowTop = $(window).scrollTop();
+ var stickyElement = $('div.toc');
+ var stickyTop = stickyElement.offset().top;
- if (stickyTop - 10 < windowTop) {
- $('div.toc').css({ position: 'fixed', top: '10px' });
- } else {
- $('div.toc').css('position', 'static');
- }
- });
+ $(window).scroll(function() {
+ var windowTop = $(window).scrollTop();
+
+ if (stickyTop - 10 < windowTop) {
+ if (stickyElement.css('position') != 'fixed') {
+ stickyElement.css({ position: 'fixed', top: '10px' });
+ }
+ } else {
+ if (stickyElement.css('position') != 'static') {
+ stickyElement.css('position', 'static');
+ }
+ }
+ });
+ } else {
+ $('body').addClass('vh-unuspported');
+ }
});
Modified: trunk/doc-new/guide/resources/tabs.xsl
===================================================================
--- trunk/doc-new/guide/resources/tabs.xsl 2014-06-12 17:59:36 UTC (rev 120957)
+++ trunk/doc-new/guide/resources/tabs.xsl 2014-06-12 18:08:47 UTC (rev 120958)
@@ -16,5 +16,6 @@
</a>
</div>
</div>
+ <div id="vh-test"></div> <!-- needed for the sticky sidebar -->
</xsl:template>
</xsl:stylesheet>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20140612/34769f0e/attachment.html>
More information about the macports-changes
mailing list