education-header.jsp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. </nav>
  22. <form class="edu-top-search" action="/search" method="get" role="search">
  23. <label class="edu-sr-only" for="edu-top-search-input">搜索本站内容</label>
  24. <input id="edu-top-search-input" name="str" type="search" value="${str}" placeholder="搜索文章、通知、专业…" autocomplete="off">
  25. <button type="submit" aria-label="搜索">
  26. <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>
  27. </button>
  28. </form>
  29. <button class="edu-nav-toggle" type="button" aria-label="打开导航" aria-expanded="false" aria-controls="education-main-nav"><span></span><span></span><span></span></button>
  30. </div>
  31. </div>
  32. </header>
  33. <nav class="edu-nav" id="education-main-nav" aria-label="${educationSiteTitle}主导航">
  34. <div class="edu-wrap edu-nav-inner">
  35. <div class="edu-nav-item">
  36. <a class="edu-nav-link ${empty navigation ? 'is-active' : ''}" href="/">首页</a>
  37. </div>
  38. <c:forEach items="${navList}" var="item">
  39. <c:if test="${item.name ne '首页' and item.name ne '首页子栏目'}">
  40. <div class="edu-nav-item ${not empty item.children ? 'has-children' : ''}">
  41. <c:set var="educationNavHref" value="${item.href}"/>
  42. <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>
  43. <div class="edu-nav-row">
  44. <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>
  45. <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>
  46. </div>
  47. <c:if test="${not empty item.children}">
  48. <div class="edu-subnav" id="education-subnav-${item.navigationid}">
  49. <c:forEach items="${item.children}" var="child"><a href="${child.href}" target="${child.target}" rel="noopener">${child.name}</a></c:forEach>
  50. </div>
  51. </c:if>
  52. </div>
  53. </c:if>
  54. </c:forEach>
  55. </div>
  56. </nav>
  57. <div class="edu-menu-mask" aria-hidden="true"></div>
  58. <script>
  59. (function () {
  60. var toggle = document.querySelector('.edu-nav-toggle');
  61. var nav = document.querySelector('.edu-nav');
  62. var mask = document.querySelector('.edu-menu-mask');
  63. if (!toggle || !nav || !mask) return;
  64. var mobileBreakpoint = 1120;
  65. var backgroundNodes = [
  66. document.querySelector('.edu-brand'),
  67. document.querySelector('.edu-top-links'),
  68. document.querySelector('.edu-top-search'),
  69. document.querySelector('main'),
  70. document.querySelector('.edu-footer'),
  71. document.querySelector('.edu-back-top')
  72. ].filter(Boolean);
  73. function setBackgroundInert(inert) {
  74. backgroundNodes.forEach(function (node) { node.inert = inert; });
  75. }
  76. function syncState() {
  77. var mobile = window.innerWidth <= mobileBreakpoint;
  78. if (!mobile) {
  79. nav.classList.remove('is-open');
  80. mask.classList.remove('is-open');
  81. toggle.classList.remove('is-open');
  82. toggle.setAttribute('aria-expanded', 'false');
  83. toggle.setAttribute('aria-label', '打开导航');
  84. document.documentElement.style.overflow = '';
  85. Array.prototype.forEach.call(nav.querySelectorAll('.edu-nav-item.has-children.is-open'), function (item) {
  86. item.classList.remove('is-open');
  87. var itemLink = item.querySelector('.edu-nav-link');
  88. if (itemLink) itemLink.setAttribute('aria-expanded', 'false');
  89. });
  90. }
  91. var offscreen = mobile && !nav.classList.contains('is-open');
  92. nav.inert = offscreen;
  93. if (mobile) nav.setAttribute('aria-hidden', offscreen ? 'true' : 'false');
  94. else nav.removeAttribute('aria-hidden');
  95. setBackgroundInert(mobile && nav.classList.contains('is-open'));
  96. }
  97. function setOpen(open) {
  98. nav.classList.toggle('is-open', open);
  99. mask.classList.toggle('is-open', open);
  100. toggle.classList.toggle('is-open', open);
  101. toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
  102. toggle.setAttribute('aria-label', open ? '关闭导航' : '打开导航');
  103. document.documentElement.style.overflow = open ? 'hidden' : '';
  104. setBackgroundInert(open && window.innerWidth <= mobileBreakpoint);
  105. syncState();
  106. }
  107. toggle.addEventListener('click', function () { setOpen(!nav.classList.contains('is-open')); });
  108. mask.addEventListener('click', function () { setOpen(false); });
  109. Array.prototype.forEach.call(nav.querySelectorAll('.edu-subnav-toggle'), function (button) {
  110. button.addEventListener('click', function (event) {
  111. event.preventDefault();
  112. var item = button.closest('.edu-nav-item');
  113. if (!item) return;
  114. var open = !item.classList.contains('is-open');
  115. Array.prototype.forEach.call(nav.querySelectorAll('.edu-nav-item.has-children.is-open'), function (otherItem) {
  116. otherItem.classList.remove('is-open');
  117. var otherButton = otherItem.querySelector('.edu-subnav-toggle');
  118. if (otherButton) otherButton.setAttribute('aria-expanded', 'false');
  119. });
  120. item.classList.toggle('is-open', open);
  121. button.setAttribute('aria-expanded', open ? 'true' : 'false');
  122. });
  123. });
  124. Array.prototype.forEach.call(nav.querySelectorAll('.edu-subnav a'), function (link) {
  125. link.addEventListener('click', function () { if (window.innerWidth <= mobileBreakpoint) setOpen(false); });
  126. });
  127. document.addEventListener('keydown', function (event) { if (event.key === 'Escape') setOpen(false); });
  128. window.addEventListener('resize', syncState);
  129. syncState();
  130. })();
  131. </script>