_init.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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: {
  13. weekday: 'short'
  14. },
  15. hiddenDays: [ 0,6,7 ]
  16. },
  17. },
  18. displayEventEnd: { month: true, basicWeek: true, "default": true },
  19. stickyHeaderDates: false,
  20. eventDataTransform: function(event) {
  21. event.url = "";
  22. return event;
  23. },
  24. firstDay : 1,
  25. googleCalendarApiKey: 'AIzaSyAGowGJYx6dOaQvG_vSUI73uT88VWOTcNQ',
  26. events: {
  27. googleCalendarId: 'davidawindham.com_bvrht1f8n2vgldgjenpgfdd4bk@group.calendar.google.com',
  28. className: 'gcal-event',
  29. displayEventEnd: true,
  30. },
  31. eventClick: function(info) {
  32. info.jsEvent.preventDefault();
  33. }
  34. });
  35. calendar.render();
  36. });
  37. window.onload = function () {
  38. header();
  39. hamburger();
  40. parallax();
  41. waypoint_init();
  42. waypoints();
  43. why();
  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 * -1.5, backgroundsvg2);
  95. setTranslate(0, yScrollPosition * 0.5, backgroundsvg3);
  96. requestAnimationFrame(scrollLoop);
  97. };
  98. window.addEventListener("DOMContentLoaded", scrollLoop, false);
  99. }
  100. function why() {
  101. var index = 0,
  102. $section = $('.testimonials-section'),
  103. $testimonials = $('.br-testimonial'),
  104. $indicators = $('.indicators'),
  105. interval;
  106. function next(goTo) {
  107. $testimonials.removeClass('showing');
  108. if (index < $testimonials.length - 1)
  109. index++;
  110. else index = 0;
  111. $testimonials.eq(index).addClass('showing');
  112. $indicators.children().eq(index).addClass('current').siblings().removeClass('current');
  113. }
  114. function start() {
  115. interval = setInterval(function () {
  116. next();
  117. }, 6000);
  118. }
  119. function stop() {
  120. clearInterval(interval);
  121. }
  122. function makeIndicators() {
  123. for (var i = 0; i < $testimonials.length; i++) {
  124. var indicator = $('<span></span>');
  125. if (i === 0)
  126. indicator.addClass('current');
  127. $indicators.append(indicator);
  128. }
  129. }
  130. function advanceNow() {
  131. stop();
  132. next();
  133. start();
  134. }
  135. if ($testimonials.length) {
  136. makeIndicators();
  137. start();
  138. $section.on('mouseenter', '.br-testimonial', function () { stop(); });
  139. $section.on('mouseleave', '.br-testimonial', function () { start(); });
  140. $indicators.on('click', 'span', function () {
  141. index = $(this).index() - 1;
  142. advanceNow();
  143. });
  144. $('.next-testimonial').on('click', function () { advanceNow(); });
  145. }
  146. }
  147. function waypoints() {
  148. var waypoints = [];
  149. var $window = $(window),
  150. $body = $('body');
  151. var $headerSmall = $('.header-small');
  152. var $pages = $('.page-view');
  153. var $html = $('html'), isSmallWindow;
  154. function removeClasses($element) {
  155. $element.removeClass('viewport-above viewport-below viewport-inside');
  156. }
  157. function setClass($element, className) {
  158. removeClasses($element);
  159. $element.addClass(className);
  160. }
  161. function manageSize() {
  162. isSmallWindow = $window.width() <= 620;
  163. }
  164. function manageBackground($element) {
  165. var $colorSource = $element.prev('.background-color'),
  166. bgClass = false, hasGradient, background, gradient;
  167. if ($colorSource.length) {
  168. bgClass = $colorSource[0].hasAttribute('data-dark-bg') ? 'dark-bg' : 'light-bg';
  169. background = $colorSource.css('background-color');
  170. $body.css('background', background);
  171. //$html.css('background', background);
  172. $body.attr('bg', bgClass);
  173. $headerSmall.css('color', background);
  174. }
  175. }
  176. function waypoint_init() {
  177. $pages.each(function () {
  178. var $this = $(this);
  179. var inview = new Waypoint.Inview({
  180. element: $this[0],
  181. enter: function (direction) {
  182. manageBackground($this);
  183. setClass($this, 'viewport-inside');
  184. },
  185. exited: function (direction) {
  186. if (direction == 'down')
  187. setClass($this, 'viewport-above');
  188. else setClass($this, 'viewport-below');
  189. },
  190. offset: {
  191. top: $window.height() / 2,
  192. bottom: $window.height() / 2
  193. }
  194. });
  195. waypoints.push(inview);
  196. });
  197. }
  198. function clearWaypoints() {
  199. for (var i = 0; i < waypoints.length; i++) {
  200. waypoints[i].destroy();
  201. }
  202. waypoints = [];
  203. }
  204. function handleWaypoints() {
  205. clearWaypoints();
  206. waypoint_init();
  207. }
  208. handleWaypoints();
  209. manageSize();
  210. $(window).on('resize', function () {
  211. $pages.each(function () {
  212. removeClasses($(this));
  213. });
  214. handleWaypoints();
  215. manageSize();
  216. });
  217. }
  218. function waypoint_init() {
  219. Waypoint.Inview.prototype.createWaypoints = function () {
  220. function outerHeight(el) {
  221. var height = el.offsetHeight;
  222. var style = getComputedStyle(el);
  223. height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  224. return height;
  225. }
  226. var configs = {
  227. vertical: [{
  228. down: 'enter', up: 'exited',
  229. offset: function () {
  230. var _offset = this.options.offset && this.options.offset.bottom || 0;
  231. return this.options.context.innerHeight - _offset;
  232. }.bind(this)
  233. }, {
  234. down: 'entered', up: 'exit',
  235. offset: function () {
  236. var _offset = this.options.offset && this.options.offset.bottom || 0;
  237. return this.options.context.innerHeight - outerHeight(this.element) - _offset;
  238. }.bind(this)
  239. }, {
  240. down: 'exit', up: 'entered',
  241. offset: function () {
  242. var _offset = this.options.offset && this.options.offset.top || 0;
  243. return _offset;
  244. }.bind(this)
  245. }, {
  246. down: 'exited', up: 'enter',
  247. offset: function () {
  248. var _offset = this.options.offset && this.options.offset.top || 0;
  249. return _offset - outerHeight(this.element);
  250. }.bind(this)
  251. }],
  252. horizontal: [{
  253. right: 'enter',
  254. left: 'exited',
  255. offset: '100%'
  256. }, {
  257. right: 'entered',
  258. left: 'exit',
  259. offset: 'right-in-view'
  260. }, {
  261. right: 'exit',
  262. left: 'entered',
  263. offset: 0
  264. }, {
  265. right: 'exited',
  266. left: 'enter',
  267. offset: function () {
  268. return -this.adapter.outerWidth()
  269. }
  270. }]
  271. };
  272. for (var i = 0, end = configs[this.axis].length; i < end; i++) {
  273. var config = configs[this.axis][i];
  274. this.createWaypoint(config)
  275. }
  276. };
  277. // $.fn.scrollEnd = function (callback, timeout) {
  278. // $(this).scroll(function () {
  279. // var $this = $(this);
  280. // if ($this.data('scrollTimeout')) {
  281. // clearTimeout($this.data('scrollTimeout'));
  282. // }
  283. // $this.data('scrollTimeout', setTimeout(callback, timeout));
  284. // });
  285. // };
  286. }