-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall.js
71 lines (66 loc) · 1.75 KB
/
all.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// enable tooltips
var tooltipTriggerList = [].slice.call(
document.querySelectorAll('[data-bs-toggle="tooltip"]')
);
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// form validation
(function () {
"use strict";
var forms = document.querySelectorAll(".needs-validation");
Array.prototype.slice.call(forms).forEach(function (form) {
form.addEventListener(
"submit",
function (event) {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add("was-validated");
},
false
);
});
})();
// click nav&tab go there & click go to form
var form = document.getElementById("form");
function heightToTop(ele) {
let bridge = ele;
let root = document.body;
let height = 0;
do {
height += bridge.offsetTop;
bridge = bridge.offsetParent;
} while (bridge !== root);
return height;
}
function goToTab() {
window.scrollTo({
top: heightToTop(document.getElementsByClassName("tab-content")[0]) - 70,
behavior: "smooth"
});
}
function goForm() {
window.scrollTo({
top: heightToTop(form) - 170,
behavior: "smooth"
});
}
// mobile btn toggle
var bottomBtn = document.getElementById("bottomBtn");
bottomBtn.style.display = "none";
window.onscroll = function () {
const t = document.documentElement.scrollTop || document.body.scrollTop;
if (bottomBtn !== null) {
if (
t >
heightToTop(document.getElementsByClassName("tab-content")[0]) - 100 &&
t < heightToTop(form) - 245
) {
bottomBtn.style.display = "block";
} else {
bottomBtn.style.display = "none";
}
}
};