education-header.jsp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <%@ page pageEncoding="UTF-8"%>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  3. <script src="/main/dist/websites/plug-in/jquery/jquery1.11.3.min.js"></script>
  4. <c:set var="educationSiteTitle" value="${empty website.seoTitle ? website.name : website.seoTitle}"/>
  5. <c:set var="educationLogo" value="${empty website.logo ? '/main/ffkj-portal/education/education-logo.png' : website.logo}"/>
  6. <header class="edu-topbar" id="top">
  7. <div class="edu-wrap edu-topbar-inner">
  8. <a class="edu-brand" href="/" aria-label="${educationSiteTitle}首页">
  9. <img class="edu-brand-logo" src="${educationLogo}" alt="${educationSiteTitle}">
  10. </a>
  11. <div class="edu-top-tools">
  12. <nav class="edu-top-links" aria-label="快捷入口">
  13. <c:set var="educationSchoolHomeFound" value="${false}" scope="request"/>
  14. <c:forEach items="${educationTopLinksNmv.articleList}" var="item">
  15. <c:if test="${item.title eq '学校首页'}"><c:set var="educationSchoolHomeFound" value="${true}" scope="request"/></c:if>
  16. <a href="${item.url}" target="${item.target}" rel="noopener">${item.title}</a>
  17. </c:forEach>
  18. <c:if test="${not educationSchoolHomeFound}">
  19. <a href="${empty educationSchoolHomeUrl ? 'https://www.gzhxtc.edu.cn/' : educationSchoolHomeUrl}">${empty educationSchoolHomeName ? '学校首页' : educationSchoolHomeName}</a>
  20. </c:if>
  21. <c:if test="${empty educationTopLinksNmv.articleList}"><a href="/">本站首页</a></c:if>
  22. </nav>
  23. <form class="edu-top-search" action="/search" method="get" role="search">
  24. <label class="edu-sr-only" for="edu-top-search-input">搜索本站内容</label>
  25. <input id="edu-top-search-input" name="str" type="search" value="${str}" placeholder="搜索文章、通知、专业…" autocomplete="off">
  26. <button type="submit" aria-label="搜索">
  27. <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.7" cy="10.7" r="6.5"></circle><path d="m15.5 15.5 5 5"></path></svg>
  28. </button>
  29. </form>
  30. <button class="edu-nav-toggle" type="button" aria-label="打开导航" aria-expanded="false" aria-controls="education-main-nav"><span></span><span></span><span></span></button>
  31. </div>
  32. </div>
  33. </header>
  34. <nav class="edu-nav" id="education-main-nav" aria-label="${educationSiteTitle}主导航">
  35. <div class="edu-wrap edu-nav-inner">
  36. <div class="edu-nav-item">
  37. <a class="edu-nav-link ${empty navigation ? 'is-active' : ''}" href="/">首页</a>
  38. </div>
  39. <c:forEach items="${navList}" var="item">
  40. <c:if test="${item.name ne '首页' and item.name ne '首页子栏目'}">
  41. <div class="edu-nav-item ${not empty item.children ? 'has-children' : ''}">
  42. <c:set var="educationNavHref" value="${item.href}"/>
  43. <c:if test="${not empty item.children}"><c:set var="educationNavHref" value="${empty item.children[0].href ? item.href : item.children[0].href}"/></c:if>
  44. <div class="edu-nav-row">
  45. <a class="edu-nav-link ${item.navigationid eq navigation.navigationid or item.navigationid eq navigation.parentNid ? 'is-active' : ''}" href="${educationNavHref}" target="${item.target}" rel="noopener">${item.name}</a>
  46. <c:if test="${not empty item.children}"><button class="edu-subnav-toggle" type="button" aria-label="展开${item.name}子栏目" aria-expanded="false" aria-controls="education-subnav-${item.navigationid}"></button></c:if>
  47. </div>
  48. <c:if test="${not empty item.children}">
  49. <div class="edu-subnav" id="education-subnav-${item.navigationid}">
  50. <c:forEach items="${item.children}" var="child"><a href="${child.href}" target="${child.target}" rel="noopener">${child.name}</a></c:forEach>
  51. </div>
  52. </c:if>
  53. </div>
  54. </c:if>
  55. </c:forEach>
  56. </div>
  57. </nav>
  58. <div class="edu-menu-mask" aria-hidden="true"></div>
  59. <script>
  60. (function () {
  61. var toggle = document.querySelector('.edu-nav-toggle');
  62. var nav = document.querySelector('.edu-nav');
  63. var mask = document.querySelector('.edu-menu-mask');
  64. if (!toggle || !nav || !mask) return;
  65. var mobileBreakpoint = 1120;
  66. var backgroundNodes = [
  67. document.querySelector('.edu-brand'),
  68. document.querySelector('.edu-top-links'),
  69. document.querySelector('.edu-top-search'),
  70. document.querySelector('main'),
  71. document.querySelector('.edu-footer'),
  72. document.querySelector('.edu-back-top')
  73. ].filter(Boolean);
  74. function setBackgroundInert(inert) {
  75. backgroundNodes.forEach(function (node) { node.inert = inert; });
  76. }
  77. function syncState() {
  78. var mobile = window.innerWidth <= mobileBreakpoint;
  79. if (!mobile) {
  80. nav.classList.remove('is-open');
  81. mask.classList.remove('is-open');
  82. toggle.classList.remove('is-open');
  83. toggle.setAttribute('aria-expanded', 'false');
  84. toggle.setAttribute('aria-label', '打开导航');
  85. document.documentElement.style.overflow = '';
  86. Array.prototype.forEach.call(nav.querySelectorAll('.edu-nav-item.has-children.is-open'), function (item) {
  87. item.classList.remove('is-open');
  88. var itemLink = item.querySelector('.edu-nav-link');
  89. if (itemLink) itemLink.setAttribute('aria-expanded', 'false');
  90. });
  91. }
  92. var offscreen = mobile && !nav.classList.contains('is-open');
  93. nav.inert = offscreen;
  94. if (mobile) nav.setAttribute('aria-hidden', offscreen ? 'true' : 'false');
  95. else nav.removeAttribute('aria-hidden');
  96. setBackgroundInert(mobile && nav.classList.contains('is-open'));
  97. }
  98. function setOpen(open) {
  99. nav.classList.toggle('is-open', open);
  100. mask.classList.toggle('is-open', open);
  101. toggle.classList.toggle('is-open', open);
  102. toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
  103. toggle.setAttribute('aria-label', open ? '关闭导航' : '打开导航');
  104. document.documentElement.style.overflow = open ? 'hidden' : '';
  105. setBackgroundInert(open && window.innerWidth <= mobileBreakpoint);
  106. syncState();
  107. }
  108. toggle.addEventListener('click', function () { setOpen(!nav.classList.contains('is-open')); });
  109. mask.addEventListener('click', function () { setOpen(false); });
  110. Array.prototype.forEach.call(nav.querySelectorAll('.edu-subnav-toggle'), function (button) {
  111. button.addEventListener('click', function (event) {
  112. event.preventDefault();
  113. var item = button.closest('.edu-nav-item');
  114. if (!item) return;
  115. var open = !item.classList.contains('is-open');
  116. Array.prototype.forEach.call(nav.querySelectorAll('.edu-nav-item.has-children.is-open'), function (otherItem) {
  117. otherItem.classList.remove('is-open');
  118. var otherButton = otherItem.querySelector('.edu-subnav-toggle');
  119. if (otherButton) otherButton.setAttribute('aria-expanded', 'false');
  120. });
  121. item.classList.toggle('is-open', open);
  122. button.setAttribute('aria-expanded', open ? 'true' : 'false');
  123. });
  124. });
  125. Array.prototype.forEach.call(nav.querySelectorAll('.edu-subnav a'), function (link) {
  126. link.addEventListener('click', function () { if (window.innerWidth <= mobileBreakpoint) setOpen(false); });
  127. });
  128. document.addEventListener('keydown', function (event) { if (event.key === 'Escape') setOpen(false); });
  129. window.addEventListener('resize', syncState);
  130. syncState();
  131. })();
  132. </script>