BCB Bank static website
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

177 行
4.4 KiB

  1. var hamburger_menu = document.getElementById('mobile-hamburger-menu');
  2. var mobile_menu = document.getElementById('mobile-nav-menu');
  3. hamburger_menu.addEventListener('click', show_menu);
  4. function show_menu() {
  5. 'use strict';
  6. hamburger_menu.classList.toggle('active');
  7. document.body.classList.toggle('non-scrollable');
  8. mobile_menu.classList.toggle('show');
  9. }
  10. var desktop_navigation_menu_links = document.querySelectorAll('#desktop-navigation-menu ul li');
  11. for (var i = 0; i < desktop_navigation_menu_links.length; i++) {
  12. desktop_navigation_menu_links[i].addEventListener('click', changeActiveClass);
  13. }
  14. function changeActiveClass(e) {
  15. for (var i = 0; i < desktop_navigation_menu_links.length; i++) {
  16. desktop_navigation_menu_links[i].classList.remove('active');
  17. }
  18. e.currentTarget.classList.add('active');
  19. }
  20. var page_header = document.getElementById('page-header');
  21. var about_description_animate = document.querySelector('#about .description');
  22. var about_image_animate = document.querySelector('#about figure');
  23. window.addEventListener('scroll', page_scroll);
  24. document.addEventListener('DOMContentLoaded', page_loaded);
  25. function page_scroll() {
  26. 'use strict';
  27. var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
  28. if (-120 + winScroll >= about_description_animate.offsetTop) {
  29. about_description_animate.classList.add('show');
  30. about_image_animate.classList.add('show');
  31. }
  32. }
  33. var home_image = document.querySelector('#home figure');
  34. var home_description = document.querySelector('#home .description');
  35. var temp_contact_info = document.querySelectorAll('.temp-contact-info ul li');
  36. function page_loaded() {
  37. home_image.classList.remove('hide');
  38. home_description.classList.remove('hide');
  39. if ($(window).width() < 960) {
  40. $(document).on('click', 'a[href^="#"]', function (event) {
  41. event.preventDefault();
  42. $('html, body').animate({
  43. scrollTop: $($.attr(this, 'href')).offset().top - 780
  44. }, 500);
  45. });
  46. for (var i = 0; i < temp_contact_info.length; i++) {
  47. temp_contact_info[i].addEventListener('click', toggle_contact_info);
  48. }
  49. }
  50. }
  51. function toggle_contact_info(e) {
  52. for (var i = 0; i < temp_contact_info.length; i++) {
  53. temp_contact_info[i].classList.remove('active');
  54. }
  55. e.currentTarget.classList.add('active');
  56. }
  57. var mobile_nav_lists = document.querySelectorAll('#mobile-nav-menu ul li');
  58. for (var i = 0; i < mobile_nav_lists.length; i++) {
  59. mobile_nav_lists[i].addEventListener('click', hide_mobile_nav);
  60. }
  61. function hide_mobile_nav() {
  62. mobile_menu.classList.remove('show');
  63. hamburger_menu.classList.remove('active');
  64. document.body.classList.remove('non-scrollable');
  65. }
  66. // Native method of doing smooth scrolling
  67. // document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
  68. // anchor.addEventListener('click', function (e) {
  69. // e.preventDefault();
  70. // document.querySelector(this.getAttribute('href')).scrollIntoView({
  71. // behavior: 'smooth'
  72. // });
  73. // });
  74. // });
  75. // Support for old Browsers.
  76. $(document).on('click', 'a[href^="#"]', function (event) {
  77. event.preventDefault();
  78. $('html, body').animate({
  79. scrollTop: $($.attr(this, 'href')).offset().top - 100
  80. }, 500);
  81. });
  82. var owl = $('.owl-service');
  83. owl.owlCarousel({
  84. loop: true,
  85. margin: 0,
  86. autoplay: true,
  87. autoplayTimeout: 3000,
  88. autoplayHoverPause: true,
  89. responsiveClass: true,
  90. responsive: {
  91. 0: {
  92. items: 1,
  93. stagePadding: 100,
  94. },
  95. 600: {
  96. items: 1,
  97. stagePadding: 100,
  98. },
  99. 1000: {
  100. items: 4
  101. }
  102. }
  103. });
  104. var service_carousel_Btn = $('.owl-service');
  105. owl.owlCarousel();
  106. $('#service-carousel-left-btn').click(function () {
  107. "use strict";
  108. service_carousel_Btn.trigger('next.owl.carousel', [300]);
  109. });
  110. $('#service-carousel-right-btn').click(function () {
  111. "use strict";
  112. service_carousel_Btn.trigger('prev.owl.carousel', [300]);
  113. });
  114. var owl = $('.owl-branches');
  115. owl.owlCarousel({
  116. loop: true,
  117. margin: 0,
  118. autoplay: true,
  119. autoplayTimeout: 3000,
  120. autoplayHoverPause: true,
  121. responsiveClass: true,
  122. responsive: {
  123. 0: {
  124. items: 1
  125. },
  126. 600: {
  127. items: 1
  128. },
  129. 1000: {
  130. items: 2,
  131. stagePadding: -10
  132. }
  133. }
  134. });
  135. var branches_carousel_Btn = $('.owl-branches');
  136. owl.owlCarousel();
  137. $('#branches-carousel-left-btn').click(function () {
  138. "use strict";
  139. branches_carousel_Btn.trigger('next.owl.carousel', [300]);
  140. });
  141. $('#branches-carousel-right-btn').click(function () {
  142. "use strict";
  143. branches_carousel_Btn.trigger('prev.owl.carousel', [300]);
  144. });