-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
96 lines (72 loc) · 1.92 KB
/
script.js
File metadata and controls
96 lines (72 loc) · 1.92 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
"use strict";
const navbarPosition = () => {
let prevScrollpos = window.pageYOffset
window.onscroll = () => {
let currentScrollPos = window.pageYOffset
if (prevScrollpos > currentScrollPos) {
//console.log($('#navbar'))
$('#navbar')[0].style.top = '0'
} else {
$('#navbar')[0].style.top = '-100px'
}
prevScrollpos = currentScrollPos
}
}
const smoothScrollPolyfill = () => {
$('a[data-smooth-scroll]').on('click', (event) => {
if (this.hash !== "") {
event.preventDefault()
const hash = this.hash
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 800, () => {
window.location.hash = hash
})
}
})
}
const bsColumns = () => {
const $rows = $('.wp-block-columns')
$rows.each((i, e) => {
e.classList.add('row')
const n = [].slice.call(e.classList).reduce((prev, curr) => {
if (prev.found) return prev
const m = curr.match(/has-(\d)-columns/)
if (m && m[1]) {
return { found: true, value: parseInt(m[1]) }
} else {
return { found: false, value: null }
}
}, { found: false, value: null }).value
if (!n) return
const d = 12 / n
$(e).children().each((j, c) => {
c.classList.add(`col-md-${d}`)
})
})
}
const bsTables = () => {
$('.wp-block-table').addClass('table')
$('.is-style-stripes').addClass('table-striped')
}
const bsGallery = () => {
$('.carousel').carousel()
}
const registerFormOverlay = (e) => {
$('#overlay').css('display', 'flex')
$(e).children(':input').attr('disabled', 'disabled')
}
$(document).ready(e => {
if (!('scrollBehavior' in document.documentElement.style)) {
smoothScrollPolyfill()
}
navbarPosition()
bsColumns()
bsTables()
bsGallery()
$('#register_form').submit(registerFormOverlay)
$('body').tooltip({ selector: '[data-toggle=tooltip]' })
$('.collapse').collapse({
toggle: false
})
})