-
Notifications
You must be signed in to change notification settings - Fork 1
/
application.js
51 lines (43 loc) · 1.86 KB
/
application.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
up.link.config.instantSelectors.unshift('a[up-follow]')
up.link.config.preloadSelectors.unshift('a[up-follow]')
up.link.config.instantSelectors.push('a[href]')
// Enable more logging for curious users.
//up.log.enable()
// Gray out tour dots once clicked.
up.on('up:link:follow', '.tour-dot', (event, element) => { element.classList.add('viewed') })
/*
up.compiler('nav a[href]', (link) => {
if(!link.href.endsWith('#')) link.setAttribute('up-alias', link.href + '?*')
})
*/
up.compiler('.pagination .page-item a.page-link', (link) => {
link.setAttribute('up-follow', link.href)
link.setAttribute('up-target', ".table-container")
link.setAttribute('up-history', "true")
})
up.compiler('th.orderable a[href]', (link) => {
link.setAttribute('up-follow', link.href)
link.setAttribute('up-target', ".table-container")
link.setAttribute('up-history', "true")
})
async function reloadWithFlash(selector, flash) {
await up.reload(selector, { focus: ':main' })
up.element.affix(document.getElementById('flash-messages'), '.alert.fade.show.alert-success', { text: flash })
}
async function reloadWithFlashIfEvent(selector, flash, value) {
if (value != ':peel') {
await up.reload(selector, { focus: ':main' })
}
if (value instanceof Event || value == ':peel') {
up.element.affix(document.getElementById('flash-messages'), '.alert.fade.show.alert-danger', { text: flash })
}
}
// Don't highlight the fragment insertion from the initial compile on DOMContentLoaded.
window.addEventListener('load', (event) => {
// Show the yellow flash when a new fragment was inserted.
up.on('up:fragment:inserted', (event, fragment) => {
fragment.classList.add('new-fragment', 'inserted')
up.util.timer(0, () => fragment.classList.remove('inserted'))
up.util.timer(1000, () => fragment.classList.remove('new-fragment'))
})
})