lato 3.11.1 → 3.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f74224daab88d3ccd9e30a552503efaa04503a4e4e1bf103bf0aefa43a1d743
|
4
|
+
data.tar.gz: 1995b2071e0ef30bfdcad2259dd90b7500af23506ac63fe77375ee8955b19920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f22a9b7694ee48adbef3b63c1d02cf6ad00b4a719c71c2099576348c6726c5cf2edc7f9b6152d2213fc3dd7ffc9242ea29ac4fe96c3874a957a32e61707ed11b
|
7
|
+
data.tar.gz: e14da8bcb3bffadcc298a41ad48e47fcdfd631a7025574f7a19e4f1a4377e9f8c449ba82ca5005216ec1b5ef130ab1da4870edeaf217d1bf8b158a7650ea520c
|
@@ -55,10 +55,5 @@ document.addEventListener('turbo:before-cache', (e) => {
|
|
55
55
|
document.querySelector('.navbar-toggler').classList.add('collapsed')
|
56
56
|
document.querySelector('.navbar-collapse').classList.remove('show')
|
57
57
|
|
58
|
-
// remove all tooltips
|
59
|
-
document.querySelectorAll('.tooltip').forEach((el) => {
|
60
|
-
el.remove()
|
61
|
-
})
|
62
|
-
|
63
58
|
e.detail?.resume()
|
64
59
|
})
|
@@ -10,84 +10,129 @@ export default class extends Controller {
|
|
10
10
|
connect() {
|
11
11
|
const localStorageStatus = localStorage.getItem('lato_guide')
|
12
12
|
this.status = localStorageStatus ? JSON.parse(localStorageStatus) : {}
|
13
|
-
this.items = null
|
14
|
-
this.showing = false
|
15
|
-
|
16
13
|
this.storeStatus()
|
17
|
-
|
18
|
-
this.
|
14
|
+
|
15
|
+
this.connected = true
|
16
|
+
this.tooltip = null
|
17
|
+
this.run()
|
18
|
+
|
19
|
+
window.addEventListener('resize', this.onDomChange.bind(this))
|
20
|
+
document.addEventListener('turbo:load', this.onDomChange.bind(this))
|
21
|
+
document.addEventListener('turbo:frame-load', this.onDomChange.bind(this))
|
22
|
+
}
|
23
|
+
|
24
|
+
disconnect() {
|
25
|
+
this.storeStatus()
|
26
|
+
|
27
|
+
if (this.tooltip) {
|
28
|
+
this.tooltip.dispose()
|
29
|
+
this.tooltip = null
|
30
|
+
}
|
31
|
+
|
32
|
+
this.connected = false
|
33
|
+
|
34
|
+
window.removeEventListener('resize', this.onDomChange.bind(this))
|
35
|
+
window.removeEventListener('turbo:load', this.onDomChange.bind(this))
|
36
|
+
window.removeEventListener('turbo:frame-load', this.onDomChange.bind(this))
|
19
37
|
}
|
20
38
|
|
21
39
|
itemTargetConnected(e) {
|
22
|
-
this.
|
23
|
-
this.showGuide()
|
40
|
+
this.run()
|
24
41
|
}
|
25
42
|
|
26
43
|
itemTargetDisconnected(e) {
|
27
|
-
this.
|
44
|
+
if (this.tooltip && this.tooltip.itemKey === e.target.dataset.guideKey) {
|
45
|
+
this.tooltip.dispose()
|
46
|
+
this.tooltip = null
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Exposed functions
|
52
|
+
*/
|
53
|
+
|
54
|
+
rerun(e = null) {
|
55
|
+
if (e) e.preventDefault()
|
56
|
+
this.resetStatus()
|
57
|
+
this.run()
|
28
58
|
}
|
29
59
|
|
30
|
-
|
60
|
+
run(e = null) {
|
31
61
|
if (e) e.preventDefault()
|
62
|
+
if (!this.connected) return
|
32
63
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
64
|
+
const items = this.getNotShowedItems()
|
65
|
+
if (items.length === 0) return
|
66
|
+
|
67
|
+
this.showItem(items[0])
|
37
68
|
}
|
38
69
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if (!this.items) return
|
70
|
+
/**
|
71
|
+
* Helpers
|
72
|
+
*/
|
43
73
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
74
|
+
getNotShowedItems() {
|
75
|
+
const items = this.itemTargets.map(item => ({ element: item, key: item.dataset.guideKey, content: item.dataset.guideContent, index: parseInt(item.dataset.guideIndex) })).map(item => {
|
76
|
+
item.index = isNaN(item.index) ? 999 : item.index
|
77
|
+
return item
|
78
|
+
}).sort((a, b) => a.index - b.index).filter((item) => !this.status[item.key])
|
79
|
+
|
80
|
+
return items
|
48
81
|
}
|
49
82
|
|
50
|
-
|
51
|
-
if (this.showing) return
|
83
|
+
showItem(item) {
|
52
84
|
if (!this.status) return
|
53
85
|
if (this.status[item.key]) return
|
86
|
+
if (this.tooltip) return
|
54
87
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
<
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
})
|
78
|
-
tooltip.show()
|
88
|
+
// setup tooltip
|
89
|
+
const tooltipCloseId = `lato-guide-close-${Math.random().toString(36).substring(7)}`
|
90
|
+
const tooltipTitle = `
|
91
|
+
<div class="px-2 py-2 d-flex align-items-center justify-content-between">
|
92
|
+
<p class="me-2 mb-0 text-start">${item.content}</p>
|
93
|
+
<a id="${tooltipCloseId}" class="btn btn-light btn-sm">Next</a>
|
94
|
+
</div>
|
95
|
+
`
|
96
|
+
this.tooltip = new bootstrap.Tooltip(item.element, { title: tooltipTitle, trigger: 'manual', html: true, customClass: 'lato-guide-tooltip' })
|
97
|
+
this.tooltip.itemKey = item.key
|
98
|
+
|
99
|
+
// listen to tooltip close
|
100
|
+
item.element.addEventListener('shown.bs.tooltip', () => {
|
101
|
+
setTimeout(() => {
|
102
|
+
document.getElementById(tooltipCloseId).addEventListener('click', () => {
|
103
|
+
this.tooltip.dispose()
|
104
|
+
this.tooltip = null
|
105
|
+
this.status[item.key] = true
|
106
|
+
this.storeStatus()
|
107
|
+
this.run()
|
108
|
+
})
|
109
|
+
}, 250)
|
79
110
|
})
|
111
|
+
this.tooltip.show()
|
112
|
+
|
113
|
+
return true
|
80
114
|
}
|
81
115
|
|
82
|
-
storeStatus(
|
83
|
-
if (e) e.preventDefault()
|
116
|
+
storeStatus() {
|
84
117
|
localStorage.setItem('lato_guide', JSON.stringify(this.status))
|
118
|
+
|
119
|
+
return true
|
85
120
|
}
|
86
121
|
|
87
|
-
resetStatus(
|
88
|
-
if (e) e.preventDefault()
|
122
|
+
resetStatus() {
|
89
123
|
this.status = {}
|
90
124
|
this.storeStatus()
|
91
|
-
|
125
|
+
|
126
|
+
return true
|
127
|
+
}
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Events
|
131
|
+
*/
|
132
|
+
|
133
|
+
onDomChange(e) { // when page size changes (change of length of the document), we need to reposition the tooltip
|
134
|
+
if (this.tooltip) {
|
135
|
+
this.tooltip.update()
|
136
|
+
}
|
92
137
|
}
|
93
138
|
}
|
data/lib/lato/version.rb
CHANGED