theme-settings.js 7.8 KB

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