just-the-docs 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/_includes/css/custom.scss.liquid +1 -0
- data/_includes/css/just-the-docs.scss.liquid +7 -0
- data/_includes/head.html +19 -13
- data/_includes/head_custom.html +0 -0
- data/_includes/js/custom.js +0 -0
- data/_includes/nav.html +55 -44
- data/_includes/title.html +5 -0
- data/_includes/vendor/anchor_headings.html +100 -0
- data/_layouts/default.html +146 -55
- data/_layouts/table_wrappers.html +7 -0
- data/_layouts/vendor/compress.html +10 -0
- data/_sass/base.scss +16 -18
- data/_sass/buttons.scss +1 -1
- data/_sass/code.scss +211 -72
- data/_sass/color_schemes/dark.scss +4 -1
- data/_sass/color_schemes/light.scss +0 -0
- data/_sass/content.scss +80 -1
- data/_sass/custom/custom.scss +0 -120
- data/_sass/labels.scss +5 -4
- data/_sass/layout.scss +118 -62
- data/_sass/modules.scss +20 -0
- data/_sass/navigation.scss +125 -77
- data/_sass/print.scss +40 -0
- data/_sass/search.scss +263 -56
- data/_sass/support/_functions.scss +2 -3
- data/_sass/support/_variables.scss +27 -22
- data/_sass/support/mixins/_layout.scss +1 -3
- data/_sass/support/mixins/_typography.scss +6 -1
- data/_sass/tables.scss +13 -33
- data/_sass/typography.scss +9 -7
- data/_sass/utilities/_layout.scss +74 -17
- data/_sass/utilities/_lists.scss +7 -1
- data/_sass/utilities/_spacing.scss +69 -25
- data/assets/css/just-the-docs-dark.scss +3 -0
- data/assets/css/just-the-docs-default.scss +8 -0
- data/assets/css/just-the-docs-light.scss +3 -0
- data/assets/js/just-the-docs.js +425 -130
- data/assets/js/vendor/lunr.min.js +3 -3
- data/assets/js/zzzz-search-data.json +58 -0
- data/lib/tasks/search.rake +54 -9
- metadata +43 -26
- data/assets/css/dark-mode-preview.scss +0 -41
- data/assets/css/just-the-docs.scss +0 -44
- data/assets/js/search-data.json +0 -12
data/assets/js/just-the-docs.js
CHANGED
@@ -1,176 +1,471 @@
|
|
1
|
+
---
|
2
|
+
---
|
3
|
+
(function (jtd, undefined) {
|
4
|
+
|
1
5
|
// Event handling
|
2
6
|
|
3
|
-
function
|
4
|
-
|
7
|
+
jtd.addEvent = function(el, type, handler) {
|
8
|
+
if (el.attachEvent) el.attachEvent('on'+type, handler); else el.addEventListener(type, handler);
|
5
9
|
}
|
6
|
-
function
|
7
|
-
|
10
|
+
jtd.removeEvent = function(el, type, handler) {
|
11
|
+
if (el.detachEvent) el.detachEvent('on'+type, handler); else el.removeEventListener(type, handler);
|
8
12
|
}
|
9
|
-
|
10
|
-
//
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
addEvent(navTrigger, 'click', function(){
|
19
|
-
var text = navTrigger.innerText;
|
20
|
-
var textToggle = navTrigger.getAttribute('data-text-toggle');
|
21
|
-
|
22
|
-
nav.classList.toggle('nav-open');
|
23
|
-
auxNav.classList.toggle('nav-open');
|
24
|
-
navTrigger.classList.toggle('nav-open');
|
25
|
-
search.classList.toggle('nav-open');
|
26
|
-
navTrigger.innerText = textToggle;
|
27
|
-
navTrigger.setAttribute('data-text-toggle', text);
|
28
|
-
textToggle = text;
|
29
|
-
})
|
13
|
+
jtd.onReady = function(ready) {
|
14
|
+
// in case the document is already rendered
|
15
|
+
if (document.readyState!='loading') ready();
|
16
|
+
// modern browsers
|
17
|
+
else if (document.addEventListener) document.addEventListener('DOMContentLoaded', ready);
|
18
|
+
// IE <= 8
|
19
|
+
else document.attachEvent('onreadystatechange', function(){
|
20
|
+
if (document.readyState=='complete') ready();
|
21
|
+
});
|
30
22
|
}
|
31
23
|
|
32
|
-
//
|
24
|
+
// Show/hide mobile menu
|
33
25
|
|
34
|
-
function
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
26
|
+
function initNav() {
|
27
|
+
jtd.addEvent(document, 'click', function(e){
|
28
|
+
var target = e.target;
|
29
|
+
while (target && !(target.classList && target.classList.contains('nav-list-expander'))) {
|
30
|
+
target = target.parentNode;
|
31
|
+
}
|
32
|
+
if (target) {
|
33
|
+
e.preventDefault();
|
34
|
+
target.parentNode.classList.toggle('active');
|
35
|
+
}
|
40
36
|
});
|
41
37
|
|
42
|
-
|
38
|
+
const siteNav = document.getElementById('site-nav');
|
39
|
+
const mainHeader = document.getElementById('main-header');
|
40
|
+
const menuButton = document.getElementById('menu-button');
|
41
|
+
|
42
|
+
jtd.addEvent(menuButton, 'click', function(e){
|
43
|
+
e.preventDefault();
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
if (menuButton.classList.toggle('nav-open')) {
|
46
|
+
siteNav.classList.add('nav-open');
|
47
|
+
mainHeader.classList.add('nav-open');
|
48
|
+
} else {
|
49
|
+
siteNav.classList.remove('nav-open');
|
50
|
+
mainHeader.classList.remove('nav-open');
|
51
|
+
}
|
52
|
+
});
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
{%- if site.search_enabled != false and site.search.button %}
|
55
|
+
const searchInput = document.getElementById('search-input');
|
56
|
+
const searchButton = document.getElementById('search-button');
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
}
|
58
|
+
jtd.addEvent(searchButton, 'click', function(e){
|
59
|
+
e.preventDefault();
|
54
60
|
|
55
|
-
|
61
|
+
mainHeader.classList.add('nav-open');
|
62
|
+
searchInput.focus();
|
63
|
+
});
|
64
|
+
{%- endif %}
|
65
|
+
}
|
56
66
|
|
57
|
-
|
67
|
+
{%- if site.search_enabled != false %}
|
68
|
+
// Site search
|
58
69
|
|
70
|
+
function initSearch() {
|
59
71
|
var request = new XMLHttpRequest();
|
60
|
-
request.open('GET',
|
72
|
+
request.open('GET', '{{ "assets/js/search-data.json" | absolute_url }}', true);
|
61
73
|
|
62
|
-
request.onload = function()
|
74
|
+
request.onload = function(){
|
63
75
|
if (request.status >= 200 && request.status < 400) {
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
}
|
75
|
-
|
76
|
-
|
76
|
+
var docs = JSON.parse(request.responseText);
|
77
|
+
|
78
|
+
lunr.tokenizer.separator = {{ site.search.tokenizer_separator | default: site.search_tokenizer_separator | default: "/[\s\-/]+/" }}
|
79
|
+
|
80
|
+
var index = lunr(function(){
|
81
|
+
this.ref('id');
|
82
|
+
this.field('title', { boost: 200 });
|
83
|
+
this.field('content', { boost: 2 });
|
84
|
+
{%- if site.search.rel_url != false %}
|
85
|
+
this.field('relUrl');
|
86
|
+
{%- endif %}
|
87
|
+
this.metadataWhitelist = ['position']
|
88
|
+
|
89
|
+
for (var i in docs) {
|
90
|
+
this.add({
|
91
|
+
id: i,
|
92
|
+
title: docs[i].title,
|
93
|
+
content: docs[i].content,
|
94
|
+
{%- if site.search.rel_url != false %}
|
95
|
+
relUrl: docs[i].relUrl
|
96
|
+
{%- endif %}
|
97
|
+
});
|
98
|
+
}
|
99
|
+
});
|
100
|
+
|
101
|
+
searchLoaded(index, docs);
|
77
102
|
} else {
|
78
|
-
// We reached our target server, but it returned an error
|
79
103
|
console.log('Error loading ajax request. Request status:' + request.status);
|
80
104
|
}
|
81
105
|
};
|
82
106
|
|
83
|
-
request.onerror = function()
|
84
|
-
// There was a connection error of some sort
|
107
|
+
request.onerror = function(){
|
85
108
|
console.log('There was a connection error');
|
86
109
|
};
|
87
110
|
|
88
111
|
request.send();
|
112
|
+
}
|
89
113
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
114
|
+
function searchLoaded(index, docs) {
|
115
|
+
var index = index;
|
116
|
+
var docs = docs;
|
117
|
+
var searchInput = document.getElementById('search-input');
|
118
|
+
var searchResults = document.getElementById('search-results');
|
119
|
+
var mainHeader = document.getElementById('main-header');
|
120
|
+
var currentInput;
|
121
|
+
var currentSearchIndex = 0;
|
122
|
+
|
123
|
+
function showSearch() {
|
124
|
+
document.documentElement.classList.add('search-active');
|
125
|
+
}
|
126
|
+
|
127
|
+
function hideSearch() {
|
128
|
+
document.documentElement.classList.remove('search-active');
|
129
|
+
}
|
130
|
+
|
131
|
+
function update() {
|
132
|
+
currentSearchIndex++;
|
133
|
+
|
134
|
+
var input = searchInput.value;
|
135
|
+
if (input === '') {
|
136
|
+
hideSearch();
|
137
|
+
} else {
|
138
|
+
showSearch();
|
139
|
+
// scroll search input into view, workaround for iOS Safari
|
140
|
+
window.scroll(0, -1);
|
141
|
+
setTimeout(function(){ window.scroll(0, 0); }, 0);
|
142
|
+
}
|
143
|
+
if (input === currentInput) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
currentInput = input;
|
147
|
+
searchResults.innerHTML = '';
|
148
|
+
if (input === '') {
|
149
|
+
return;
|
150
|
+
}
|
94
151
|
|
95
|
-
function
|
96
|
-
|
97
|
-
|
152
|
+
var results = index.query(function (query) {
|
153
|
+
var tokens = lunr.tokenizer(input)
|
154
|
+
query.term(tokens, {
|
155
|
+
boost: 10
|
156
|
+
});
|
157
|
+
query.term(tokens, {
|
158
|
+
wildcard: lunr.Query.wildcard.TRAILING
|
159
|
+
});
|
160
|
+
});
|
161
|
+
|
162
|
+
if ((results.length == 0) && (input.length > 2)) {
|
163
|
+
var tokens = lunr.tokenizer(input).filter(function(token, i) {
|
164
|
+
return token.str.length < 20;
|
165
|
+
})
|
166
|
+
if (tokens.length > 0) {
|
167
|
+
results = index.query(function (query) {
|
168
|
+
query.term(tokens, {
|
169
|
+
editDistance: Math.round(Math.sqrt(input.length / 2 - 1))
|
170
|
+
});
|
171
|
+
});
|
172
|
+
}
|
173
|
+
}
|
174
|
+
|
175
|
+
if (results.length == 0) {
|
176
|
+
var noResultsDiv = document.createElement('div');
|
177
|
+
noResultsDiv.classList.add('search-no-result');
|
178
|
+
noResultsDiv.innerText = 'No results found';
|
179
|
+
searchResults.appendChild(noResultsDiv);
|
180
|
+
|
181
|
+
} else {
|
182
|
+
var resultsList = document.createElement('ul');
|
183
|
+
resultsList.classList.add('search-results-list');
|
184
|
+
searchResults.appendChild(resultsList);
|
185
|
+
|
186
|
+
addResults(resultsList, results, 0, 10, 100, currentSearchIndex);
|
187
|
+
}
|
188
|
+
|
189
|
+
function addResults(resultsList, results, start, batchSize, batchMillis, searchIndex) {
|
190
|
+
if (searchIndex != currentSearchIndex) {
|
191
|
+
return;
|
192
|
+
}
|
193
|
+
for (var i = start; i < (start + batchSize); i++) {
|
194
|
+
if (i == results.length) {
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
addResult(resultsList, results[i]);
|
198
|
+
}
|
199
|
+
setTimeout(function() {
|
200
|
+
addResults(resultsList, results, start + batchSize, batchSize, batchMillis, searchIndex);
|
201
|
+
}, batchMillis);
|
98
202
|
}
|
99
203
|
|
100
|
-
|
101
|
-
var
|
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
|
-
|
204
|
+
function addResult(resultsList, result) {
|
205
|
+
var doc = docs[result.ref];
|
206
|
+
|
207
|
+
var resultsListItem = document.createElement('li');
|
208
|
+
resultsListItem.classList.add('search-results-list-item');
|
209
|
+
resultsList.appendChild(resultsListItem);
|
210
|
+
|
211
|
+
var resultLink = document.createElement('a');
|
212
|
+
resultLink.classList.add('search-result');
|
213
|
+
resultLink.setAttribute('href', doc.url);
|
214
|
+
resultsListItem.appendChild(resultLink);
|
215
|
+
|
216
|
+
var resultTitle = document.createElement('div');
|
217
|
+
resultTitle.classList.add('search-result-title');
|
218
|
+
resultLink.appendChild(resultTitle);
|
219
|
+
|
220
|
+
var resultDoc = document.createElement('div');
|
221
|
+
resultDoc.classList.add('search-result-doc');
|
222
|
+
resultDoc.innerHTML = '<svg viewBox="0 0 24 24" class="search-result-icon"><use xlink:href="#svg-doc"></use></svg>';
|
223
|
+
resultTitle.appendChild(resultDoc);
|
224
|
+
|
225
|
+
var resultDocTitle = document.createElement('div');
|
226
|
+
resultDocTitle.classList.add('search-result-doc-title');
|
227
|
+
resultDocTitle.innerHTML = doc.doc;
|
228
|
+
resultDoc.appendChild(resultDocTitle);
|
229
|
+
var resultDocOrSection = resultDocTitle;
|
230
|
+
|
231
|
+
if (doc.doc != doc.title) {
|
232
|
+
resultDoc.classList.add('search-result-doc-parent');
|
233
|
+
var resultSection = document.createElement('div');
|
234
|
+
resultSection.classList.add('search-result-section');
|
235
|
+
resultSection.innerHTML = doc.title;
|
236
|
+
resultTitle.appendChild(resultSection);
|
237
|
+
resultDocOrSection = resultSection;
|
238
|
+
}
|
239
|
+
|
240
|
+
var metadata = result.matchData.metadata;
|
241
|
+
var titlePositions = [];
|
242
|
+
var contentPositions = [];
|
243
|
+
for (var j in metadata) {
|
244
|
+
var meta = metadata[j];
|
245
|
+
if (meta.title) {
|
246
|
+
var positions = meta.title.position;
|
247
|
+
for (var k in positions) {
|
248
|
+
titlePositions.push(positions[k]);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
if (meta.content) {
|
252
|
+
var positions = meta.content.position;
|
253
|
+
for (var k in positions) {
|
254
|
+
var position = positions[k];
|
255
|
+
var previewStart = position[0];
|
256
|
+
var previewEnd = position[0] + position[1];
|
257
|
+
var ellipsesBefore = true;
|
258
|
+
var ellipsesAfter = true;
|
259
|
+
for (var k = 0; k < {{ site.search.preview_words_before | default: 5 }}; k++) {
|
260
|
+
var nextSpace = doc.content.lastIndexOf(' ', previewStart - 2);
|
261
|
+
var nextDot = doc.content.lastIndexOf('. ', previewStart - 2);
|
262
|
+
if ((nextDot >= 0) && (nextDot > nextSpace)) {
|
263
|
+
previewStart = nextDot + 1;
|
264
|
+
ellipsesBefore = false;
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
if (nextSpace < 0) {
|
268
|
+
previewStart = 0;
|
269
|
+
ellipsesBefore = false;
|
270
|
+
break;
|
271
|
+
}
|
272
|
+
previewStart = nextSpace + 1;
|
273
|
+
}
|
274
|
+
for (var k = 0; k < {{ site.search.preview_words_after | default: 10 }}; k++) {
|
275
|
+
var nextSpace = doc.content.indexOf(' ', previewEnd + 1);
|
276
|
+
var nextDot = doc.content.indexOf('. ', previewEnd + 1);
|
277
|
+
if ((nextDot >= 0) && (nextDot < nextSpace)) {
|
278
|
+
previewEnd = nextDot;
|
279
|
+
ellipsesAfter = false;
|
280
|
+
break;
|
281
|
+
}
|
282
|
+
if (nextSpace < 0) {
|
283
|
+
previewEnd = doc.content.length;
|
284
|
+
ellipsesAfter = false;
|
285
|
+
break;
|
286
|
+
}
|
287
|
+
previewEnd = nextSpace;
|
288
|
+
}
|
289
|
+
contentPositions.push({
|
290
|
+
highlight: position,
|
291
|
+
previewStart: previewStart, previewEnd: previewEnd,
|
292
|
+
ellipsesBefore: ellipsesBefore, ellipsesAfter: ellipsesAfter
|
293
|
+
});
|
136
294
|
}
|
137
295
|
}
|
296
|
+
}
|
297
|
+
|
298
|
+
if (titlePositions.length > 0) {
|
299
|
+
titlePositions.sort(function(p1, p2){ return p1[0] - p2[0] });
|
300
|
+
resultDocOrSection.innerHTML = '';
|
301
|
+
addHighlightedText(resultDocOrSection, doc.title, 0, doc.title.length, titlePositions);
|
302
|
+
}
|
138
303
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
304
|
+
if (contentPositions.length > 0) {
|
305
|
+
contentPositions.sort(function(p1, p2){ return p1.highlight[0] - p2.highlight[0] });
|
306
|
+
var contentPosition = contentPositions[0];
|
307
|
+
var previewPosition = {
|
308
|
+
highlight: [contentPosition.highlight],
|
309
|
+
previewStart: contentPosition.previewStart, previewEnd: contentPosition.previewEnd,
|
310
|
+
ellipsesBefore: contentPosition.ellipsesBefore, ellipsesAfter: contentPosition.ellipsesAfter
|
311
|
+
};
|
312
|
+
var previewPositions = [previewPosition];
|
313
|
+
for (var j = 1; j < contentPositions.length; j++) {
|
314
|
+
contentPosition = contentPositions[j];
|
315
|
+
if (previewPosition.previewEnd < contentPosition.previewStart) {
|
316
|
+
previewPosition = {
|
317
|
+
highlight: [contentPosition.highlight],
|
318
|
+
previewStart: contentPosition.previewStart, previewEnd: contentPosition.previewEnd,
|
319
|
+
ellipsesBefore: contentPosition.ellipsesBefore, ellipsesAfter: contentPosition.ellipsesAfter
|
320
|
+
}
|
321
|
+
previewPositions.push(previewPosition);
|
322
|
+
} else {
|
323
|
+
previewPosition.highlight.push(contentPosition.highlight);
|
324
|
+
previewPosition.previewEnd = contentPosition.previewEnd;
|
325
|
+
previewPosition.ellipsesAfter = contentPosition.ellipsesAfter;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
var resultPreviews = document.createElement('div');
|
330
|
+
resultPreviews.classList.add('search-result-previews');
|
331
|
+
resultLink.appendChild(resultPreviews);
|
332
|
+
|
333
|
+
var content = doc.content;
|
334
|
+
for (var j = 0; j < Math.min(previewPositions.length, {{ site.search.previews | default: 3 }}); j++) {
|
335
|
+
var position = previewPositions[j];
|
336
|
+
|
337
|
+
var resultPreview = document.createElement('div');
|
338
|
+
resultPreview.classList.add('search-result-preview');
|
339
|
+
resultPreviews.appendChild(resultPreview);
|
340
|
+
|
341
|
+
if (position.ellipsesBefore) {
|
342
|
+
resultPreview.appendChild(document.createTextNode('... '));
|
343
|
+
}
|
344
|
+
addHighlightedText(resultPreview, content, position.previewStart, position.previewEnd, position.highlight);
|
345
|
+
if (position.ellipsesAfter) {
|
346
|
+
resultPreview.appendChild(document.createTextNode(' ...'));
|
347
|
+
}
|
143
348
|
}
|
144
349
|
}
|
145
|
-
});
|
146
350
|
|
147
|
-
|
148
|
-
|
149
|
-
|
351
|
+
{%- if site.search.rel_url != false %}
|
352
|
+
var resultRelUrl = document.createElement('span');
|
353
|
+
resultRelUrl.classList.add('search-result-rel-url');
|
354
|
+
resultRelUrl.innerText = doc.relUrl;
|
355
|
+
resultTitle.appendChild(resultRelUrl);
|
356
|
+
{%- endif %}
|
357
|
+
}
|
358
|
+
|
359
|
+
function addHighlightedText(parent, text, start, end, positions) {
|
360
|
+
var index = start;
|
361
|
+
for (var i in positions) {
|
362
|
+
var position = positions[i];
|
363
|
+
var span = document.createElement('span');
|
364
|
+
span.innerHTML = text.substring(index, position[0]);
|
365
|
+
parent.appendChild(span);
|
366
|
+
index = position[0] + position[1];
|
367
|
+
var highlight = document.createElement('span');
|
368
|
+
highlight.classList.add('search-result-highlight');
|
369
|
+
highlight.innerHTML = text.substring(position[0], index);
|
370
|
+
parent.appendChild(highlight);
|
371
|
+
}
|
372
|
+
var span = document.createElement('span');
|
373
|
+
span.innerHTML = text.substring(index, end);
|
374
|
+
parent.appendChild(span);
|
375
|
+
}
|
150
376
|
}
|
151
|
-
}
|
152
377
|
|
153
|
-
function
|
154
|
-
|
155
|
-
|
378
|
+
jtd.addEvent(searchInput, 'focus', function(){
|
379
|
+
setTimeout(update, 0);
|
380
|
+
});
|
381
|
+
|
382
|
+
jtd.addEvent(searchInput, 'keyup', function(e){
|
383
|
+
switch (e.keyCode) {
|
384
|
+
case 27: // When esc key is pressed, hide the results and clear the field
|
385
|
+
searchInput.value = '';
|
386
|
+
break;
|
387
|
+
case 38: // arrow up
|
388
|
+
case 40: // arrow down
|
389
|
+
case 13: // enter
|
390
|
+
e.preventDefault();
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
update();
|
394
|
+
});
|
395
|
+
|
396
|
+
jtd.addEvent(searchInput, 'keydown', function(e){
|
397
|
+
switch (e.keyCode) {
|
398
|
+
case 38: // arrow up
|
399
|
+
e.preventDefault();
|
400
|
+
var active = document.querySelector('.search-result.active');
|
401
|
+
if (active) {
|
402
|
+
active.classList.remove('active');
|
403
|
+
if (active.parentElement.previousSibling) {
|
404
|
+
var previous = active.parentElement.previousSibling.querySelector('.search-result');
|
405
|
+
previous.classList.add('active');
|
406
|
+
}
|
407
|
+
}
|
408
|
+
return;
|
409
|
+
case 40: // arrow down
|
410
|
+
e.preventDefault();
|
411
|
+
var active = document.querySelector('.search-result.active');
|
412
|
+
if (active) {
|
413
|
+
if (active.parentElement.nextSibling) {
|
414
|
+
var next = active.parentElement.nextSibling.querySelector('.search-result');
|
415
|
+
active.classList.remove('active');
|
416
|
+
next.classList.add('active');
|
417
|
+
}
|
418
|
+
} else {
|
419
|
+
var next = document.querySelector('.search-result');
|
420
|
+
if (next) {
|
421
|
+
next.classList.add('active');
|
422
|
+
}
|
423
|
+
}
|
424
|
+
return;
|
425
|
+
case 13: // enter
|
426
|
+
e.preventDefault();
|
427
|
+
var active = document.querySelector('.search-result.active');
|
428
|
+
if (active) {
|
429
|
+
active.click();
|
430
|
+
} else {
|
431
|
+
var first = document.querySelector('.search-result');
|
432
|
+
if (first) {
|
433
|
+
first.click();
|
434
|
+
}
|
435
|
+
}
|
436
|
+
return;
|
437
|
+
}
|
438
|
+
});
|
439
|
+
|
440
|
+
jtd.addEvent(document, 'click', function(e){
|
441
|
+
if (e.target != searchInput) {
|
442
|
+
hideSearch();
|
443
|
+
}
|
444
|
+
});
|
156
445
|
}
|
446
|
+
{%- endif %}
|
157
447
|
|
448
|
+
// Switch theme
|
158
449
|
|
159
|
-
|
450
|
+
jtd.getTheme = function() {
|
451
|
+
var cssFileHref = document.querySelector('[rel="stylesheet"]').getAttribute('href');
|
452
|
+
return cssFileHref.substring(cssFileHref.lastIndexOf('-') + 1, cssFileHref.length - 4);
|
453
|
+
}
|
160
454
|
|
161
|
-
function
|
162
|
-
|
163
|
-
|
164
|
-
if (typeof lunr !== 'undefined') {
|
165
|
-
initSearch();
|
166
|
-
}
|
455
|
+
jtd.setTheme = function(theme) {
|
456
|
+
var cssFile = document.querySelector('[rel="stylesheet"]');
|
457
|
+
cssFile.setAttribute('href', '{{ "assets/css/just-the-docs-" | absolute_url }}' + theme + '.css');
|
167
458
|
}
|
168
459
|
|
169
|
-
//
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
460
|
+
// Document ready
|
461
|
+
|
462
|
+
jtd.onReady(function(){
|
463
|
+
initNav();
|
464
|
+
{%- if site.search_enabled != false %}
|
465
|
+
initSearch();
|
466
|
+
{%- endif %}
|
176
467
|
});
|
468
|
+
|
469
|
+
})(window.jtd = window.jtd || {});
|
470
|
+
|
471
|
+
{% include js/custom.js %}
|