<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/jsp/includes.jsp" %>

<div class="sidebar">
    <div class="panel">
        <div class="panel-body">
            <div class="model-box model-user">
                <a class="model-img" href="javascript:void(0)">
                    <c:choose>
                        <c:when test="${not empty userInfo.useravatar90}">
                            <coeus:img className="user-max" src="${userInfo.useravatar90}"/>
                        </c:when>
                        <c:otherwise>
                            <coeus:img className="user-max" src="images/user-head.png"/>
                        </c:otherwise>
                    </c:choose>
                </a>

                <h3 class="model-title substr">
                    <c:if test="${empty userInfo.nickName}">${userInfo.loginName}</c:if>
                    <c:if test="${not empty userInfo.nickName}">${userInfo.nickName}</c:if>
                </h3>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    $(function () {
        $(".sub-nav-text").click(function () {
            $(this).parent().siblings().find(".current").removeClass("current");
            $(this).addClass("current");
        });

        selectMenu();

        function selectMenu() {
            var currentMenu = $("#currentMenu").val();
            var $target = $(".nav-item").find("a[content='" + currentMenu + "']");
            $target.addClass("current");
            var $sub = $target.parents(".sub-nav");
            if ($sub.length != 0) {
                $sub.prev(".nav-text").addClass("current");
                $sub.parent(".nav-item").addClass("open-up navItem");
            }
            else {
                $target.parent(".nav-item").addClass("open-up navItem");
            }
        }

        //侧栏导航,非当前选中菜单下的二级菜单须收起来。
        $(".nav-item").find("a").click(function () {
            $li = $(this).parent();
            $li.parents(".nav-list").find(".current").removeClass("current");
            $li.siblings().find(".sub-nav").slideUp();
            $(this).addClass("current");
            //如果当前是父nav 子nav默认选中第一个
            $li.children("ul").slideDown().find("li:first").find("a").addClass("current");
            //如果当前是子nav 父导航也选中
            $li.parent("ul").prev("a").addClass("current");
        });

        $(".nav-text.current").parent().siblings().find(".sub-nav").slideUp();
    })
</script>