jekyll-theme-open-project 1.2.5 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/_nav-item.html +2 -1
- data/_layouts/docs-base.html +3 -0
- data/_layouts/product.html +3 -0
- data/_sass/open-project-mixins.scss +57 -6
- data/assets/js/adoc-toc.js +124 -0
- data/assets/js/anchor-scroll.js +81 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82039c5e0b7470495d92c3be14a95d13cfce792e2870a4f8a8750d2c5420352e
|
4
|
+
data.tar.gz: 9bc073983409ad7f531b9a98cf560615fddb746a3274ec89edfede271350dc90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e0bb94398bfa1112d58c8df0ee5b4974253cd3e3bc3e64fc192810244a65319571391c71a7b1c8ca1e24f147f8cc1f1d00bb6e43a2ba101b601923c5d0e6219
|
7
|
+
data.tar.gz: e04958a143f4bff3bdd185fd052a656f05380e8fb4c83aca8277c6c40406ed65a8f27392cfc201d5365c95d6d626a267db93bacedc899a604ff6b0c7fabc39f7
|
data/_includes/_nav-item.html
CHANGED
@@ -11,7 +11,8 @@
|
|
11
11
|
{% endif %}
|
12
12
|
|
13
13
|
<li class="item {% if selected %}selected{% endif %}">
|
14
|
-
<div class="item-title"
|
14
|
+
<div class="item-title"
|
15
|
+
title="{{ include.item.title }}{% if include.item.description %} ({{ include.item.description }}){% endif %}">
|
15
16
|
{% if include.item.path == null or selected == true %}
|
16
17
|
<span>
|
17
18
|
{{ include.item.title }}
|
data/_layouts/docs-base.html
CHANGED
data/_layouts/product.html
CHANGED
@@ -145,6 +145,15 @@
|
|
145
145
|
padding: .3em .6em;
|
146
146
|
}
|
147
147
|
|
148
|
+
h1, h2, h3, h4, h5, h6 {
|
149
|
+
&.highlighted {
|
150
|
+
&:before {
|
151
|
+
content: "→";
|
152
|
+
margin-right: .5em;
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
148
157
|
// Used for tip block labels
|
149
158
|
.admonitionblock {
|
150
159
|
overflow-x: scroll;
|
@@ -319,7 +328,7 @@
|
|
319
328
|
|
320
329
|
// New style: Nav with nested items
|
321
330
|
> ul.nav-items {
|
322
|
-
$sidePadding:
|
331
|
+
$sidePadding: 1em;
|
323
332
|
|
324
333
|
@include reset-list;
|
325
334
|
|
@@ -328,7 +337,7 @@
|
|
328
337
|
bottom: 0;
|
329
338
|
right: 0;
|
330
339
|
|
331
|
-
padding:
|
340
|
+
padding: .75em $sidePadding;
|
332
341
|
|
333
342
|
z-index: 5;
|
334
343
|
background: #f7f7f7;
|
@@ -350,7 +359,19 @@
|
|
350
359
|
font-size: 15px;
|
351
360
|
font-weight: normal;
|
352
361
|
|
362
|
+
> .item-title {
|
363
|
+
white-space: nowrap;
|
364
|
+
overflow: hidden;
|
365
|
+
text-overflow: ellipsis;
|
366
|
+
}
|
367
|
+
|
353
368
|
&.selected {
|
369
|
+
> .item-title {
|
370
|
+
background-color: #f0f0f0;
|
371
|
+
margin-left: -.5em;
|
372
|
+
padding-left: .5em;
|
373
|
+
}
|
374
|
+
|
354
375
|
span {
|
355
376
|
font-weight: bold;
|
356
377
|
color: $primary-dark-color;
|
@@ -362,13 +383,46 @@
|
|
362
383
|
> li.item {
|
363
384
|
> .item-title {
|
364
385
|
font-size: 20px;
|
365
|
-
font-weight: bold;
|
366
386
|
margin: 0;
|
367
387
|
line-height: 1.8;
|
368
388
|
}
|
369
389
|
> ul {
|
370
390
|
@include reset-list;
|
391
|
+
|
392
|
+
margin-left: .75em;
|
393
|
+
padding-left: 0;
|
371
394
|
line-height: 2;
|
395
|
+
margin-bottom: .5em;
|
396
|
+
}
|
397
|
+
|
398
|
+
ul {
|
399
|
+
margin-left: 1.25em;
|
400
|
+
padding-left: 0;
|
401
|
+
}
|
402
|
+
|
403
|
+
ul.in-page-toc {
|
404
|
+
padding: .25em .25em .25em 1em;
|
405
|
+
background-color: #f0f0f0;
|
406
|
+
|
407
|
+
margin-left: .75em;
|
408
|
+
|
409
|
+
&, ul {
|
410
|
+
list-style: none;
|
411
|
+
}
|
412
|
+
ul {
|
413
|
+
padding: 0;
|
414
|
+
}
|
415
|
+
li.item {
|
416
|
+
font-size: 13px;
|
417
|
+
line-height: 1.5;
|
418
|
+
|
419
|
+
&.highlighted > .item-title {
|
420
|
+
a:link, a:visited {
|
421
|
+
color: $primary-dark-color;
|
422
|
+
font-weight: bold;
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
372
426
|
}
|
373
427
|
}
|
374
428
|
}
|
@@ -517,9 +571,6 @@
|
|
517
571
|
|
518
572
|
.docs-nav {
|
519
573
|
.external-links {
|
520
|
-
margin-top: 1em;
|
521
|
-
margin-bottom: .5em;
|
522
|
-
|
523
574
|
> .nav-items > .item {
|
524
575
|
margin-bottom: 0;
|
525
576
|
margin-right: -$external-links-side-margin;
|
@@ -0,0 +1,124 @@
|
|
1
|
+
(function () {
|
2
|
+
|
3
|
+
const HEADER_TAGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
4
|
+
const IN_PAGE_NAV_HTML_CLASS = 'in-page-toc';
|
5
|
+
|
6
|
+
/* Given a container of AsciiDoc .sectN elementss,
|
7
|
+
* returns an object containing navigation structure like this:
|
8
|
+
* { items: [ { title: "Some title", path: "./#some-title", items: [ ...subitems ] }, ... }
|
9
|
+
* Works recursively through nested sections.
|
10
|
+
*/
|
11
|
+
function getAdocTocItems(containerEl, sectLvl) {
|
12
|
+
sectLvl = sectLvl || 1;
|
13
|
+
var items = [];
|
14
|
+
|
15
|
+
const topLevelSections = Array.from(containerEl.children).filter((el) => {
|
16
|
+
return el.matches(`div.sect${sectLvl}`);
|
17
|
+
});
|
18
|
+
|
19
|
+
for (let sectionEl of topLevelSections) {
|
20
|
+
const headerEl = Array.from(sectionEl.children).filter((el) => {
|
21
|
+
for (let hTagName of HEADER_TAGS) {
|
22
|
+
if (el.matches(hTagName)) { return true; }
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
})[0];
|
26
|
+
const headerId = headerEl.getAttribute('id');
|
27
|
+
|
28
|
+
var subItems = [];
|
29
|
+
const sectionBody = sectionEl.querySelector('div.sectionbody');
|
30
|
+
if (sectionBody) {
|
31
|
+
subItems = getAdocTocItems(sectionBody, sectLvl + 1);
|
32
|
+
} else {
|
33
|
+
subItems = getAdocTocItems(sectionEl, sectLvl + 1);
|
34
|
+
}
|
35
|
+
|
36
|
+
items.push({
|
37
|
+
title: headerEl.innerText,
|
38
|
+
description: headerEl.innerText,
|
39
|
+
path: `./#${headerId}`,
|
40
|
+
items: subItems,
|
41
|
+
|
42
|
+
id: headerId,
|
43
|
+
});
|
44
|
+
}
|
45
|
+
|
46
|
+
return items;
|
47
|
+
}
|
48
|
+
|
49
|
+
function highlightSelected(headerId, itemPath) {
|
50
|
+
for (const itemEl of document.querySelectorAll(`.${IN_PAGE_NAV_HTML_CLASS} li`)) {
|
51
|
+
const link = (itemEl.firstChild || {}).firstChild;
|
52
|
+
if (link && link.getAttribute('href') == itemPath) {
|
53
|
+
itemEl.classList.add('highlighted');
|
54
|
+
} else {
|
55
|
+
itemEl.classList.remove('highlighted');
|
56
|
+
}
|
57
|
+
}
|
58
|
+
for (const hTag of HEADER_TAGS) {
|
59
|
+
for (const headerEl of document.querySelectorAll(hTag)) {
|
60
|
+
headerEl.classList.remove('highlighted');
|
61
|
+
}
|
62
|
+
}
|
63
|
+
const selectedHeaderEl = document.getElementById(headerId);
|
64
|
+
selectedHeaderEl.classList.add('highlighted');
|
65
|
+
}
|
66
|
+
|
67
|
+
/* Given a list of navigation items, returns an <ul> containing items recursively
|
68
|
+
* with CSS classes and layout consistent with docs navigation markup expected by the theme.
|
69
|
+
*/
|
70
|
+
function formatSubItems(tocItems) {
|
71
|
+
const subItemContainer = document.createElement('ul');
|
72
|
+
|
73
|
+
subItemContainer.classList.add('nav-items');
|
74
|
+
subItemContainer.classList.add('subitems');
|
75
|
+
|
76
|
+
for (let item of tocItems) {
|
77
|
+
let itemEl, itemTitleEl, itemLinkEl;
|
78
|
+
|
79
|
+
itemEl = document.createElement('li');
|
80
|
+
itemEl.classList.add('item');
|
81
|
+
|
82
|
+
itemTitleEl = document.createElement('div');
|
83
|
+
itemTitleEl.classList.add('item-title');
|
84
|
+
|
85
|
+
itemLinkEl = document.createElement('a');
|
86
|
+
itemLinkEl.setAttribute('href', item.path);
|
87
|
+
itemLinkEl.setAttribute('title', item.title);
|
88
|
+
itemLinkEl.innerText = item.title;
|
89
|
+
|
90
|
+
itemTitleEl.appendChild(itemLinkEl);
|
91
|
+
itemEl.appendChild(itemTitleEl);
|
92
|
+
|
93
|
+
if (item.items.length > 0) {
|
94
|
+
itemEl.appendChild(formatSubItems(item.items));
|
95
|
+
}
|
96
|
+
|
97
|
+
itemLinkEl.addEventListener('click', () => highlightSelected(item.id, item.path));
|
98
|
+
|
99
|
+
subItemContainer.appendChild(itemEl);
|
100
|
+
}
|
101
|
+
|
102
|
+
return subItemContainer;
|
103
|
+
}
|
104
|
+
|
105
|
+
const articleBody = document.querySelector('main section article .body');
|
106
|
+
const selectedItem = document.querySelector('main .docs-nav .nav-items .item.selected');
|
107
|
+
|
108
|
+
if (articleBody && selectedItem) {
|
109
|
+
const items = getAdocTocItems(articleBody);
|
110
|
+
|
111
|
+
if (items.length > 0) {
|
112
|
+
const ulEl = formatSubItems(items);
|
113
|
+
ulEl.classList.add(IN_PAGE_NAV_HTML_CLASS);
|
114
|
+
|
115
|
+
const existingSubItems = selectedItem.querySelector('ul.nav-items');
|
116
|
+
if (existingSubItems) {
|
117
|
+
selectedItem.insertBefore(ulEl, existingSubItems);
|
118
|
+
} else {
|
119
|
+
selectedItem.appendChild(ulEl);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
}());
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* Credit: Ian Clark https://stackoverflow.com/a/13067009/247441 */
|
2
|
+
|
3
|
+
(function(document, history, location) {
|
4
|
+
var HISTORY_SUPPORT = !!(history && history.pushState);
|
5
|
+
|
6
|
+
var anchorScrolls = {
|
7
|
+
ANCHOR_REGEX: /^#[^ ]+$/,
|
8
|
+
OFFSET_HEIGHT_PX: 150, // Roughly Metanorma’s header
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Establish events, and fix initial scroll position if a hash is provided.
|
12
|
+
*/
|
13
|
+
init: function() {
|
14
|
+
this.scrollToCurrent();
|
15
|
+
window.addEventListener('hashchange', this.scrollToCurrent.bind(this));
|
16
|
+
document.body.addEventListener('click', this.delegateAnchors.bind(this));
|
17
|
+
},
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Return the offset amount to deduct from the normal scroll position.
|
21
|
+
* Modify as appropriate to allow for dynamic calculations
|
22
|
+
*/
|
23
|
+
getFixedOffset: function() {
|
24
|
+
return this.OFFSET_HEIGHT_PX;
|
25
|
+
},
|
26
|
+
|
27
|
+
/**
|
28
|
+
* If the provided href is an anchor which resolves to an element on the
|
29
|
+
* page, scroll to it.
|
30
|
+
* @param {String} href
|
31
|
+
* @return {Boolean} - Was the href an anchor.
|
32
|
+
*/
|
33
|
+
scrollIfAnchor: function(href, pushToHistory) {
|
34
|
+
var match, rect, anchorOffset;
|
35
|
+
|
36
|
+
if(!this.ANCHOR_REGEX.test(href)) {
|
37
|
+
return false;
|
38
|
+
}
|
39
|
+
|
40
|
+
match = document.getElementById(href.slice(1));
|
41
|
+
|
42
|
+
if(match) {
|
43
|
+
rect = match.getBoundingClientRect();
|
44
|
+
anchorOffset = window.pageYOffset + rect.top - this.getFixedOffset();
|
45
|
+
window.scrollTo(window.pageXOffset, anchorOffset);
|
46
|
+
|
47
|
+
// Add the state to history as-per normal anchor links
|
48
|
+
if(HISTORY_SUPPORT && pushToHistory) {
|
49
|
+
history.pushState({}, document.title, location.pathname + href);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
return !!match;
|
54
|
+
},
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Attempt to scroll to the current location's hash.
|
58
|
+
*/
|
59
|
+
scrollToCurrent: function() {
|
60
|
+
this.scrollIfAnchor(window.location.hash);
|
61
|
+
},
|
62
|
+
|
63
|
+
/**
|
64
|
+
* If the click event's target was an anchor, fix the scroll position.
|
65
|
+
*/
|
66
|
+
delegateAnchors: function(e) {
|
67
|
+
var elem = e.target;
|
68
|
+
|
69
|
+
if(
|
70
|
+
elem.nodeName === 'A' &&
|
71
|
+
this.scrollIfAnchor(elem.getAttribute('href'), true)
|
72
|
+
) {
|
73
|
+
e.preventDefault();
|
74
|
+
}
|
75
|
+
}
|
76
|
+
};
|
77
|
+
|
78
|
+
window.addEventListener(
|
79
|
+
'DOMContentLoaded', anchorScrolls.init.bind(anchorScrolls)
|
80
|
+
);
|
81
|
+
})(window.document, window.history, window.location);
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-theme-open-project
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: '1.3'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: bundler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +208,8 @@ files:
|
|
208
208
|
- assets/fa/fa-solid.js
|
209
209
|
- assets/fa/fontawesome.js
|
210
210
|
- assets/img/external-link.svg
|
211
|
+
- assets/js/adoc-toc.js
|
212
|
+
- assets/js/anchor-scroll.js
|
211
213
|
- assets/js/headroom.min.js
|
212
214
|
- assets/js/opf.js
|
213
215
|
homepage: https://github.com/riboseinc/jekyll-theme-open-project/
|