_init.js 8.5 KB

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