script-menu.js 4.6 KB

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