_init.js 8.2 KB

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