-
Notifications
You must be signed in to change notification settings - Fork 46
/
faqs.html
89 lines (85 loc) · 5.52 KB
/
faqs.html
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
---
layout: default
title: FAQs
---
<div class="mk-masthead__content--sub">
<h1 class="mk-masthead__content--sub__title">Frequently Asked Questions</h1>
<p>Here are some answers to common questions, discover more about Metal<sup>3</sup></p>
</div>
<section class="mk-faqs mk-main__section">
<div data-aria-faq data-multi data-transition data-default="none" id="accGen">
{% for faq in site.faqs %}
<h3 class="mk-heading--md" data-aria-faq-heading>
{{ faq.question }}
</h3>
<div data-aria-faq-panel>
{{ faq.content }}
</div>
{% endfor %}
</div>
</section>
<script>
! function(t, e, a) {
"use strict";
var r = {};
var i = "mk-faqs",
l = i + "__question",
n = i + "__answer",
o = "[data-aria-faq-heading]",
d = "[data-aria-faq-panel]",
c = 0;
r.create = function() {
var t, a, s, u, A, g, h = "none",
b = e.querySelectorAll("[data-aria-faq]");
for (c += 1, g = 0; g < b.length; g++) {
var f;
if ((t = b[g]).hasAttribute("id") || (t.id = "acc_" + c + "-" + g), t.classList.add(i), e.querySelectorAll("#" + t.id + "> li").length ? (a = e.querySelectorAll("#" + t.id + " li > " + d), s = e.querySelectorAll("#" + t.id + " li > " + o)) : (a = e.querySelectorAll("#" + t.id + " > " + d), s = e.querySelectorAll("#" + t.id + " > " + o)), t.hasAttribute("data-default") && (h = t.getAttribute("data-default")), A = t.hasAttribute("data-constant"), t.hasAttribute("data-multi"), t.hasAttribute("data-transition")) {
var y = t.querySelectorAll(d);
for (f = 0; f < y.length; f++) y[f].classList.add(n + "--transition")
}
for (r.setupPanels(t.id, a, h, A), r.setupHeadingButton(s, A), u = e.querySelectorAll("#" + t.id + "> li").length ? e.querySelectorAll("#" + t.id + " li > " + o + " ." + l) : e.querySelectorAll("#" + t.id + " > " + o + " ." + l), f = 0; f < u.length; f++) u[f].addEventListener("click", r.actions), u[f].addEventListener("keydown", r.keytrolls)
}
}, r.setupPanels = function(t, e, a, r) {
var i, l, o, d, c;
for (i = 0; i < e.length; i++) o = t + "_panel_" + (i + 1), d = a, c = r, (l = e[i]).setAttribute("id", o), s(e[0], !0), l.classList.add(n), "none" !== d && NaN !== parseInt(d) && (d <= 1 ? s(e[0], !1) : d - 1 >= e.length ? s(e[e.length - 1], !1) : s(e[d - 1], !1)), (c && "none" === d || NaN === parseInt(d)) && s(e[0], !1)
}, r.setupHeadingButton = function(t, a) {
var r, i, n, o, d, c;
for (c = 0; c < t.length; c++) i = (r = t[c]).nextElementSibling.id, n = e.getElementById(i).getAttribute("aria-hidden"), o = e.createElement("button"), d = r.textContent, r.innerHTML = "", o.setAttribute("type", "button"), o.setAttribute("aria-controls", i), o.setAttribute("id", i + "_question"), o.classList.add(l), "false" === n ? (u(o, !0), g(o, !0), a && o.setAttribute("aria-disabled", "true")) : (u(o, !1), g(o, !1)), r.appendChild(o), o.appendChild(e.createTextNode(d))
}, r.actions = function(t) {
var a, i = this.id.replace(/_panel.*$/g, ""),
n = e.getElementById(this.getAttribute("aria-controls"));
a = e.querySelectorAll("#" + i + "> li").length ? e.querySelectorAll("#" + i + " li > " + o + " ." + l) : e.querySelectorAll("#" + i + " > " + o + " ." + l), t.preventDefault(), r.togglePanel(t, i, n, a)
}, r.togglePanel = function(t, a, r, i) {
var l, n, o = t.target;
if ("true" !== o.getAttribute("aria-disabled") && (l = o.getAttribute("aria-controls"), g(o, "true"), "true" === o.getAttribute("aria-expanded") ? (u(o, "false"), s(r, "true")) : (u(o, "true"), s(r, "false"), e.getElementById(a).hasAttribute("data-constant") && A(o, "true")), e.getElementById(a).hasAttribute("data-constant") || !e.getElementById(a).hasAttribute("data-multi")))
for (n = 0; n < i.length; n++) o !== i[n] && (g(i[n], "false"), l = i[n].getAttribute("aria-controls"), A(i[n], "false"), u(i[n], "false"), s(e.getElementById(l), "true"))
}, r.keytrolls = function(t) {
if (t.target.classList.contains(l)) {
var a, r = t.keyCode || t.which,
i = this.id.replace(/_panel.*$/g, "");
switch (a = e.querySelectorAll("#" + i + "> li").length ? e.querySelectorAll("#" + i + " li > " + o + " ." + l) : e.querySelectorAll("#" + i + " > " + o + " ." + l), r) {
case 35:
t.preventDefault(), a[a.length - 1].focus();
break;
case 36:
t.preventDefault(), a[0].focus()
}
}
}, r.init = function() {
r.create()
};
var s = function(t, e) {
t.setAttribute("aria-hidden", e)
},
u = function(t, e) {
t.setAttribute("aria-expanded", e)
},
A = function(t, e) {
t.setAttribute("aria-disabled", e)
},
g = function(t, e) {
t.setAttribute("data-current", e)
};
r.init()
}(window, document);
</script>