feat(character/achievements): close opened subcategory when clicking other categories
This commit is contained in:
parent
9c56c55ac8
commit
e897b011ac
1 changed files with 22 additions and 12 deletions
|
|
@ -61,6 +61,7 @@
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
let achievementsData = {};
|
let achievementsData = {};
|
||||||
|
let $openCategory;
|
||||||
const $achievementTemplate = $("#achievement-template").detach().removeAttr("id");
|
const $achievementTemplate = $("#achievement-template").detach().removeAttr("id");
|
||||||
const $progressTemplate = $("#progress-template").detach().removeAttr("id");
|
const $progressTemplate = $("#progress-template").detach().removeAttr("id");
|
||||||
|
|
||||||
|
|
@ -69,18 +70,16 @@
|
||||||
.attr("href", "#")
|
.attr("href", "#")
|
||||||
.text(cat.nameLang0)
|
.text(cat.nameLang0)
|
||||||
.on("click", () => {
|
.on("click", () => {
|
||||||
|
if ($openCategory !== undefined && !$openCategory.data("children")[0].contains($a[0])) {
|
||||||
|
closeCategory();
|
||||||
|
}
|
||||||
|
|
||||||
const $children = $a.data("children");
|
const $children = $a.data("children");
|
||||||
if ($children !== undefined) {
|
if ($children !== undefined) {
|
||||||
|
$openCategory = $a;
|
||||||
if (!$children.is(":visible")) {
|
if (!$children.is(":visible")) {
|
||||||
// Close the currently selected category
|
|
||||||
$("#categories .open")
|
|
||||||
.slideUp()
|
|
||||||
.removeClass("open");
|
|
||||||
|
|
||||||
// Open the clicked category
|
// Open the clicked category
|
||||||
$children
|
$children.slideDown();
|
||||||
.slideDown()
|
|
||||||
.addClass("open");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
openCategory(cat);
|
openCategory(cat);
|
||||||
|
|
@ -130,7 +129,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function closeCategory() {
|
||||||
|
if ($openCategory === undefined || $openCategory.data("children") === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$openCategory
|
||||||
|
.data("children")
|
||||||
|
.slideUp();
|
||||||
|
}
|
||||||
|
|
||||||
function openSummary() {
|
function openSummary() {
|
||||||
|
closeCategory();
|
||||||
$("#achievements").empty();
|
$("#achievements").empty();
|
||||||
const achievements = Object.keys(achievementsData.earned)
|
const achievements = Object.keys(achievementsData.earned)
|
||||||
.filter(key => achievementsData.earned.hasOwnProperty(key))
|
.filter(key => achievementsData.earned.hasOwnProperty(key))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue