_init.js 8.3 KB

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