-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabbox.js
33 lines (28 loc) · 1.24 KB
/
tabbox.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
let tabs = ($container, $classForActiveBtn, $classForActiveTab, $addAnimate) => {
$container.each(function() {
let _container = $(this),
tabsline = _container.find("[data-tabsline]").filter(":first"),
button = tabsline.find("> *"),
contentbox = _container.find("[data-contentbox]").filter(":first"),
content = contentbox.find("> *");
button.on("click", function() {
let _thisButton = $(this),
_i = _thisButton.index(),
eqContent = content.eq(_i),
siblings = {
btn: _thisButton.siblings(),
content: eqContent.siblings()
};
if ($addAnimate === true) {
eqContent.fadeIn("fast").css({ display: "" });
siblings.content.css({ display: "" });
}
_thisButton.addClass($classForActiveBtn);
eqContent.addClass($classForActiveTab);
siblings.btn.removeClass($classForActiveBtn);
siblings.content.removeClass($classForActiveTab);
});
});
}
tabs($("[data-tabbox]"), "btn--active", "tab--active", true);
tabs($("[data-innertabbox]"), "innerbtn--active", "innertab--active", true);