_init.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. document.addEventListener('DOMContentLoaded', function() {
  2. var calendarEl = document.getElementById('calendar');
  3. var calendar = new FullCalendar.Calendar(calendarEl, {
  4. height: 'auto',
  5. headerToolbar: { start: 'title', center: '', end: 'list,timeGridWeek,dayGridMonth,prev,next' },
  6. buttonText: { list:'day' },
  7. views: {
  8. dayGrid: { hiddenDays: [ 0,6,7 ] },
  9. timeGrid: {
  10. slotMinTime: '08:00:00',
  11. slotMaxTime: '17:00:00',
  12. dayHeaderFormat: { weekday: 'short' },
  13. hiddenDays: [ 0,6,7 ]
  14. },
  15. },
  16. displayEventEnd: { month: true, basicWeek: true, "default": true },
  17. stickyHeaderDates: false,
  18. firstDay : 1,
  19. googleCalendarApiKey: 'AIzaSyAGowGJYx6dOaQvG_vSUI73uT88VWOTcNQ',
  20. events: { googleCalendarId: 'davidawindham.com_bvrht1f8n2vgldgjenpgfdd4bk@group.calendar.google.com', className: 'gcal-event', displayEventEnd: true, },
  21. eventDataTransform: function(event) { event.url = ""; return event; },
  22. eventClick: function(info) { info.jsEvent.preventDefault(); }
  23. });
  24. calendar.render();
  25. var openDate = document.getElementById('opendate');
  26. if (openDate) {
  27. openDate.addEventListener('click', function(){
  28. calendar.gotoDate('2023-05-01')
  29. });
  30. }
  31. });
  32. window.onload = function () {
  33. header();
  34. hamburger();
  35. parallax();
  36. flip();
  37. waypoint_init();
  38. waypoints();
  39. why();
  40. };
  41. function flip() {
  42. var card = document.getElementById('zw-card');
  43. card.classList.toggle('flip');
  44. }
  45. function header() {
  46. var $window = $(window),
  47. $smallHeader = $('.header-small'),
  48. smallHeaderShowing = false;
  49. function small_header() {
  50. var top = $window.scrollTop();
  51. if (top > 200 && !smallHeaderShowing) {
  52. $smallHeader.addClass('showing');
  53. smallHeaderShowing = true;
  54. }
  55. else if (top <= 200 && smallHeaderShowing) {
  56. $smallHeader.removeClass('showing');
  57. smallHeaderShowing = false;
  58. }
  59. };
  60. $window.on('scroll', function() {
  61. small_header();
  62. });
  63. }
  64. function hamburger() {
  65. var isOpen = false,
  66. $hamburger = $('.hamburger'),
  67. $headerSmall = $('.header-small');
  68. $hamburger.on('click', function () {
  69. isOpen = !isOpen;
  70. $hamburger.toggleClass('is-active');
  71. $headerSmall.toggleClass('menu-open');
  72. });
  73. $(window).on('scroll', function() {
  74. if(isOpen){
  75. $hamburger.removeClass('is-active');
  76. $headerSmall.removeClass('menu-open');
  77. isOpen = false;
  78. }
  79. });
  80. }
  81. function parallax() {
  82. var backgroundsvg = document.querySelector('#backgroundsvg');
  83. var backgroundsvg2 = document.querySelector('#backgroundsvg2');
  84. var backgroundsvg3 = document.querySelector('#backgroundsvg3');
  85. var xScrollPosition;
  86. var yScrollPosition;
  87. function setTranslate(xPos, yPos, el) {
  88. el.style.transform = "translate3d(" + xPos + ", " + yPos + "px, 0)";
  89. };
  90. function scrollLoop() {
  91. xScrollPosition = window.scrollX;
  92. yScrollPosition = window.scrollY;
  93. setTranslate(0, yScrollPosition * -0.2, backgroundsvg);
  94. setTranslate(0, yScrollPosition * -0.5, backgroundsvg2);
  95. setTranslate(0, yScrollPosition * -0.8, backgroundsvg3);
  96. requestAnimationFrame(scrollLoop);
  97. };
  98. scrollLoop();
  99. //window.addEventListener("DOMContentLoaded", scrollLoop, false);
  100. }
  101. function why() {
  102. var index = 0,
  103. $section = $('.testimonials-section'),
  104. $testimonials = $('.br-testimonial'),
  105. $indicators = $('.indicators'),
  106. interval;
  107. function next(goTo) {
  108. $testimonials.removeClass('showing');
  109. if (index < $testimonials.length - 1)
  110. index++;
  111. else index = 0;
  112. $testimonials.eq(index).addClass('showing');
  113. $indicators.children().eq(index).addClass('current').siblings().removeClass('current');
  114. }
  115. function start() {
  116. interval = setInterval(function () {
  117. next();
  118. }, 6000);
  119. }
  120. function stop() {
  121. clearInterval(interval);
  122. }
  123. function makeIndicators() {
  124. for (var i = 0; i < $testimonials.length; i++) {
  125. var indicator = $('<span></span>');
  126. if (i === 0)
  127. indicator.addClass('current');
  128. $indicators.append(indicator);
  129. }
  130. }
  131. function advanceNow() {
  132. stop();
  133. next();
  134. start();
  135. }
  136. if ($testimonials.length) {
  137. makeIndicators();
  138. start();
  139. $section.on('mouseenter', '.br-testimonial', function () { stop(); });
  140. $section.on('mouseleave', '.br-testimonial', function () { start(); });
  141. $indicators.on('click', 'span', function () {
  142. index = $(this).index() - 1;
  143. advanceNow();
  144. });
  145. $('.next-testimonial').on('click', function () { advanceNow(); });
  146. }
  147. }
  148. function waypoints() {
  149. var waypoints = [];
  150. var $window = $(window),
  151. $body = $('body');
  152. var $headerSmall = $('.header-small');
  153. var $pages = $('.page-view');
  154. var $html = $('html'), isSmallWindow;
  155. function removeClasses($element) {
  156. $element.removeClass('viewport-above viewport-below viewport-inside');
  157. }
  158. function setClass($element, className) {
  159. removeClasses($element);
  160. $element.addClass(className);
  161. }
  162. function manageSize() {
  163. isSmallWindow = $window.width() <= 620;
  164. }
  165. function manageBackground($element) {
  166. var $colorSource = $element.prev('.background-color'),
  167. bgClass = false, hasGradient, background, gradient;
  168. if ($colorSource.length) {
  169. bgClass = $colorSource[0].hasAttribute('data-dark-bg') ? 'dark-bg' : 'light-bg';
  170. background = $colorSource.css('background-color');
  171. $body.css('background', background);
  172. //$html.css('background', background);
  173. $body.attr('bg', bgClass);
  174. $headerSmall.css('color', background);
  175. }
  176. }
  177. function waypoint_init() {
  178. $pages.each(function () {
  179. var $this = $(this);
  180. var inview = new Waypoint.Inview({
  181. element: $this[0],
  182. enter: function (direction) {
  183. manageBackground($this);
  184. setClass($this, 'viewport-inside');
  185. },
  186. exited: function (direction) {
  187. if (direction == 'down')
  188. setClass($this, 'viewport-above');
  189. else setClass($this, 'viewport-below');
  190. },
  191. offset: {
  192. top: $window.height() / 2,
  193. bottom: $window.height() / 2
  194. }
  195. });
  196. waypoints.push(inview);
  197. });
  198. }
  199. function clearWaypoints() {
  200. for (var i = 0; i < waypoints.length; i++) {
  201. waypoints[i].destroy();
  202. }
  203. waypoints = [];
  204. }
  205. function handleWaypoints() {
  206. clearWaypoints();
  207. waypoint_init();
  208. }
  209. handleWaypoints();
  210. manageSize();
  211. $(window).on('resize', function () {
  212. $pages.each(function () {
  213. removeClasses($(this));
  214. });
  215. handleWaypoints();
  216. manageSize();
  217. });
  218. }
  219. function waypoint_init() {
  220. Waypoint.Inview.prototype.createWaypoints = function () {
  221. function outerHeight(el) {
  222. var height = el.offsetHeight;
  223. var style = getComputedStyle(el);
  224. height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  225. return height;
  226. }
  227. var configs = {
  228. vertical: [{
  229. down: 'enter', up: 'exited',
  230. offset: function () {
  231. var _offset = this.options.offset && this.options.offset.bottom || 0;
  232. return this.options.context.innerHeight - _offset;
  233. }.bind(this)
  234. }, {
  235. down: 'entered', up: 'exit',
  236. offset: function () {
  237. var _offset = this.options.offset && this.options.offset.bottom || 0;
  238. return this.options.context.innerHeight - outerHeight(this.element) - _offset;
  239. }.bind(this)
  240. }, {
  241. down: 'exit', up: 'entered',
  242. offset: function () {
  243. var _offset = this.options.offset && this.options.offset.top || 0;
  244. return _offset;
  245. }.bind(this)
  246. }, {
  247. down: 'exited', up: 'enter',
  248. offset: function () {
  249. var _offset = this.options.offset && this.options.offset.top || 0;
  250. return _offset - outerHeight(this.element);
  251. }.bind(this)
  252. }],
  253. horizontal: [{
  254. right: 'enter',
  255. left: 'exited',
  256. offset: '100%'
  257. }, {
  258. right: 'entered',
  259. left: 'exit',
  260. offset: 'right-in-view'
  261. }, {
  262. right: 'exit',
  263. left: 'entered',
  264. offset: 0
  265. }, {
  266. right: 'exited',
  267. left: 'enter',
  268. offset: function () {
  269. return -this.adapter.outerWidth()
  270. }
  271. }]
  272. };
  273. for (var i = 0, end = configs[this.axis].length; i < end; i++) {
  274. var config = configs[this.axis][i];
  275. this.createWaypoint(config)
  276. }
  277. };
  278. $(".nav-link").hover(function(){
  279. $(this).tab('show');
  280. });
  281. // $.fn.scrollEnd = function (callback, timeout) {
  282. // $(this).scroll(function () {
  283. // var $this = $(this);
  284. // if ($this.data('scrollTimeout')) {
  285. // clearTimeout($this.data('scrollTimeout'));
  286. // }
  287. // $this.data('scrollTimeout', setTimeout(callback, timeout));
  288. // });
  289. // };
  290. }