_init.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. // the hamburger toggles BOTH the side nav (header-small menu) and the top nav (#worknav offcanvas)
  69. var topNav = function () {
  70. var el = document.getElementById('worknav');
  71. return (el && window.bootstrap) ? bootstrap.Offcanvas.getOrCreateInstance(el) : null;
  72. };
  73. $hamburger.on('click', function () {
  74. isOpen = !isOpen;
  75. $hamburger.toggleClass('is-active');
  76. $headerSmall.toggleClass('menu-open');
  77. var tn = topNav(); if (tn) { isOpen ? tn.show() : tn.hide(); }
  78. });
  79. $(window).on('scroll', function() {
  80. if(isOpen){
  81. $hamburger.removeClass('is-active');
  82. $headerSmall.removeClass('menu-open');
  83. var tn = topNav(); if (tn) tn.hide();
  84. isOpen = false;
  85. }
  86. });
  87. }
  88. function parallax() {
  89. var backgroundsvg = document.querySelector('#backgroundsvg');
  90. var backgroundsvg2 = document.querySelector('#backgroundsvg2');
  91. var backgroundsvg3 = document.querySelector('#backgroundsvg3');
  92. var xScrollPosition;
  93. var yScrollPosition;
  94. function setTranslate(xPos, yPos, el) {
  95. el.style.transform = "translate3d(" + xPos + ", " + yPos + "px, 0)";
  96. };
  97. function scrollLoop() {
  98. xScrollPosition = window.scrollX;
  99. yScrollPosition = window.scrollY;
  100. setTranslate(0, yScrollPosition * -0.2, backgroundsvg);
  101. setTranslate(0, yScrollPosition * -0.5, backgroundsvg2);
  102. setTranslate(0, yScrollPosition * -0.8, backgroundsvg3);
  103. requestAnimationFrame(scrollLoop);
  104. };
  105. scrollLoop();
  106. //window.addEventListener("DOMContentLoaded", scrollLoop, false);
  107. }
  108. function why() {
  109. var index = 0,
  110. $section = $('.testimonials-section'),
  111. $testimonials = $('.br-testimonial'),
  112. $indicators = $('.indicators'),
  113. interval;
  114. function next(goTo) {
  115. $testimonials.removeClass('showing');
  116. if (index < $testimonials.length - 1)
  117. index++;
  118. else index = 0;
  119. $testimonials.eq(index).addClass('showing');
  120. $indicators.children().eq(index).addClass('current').siblings().removeClass('current');
  121. }
  122. function start() {
  123. interval = setInterval(function () {
  124. next();
  125. }, 6000);
  126. }
  127. function stop() {
  128. clearInterval(interval);
  129. }
  130. function makeIndicators() {
  131. for (var i = 0; i < $testimonials.length; i++) {
  132. var indicator = $('<span></span>');
  133. if (i === 0)
  134. indicator.addClass('current');
  135. $indicators.append(indicator);
  136. }
  137. }
  138. function advanceNow() {
  139. stop();
  140. next();
  141. start();
  142. }
  143. if ($testimonials.length) {
  144. makeIndicators();
  145. start();
  146. $section.on('mouseenter', '.br-testimonial', function () { stop(); });
  147. $section.on('mouseleave', '.br-testimonial', function () { start(); });
  148. $indicators.on('click', 'span', function () {
  149. index = $(this).index() - 1;
  150. advanceNow();
  151. });
  152. $('.next-testimonial').on('click', function () { advanceNow(); });
  153. }
  154. }
  155. function waypoints() {
  156. var waypoints = [];
  157. var $window = $(window),
  158. $body = $('body');
  159. var $headerSmall = $('.header-small');
  160. var $pages = $('.page-view');
  161. var $html = $('html'), isSmallWindow;
  162. function removeClasses($element) {
  163. $element.removeClass('viewport-above viewport-below viewport-inside');
  164. }
  165. function setClass($element, className) {
  166. removeClasses($element);
  167. $element.addClass(className);
  168. }
  169. function manageSize() {
  170. isSmallWindow = $window.width() <= 620;
  171. }
  172. function manageBackground($element) {
  173. var $colorSource = $element.prev('.background-color'),
  174. bgClass = false, hasGradient, background, gradient;
  175. if ($colorSource.length) {
  176. bgClass = $colorSource[0].hasAttribute('data-dark-bg') ? 'dark-bg' : 'light-bg';
  177. background = $colorSource.css('background-color');
  178. $body.css('background', background);
  179. //$html.css('background', background);
  180. $body.attr('bg', bgClass);
  181. $headerSmall.css('color', background);
  182. }
  183. }
  184. function waypoint_init() {
  185. $pages.each(function () {
  186. var $this = $(this);
  187. var inview = new Waypoint.Inview({
  188. element: $this[0],
  189. enter: function (direction) {
  190. manageBackground($this);
  191. setClass($this, 'viewport-inside');
  192. },
  193. exited: function (direction) {
  194. if (direction == 'down')
  195. setClass($this, 'viewport-above');
  196. else setClass($this, 'viewport-below');
  197. },
  198. offset: {
  199. top: $window.height() / 2,
  200. bottom: $window.height() / 2
  201. }
  202. });
  203. waypoints.push(inview);
  204. });
  205. }
  206. function clearWaypoints() {
  207. for (var i = 0; i < waypoints.length; i++) {
  208. waypoints[i].destroy();
  209. }
  210. waypoints = [];
  211. }
  212. function handleWaypoints() {
  213. clearWaypoints();
  214. waypoint_init();
  215. }
  216. handleWaypoints();
  217. manageSize();
  218. $(window).on('resize', function () {
  219. $pages.each(function () {
  220. removeClasses($(this));
  221. });
  222. handleWaypoints();
  223. manageSize();
  224. });
  225. }
  226. function waypoint_init() {
  227. Waypoint.Inview.prototype.createWaypoints = function () {
  228. function outerHeight(el) {
  229. var height = el.offsetHeight;
  230. var style = getComputedStyle(el);
  231. height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  232. return height;
  233. }
  234. var configs = {
  235. vertical: [{
  236. down: 'enter', up: 'exited',
  237. offset: function () {
  238. var _offset = this.options.offset && this.options.offset.bottom || 0;
  239. return this.options.context.innerHeight - _offset;
  240. }.bind(this)
  241. }, {
  242. down: 'entered', up: 'exit',
  243. offset: function () {
  244. var _offset = this.options.offset && this.options.offset.bottom || 0;
  245. return this.options.context.innerHeight - outerHeight(this.element) - _offset;
  246. }.bind(this)
  247. }, {
  248. down: 'exit', up: 'entered',
  249. offset: function () {
  250. var _offset = this.options.offset && this.options.offset.top || 0;
  251. return _offset;
  252. }.bind(this)
  253. }, {
  254. down: 'exited', up: 'enter',
  255. offset: function () {
  256. var _offset = this.options.offset && this.options.offset.top || 0;
  257. return _offset - outerHeight(this.element);
  258. }.bind(this)
  259. }],
  260. horizontal: [{
  261. right: 'enter',
  262. left: 'exited',
  263. offset: '100%'
  264. }, {
  265. right: 'entered',
  266. left: 'exit',
  267. offset: 'right-in-view'
  268. }, {
  269. right: 'exit',
  270. left: 'entered',
  271. offset: 0
  272. }, {
  273. right: 'exited',
  274. left: 'enter',
  275. offset: function () {
  276. return -this.adapter.outerWidth()
  277. }
  278. }]
  279. };
  280. for (var i = 0, end = configs[this.axis].length; i < end; i++) {
  281. var config = configs[this.axis][i];
  282. this.createWaypoint(config)
  283. }
  284. };
  285. $(".nav-link").hover(function(){
  286. $(this).tab('show');
  287. });
  288. // $.fn.scrollEnd = function (callback, timeout) {
  289. // $(this).scroll(function () {
  290. // var $this = $(this);
  291. // if ($this.data('scrollTimeout')) {
  292. // clearTimeout($this.data('scrollTimeout'));
  293. // }
  294. // $this.data('scrollTimeout', setTimeout(callback, timeout));
  295. // });
  296. // };
  297. }
  298. // Deep-link support for the URL hash on load.
  299. // - #zw: friendly alias from the main site's "Zeken Woözer Enterprises" link —
  300. // scroll to the What section and open the zw card modal.
  301. // - otherwise: if the hash names a Bootstrap .modal, open it.
  302. document.addEventListener('DOMContentLoaded', function () {
  303. var hash = window.location.hash;
  304. if (!hash) return;
  305. if (hash === '#zw') {
  306. var what = document.getElementById('what');
  307. if (what) what.scrollIntoView();
  308. var zw = document.getElementById('zw-card-modal');
  309. if (zw && window.bootstrap) bootstrap.Modal.getOrCreateInstance(zw).show();
  310. return;
  311. }
  312. var target = document.querySelector(hash);
  313. if (target && target.classList.contains('modal') && window.bootstrap) {
  314. bootstrap.Modal.getOrCreateInstance(target).show();
  315. }
  316. });