Removed floating TOC (for now) as it was very inconsistent
This commit is contained in:
parent
8780370415
commit
94cc8e2ffe
2 changed files with 47 additions and 52 deletions
|
@ -1,16 +1,15 @@
|
|||
|
||||
// hackity-hack
|
||||
|
||||
$(document).ready(function() {
|
||||
var ft = $("#floating-toc")
|
||||
var ul = ft.find('ul')
|
||||
var lis = ft.find('li')
|
||||
var ft = $("#floating-toc");
|
||||
var ul = ft.find('ul');
|
||||
var lis = ft.find('li');
|
||||
|
||||
ul.css('maring', '0px')
|
||||
ul.css('maring', '0px');
|
||||
|
||||
var liHeight = $(lis.get(0)).height()
|
||||
var liHeight = $(lis.get(0)).height();
|
||||
|
||||
ft.css('height', (liHeight) + 'px')
|
||||
ft.css('height', (liHeight) + 'px');
|
||||
|
||||
|
||||
showNs = function(ns) {
|
||||
|
@ -18,77 +17,77 @@ $(document).ready(function() {
|
|||
//var el = $("[id='floating-toc_" + ns + "']")
|
||||
//var index = lis.index(el)
|
||||
|
||||
var index = 0
|
||||
var index = 0;
|
||||
|
||||
for(i in nsPositions.nss) {
|
||||
if(ns == nsPositions.nss[i]) index = i
|
||||
if(ns == nsPositions.nss[i])
|
||||
index = i;
|
||||
}
|
||||
|
||||
console.log(index)
|
||||
console.log(index);
|
||||
|
||||
if(index == lastNsIndex) return;
|
||||
|
||||
lastNsIndex = index
|
||||
lastNsIndex = index;
|
||||
|
||||
|
||||
ul.animate({marginTop: (-1 * liHeight * index) + 'px'},
|
||||
300)
|
||||
// ul.css('margin-top', (-1 * liHeight * index) + 'px')
|
||||
|
||||
}
|
||||
ul.animate({marginTop: (-1 * liHeight * index) + 'px'}, 300);
|
||||
};
|
||||
|
||||
var calcNsPositions = function() {
|
||||
var nss = []
|
||||
var anchors = []
|
||||
var positions = []
|
||||
var nss = [];
|
||||
var anchors = [];
|
||||
var positions = [];
|
||||
|
||||
$.each(lis, function(i, el) {
|
||||
var ns = $(el).attr('id').split('_')[1]
|
||||
nss.push(ns)
|
||||
var a = $("a[name='"+ns+"']")
|
||||
anchors.push(a)
|
||||
positions.push(a.offset().top)
|
||||
console.log(a.offset().top)
|
||||
var ns = $(el).attr('id').split('_')[1];
|
||||
nss.push(ns);
|
||||
var a = $("a[name='"+ns+"']");
|
||||
anchors.push(a);
|
||||
positions.push(a.offset().top);
|
||||
console.log(a.offset().top);
|
||||
});
|
||||
|
||||
return {nss: nss, positions: positions}
|
||||
}
|
||||
return {nss: nss, positions: positions};
|
||||
};
|
||||
|
||||
var nsPositions = calcNsPositions()
|
||||
var nsPositions = calcNsPositions();
|
||||
|
||||
console.log(nsPositions)
|
||||
console.log(nsPositions);
|
||||
|
||||
var lastNsIndex = -1
|
||||
var lastNsIndex = -1;
|
||||
|
||||
var $window = $(window)
|
||||
var $window = $(window);
|
||||
|
||||
var currentSection = function(nsp) {
|
||||
console.log(nsp);
|
||||
var ps = nsp.positions;
|
||||
var nss = nsp.nss;
|
||||
var scroll = $window.scrollTop() + 300;
|
||||
var nsIndex = -1;
|
||||
|
||||
var ps = nsp.positions
|
||||
var nss = nsp.nss
|
||||
var scroll = $window.scrollTop() + 300
|
||||
var nsIndex = -1
|
||||
for(var i in ps) {
|
||||
var p = ps[i]
|
||||
var p = ps[i];
|
||||
|
||||
if(p >= scroll) {
|
||||
nsIndex = i-1
|
||||
nsIndex = i-1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(nsIndex == -1 && scroll >= ps[0]) {
|
||||
nsIndex = ps.length-1
|
||||
nsIndex = ps.length-1;
|
||||
}
|
||||
|
||||
if(nsIndex == -1) nsIndex = 0
|
||||
if(nsIndex == -1) nsIndex = 0;
|
||||
|
||||
return nss[nsIndex]
|
||||
}
|
||||
return nss[nsIndex];
|
||||
};
|
||||
|
||||
$(window).scroll(function(e) {
|
||||
showNs(currentSection(nsPositions))
|
||||
})
|
||||
showNs(currentSection(nsPositions));
|
||||
});
|
||||
|
||||
ul.css('margin-top', '0px')
|
||||
|
||||
})
|
||||
ul.css('margin-top', '0px');
|
||||
});
|
||||
|
|
|
@ -345,14 +345,13 @@
|
|||
"Notice that we're inlining the css & javascript for [SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) (`inline-js`
|
||||
& `inline-css`) to be able to package the output as a single file (uberdoc if you will). It goes without
|
||||
saying that all this is WIP and will prabably change in the future."
|
||||
[project-metadata opt-resources header toc floating-toc content]
|
||||
[project-metadata opt-resources header toc content]
|
||||
(html
|
||||
(doctype :html5)
|
||||
[:html
|
||||
[:head
|
||||
[:meta {:http-equiv "Content-Type" :content "text/html" :charset "utf-8"}]
|
||||
[:meta {:name "description" :content (:description project-metadata)}]
|
||||
#_[:script {:type "text/javascript" :src "./../resources/app.js"}]
|
||||
(inline-css (str *resources* "shCore.css"))
|
||||
(css
|
||||
[:.syntaxhighlighter {:overflow "hidden !important"}])
|
||||
|
@ -365,7 +364,6 @@
|
|||
(inline-js (str *resources* "xregexp-min.js"))
|
||||
(inline-js (str *resources* "shCore.js"))
|
||||
(inline-js (str *resources* "shBrushClojure.js"))
|
||||
(inline-js (str *resources* "app.js"))
|
||||
opt-resources
|
||||
[:title (:name project-metadata) " -- Marginalia"]]
|
||||
[:body
|
||||
|
@ -380,7 +378,7 @@
|
|||
"Syntax highlighting provided by Alex Gorbatchev's "
|
||||
[:a {:href "http://alexgorbatchev.com/SyntaxHighlighter/"}
|
||||
"SyntaxHighlighter"]
|
||||
floating-toc]
|
||||
#_floating-toc]
|
||||
[:script {:type "text/javascript"}
|
||||
"SyntaxHighlighter.defaults['gutter'] = false;
|
||||
SyntaxHighlighter.all()"]]]))
|
||||
|
@ -399,7 +397,6 @@
|
|||
(opt-resources-html project-metadata)
|
||||
(header-html project-metadata)
|
||||
(toc-html {:uberdoc? true} docs)
|
||||
(floating-toc-html docs)
|
||||
(map #(groups-html {:uberdoc? true} %) docs)))
|
||||
|
||||
(defn index-html
|
||||
|
@ -419,5 +416,4 @@
|
|||
(opt-resources-html project-metadata)
|
||||
"" ;; no header
|
||||
"" ;; no toc
|
||||
(floating-toc-html all-docs)
|
||||
(groups-html {:uberdoc? false} doc)))
|
||||
|
|
Loading…
Reference in a new issue