게시판 진입시 게시판 메뉴 오픈

master
강석 최 2022-01-06 16:24:01 +09:00
parent 50bb514733
commit dd36eda244
2 changed files with 36 additions and 7 deletions

View File

@ -3,6 +3,8 @@ $(function (){
format: "yyyy-mm-dd", format: "yyyy-mm-dd",
language: "ko" language: "ko"
}); });
setMenu();
}) })
$(document).on('click', '.categoryTr', function (){ $(document).on('click', '.categoryTr', function (){
if(location.pathname.indexOf("contentSearch")<0){ if(location.pathname.indexOf("contentSearch")<0){
@ -128,3 +130,24 @@ function getBoardLog(contentSeq){
}); });
} }
} }
function setMenu(){
const categorySeq = getParam("categorySeq");
openMenu($("[data-categoryseq='"+categorySeq+"']").attr("data-parentseq"));
}
function getParam(sname) {
const paramAry = location.search.substr(1).split("&");
for (let i = 0; i < paramAry.length; i++) {
const param = paramAry[i].split("=");
if (param[0] === sname) { return param[1]; }
}
}
function openMenu(parentSeq){
if(parentSeq){
const target = $("[data-categoryseq='"+parentSeq+"']")
target.click();
openMenu(target.attr("data-parentseq"));
}
}

View File

@ -24,8 +24,9 @@
<th:block th:each="depth1:${session.categoryList}"> <th:block th:each="depth1:${session.categoryList}">
<li class="mb-1"> <li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" <button class="btn btn-toggle align-items-center rounded collapsed"
data-bs-toggle="collapse" aria-expanded="false" th:data-bs-target="'#collapse'+${depth1.categorySeq}" data-bs-toggle="collapse" aria-expanded="false"
th:text="${depth1.categoryName}"> th:data-categoryseq="${depth1.categorySeq}"
th:data-bs-target="'#collapse'+${depth1.categorySeq}" th:text="${depth1.categoryName}">
</button> </button>
<div class="collapse ps-3" th:id="|collapse${depth1.categorySeq}|"> <div class="collapse ps-3" th:id="|collapse${depth1.categorySeq}|">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1"> <ul class="btn-toggle-nav list-unstyled fw-normal pb-1">
@ -35,6 +36,7 @@
<li class="mb-1"> <li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" <button class="btn btn-toggle align-items-center rounded collapsed"
data-bs-toggle="collapse" aria-expanded="false" data-bs-toggle="collapse" aria-expanded="false"
th:data-categoryseq="${depth2.categorySeq}" th:data-parentseq="${depth2.parentSeq}"
th:data-bs-target="'#collapse'+${depth2.categorySeq}" th:text="${depth2.categoryName}"> th:data-bs-target="'#collapse'+${depth2.categorySeq}" th:text="${depth2.categoryName}">
</button> </button>
<div class="collapse ps-3" th:id="|collapse${depth2.categorySeq}|"> <div class="collapse ps-3" th:id="|collapse${depth2.categorySeq}|">
@ -45,12 +47,16 @@
<li class="mb-1"> <li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" <button class="btn btn-toggle align-items-center rounded collapsed"
data-bs-toggle="collapse" aria-expanded="false" data-bs-toggle="collapse" aria-expanded="false"
th:data-categoryseq="${depth3.categorySeq}" th:data-parentseq="${depth3.parentSeq}"
th:data-bs-target="'#collapse'+${depth3.categorySeq}" th:text="${depth3.categoryName}"> th:data-bs-target="'#collapse'+${depth3.categorySeq}" th:text="${depth3.categoryName}">
</button> </button>
<div class="collapse ps-3" th:id="|collapse${depth3.categorySeq}|"> <div class="collapse ps-3" th:id="|collapse${depth3.categorySeq}|">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1"> <ul class="btn-toggle-nav list-unstyled fw-normal pb-1">
<th:block th:each="depth4:${depth3.childCategoryList}"> <th:block th:each="depth4:${depth3.childCategoryList}">
<li><a th:href="|@{/board/contentList}?categorySeq=${depth4.categorySeq}|" class="bi bi-dash link-dark rounded ps-3 text-decoration-none" th:text="${depth4.categoryName}"></a></li> <li><a th:href="|@{/board/contentList}?categorySeq=${depth4.categorySeq}|"
th:data-categoryseq="${depth4.categorySeq}" th:data-parentseq="${depth4.parentSeq}"
class="bi bi-dash link-dark rounded ps-3 text-decoration-none"
th:text="${depth4.categoryName}"></a></li>
</th:block> </th:block>
<th:block th:if="${depth3.childCategoryList.size==0}"> <th:block th:if="${depth3.childCategoryList.size==0}">
<li>등록된 소분류가 없습니다.</li> <li>등록된 소분류가 없습니다.</li>