theme-settings.js 6.9 KB

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