{{ define "admin/nav/side.html" }}
<div class="layui-side">
    <div class="layui-side-scroll">
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
            <li class="layui-nav-item {{ if eq .menu 2 }} layui-nav-itemed {{ end }}">
                <a class="" href="javascript:;">用户设置</a>
                <dl class="layui-nav-child">
                    <dd><a class="{{ if eq .url "/admin/profile" }}admin-subnav-active{{ end }}" href="/admin/profile">个人资料</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item {{ if eq .menu 1 }} layui-nav-itemed {{ end }}">
                <a class="" href="javascript:;">卡片管理</a>
                <dl class="layui-nav-child">
                    <dd><a class="{{ if eq .url "/admin/card" }}admin-subnav-active{{ end }}" href="/admin/card">卡片一览</a></dd>
                    <dd><a class="{{ if eq .url "/admin/upload" }}admin-subnav-active{{ end }}" href="/admin/upload">卡片导入</a>
                    </dd>
                </dl>
            </li>
        </ul>
    </div>
</div>
<div class="admin-mobile-mask"></div>
<script>
    (function () {
        function closeAdminSide() {
            document.body.classList.remove('admin-side-open');
        }

        function toggleAdminSide() {
            document.body.classList.toggle('admin-side-open');
        }

        document.addEventListener('click', function (event) {
            var menuTrigger = event.target.closest('[lay-header-event="menuLeft"]');
            if (menuTrigger) {
                event.preventDefault();
                toggleAdminSide();
                return;
            }

            if (event.target.closest('.admin-mobile-mask')) {
                closeAdminSide();
                return;
            }

            if (window.innerWidth <= 767.98 && event.target.closest('.layui-side .layui-nav-child a[href]')) {
                closeAdminSide();
            }
        });

        window.addEventListener('resize', function () {
            if (window.innerWidth > 767.98) {
                closeAdminSide();
            }
        });
    })();
</script>
{{ end }}
