script-menu.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. const ham = document.getElementById('ham');
  2. ham.addEventListener('click', function () {
  3. console.log("open");
  4. document.body.classList.toggle('nav-is-toggled');
  5. });
  6. const ham1 = document.getElementById('closemenu');
  7. ham1.addEventListener('click', function () {
  8. console.log("close");
  9. document.body.classList.toggle('nav-is-toggled');
  10. });
  11. const links = document.querySelectorAll(".item-link");
  12. for (const link of links) {
  13. link.addEventListener("click", clickHandler);
  14. }
  15. function clickHandler(e) {
  16. e.preventDefault();
  17. const href = this.getAttribute("href");
  18. const offsetTop = document.querySelector(href).offsetTop - 81;
  19. scroll({
  20. top: offsetTop,
  21. behavior: "smooth"
  22. });
  23. }
  24. $(document).ready(function () {
  25. // active thumbnail
  26. $("#thumbSlider .thumb").on("click", function () {
  27. $(this).addClass("active");
  28. $(this).siblings().removeClass("active");
  29. });
  30. $(document).click(function (event) {
  31. var clickover = $(event.target);
  32. var _opened = $("body").hasClass("nav-is-toggled");
  33. if (_opened === true && !clickover.hasClass("navbar-collapse") && clickover.parents("#navbar").length == 0 && clickover.attr("id") != "ham" && clickover.parent().attr("id") != "ham") {
  34. document.body.classList.toggle('nav-is-toggled');
  35. }
  36. });
  37. })
  38. // $(document).ready(function () {
  39. // $('.blog').click(function (e) {
  40. // $(".submenu").toggleClass("show-menu");
  41. // $(".ftco-section").toggleClass("show-menu");
  42. // $(".main-archive").toggleClass("show-menu");
  43. // });
  44. // $(window).click(function (event) {
  45. // var $target = $(event.target);
  46. // var $parent = $target.closest(".submenu");
  47. // var $show = $target.closest(".blog");
  48. // if ($parent.length == 0 && $show.length == 0) {
  49. // var $menu = $('.submenu');
  50. // $menu.removeClass("show-menu");
  51. // var $menu1 = $('.ftco-section');
  52. // $menu1.removeClass("show-menu");
  53. // var $menu2 = $('.main-archive');
  54. // $menu2.removeClass("show-menu");
  55. // }
  56. // });
  57. // });
  58. // custom
  59. var lang;
  60. $(document).ready(function () {
  61. lang = getCookie("Language");
  62. console.log(lang);
  63. $(".setLang").on("click", function (event) {
  64. var lang = $(this).attr("lang");
  65. console.log(lang);
  66. document.cookie = "Language" + "=" + lang + ";path=/";
  67. $.ajax({
  68. url: "/Language/ChangeLanguage",
  69. data: {
  70. __RequestVerificationToken: $('input[name=__RequestVerificationToken]').val(),
  71. LanguageAbbrevation: lang
  72. },
  73. type: "POST",
  74. success: function (data) {
  75. console.log(data);
  76. location.reload(true);
  77. },
  78. error: function (req, st, error) {
  79. console.log("Error : " + error);
  80. }
  81. });
  82. });
  83. if (lang == null || lang == undefined) {
  84. lang = "fr";
  85. //document.cookie = "Language" + "=" + lang + ";"
  86. $(".setLang[lang='" + lang + "']").click();
  87. }
  88. console.log($(".setLang[lang='" + lang + "']").find("span:first").html());
  89. //$(".current-lang").html("<span>" + $(".setLang[lang='" + lang + "']").find("span:first").html() + "</span>");
  90. $("#langLabel").html(lang == 'en' ? 'EN' : 'TL');
  91. });
  92. function getCookie(ck_name) {
  93. var ck_value = document.cookie;
  94. console.log(ck_name);
  95. console.log(ck_value);
  96. var ck_start = ck_value.indexOf(" " + ck_name + "=");
  97. if (ck_start == -1) {
  98. ck_start = ck_value.indexOf(ck_name + "=");
  99. }
  100. if (ck_start == -1) {
  101. ck_value = null;
  102. } else {
  103. ck_start = ck_value.indexOf("=", ck_start) + 1;
  104. var ck_end = ck_value.indexOf(";", ck_start);
  105. if (ck_end == -1) {
  106. ck_end = ck_value.length;
  107. }
  108. ck_value = unescape(ck_value.substring(ck_start, ck_end));
  109. }
  110. return ck_value;
  111. };
  112. jQuery(document).ready(function () {
  113. //$(".menu-top")
  114. $("#loginRedirect").val("/");
  115. });
  116. $('body').on('click', '.is-invalid', function () {
  117. // do something
  118. $(".is-invalid").removeClass("is-invalid");
  119. });
  120. $(".login-dialog").click(function () {
  121. console.log("login click");
  122. $("#modalLogin").modal({ backdrop: 'static', keyboard: false });
  123. });
  124. $("input").keypress(function () {
  125. $(this).next(".invalid-feedback").hide();
  126. });