dept-red-header.jsp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <%@ page pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <c:set var="headerBackgroundImage" value="${empty deptHeroNmv.articleList[0].thumbnail ? '/main/ffkj-portal/news-red/hero-building.jpg' : deptHeroNmv.articleList[0].thumbnail}"/>
  4. <header class="hero-head" style="--hero-bg:url('${headerBackgroundImage}')">
  5. <div class="head-inner">
  6. <div class="top-links">
  7. <c:choose>
  8. <c:when test="${not empty utilityLinksNmv.articleList}">
  9. <c:forEach items="${utilityLinksNmv.articleList}" var="item" varStatus="vs">
  10. <c:if test="${not vs.first}"><b>|</b></c:if>
  11. <a href="${item.url}" target="${item.target}">${item.title}</a>
  12. </c:forEach>
  13. </c:when>
  14. <c:otherwise><a href="/">学校首页</a><b>|</b><a href="/">新闻首页</a></c:otherwise>
  15. </c:choose>
  16. </div>
  17. <a class="brand" href="/" aria-label="${empty website.seoTitle ? website.name : website.seoTitle}首页">
  18. <c:if test="${not empty website.logo}"><img class="brand-logo" src="${website.logo}" alt="${website.name}"></c:if>
  19. <span class="brand-name">${empty website.seoTitle ? website.name : website.seoTitle}</span>
  20. </a>
  21. <form class="search" action="/search" method="get"><input name="str" value="${str}" placeholder="站内" aria-label="站内搜索"><button type="submit">搜索</button></form>
  22. </div>
  23. </header>
  24. <button class="mobile-nav-toggle" type="button" aria-label="打开导航" aria-expanded="false"><span></span><span></span><span></span></button>
  25. <nav class="main-nav" aria-label="主导航"><ul>
  26. <li class="mobile-nav-search-item"><form class="mobile-nav-search" action="/search" method="get"><input name="str" value="${str}" placeholder="站内" aria-label="站内搜索"><button type="submit">搜索</button></form></li>
  27. <li><a class="${empty navigation ? 'active' : ''}" href="/">首页</a></li>
  28. <c:forEach items="${navList}" var="item">
  29. <c:if test="${item.name ne '首页' and item.name ne '首页子栏目'}">
  30. <li class="${not empty item.children ? 'has-children' : ''}">
  31. <a class="${item.navigationid eq navigation.navigationid or item.navigationid eq navigation.parentNid ? 'active' : ''}" href="${item.href}" target="${item.target}">${item.name}</a>
  32. <c:if test="${not empty item.children}">
  33. <ul class="dept-nav-panel">
  34. <c:forEach items="${item.children}" var="child"><li><a href="${child.href}" target="${child.target}">${child.name}</a></li></c:forEach>
  35. </ul>
  36. </c:if>
  37. </li>
  38. </c:if>
  39. </c:forEach>
  40. </ul></nav>
  41. <div class="mobile-nav-mask" aria-hidden="true"></div>
  42. <script>
  43. (function () {
  44. var toggle = document.querySelector('.mobile-nav-toggle');
  45. var nav = document.querySelector('.main-nav');
  46. var mask = document.querySelector('.mobile-nav-mask');
  47. if (!toggle || !nav || !mask) return;
  48. function setOpen(open) {
  49. nav.classList.toggle('is-open', open);
  50. mask.classList.toggle('is-open', open);
  51. toggle.classList.toggle('is-open', open);
  52. toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
  53. document.documentElement.style.overflow = open ? 'hidden' : '';
  54. }
  55. toggle.addEventListener('click', function () {
  56. setOpen(!nav.classList.contains('is-open'));
  57. });
  58. mask.addEventListener('click', function () { setOpen(false); });
  59. Array.prototype.forEach.call(nav.querySelectorAll('a'), function (link) {
  60. link.addEventListener('click', function () { setOpen(false); });
  61. });
  62. document.addEventListener('keydown', function (event) {
  63. if (event.key === 'Escape') setOpen(false);
  64. });
  65. })();
  66. </script>