asciidoctor-tabs 1.0.0.beta.1 → 1.0.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +15 -0
- data/README.adoc +5 -2
- data/data/css/tabs.css +4 -0
- data/data/js/tabs.js +25 -17
- data/lib/asciidoctor/tabs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0a17ea54a3c9b7c4c8e152b8cb6c80e4aceb4e7aaa9a03b7cf3dfdf5783d0c
|
4
|
+
data.tar.gz: e9f4f8844fbdf8435bbb1fc99ac600b35820cabe0a22c4b51902cf39c851e203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e296393e9638c0131b2e4c1a20ec388944de811295d28c30548befda9d786b5131c2039c2b46096a315218bb4a5335532603b0dd9cb557388f5283af7ddc04d
|
7
|
+
data.tar.gz: e53ca031e1b78d56b80612403323254cd29ecf38c5a757af1996e3c08fb3a02bbe644ad9010c7a034c55062ec4b4752b669c02978ea6a90c9435d5568f280dce
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,21 @@
|
|
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.2 (2023-01-30) - @mojavelinux
|
8
|
+
|
9
|
+
=== Changed
|
10
|
+
|
11
|
+
* Only sync congruent tabs blocks (i.e., tabs blocks that have the same tablist) (#47)
|
12
|
+
* Store sync tab selection by sync group (e.g., `preferred-tab-a|b|c`) (#47)
|
13
|
+
|
14
|
+
=== Fixed
|
15
|
+
|
16
|
+
* Turn off :focus-visible outline on tab selected by URL fragment
|
17
|
+
|
18
|
+
=== Details
|
19
|
+
|
20
|
+
{url-repo}/releases/tag/v1.0.0-beta.2[git tag] | {url-repo}/compare/v1.0.0-beta.1\...v1.0.0-beta.2[full diff]
|
21
|
+
|
7
22
|
== 1.0.0-beta.1 (2023-01-30) - @mojavelinux
|
8
23
|
|
9
24
|
=== Added
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Asciidoctor Tabs
|
2
2
|
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>
|
3
|
-
v1.0.0-beta.
|
3
|
+
v1.0.0-beta.2, 2023-01-30
|
4
4
|
:idprefix:
|
5
5
|
:idseparator: -
|
6
6
|
ifndef::env-github[:icons: font]
|
@@ -85,7 +85,7 @@ The term is used as the tab's label and the description is used as the tab's con
|
|
85
85
|
The contents can be defined as primary text, attached blocks, or both.
|
86
86
|
If the attached blocks are themselves enclosed in a single open block, the open block enclosure itself is discarded upon conversion.
|
87
87
|
|
88
|
-
You may choose to extend the block delimiter length from the typical 4 characters to 6 in order to avoid conflicts with any example blocks inside the
|
88
|
+
You may choose to extend the block delimiter length from the typical 4 characters to 6 in order to avoid conflicts with any example blocks inside the tabs block (or just as a matter of style).
|
89
89
|
|
90
90
|
[,asciidoc]
|
91
91
|
----
|
@@ -125,6 +125,9 @@ Tab B:: Contents of tab B in second tabset.
|
|
125
125
|
====
|
126
126
|
----
|
127
127
|
|
128
|
+
Note that only tabs blocks with congruent tablists are synchronized.
|
129
|
+
Each unique combination of tabs implicitly creates a new sync group.
|
130
|
+
|
128
131
|
Alternately, you can set the `sync` option on each tabs block.
|
129
132
|
If you want to delist a tabs block from sync, set the `nosync` option on that block.
|
130
133
|
|
data/data/css/tabs.css
CHANGED
data/data/js/tabs.js
CHANGED
@@ -8,14 +8,11 @@
|
|
8
8
|
|
9
9
|
function init (tabsBlocks) {
|
10
10
|
if (!tabsBlocks.length) return
|
11
|
-
var preferredSyncId = 'syncStorageKey' in config
|
12
|
-
? window[(config.syncStorageScope || 'local') + 'Storage'].getItem(config.syncStorageKey)
|
13
|
-
: undefined
|
14
11
|
forEach.call(tabsBlocks, function (tabs) {
|
15
12
|
var syncIds = tabs.classList.contains('is-sync') ? {} : undefined
|
16
13
|
var tablist = tabs.querySelector('.tablist ul')
|
17
14
|
tablist.setAttribute('role', 'tablist')
|
18
|
-
var
|
15
|
+
var initial
|
19
16
|
forEach.call(tablist.querySelectorAll('li'), function (tab, idx) {
|
20
17
|
tab.setAttribute('role', (tab.className = 'tab')) // NOTE converter may not have set class on li
|
21
18
|
var id, anchor, syncId
|
@@ -25,11 +22,10 @@
|
|
25
22
|
}
|
26
23
|
var panel = tabs.querySelector('.tabpanel[aria-labelledby~="' + id + '"]')
|
27
24
|
if (!panel) return // invalid state
|
28
|
-
if (!idx) first = { tab: tab, panel: panel }
|
29
25
|
tab.tabIndex = -1
|
30
|
-
syncIds &&
|
31
|
-
|
32
|
-
|
26
|
+
syncIds && (((syncId = tab.textContent.toLowerCase().trim()) in syncIds) ? (syncId = undefined) : true) &&
|
27
|
+
(syncIds[(tab.dataset.syncId = syncId)] = tab)
|
28
|
+
idx || (initial = { tab: tab, panel: panel }) && syncIds ? toggleHidden(panel, true) : toggleSelected(tab, true)
|
33
29
|
tab.setAttribute('aria-controls', panel.id)
|
34
30
|
panel.setAttribute('role', 'tabpanel')
|
35
31
|
forEach.call(panel.querySelectorAll('table.tableblock'), function (table) {
|
@@ -39,7 +35,14 @@
|
|
39
35
|
var onClick = syncId === undefined ? activateTab : activateTabSync
|
40
36
|
tab.addEventListener('click', onClick.bind({ tabs: tabs, tab: tab, panel: panel }))
|
41
37
|
})
|
42
|
-
if (
|
38
|
+
if (syncIds && initial) {
|
39
|
+
var syncGroup = tabs.dataset.syncGroup = Object.keys(syncIds).sort().join('|')
|
40
|
+
var preferredSyncId = 'syncStorageKey' in config &&
|
41
|
+
window[(config.syncStorageScope || 'local') + 'Storage'].getItem(config.syncStorageKey + '-' + syncGroup)
|
42
|
+
var tab = preferredSyncId && syncIds[preferredSyncId]
|
43
|
+
tab && Object.assign(initial, { tab: tab, panel: document.getElementById(tab.getAttribute('aria-controls')) })
|
44
|
+
toggleSelected(initial.tab, true) || toggleHidden(initial.panel, false)
|
45
|
+
}
|
43
46
|
})
|
44
47
|
onHashChange()
|
45
48
|
forEach.call(tabsBlocks, function (tabs) {
|
@@ -58,8 +61,9 @@
|
|
58
61
|
forEach.call(tabs.querySelectorAll('.tabpanel'), function (el) {
|
59
62
|
toggleHidden(el, el !== panel)
|
60
63
|
})
|
61
|
-
if (!this.isSync && 'syncStorageKey' in config &&
|
62
|
-
|
64
|
+
if (!this.isSync && 'syncStorageKey' in config && 'syncGroup' in tabs.dataset) {
|
65
|
+
var storageKey = config.syncStorageKey + '-' + tabs.dataset.syncGroup
|
66
|
+
window[(config.syncStorageScope || 'local') + 'Storage'].setItem(storageKey, tab.dataset.syncId)
|
63
67
|
}
|
64
68
|
if (!e) return
|
65
69
|
var loc = window.location
|
@@ -70,13 +74,17 @@
|
|
70
74
|
|
71
75
|
function activateTabSync (e) {
|
72
76
|
activateTab.call(this, e)
|
73
|
-
var
|
77
|
+
var thisTabs = this.tabs
|
74
78
|
var thisTab = this.tab
|
75
|
-
var initialY =
|
76
|
-
forEach.call(document.querySelectorAll('.tabs
|
77
|
-
if (
|
79
|
+
var initialY = thisTabs.getBoundingClientRect().y
|
80
|
+
forEach.call(document.querySelectorAll('.tabs'), function (tabs) {
|
81
|
+
if (tabs !== thisTabs && tabs.dataset.syncGroup === thisTabs.dataset.syncGroup) {
|
82
|
+
forEach.call(tabs.querySelectorAll('.tablist .tab'), function (tab) {
|
83
|
+
if (tab.dataset.syncId === thisTab.dataset.syncId) activateTab.call({ tabs: tabs, tab: tab, isSync: true })
|
84
|
+
})
|
85
|
+
}
|
78
86
|
})
|
79
|
-
var shiftedBy =
|
87
|
+
var shiftedBy = thisTabs.getBoundingClientRect().y - initialY
|
80
88
|
if (shiftedBy && (shiftedBy = Math.round(shiftedBy))) window.scrollBy({ top: shiftedBy, behavior: 'instant' })
|
81
89
|
}
|
82
90
|
|
@@ -95,6 +103,6 @@
|
|
95
103
|
if (!id) return
|
96
104
|
var tab = document.getElementById(~id.indexOf('%') ? decodeURIComponent(id) : id)
|
97
105
|
if (!(tab && tab.classList.contains('tab'))) return
|
98
|
-
tab.dataset
|
106
|
+
'syncId' in tab.dataset ? activateTabSync.call({ tab: tab }) : activateTab.call({ tab: tab })
|
99
107
|
}
|
100
108
|
})()
|