landing.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. (function ($) {
  2. "use strict";
  3. // PAGE LOADING
  4. $(window).on("load", function (e) {
  5. $("#global-loader").fadeOut("slow");
  6. });
  7. // CARD
  8. const DIV_CARD = "div.card";
  9. // FUNCTIONS FOR COLLAPSED CARD
  10. $(document).on("click", '[data-bs-toggle="card-collapse"]', function (e) {
  11. let $card = $(this).closest(DIV_CARD);
  12. $card.toggleClass("card-collapsed");
  13. e.preventDefault();
  14. return false;
  15. });
  16. // BACK TO TOP BUTTON
  17. $(window).on("scroll", function (e) {
  18. if ($(this).scrollTop() > 0) {
  19. $("#back-to-top").fadeIn("slow");
  20. } else {
  21. $("#back-to-top").fadeOut("slow");
  22. }
  23. });
  24. $(document).on("click", "#back-to-top", function (e) {
  25. $("html, body").animate(
  26. {
  27. scrollTop: 0,
  28. },
  29. 0
  30. );
  31. return false;
  32. });
  33. $(".testimonial-carousel").slick({
  34. slidesToShow: 1,
  35. slidesToScroll: 1,
  36. autoplay: true,
  37. autoplaySpeed: 1000,
  38. arrows: true,
  39. dots: false,
  40. pauseOnHover: false,
  41. responsive: [
  42. {
  43. breakpoint: 768,
  44. settings: {
  45. slidesToShow: 1,
  46. },
  47. },
  48. {
  49. breakpoint: 520,
  50. settings: {
  51. slidesToShow: 1,
  52. },
  53. },
  54. ],
  55. });
  56. $(".feature-logos").slick({
  57. slidesToShow: 6,
  58. slidesToScroll: 1,
  59. autoplay: true,
  60. autoplaySpeed: 1000,
  61. arrows: false,
  62. dots: false,
  63. pauseOnHover: false,
  64. responsive: [
  65. {
  66. breakpoint: 992,
  67. settings: {
  68. slidesToShow: 4,
  69. },
  70. },
  71. {
  72. breakpoint: 520,
  73. settings: {
  74. slidesToShow: 2,
  75. },
  76. },
  77. ],
  78. });
  79. $(document).on("click", ".page", function () {
  80. if ($(".demo_changer").hasClass("active")) {
  81. $(".demo_changer").animate({ "inset-inline-end": "-270px" }, function () {
  82. $(".demo_changer").toggleClass("active");
  83. });
  84. }
  85. });
  86. // RTL STYLE START
  87. $("#myonoffswitch24").on("click", function () {
  88. if (this.checked) {
  89. $("body").addClass("rtl");
  90. $(".slick-slider").slick("slickSetOption", "rtl", true);
  91. $("html[lang=en]").attr("dir", "rtl");
  92. $("body").removeClass("ltr");
  93. $("head link#style").attr("href", $(this));
  94. document
  95. .getElementById("style")
  96. .setAttribute(
  97. "href",
  98. "../assets/plugins/bootstrap/css/bootstrap.rtl.min.css"
  99. );
  100. var carousel = $(".owl-carousel");
  101. $.each(carousel, function (index, element) {
  102. // element == this
  103. var carouselData = $(element).data("owl.carousel");
  104. carouselData.settings.rtl = true; //don't know if both are necessary
  105. carouselData.options.rtl = true;
  106. $(element).trigger("refresh.owl.carousel");
  107. });
  108. localStorage.setItem("sashrtl", true);
  109. localStorage.removeItem("sashltr");
  110. }
  111. });
  112. // RTL STYLE END
  113. // LTR STYLE START
  114. $("#myonoffswitch23").on("click", function () {
  115. if (this.checked) {
  116. $("body").addClass("ltr");
  117. $(".slick-slider").slick("slickSetOption", "rtl", false);
  118. $("html[lang=en]").attr("dir", "ltr");
  119. $("body").removeClass("rtl");
  120. $("head link#style").attr("href", $(this));
  121. document
  122. .getElementById("style")
  123. .setAttribute(
  124. "href",
  125. "../assets/plugins/bootstrap/css/bootstrap.min.css"
  126. );
  127. var carousel = $(".owl-carousel");
  128. $.each(carousel, function (index, element) {
  129. // element == this
  130. var carouselData = $(element).data("owl.carousel");
  131. carouselData.settings.rtl = false; //don't know if both are necessary
  132. carouselData.options.rtl = false;
  133. $(element).trigger("refresh.owl.carousel");
  134. });
  135. localStorage.setItem("sashltr", true);
  136. localStorage.removeItem("sashrtl");
  137. }
  138. });
  139. // LTR STYLE END
  140. // LIGHT THEME START
  141. $(document).on("click", "#myonoffswitch1", function () {
  142. if (this.checked) {
  143. $("body").removeClass("dark-mode");
  144. $("body").addClass("light-mode");
  145. $("#myonoffswitch3").prop("checked", true);
  146. $("#myonoffswitch6").prop("checked", true);
  147. localStorage.removeItem("sashdarkMode");
  148. }
  149. });
  150. // LIGHT THEME END
  151. // DARK THEME START
  152. $(document).on("click", "#myonoffswitch2", function () {
  153. if (this.checked) {
  154. $("body").addClass("dark-mode");
  155. $("body").removeClass("light-mode");
  156. $("#myonoffswitch5").prop("checked", true);
  157. $("#myonoffswitch8").prop("checked", true);
  158. localStorage.setItem("sashdarkMode", true);
  159. }
  160. });
  161. // DARK THEME END
  162. function landingPageLocalstorage() {
  163. if (localStorage.getItem("sashrtl")) {
  164. $("body").addClass("rtl");
  165. }
  166. if (localStorage.getItem("sashdarkMode")) {
  167. $("body").addClass("dark-mode");
  168. }
  169. }
  170. landingPageLocalstorage();
  171. if ($("body").hasClass("rtl")) {
  172. $(".slick-slider").slick("slickSetOption", "rtl", true);
  173. $("#slide-left").removeClass("d-none");
  174. $("#slide-right").removeClass("d-none");
  175. $("html[lang=en]").attr("dir", "rtl");
  176. $("body").removeClass("ltr");
  177. $("head link#style").attr("href", $(this));
  178. document
  179. .getElementById("style")
  180. .setAttribute(
  181. "href",
  182. "../assets/plugins/bootstrap/css/bootstrap.rtl.min.css"
  183. );
  184. var carousel = $(".owl-carousel");
  185. $.each(carousel, function (index, element) {
  186. // element == this
  187. var carouselData = $(element).data("owl.carousel");
  188. carouselData.settings.rtl = true; //don't know if both are necessary
  189. carouselData.options.rtl = true;
  190. $(element).trigger("refresh.owl.carousel");
  191. });
  192. $("#myonoffswitch24").prop("checked", true);
  193. }
  194. if ($("body").hasClass("dark-mode")) {
  195. $("body").removeClass("light-mode");
  196. $("#myonoffswitch2").prop("checked", true);
  197. }
  198. $(document).on("click", '[data-bs-toggle="sidebar"]', function (event) {
  199. event.preventDefault();
  200. $(".app").toggleClass("sidenav-toggled");
  201. });
  202. if (window.innerWidth <= 992) {
  203. $("body").removeClass("sidenav-toggled");
  204. }
  205. })(jQuery);
  206. // FOOTER
  207. document.getElementById("year").innerHTML = new Date().getFullYear();
  208. window.addEventListener("scroll", reveal);
  209. function reveal() {
  210. var reveals = document.querySelectorAll(".reveal");
  211. for (var i = 0; i < reveals.length; i++) {
  212. var windowHeight = window.innerHeight;
  213. var cardTop = reveals[i].getBoundingClientRect().top;
  214. var cardRevealPoint = 150;
  215. // console.log('condition', windowHeight - cardRevealPoint)
  216. if (cardTop < windowHeight - cardRevealPoint) {
  217. reveals[i].classList.add("active");
  218. } else {
  219. reveals[i].classList.remove("active");
  220. }
  221. }
  222. }
  223. reveal();
  224. // ==== for menu scroll
  225. const pageLink = document.querySelectorAll(".side-menu__item");
  226. pageLink.forEach((elem) => {
  227. if (elem != 'javascript:void(0)' && elem !== "#") {
  228. elem.addEventListener("click", (e) => {
  229. e.preventDefault();
  230. document.querySelector(elem.getAttribute("href"))?.scrollIntoView({
  231. behavior: "smooth",
  232. offsetTop: 1 - 60,
  233. });
  234. });
  235. }
  236. });
  237. // section menu active
  238. function onScroll(event) {
  239. const sections = document.querySelectorAll(".side-menu__item");
  240. const scrollPos =
  241. window.pageYOffset ||
  242. document.documentElement.scrollTop ||
  243. document.body.scrollTop;
  244. sections.forEach((elem) => {
  245. const val = elem.getAttribute("href");
  246. let refElement;
  247. if (val != 'javascript:void(0)' && val !== "#") {
  248. refElement = document.querySelector(val);
  249. }
  250. const scrollTopMinus = scrollPos + 73;
  251. if (
  252. refElement?.offsetTop <= scrollTopMinus &&
  253. refElement?.offsetTop + refElement.offsetHeight > scrollTopMinus
  254. ) {
  255. elem.classList.add("active");
  256. } else {
  257. elem.classList.remove("active");
  258. }
  259. });
  260. }
  261. window.document.addEventListener("scroll", onScroll);
  262. jQuery(".demo-icon").click(function () {
  263. if ($(".demo_changer").hasClass("active")) {
  264. $(".demo_changer").animate({ "inset-inline-end": "-270px" }, function () {
  265. $(".demo_changer").toggleClass("active");
  266. });
  267. } else {
  268. $(".demo_changer").animate({ "inset-inline-end": "0px" }, function () {
  269. $(".demo_changer").toggleClass("active");
  270. });
  271. }
  272. });
  273. // RESET SWITCHER TO DEFAULT
  274. function resetData() {
  275. $('#myonoffswitch23').prop('checked', true);
  276. $('#myonoffswitch1').prop('checked', true);
  277. $('body').addClass('ltr');
  278. $('.slick-slider').slick('slickSetOption', 'rtl', false);
  279. $("html[lang=en]").attr("dir", "ltr");
  280. $('body').removeClass('rtl');
  281. $("head link#style").attr("href", $(this));
  282. (document.getElementById("style").setAttribute("href", "../assets/plugins/bootstrap/css/bootstrap.min.css"));
  283. var carousel = $('.owl-carousel');
  284. $.each(carousel, function (index, element) {
  285. // element == this
  286. var carouselData = $(element).data('owl.carousel');
  287. carouselData.settings.rtl = false; //don't know if both are necessary
  288. carouselData.options.rtl = false;
  289. $(element).trigger('refresh.owl.carousel');
  290. });
  291. $('body').removeClass('dark-mode');
  292. $('body').addClass('light-mode');
  293. $('#myonoffswitch3').prop('checked', true);
  294. $('#myonoffswitch6').prop('checked', true);
  295. localStorage.clear()
  296. }
  297. /******* RTL VERSION *******/
  298. // $('body').addClass('rtl');
  299. /******* Theme Style ********/
  300. // $('body').addClass('dark-mode');
  301. function menuClick() {
  302. $("[data-bs-toggle='slide']").off('click');
  303. $("[data-bs-toggle='sub-slide']").off('click')
  304. $("[data-bs-toggle='sub-slide2']").off('click')
  305. $("[data-bs-toggle='slide']").on('click', function (e) {
  306. var $this = $(this);
  307. var checkElement = $this.next();
  308. var animationSpeed = 300,
  309. slideMenuSelector = '.slide-menu';
  310. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  311. checkElement.slideUp(animationSpeed, function () {
  312. checkElement.removeClass('open');
  313. });
  314. checkElement.parent("li").removeClass("is-expanded");
  315. }
  316. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  317. var parent = $this.parents('ul').first();
  318. var ul = parent.find('ul[class^="slide-menu"]:visible').slideUp(animationSpeed);
  319. ul.removeClass('open');
  320. var parent_li = $this.parent("li");
  321. checkElement.slideDown(animationSpeed, function () {
  322. checkElement.addClass('open');
  323. parent.find('li.is-expanded').removeClass('is-expanded');
  324. parent_li.addClass('is-expanded');
  325. });
  326. }
  327. if (checkElement.is(slideMenuSelector)) {
  328. e.preventDefault();
  329. }
  330. if (window.innerWidth >= 992) {
  331. if (!checkElement.hasClass('double-menu-active') && !document.body.classList.contains('horizontal') && (document.body.classList.contains('double-menu') || document.body.classList.contains('double-menu-tabs'))) {
  332. if (document.querySelector('.slide-menu')) {
  333. let slidemenu = document.querySelectorAll('.slide-menu');
  334. slidemenu.forEach(e => {
  335. if (e.classList.contains('double-menu-active')) {
  336. e.classList.remove('double-menu-active')
  337. }
  338. })
  339. }
  340. checkElement.addClass('double-menu-active');
  341. document.body.classList.remove("sidenav-toggled")
  342. }
  343. }
  344. });
  345. // Activate sidebar slide toggle
  346. $("[data-bs-toggle='sub-slide']").on('click', function (e) {
  347. var $this = $(this);
  348. var checkElement = $this.next();
  349. var animationSpeed = 300,
  350. slideMenuSelector = '.sub-slide-menu';
  351. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  352. checkElement.slideUp(animationSpeed, function () {
  353. checkElement.removeClass('open');
  354. });
  355. checkElement.parent("li").removeClass("is-expanded");
  356. }
  357. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  358. var parent = $this.parents('ul').first();
  359. var ul = parent.find('ul[class^="sub-slide-menu"]:visible').slideUp(animationSpeed);
  360. ul.removeClass('open');
  361. var parent_li = $this.parent("li");
  362. checkElement.slideDown(animationSpeed, function () {
  363. checkElement.addClass('open');
  364. parent.find('li.is-expanded').removeClass('is-expanded');
  365. parent_li.addClass('is-expanded');
  366. });
  367. }
  368. if (checkElement.is(slideMenuSelector)) {
  369. e.preventDefault();
  370. }
  371. });
  372. // Activate sidebar slide toggle
  373. $("[data-bs-toggle='sub-slide2']").on('click', function (e) {
  374. var $this = $(this);
  375. var checkElement = $this.next();
  376. var animationSpeed = 300,
  377. slideMenuSelector = '.sub-slide-menu2';
  378. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  379. checkElement.slideUp(animationSpeed, function () {
  380. checkElement.removeClass('open');
  381. });
  382. checkElement.parent("li").removeClass("is-expanded");
  383. }
  384. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  385. var parent = $this.parents('ul').first();
  386. var ul = parent.find('ul[class^="sub-slide-menu"]:visible').slideUp(animationSpeed);
  387. ul.removeClass('open');
  388. var parent_li = $this.parent("li");
  389. checkElement.slideDown(animationSpeed, function () {
  390. checkElement.addClass('open');
  391. parent.find('li.is-expanded').removeClass('is-expanded');
  392. parent_li.addClass('is-expanded');
  393. });
  394. }
  395. if (checkElement.is(slideMenuSelector)) {
  396. e.preventDefault();
  397. }
  398. });
  399. }
  400. menuClick();
  401. // COVER IMAGE
  402. $(".cover-image").each(function () {
  403. var attr = $(this).attr('data-bs-image-src');
  404. if (typeof attr !== typeof undefined && attr !== false) {
  405. $(this).css('background', 'url(' + attr + ') center center');
  406. }
  407. });