-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocinfo.html
233 lines (223 loc) · 13.4 KB
/
docinfo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!--
###############################################################################
# Generate a nice TOC
#
# Thanks to StackOverflow user "rec",
# https://stackoverflow.com/users/2511197/rec
# For this answer:
# https://stackoverflow.com/questions/34481638/how-to-use-tocify-with-asciidoctor-for-a-dynamic-toc
# Which seems to be working nicely for us.
#
# The OPeNDAP Team
###############################################################################
-->
<!-- Generate a nice TOC -->
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<script>
/*! jquery.tocify - v1.9.0 - 2013-10-01
* http://gregfranko.com/jquery.tocify.js/
* Copyright (c) 2013 Greg Franko; Licensed MIT
*/
(function (e) {
"use strict"; e(window.jQuery, window, document)
})(function (e, t, s) {
"use strict"; var i = "tocify", o = "tocify-focus", n = "tocify-hover", a = "tocify-hide", l = "tocify-header", h = "." + l, r = "tocify-subheader", d = "." + r, c = "tocify-item", f = "." + c, u = "tocify-extend-page", p = "." + u; e.widget("toc.tocify", {
version: "1.9.0", options: {
context: "body", ignoreSelector: null, selectors: "h1, h2, h3", showAndHide: ! 0, showEffect: "slideDown", showEffectSpeed: "medium", hideEffect: "slideUp", hideEffectSpeed: "medium", smoothScroll: ! 0, smoothScrollSpeed: "medium", scrollTo: 0, showAndHideOnScroll: ! 0, highlightOnScroll: ! 0, highlightOffset: 40, theme: "bootstrap", extendPage: ! 0, extendPageOffset: 100, history: ! 0, scrollHistory: ! 1, hashGenerator: "compact", highlightDefault: ! 0
},
_create: function () {
var s = this; s.extendPageScroll = ! 0, s.items =[], s._generateToc(), s._addCSSClasses(), s.webkit = function () {
for (var e in t) if (e && -1 !== e.toLowerCase().indexOf("webkit")) return ! 0; return ! 1
}
(), s._setEventHandlers(), e(t).load(function () {
s._setActiveElement(! 0), e("html, body").promise().done(function () {
setTimeout(function () {
s.extendPageScroll = ! 1
},
0)
})
})
},
_generateToc: function () {
var t, s, o = this, n = o.options.ignoreSelector; return t = -1 !== this.options.selectors.indexOf(",") ? e(this.options.context).find(this.options.selectors.replace(/ /g, "").substr(0, this.options.selectors.indexOf(","))): e(this.options.context).find(this.options.selectors.replace(/ /g, "")), t.length ?(o.element.addClass(i), t.each(function (t) {
e(this).is(n) ||(s = e("<ul/>", {
id: l + t, "class": l
}).append(o._nestElements(e(this), t)), o.element.append(s), e(this).nextUntil(this.nodeName.toLowerCase()).each(function () {
0 === e(this).find(o.options.selectors).length ? e(this).filter(o.options.selectors).each(function () {
e(this).is(n) || o._appendSubheaders.call(this, o, s)
}): e(this).find(o.options.selectors).each(function () {
e(this).is(n) || o._appendSubheaders.call(this, o, s)
})
}))
}), undefined):(o.element.addClass(a), undefined)
},
_setActiveElement: function (e) {
var s = this, i = t.location.hash.substring(1), o = s.element.find('li[data-unique="' + i + '"]');
return i.length ?(s.element.find("." + s.focusClass).removeClass(s.focusClass), o.addClass(s.focusClass), s.options.showAndHide && o.click()):(s.element.find("." + s.focusClass).removeClass(s.focusClass), ! i.length && e && s.options.highlightDefault && s.element.find(f).first().addClass(s.focusClass)), s
},
_nestElements: function (t, s) {
var i, o, n; return i = e.grep(this.items, function (e) {
return e === t.text()
}), i.length ? this.items.push(t.text() + s): this.items.push(t.text()), n = this._generateHashValue(i, t, s), o = e("<li/>", {
"class": c, "data-unique": n
}).append(e("<a/>", {
text: t.text()
})), t.before(e("<div/>", {
name: n, "data-unique": n
})), o
},
_generateHashValue: function (e, t, s) {
var i = "", o = this.options.hashGenerator; if ("pretty" === o) {
for (i = t.text().toLowerCase().replace(/\s/g, "-");
i.indexOf("--") > -1;) i = i.replace(/--/g, "-");
for (; i.indexOf(":-") > -1;) i = i.replace(/:-/g, "-")
} else i = "function" == typeof o ? o(t.text(), t): t.text().replace(/\s/g, "");
return e.length &&(i += "" + s), i
},
_appendSubheaders: function (t, s) {
var i = e(this).index(t.options.selectors), o = e(t.options.selectors).eq(i -1), n = + e(this).prop("tagName").charAt(1), a = + o.prop("tagName").charAt(1);
a > n ? t.element.find(d + "[data-tag=" + n + "]").last().append(t._nestElements(e(this), i)): n === a ? s.find(f).last().after(t._nestElements(e(this), i)): s.find(f).last().after(e("<ul/>", {
"class": r, "data-tag": n
})).next(d).append(t._nestElements(e(this), i))
},
_setEventHandlers: function () {
var i = this; this.element.on("click.tocify", "li", function () {
if (i.options.history &&(t.location.hash = e(this).attr("data-unique")), i.element.find("." + i.focusClass).removeClass(i.focusClass), e(this).addClass(i.focusClass), i.options.showAndHide) {
var s = e('li[data-unique="' + e(this).attr("data-unique") + '"]');
i._triggerShow(s)
}
i._scrollTo(e(this))
}), this.element.find("li").on({
"mouseenter.tocify": function () {
e(this).addClass(i.hoverClass), e(this).css("cursor", "pointer")
},
"mouseleave.tocify": function () {
"bootstrap" !== i.options.theme && e(this).removeClass(i.hoverClass)
}
}),(i.options.extendPage || i.options.highlightOnScroll || i.options.scrollHistory || i.options.showAndHideOnScroll) && e(t).on("scroll.tocify", function () {
e("html, body").promise().done(function () {
var o, n, a, l, h = e(t).scrollTop(), r = e(t).height(), d = e(s).height(), c = e("body")[0].scrollHeight; if (i.options.extendPage &&(i.webkit && h >= c - r - i.options.extendPageOffset || ! i.webkit && r + h > d - i.options.extendPageOffset) && ! e(p).length) {
if (n = e('div[data-unique="' + e(f).last().attr("data-unique") + '"]'), ! n.length) return; a = n.offset().top, e(i.options.context).append(e("<div />", {
"class": u, height: Math.abs(a - h) + "px", "data-unique": u
})), i.extendPageScroll &&(l = i.element.find("li.active"), i._scrollTo(e('div[data-unique="' + l.attr("data-unique") + '"]')))
}
setTimeout(function () {
var s, n = null, a = null, l = e(i.options.context).find("div[data-unique]");
l.each(function (t) {
var s = Math.abs((e(this).next().length ? e(this).next(): e(this)).offset().top - h - i.options.highlightOffset);
return null == n || n > s ?(n = s, a = t, undefined): ! 1
}), s = e(l[a]).attr("data-unique"), o = e('li[data-unique="' + s + '"]'), i.options.highlightOnScroll && o.length &&(i.element.find("." + i.focusClass).removeClass(i.focusClass), o.addClass(i.focusClass)), i.options.scrollHistory && t.location.hash !== "#" + s && t.location.replace("#" + s), i.options.showAndHideOnScroll && i.options.showAndHide && i._triggerShow(o, ! 0)
},
0)
})
})
},
show: function (t) {
var s = this; if (! t.is(":visible")) switch (t.find(d).length || t.parent().is(h) || t.parent().is(":visible") ? t.children(d).length || t.parent().is(h) ||(t = t.closest(d)): t = t.parents(d).add(t), s.options.showEffect) {
case "none": t.show();
break; case "show": t.show(s.options.showEffectSpeed);
break; case "slideDown": t.slideDown(s.options.showEffectSpeed);
break; case "fadeIn": t.fadeIn(s.options.showEffectSpeed);
break; default: t.show()
}
return t.parent().is(h) ? s.hide(e(d).not(t)): s.hide(e(d).not(t.closest(h).find(d).not(t.siblings()))), s
},
hide: function (e) {
var t = this; switch (t.options.hideEffect) {
case "none": e.hide();
break; case "hide": e.hide(t.options.hideEffectSpeed);
break; case "slideUp": e.slideUp(t.options.hideEffectSpeed);
break; case "fadeOut": e.fadeOut(t.options.hideEffectSpeed);
break; default: e.hide()
}
return t
},
_triggerShow: function (e, t) {
var s = this; return e.parent().is(h) || e.next().is(d) ? s.show(e.next(d), t): e.parent().is(d) && s.show(e.parent(), t), s
},
_addCSSClasses: function () {
return "jqueryui" === this.options.theme ?(this.focusClass = "ui-state-default", this.hoverClass = "ui-state-hover", this.element.addClass("ui-widget").find(".toc-title").addClass("ui-widget-header").end().find("li").addClass("ui-widget-content")): "bootstrap" === this.options.theme ?(this.element.find(h + "," + d).addClass("nav nav-list"), this.focusClass = "active"):(this.focusClass = o, this.hoverClass = n), this
},
setOption: function () {
e.Widget.prototype._setOption.apply(this, arguments)
},
setOptions: function () {
e.Widget.prototype._setOptions.apply(this, arguments)
},
_scrollTo: function (t) {
var s = this, i = s.options.smoothScroll || 0, o = s.options.scrollTo, n = e('div[data-unique="' + t.attr("data-unique") + '"]');
return n.length ?(e("html, body").promise().done(function () {
e("html, body").animate({
scrollTop: n.offset().top -(e.isFunction(o) ? o.call(): o) + "px"
}, {
duration: i
})
}), s): s
}
})
});
</script>
<!-- We do not need the tocify CSS because the asciidoc CSS already provides most of what we neeed -->
<style>
.tocify-header {
font-style: italic;
}
.tocify-subheader {
font-style: normal;
font-size: 90%;
}
.tocify ul {
margin: 0;
}
.tocify-focus {
color: #7a2518;
background-color: rgba(0, 0, 0, 0.1);
}
.tocify-focus > a {
color: #7a2518;
}
</style>
<script type="text/javascript">
$(function () {
// Add a new container for the tocify toc into the existing toc so we can re-use its
// styling
$("#toc").append("<div id='generated-toc'></div>");
$("#generated-toc").tocify({
extendPage: true,
context: "#content",
highlightOnScroll: true,
hideEffect: "slideUp",
// Use the IDs that asciidoc already provides so that TOC links and intra-document
// links are the same. Anything else might confuse users when they create bookmarks.
hashGenerator: function(text, element) {
return $(element).attr("id");
},
// Smooth scrolling doesn't work properly if we use the asciidoc IDs
smoothScroll: false,
// Set to 'none' to use the tocify classes
theme: "none",
// Handle book (may contain h1) and article (only h2 deeper)
selectors: $( "#content" ).has( "h1" ).size() > 0 ? "h1,h2,h3,h4,h5" : "h2,h3,h4,h5",
ignoreSelector: ".discrete"
});
// Switch between static asciidoc toc and dynamic tocify toc based on browser size
// This is set to match the media selectors in the asciidoc CSS
// Without this, we keep the dynamic toc even if it is moved from the side to preamble
// position which will cause odd scrolling behavior
var handleTocOnResize = function() {
if ($(document).width() < 768) {
$("#generated-toc").hide();
$(".sectlevel0").show();
$(".sectlevel1").show();
}
else {
$("#generated-toc").show();
$(".sectlevel0").hide();
$(".sectlevel1").hide();
}
}
$(window).resize(handleTocOnResize);
handleTocOnResize();
});
</script>