theme-settings.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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. } else {
  122. biosTitle.forEach((el, index) => {
  123. console.log(el.textContent);
  124. let text =
  125. '<li onclick="displaydetails(' +
  126. index +
  127. ')"><a >' +
  128. el.textContent +
  129. "</a></li>";
  130. list.insertAdjacentHTML("beforeend", text);
  131. });
  132. bios.forEach((el) => el.classList.add("desc-block-hidden"));
  133. bios[0].classList.remove("desc-block-hidden");
  134. let listItem = document.querySelectorAll("ul.profile-choices>li");
  135. listItem[0].classList.add("desc-active");
  136. }
  137. function displaydetails(i) {
  138. bios.forEach((el) => el.classList.add("desc-block-hidden"));
  139. bios[i].classList.remove("desc-block-hidden");
  140. let listItem = document.querySelectorAll("ul.profile-choices>li");
  141. listItem.forEach((el) => el.classList.remove("desc-active"));
  142. listItem[i].classList.add("desc-active");
  143. }
  144. function showSidebarOptions() {
  145. console.log(window.innerWidth);
  146. let windowX = window.matchMedia("(max-width: 600px)");
  147. if (windowX.matches) {
  148. bios.forEach((el) => el.classList.remove(".desc-block-hidden"));
  149. } else {
  150. bios.forEach((el) => el.classList.add("desc-block-hidden"));
  151. bios[0].classList.remove("desc-block-hidden");
  152. }
  153. }
  154. // Simple example, see optional options for more configuration.
  155. const pickr = Pickr.create({
  156. el: ".color-picker",
  157. theme: "nano",
  158. swatches: [
  159. "rgba(244, 67, 54, 1)",
  160. "rgba(233, 30, 99, 0.95)",
  161. "rgba(156, 39, 176, 0.9)",
  162. "rgba(103, 58, 183, 0.85)",
  163. "rgba(63, 81, 181, 0.8)",
  164. "rgba(33, 150, 243, 0.75)",
  165. "rgba(3, 169, 244, 0.7)",
  166. "rgba(0, 188, 212, 0.7)",
  167. "rgba(0, 150, 136, 0.75)",
  168. "rgba(76, 175, 80, 0.8)",
  169. "rgba(139, 195, 74, 0.85)",
  170. "rgba(205, 220, 57, 0.9)",
  171. "rgba(255, 235, 59, 0.95)",
  172. "rgba(255, 193, 7, 1)",
  173. ],
  174. components: {
  175. // Main components
  176. preview: true,
  177. opacity: true,
  178. hue: true,
  179. // Input / output Options
  180. interaction: {
  181. hex: true,
  182. rgba: false,
  183. hsla: false,
  184. hsva: false,
  185. cmyk: false,
  186. input: true,
  187. clear: true,
  188. save: true,
  189. },
  190. },
  191. });
  192. pickr.on("change", (...args) => {
  193. let color = args[0].toHEXA();
  194. console.log(args);
  195. console.log(color.toString());
  196. const buttons = document.getElementsByClassName("primary-c");
  197. for (let i = 0; i < buttons.length; i++) {
  198. buttons[i].style.backgroundColor = color.toString();
  199. buttons[i].addEventListener("mouseenter", (e) => {
  200. buttons[i].style.backgroundColor = "#F68B1F";
  201. });
  202. buttons[i].addEventListener("mouseleave", (e) => {
  203. buttons[i].style.backgroundColor = color.toString();
  204. });
  205. }
  206. });