theme-settings.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. // const sidebar = document.querySelector('#sidebar')
  2. window.onscroll = function () {
  3. let navbar = document.querySelector("nav#first-nav");
  4. let secondNav = document.querySelector("nav#second-nav");
  5. if (window.scrollY > 300) {
  6. if (secondNav) secondNav.classList.add("second-nav-active");
  7. navbar.classList.add("nav-resp");
  8. } else {
  9. if (secondNav) secondNav.classList.remove("second-nav-active");
  10. navbar.classList.remove("nav-resp");
  11. }
  12. };
  13. // const buttons = document.querySelectorAll("[data-carousel-button]")
  14. document.querySelectorAll("[data-carousel-button]").forEach((button) => {
  15. button.addEventListener("click", () => {
  16. const offset = button.dataset.carouselButton === "next" ? 1 : -1;
  17. const slides = button
  18. .closest("[data-carousel]")
  19. .querySelector("[data-slides]");
  20. const activeSlide = slides.querySelector("[data-active]");
  21. let newIndex = [...slides.children].indexOf(activeSlide) + offset;
  22. if (newIndex < 0) newIndex = slides.children.length - 1;
  23. if (newIndex >= slides.children.length) newIndex = 0;
  24. slides.children[newIndex].dataset.active = true;
  25. delete activeSlide.dataset.active;
  26. });
  27. });
  28. setInterval(function () {
  29. if (document.querySelector(".carousel-button.next"))
  30. document.querySelector(".carousel-button.next").click();
  31. }, 5000);
  32. function openSearch() {
  33. document.getElementById("search-modal").style.height = "100%";
  34. console.log("search opened");
  35. }
  36. /* Close when someone clicks on the "x" symbol inside the overlay */
  37. function closeSearch() {
  38. document.getElementById("search-modal").style.height = "0%";
  39. }
  40. let totalDivs = document.querySelectorAll(
  41. "#faculty-carousel > .profile-carousel > .car-item"
  42. ).length;
  43. let screenWidth = Math.max(
  44. document.documentElement.clientWidth || 0,
  45. window.innerWidth || 0
  46. );
  47. let totalWidth = totalDivs * 340;
  48. let extraWidth = screenWidth - totalWidth;
  49. let scrolled = 0;
  50. function scrollToNext() {
  51. scrolled -= 345;
  52. let moveX = "";
  53. if (scrolled <= extraWidth - 400) {
  54. scrolled = 0;
  55. }
  56. moveX = scrolled.toString() + "px";
  57. //console.log(moveX, (-1*extraWidth), screenWidth, totalWidth, totalDivs)
  58. document.querySelectorAll(
  59. "#faculty-carousel > .profile-carousel"
  60. )[0].style.left = moveX;
  61. }
  62. function scrollToPrev() {
  63. scrolled = scrolled + 345;
  64. let moveX = "";
  65. if (scrolled > 340) {
  66. scrolled = extraWidth - 50;
  67. }
  68. moveX = scrolled.toString() + "px";
  69. //console.log(scrolled, moveX, (extraWidth), screenWidth, totalWidth, totalDivs)
  70. document.querySelectorAll(
  71. "#faculty-carousel > .profile-carousel"
  72. )[0].style.left = moveX;
  73. }
  74. let totalDivsAl = document.querySelectorAll(
  75. "#alumni-carousel > .profile-carousel > .car-item"
  76. ).length;
  77. let screenWidthAl = Math.max(
  78. document.documentElement.clientWidth || 0,
  79. window.innerWidth || 0
  80. );
  81. let totalWidthAl = totalDivsAl * 340;
  82. let extraWidthAl = screenWidthAl - totalWidthAl;
  83. let scrolledAl = 0;
  84. function scrollToNextAl() {
  85. scrolledAl -= 340;
  86. let moveXAl = "";
  87. if (scrolledAl <= extraWidthAl - 400) {
  88. scrolledAl = 0;
  89. }
  90. moveXAl = scrolledAl.toString() + "px";
  91. document.querySelectorAll(
  92. "#alumni-carousel > .profile-carousel"
  93. )[0].style.left = moveXAl;
  94. }
  95. function scrollToPrevAl() {
  96. scrolledAl = scrolledAl + 340;
  97. let moveXAl = "";
  98. if (scrolledAl > 340) {
  99. scrolledAl = extraWidthAl - 50;
  100. }
  101. moveXAl = scrolledAl.toString() + "px";
  102. document.querySelectorAll(
  103. "#alumni-carousel > .profile-carousel"
  104. )[0].style.left = moveXAl;
  105. }
  106. //for NAV
  107. function openNav() {
  108. document.getElementById("myNav").style.height = "100%";
  109. }
  110. /* Close when someone clicks on the "x" symbol inside the overlay */
  111. function closeNav() {
  112. document.getElementById("myNav").style.height = "0%";
  113. }
  114. //profile
  115. window.addEventListener("resize", showSidebarOptions)
  116. const biosTitle = document.querySelectorAll('h2.m-text')
  117. const list = document.querySelector('ul.profile-choices')
  118. const bios = document.querySelectorAll('.desc-block')
  119. if(window.innerWidth < 600) {
  120. bios.forEach( el => el.classList.remove('.desc-block-hidden'))
  121. }
  122. else {
  123. biosTitle.forEach((el, index) => {
  124. console.log(el.textContent)
  125. let text = '<li onclick="displaydetails('+ index +')"><a >' + el.textContent + '</a></li>'
  126. list.insertAdjacentHTML("beforeend", text )
  127. })
  128. bios.forEach(el => el.classList.add('desc-block-hidden'))
  129. bios[0].classList.remove('desc-block-hidden')
  130. let listItem = document.querySelectorAll('ul.profile-choices>li')
  131. listItem[0].classList.add('desc-active')
  132. }
  133. function displaydetails (i) {
  134. bios.forEach( el => el.classList.add('desc-block-hidden'))
  135. bios[i].classList.remove('desc-block-hidden')
  136. let listItem = document.querySelectorAll('ul.profile-choices>li')
  137. listItem.forEach( el => el.classList.remove('desc-active'))
  138. listItem[i].classList.add('desc-active')
  139. }
  140. function showSidebarOptions(){
  141. console.log(window.innerWidth)
  142. let windowX = window.matchMedia("(max-width: 600px)")
  143. if(windowX.matches) {
  144. bios.forEach( el => el.classList.remove('.desc-block-hidden'))
  145. }
  146. else {
  147. bios.forEach(el => el.classList.add('desc-block-hidden'))
  148. bios[0].classList.remove('desc-block-hidden')
  149. }
  150. }
  151. // Simple example, see optional options for more configuration.
  152. const pickr = Pickr.create({
  153. el: ".color-picker",
  154. theme: "nano",
  155. swatches: [
  156. "rgba(244, 67, 54, 1)",
  157. "rgba(233, 30, 99, 0.95)",
  158. "rgba(156, 39, 176, 0.9)",
  159. "rgba(103, 58, 183, 0.85)",
  160. "rgba(63, 81, 181, 0.8)",
  161. "rgba(33, 150, 243, 0.75)",
  162. "rgba(3, 169, 244, 0.7)",
  163. "rgba(0, 188, 212, 0.7)",
  164. "rgba(0, 150, 136, 0.75)",
  165. "rgba(76, 175, 80, 0.8)",
  166. "rgba(139, 195, 74, 0.85)",
  167. "rgba(205, 220, 57, 0.9)",
  168. "rgba(255, 235, 59, 0.95)",
  169. "rgba(255, 193, 7, 1)",
  170. ],
  171. components: {
  172. // Main components
  173. preview: true,
  174. opacity: true,
  175. hue: true,
  176. // Input / output Options
  177. interaction: {
  178. hex: true,
  179. rgba: false,
  180. hsla: false,
  181. hsva: false,
  182. cmyk: false,
  183. input: true,
  184. clear: true,
  185. save: true,
  186. },
  187. },
  188. });
  189. pickr.on("change", (...args) => {
  190. let color = args[0].toHEXA();
  191. console.log(args);
  192. console.log(color.toString());
  193. const buttons = document.getElementsByClassName("primary-c");
  194. for (let i = 0; i < buttons.length; i++) {
  195. buttons[i].style.backgroundColor = color.toString();
  196. buttons[i].addEventListener("mouseenter", (e) => {
  197. buttons[i].style.backgroundColor = "#F68B1F";
  198. });
  199. buttons[i].addEventListener("mouseleave", (e) => {
  200. buttons[i].style.backgroundColor = color.toString();
  201. });
  202. }
  203. });