asciidoctor-tabs 1.0.0.beta.3 → 1.0.0.beta.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +17 -0
- data/README.adoc +1 -1
- data/data/css/tabs.css +18 -8
- data/data/js/tabs.js +28 -19
- data/lib/asciidoctor/tabs/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e73997158c47ea046d9c2016a25cac989e0f0e12e013bdc17f0c3cde8128e55f
|
4
|
+
data.tar.gz: 2dd6e9907c7c2498c1ff2226f25d00d654b872644063b02230882a2090f35e45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d530e0bb402fd7aa9346c5dc747efe5224436ef8d2e1fd4139a64fb84ed3f3c044069ba0fb807f12ecfe78104d6665395d979aeb1aac77465cef6bb831b1e0ad
|
7
|
+
data.tar.gz: c1c756f94280e8d70394c13abdfeb541f226b5eb39cfe86b514211781e5ab80bf1208e7faad6162db45571b26801ada288ae656143d074a7184ba40674afac32
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,23 @@
|
|
4
4
|
This document provides a curated view of the changes to Asciidoctor Tabs per release.
|
5
5
|
For a detailed view of what has changed, refer to the {url-repo}/commits/main[commit history] on GitHub.
|
6
6
|
|
7
|
+
== 1.0.0-beta.4 (2023-05-22) - @mojavelinux
|
8
|
+
|
9
|
+
=== Changed
|
10
|
+
|
11
|
+
* Rework styles for tab to make them compatible with a transition effect; stub in effect in built-in stylesheet
|
12
|
+
* Add tab class to tab element (if missing) rather than overwriting className property to preserve existing class names
|
13
|
+
|
14
|
+
=== Fixed
|
15
|
+
|
16
|
+
* Don't alter state of nested tabs when tab is selected (#55)
|
17
|
+
* Don't wrap tables inside nested tabs with tablecontainer div multiple times (#55)
|
18
|
+
* Fix fallback logic in behavior script when tab is missing ID or does not match a panel
|
19
|
+
|
20
|
+
=== Details
|
21
|
+
|
22
|
+
{url-repo}/releases/tag/v1.0.0-beta.4[git tag] | {url-repo}/compare/v1.0.0-beta.3\...v1.0.0-beta.4[full diff]
|
23
|
+
|
7
24
|
== 1.0.0-beta.3 (2023-02-01) - @mojavelinux
|
8
25
|
|
9
26
|
=== Added
|
data/README.adoc
CHANGED
data/data/css/tabs.css
CHANGED
@@ -35,6 +35,16 @@
|
|
35
35
|
margin-left: 0.25em;
|
36
36
|
}
|
37
37
|
|
38
|
+
.tabs .tablist li::after {
|
39
|
+
content: "";
|
40
|
+
display: block;
|
41
|
+
height: 1px;
|
42
|
+
position: absolute;
|
43
|
+
bottom: -1px;
|
44
|
+
left: 0;
|
45
|
+
right: 0;
|
46
|
+
}
|
47
|
+
|
38
48
|
.tabs.is-loading .tablist li:not(:first-child),
|
39
49
|
.tabs:not(.is-loading) .tablist li:not(.is-selected) {
|
40
50
|
background-color: #f5f5f5;
|
@@ -42,15 +52,15 @@
|
|
42
52
|
|
43
53
|
.tabs.is-loading .tablist li:first-child::after,
|
44
54
|
.tabs:not(.is-loading) .tablist li.is-selected::after {
|
45
|
-
background-color:
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
right: 0;
|
55
|
+
background-color: #fff;
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
.tabs:not(.is-loading) .tablist li,
|
60
|
+
.tabs:not(.is-loading) .tablist li::after {
|
61
|
+
transition: background-color 200ms ease-in-out;
|
53
62
|
}
|
63
|
+
*/
|
54
64
|
|
55
65
|
.tablist > ul p {
|
56
66
|
line-height: inherit;
|
data/data/js/tabs.js
CHANGED
@@ -12,30 +12,31 @@
|
|
12
12
|
var syncIds = tabs.classList.contains('is-sync') ? {} : undefined
|
13
13
|
var tablist = tabs.querySelector('.tablist ul')
|
14
14
|
tablist.setAttribute('role', 'tablist')
|
15
|
-
var
|
15
|
+
var start
|
16
16
|
forEach.call(tablist.querySelectorAll('li'), function (tab, idx) {
|
17
|
-
tab.
|
17
|
+
tab.tabIndex = -1
|
18
|
+
tab.setAttribute('role', tab.classList.add('tab') || 'tab')
|
18
19
|
var id, anchor, syncId
|
19
|
-
if (!(id = tab.id)) {
|
20
|
-
|
21
|
-
tab.id = id = anchor.parentNode.removeChild(anchor).id
|
20
|
+
if (!(id = tab.id) && (anchor = tab.querySelector('a[id]'))) {
|
21
|
+
id = tab.id = anchor.parentNode.removeChild(anchor).id
|
22
22
|
}
|
23
|
-
var panel = tabs.querySelector('.tabpanel[aria-labelledby~="' + id + '"]')
|
24
|
-
if (!panel) return // invalid state
|
25
|
-
tab.tabIndex = -1
|
23
|
+
var panel = id && tabs.querySelector('.tabpanel[aria-labelledby~="' + id + '"]')
|
24
|
+
if (!panel) return idx ? undefined : toggleSelected(tab, true) // invalid state
|
26
25
|
syncIds && (((syncId = tab.textContent.trim()) in syncIds) ? (syncId = undefined) : true) &&
|
27
26
|
(syncIds[(tab.dataset.syncId = syncId)] = tab)
|
28
|
-
idx || (
|
27
|
+
idx || (syncIds && (start = { tab: tab, panel: panel })) ? toggleHidden(panel, true) : toggleSelected(tab, true)
|
29
28
|
tab.setAttribute('aria-controls', panel.id)
|
30
29
|
panel.setAttribute('role', 'tabpanel')
|
31
|
-
forEach.call(panel.querySelectorAll('table.tableblock'), function (table) {
|
32
|
-
var container = Object.assign(document.createElement('div'), { className: 'tablecontainer' })
|
33
|
-
table.parentNode.insertBefore(container, table).appendChild(table)
|
34
|
-
})
|
35
30
|
var onClick = syncId === undefined ? activateTab : activateTabSync
|
36
31
|
tab.addEventListener('click', onClick.bind({ tabs: tabs, tab: tab, panel: panel }))
|
37
32
|
})
|
38
|
-
if (
|
33
|
+
if (!tabs.closest('.tabpanel')) {
|
34
|
+
forEach.call(tabs.querySelectorAll('.tabpanel table.tableblock'), function (table) {
|
35
|
+
var container = Object.assign(document.createElement('div'), { className: 'tablecontainer' })
|
36
|
+
table.parentNode.insertBefore(container, table).appendChild(table)
|
37
|
+
})
|
38
|
+
}
|
39
|
+
if (start) {
|
39
40
|
var syncGroupId
|
40
41
|
for (var i = 0, lst = tabs.classList, len = lst.length, className; i !== len; i++) {
|
41
42
|
if (!(className = lst.item(i)).startsWith('data-sync-group-id=')) continue
|
@@ -46,8 +47,8 @@
|
|
46
47
|
var preferredSyncId = 'syncStorageKey' in config &&
|
47
48
|
window[(config.syncStorageScope || 'local') + 'Storage'].getItem(config.syncStorageKey + '-' + syncGroupId)
|
48
49
|
var tab = preferredSyncId && syncIds[preferredSyncId]
|
49
|
-
tab && Object.assign(
|
50
|
-
toggleSelected(
|
50
|
+
tab && Object.assign(start, { tab: tab, panel: document.getElementById(tab.getAttribute('aria-controls')) })
|
51
|
+
toggleSelected(start.tab, true) || toggleHidden(start.panel, false)
|
51
52
|
}
|
52
53
|
})
|
53
54
|
onHashChange()
|
@@ -60,10 +61,10 @@
|
|
60
61
|
var tab = this.tab
|
61
62
|
var tabs = this.tabs || (this.tabs = tab.closest('.tabs'))
|
62
63
|
var panel = this.panel || (this.panel = document.getElementById(tab.getAttribute('aria-controls')))
|
63
|
-
|
64
|
+
querySelectorWithSiblings(tabs, '.tablist .tab', 'tab').forEach(function (el) {
|
64
65
|
toggleSelected(el, el === tab)
|
65
66
|
})
|
66
|
-
|
67
|
+
querySelectorWithSiblings(tabs, '.tabpanel', 'tabpanel').forEach(function (el) {
|
67
68
|
toggleHidden(el, el !== panel)
|
68
69
|
})
|
69
70
|
if (!this.isSync && 'syncStorageKey' in config && 'syncGroupId' in tabs.dataset) {
|
@@ -84,7 +85,7 @@
|
|
84
85
|
var initialY = thisTabs.getBoundingClientRect().y
|
85
86
|
forEach.call(document.querySelectorAll('.tabs'), function (tabs) {
|
86
87
|
if (tabs === thisTabs || tabs.dataset.syncGroupId !== thisTabs.dataset.syncGroupId) return
|
87
|
-
|
88
|
+
querySelectorWithSiblings(tabs, '.tablist .tab', 'tab').forEach(function (tab) {
|
88
89
|
if (tab.dataset.syncId === thisTab.dataset.syncId) activateTab.call({ tabs: tabs, tab: tab, isSync: true })
|
89
90
|
})
|
90
91
|
})
|
@@ -92,6 +93,14 @@
|
|
92
93
|
if (shiftedBy && (shiftedBy = Math.round(shiftedBy))) window.scrollBy({ top: shiftedBy, behavior: 'instant' })
|
93
94
|
}
|
94
95
|
|
96
|
+
function querySelectorWithSiblings (scope, selector, siblingClass) {
|
97
|
+
var el = scope.querySelector(selector)
|
98
|
+
if (!el) return []
|
99
|
+
var result = [el]
|
100
|
+
while ((el = el.nextElementSibling) && el.classList.contains(siblingClass)) result.push(el)
|
101
|
+
return result
|
102
|
+
}
|
103
|
+
|
95
104
|
function toggleClassOnEach (elements, className, method) {
|
96
105
|
forEach.call(elements, function (el) {
|
97
106
|
el.classList[method](className)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|