PageSourceSearch

https://calgaryphil.com/wp-content/themes/bricks-child/js/custom.js?ver=1.0.3

js calgaryphil.com collected 2026-10-02 05:00:17 UTC 13,817 bytes, 459 lines download raw bytes

1jQuery(document).ready(function($) {
2// 	const navDropdownTriggers = document.querySelectorAll('header nav .brxe-dropdown .brx-submenu-toggle span');
3// 	navDropdownTriggers.forEach((item, index) => {});
4	
5	const navMegaMenuItems = document.querySelectorAll('header nav .brx-has-megamenu ul a');
6	const bodyTag = document.querySelector('body');
7	
8	navMegaMenuItems.forEach((item, index) => {
9		item.hasAttribute('aria-current') ? item.classList.add('active-path') : null;
10	});
11	
12// 	var docWidth = document.documentElement.offsetWidth;
13
14// 	Array.prototype.forEach.call(document.querySelectorAll('*'), function(el) {
15// 		if (el.offsetWidth > docWidth) {
16// 			console.log(el);
17// 			console.log('Element ID:', el.id);
18// 			console.log('Element Class:', el.className);
19// 			console.log('Element Tag:', el.tagName);
20// 		}
21// 	});
22	
23	// Select the anchor tag you want to convert
24	// You can use a class, ID, or tag name as the selector
25	const breadcrumbs = document.querySelector('.brxe-breadcrumbs');
26	const nonPagesForPaths = [
27		'corporate giving',
28		'education',
29		'explore + learn',
30		'individual giving',
31		'other ways to support',
32		'our people',
33		'plan your visit',
34		'subscriptions',
35		'support',
36		'ticket information',
37	];
38
39	if ( breadcrumbs ) {
40		const breadcrumbLinks = breadcrumbs.querySelectorAll('a.item');
41
42		breadcrumbLinks.forEach((crumb) => {
43			if ( nonPagesForPaths.includes(crumb.innerText.toLowerCase()) ) {
44				$(crumb).replaceWith(function() {
45					return $('<span class="item">' + $(this).html() + '</span>');
46				});
47			}
48			else {
49				crumb.classList.add('hover-underline');
50			}
51		});
52	}
53	
54	const mpspxSearchResults = document.querySelector('.mpspx-search-results');
55	if ( mpspxSearchResults ) {
56		const searchTitle = mpspxSearchResults.querySelector('.page-title');
57
58		$(searchTitle).replaceWith(function() {
59			return $('<h2 class="page-title">' + $(this).html() + '</h2>');
60		});
61	}
62	
63	// Styling helper for Team Member Pages
64	const teamMemberWrappers = document.querySelectorAll('.mpspx-team_member-wrapper');
65	if ( teamMemberWrappers.length ) {
66		bodyTag.classList.add('is-mp-team-member');
67	}
68	
69	const eventListWrapper = document.querySelectorAll('.mpspx-event-list-wrapper');
70	eventListWrapper.length ? bodyTag.classList.add('.is-mp-event-list') : null;
71	
72	const singleEventTemplate = document.querySelectorAll('.mpspx-event-single');
73	singleEventTemplate.length ? bodyTag.classList.add('is-mp-event-single') : null;
74	
75	const eventCalendarTemplate = document.querySelectorAll('.mpspx-calendar-year-month');
76	eventCalendarTemplate.length ? bodyTag.classList.add('is-mp-event-calendar') : null;
77	
78	// Button Styling
79	
80	const formSubmitButtons = document.querySelectorAll('.submit-button-wrapper button');
81	
82	if ( formSubmitButtons.length ) {
83		formSubmitButtons.forEach((button) => {
84			button.classList.add('button-light');
85		});
86	}
87	
88	$('.footer-newsletter .mpspx-button3').addClass('button-light');
89	$('main .mpspx_newsletter .mpspx-button3').addClass('button-dark');
90	
91	const allButtons = document.querySelectorAll('.bricks-button, .button-light, .button-dark, .mpspx-button4');
92// 	console.log(allButtons);
93	
94	if ( allButtons.length ) {
95		allButtons.forEach((button) => {
96// 			console.log(button.getAttribute('type'));
97			if ( !button.classList.contains('amount-button') ) {
98				wrapButtonInnerText(button);				
99			}
100			
101			if ( button.classList.contains('mpspx-button4') ) {
102				button.classList.add('button-dark');
103			}
104		});
105	}
106	
107	function wrapButtonInnerText(button) {
108		return $(button).wrapInner('<span></span>');
109	}
110});
111
112
113// Seating svg
114document.addEventListener('DOMContentLoaded', () => {
115  // Dynamic Sidebar
116  let sidebarLoaded = false;
117  const docBody = document.getElementsByTagName('body')[0];
118  const container = document.getElementById('events-sidebar-container');
119  const template  = document.getElementById('tmpl-events-sidebar');
120// console.log(docBody);
121
122  document.body.addEventListener('click', e => {
123    const openBtn = e.target.closest('.toggle-sidebar');
124    if (openBtn) {
125      if (!container || !template) return;
126
127      if (!sidebarLoaded) {
128        container.innerHTML = template.innerHTML;
129        sidebarLoaded = true;
130      }
131
132      const sidebar = container.querySelector('.events-sidebar');
133	  
134      if (sidebar) {
135		  docBody.classList.add('sidebar-active');
136		  sidebar.classList.add('open');
137	  }
138
139      return;
140    }
141
142    const closeBtn = e.target.closest('#events-sidebar-container .close');
143    if (closeBtn) {
144      if (!container) return;
145      const sidebar = container.querySelector('.events-sidebar');
146      if (sidebar) {
147		  docBody.classList.remove('sidebar-active');
148		  sidebar.classList.remove('open'); 
149	  }		  
150    }
151  });
152
153  const eventSeats = document.querySelector('.mpspx-event-seats');
154  const seatingMap = document.querySelector('.mpspx-choose-area-mapper');
155  const timeoutValue = 2300;
156
157  // Hide loader fallback
158  if (eventSeats && !eventSeats.classList.contains('hide-loader')) {
159    setTimeout(() => eventSeats.classList.add('hide-loader'), timeoutValue);
160  }
161
162  // Seating map loader
163  if (seatingMap) {
164    setTimeout(() => seatingMap.classList.add('hide-loader'), timeoutValue);
165  }
166	
167	(function($) {  
168  $(document).on("click", ".toggle-sidebar", function() {
169    var $this = $(this);
170    var eventId = $this.data('event-id');
171
172    $('.event-sidebar-content').hide();
173    $('#sidebar-' + eventId).show();
174
175    $('body').addClass('sidebar-active opening').delay(1450).queue(function(next) {
176      $(this).removeClass('opening');
177      next();
178    });
179  });
180
181  $(document).on("click", ".events-sidebar .close, .underlay", function() {
182    $('body').removeClass('sidebar-active').addClass('opening').delay(1450).queue(function(next) {
183	  $(this).removeClass('opening');
184		  next();
185		});
186	  });
187	})(jQuery);
188	
189	// Hamburger menu click + animation
190	const body = document.body;
191	const nav = document.querySelector('.nav');
192	const btnMenu = document.querySelector('.btn-menu');
193	const offcanvas = document.querySelector('.x-offcanvas_inner');
194	const header =
195	  (btnMenu && btnMenu.closest('header, .site-header, .brxe-header')) ||
196	  document.querySelector('.brxe-header');
197
198	if (!nav || !btnMenu || !offcanvas) return;
199
200	function updateMenuAria(isOpen) {
201	  btnMenu.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
202	  btnMenu.setAttribute('aria-label', isOpen ? 'Close menu' : 'Open menu');
203
204	  const openLabel = btnMenu.querySelector('.btn-label-open');
205	  const closeLabel = btnMenu.querySelector('.btn-label-close');
206	  if (openLabel && closeLabel) {
207		openLabel.hidden = isOpen;
208		closeLabel.hidden = !isOpen;
209	  }
210	}
211
212	btnMenu.addEventListener('click', () => {
213	  const willOpen = !nav.classList.contains('nav-active');
214	  body.classList.toggle('nav-active', willOpen);
215	  nav.classList.toggle('nav-active', willOpen);
216	  updateMenuAria(willOpen);
217	});
218
219	document.addEventListener('keydown', (e) => {
220	  if (e.key === 'Escape' && nav.classList.contains('nav-active')) {
221		body.classList.remove('nav-active');
222		nav.classList.remove('nav-active');
223		updateMenuAria(false);
224	  }
225	});
226
227	document.addEventListener('click', (e) => {
228	  if (!nav.classList.contains('nav-active')) return;
229
230	  const t = e.target;
231	  const keep =
232		t.closest('.x-offcanvas_inner') ||
233		t.closest('.btn-menu') ||
234		t.closest('.brxe-xheadersearch, .x-header-search_toggle-open, .x-header-search_toggle-close') ||
235		(header && header.contains(t)) ||
236		t.closest('.nav');
237
238	  if (!keep) {
239		body.classList.remove('nav-active');
240		nav.classList.remove('nav-active');
241		updateMenuAria(false);
242	  }
243	});
244});
245
246// Hide and show area
247window.addEventListener('message', (ev) => {
248
249  const body = document.body;
250  const data = ev && ev.data;
251
252  // Membership in cart
253  if (data === 'hide:membershipcta') {
254    body.classList.add('has-membership');
255  }
256
257  const getNodes = () => ({
258    eventSeats: document.querySelector('.mpspx-event-seats'),
259    infoWrapper: document.querySelector('.info-wrapper')
260  });
261
262  // Select seats loader
263  if (data === 'loading:text') {
264    const { eventSeats } = getNodes();
265    if (!eventSeats) return;
266    eventSeats.classList.remove('hide-loader');
267    setTimeout(() => eventSeats.classList.add('hide-loader'), 1000);
268  }
269
270  // Hide area section loader
271  if (data === 'hide:area') {
272    const { eventSeats } = getNodes();
273    if (!eventSeats) return;
274    eventSeats.classList.remove('hide-loader');
275    setTimeout(() => {
276      const { infoWrapper } = getNodes();
277      if (infoWrapper) infoWrapper.classList.add('hide');
278      setTimeout(() => eventSeats.classList.add('hide-loader'), 1000);
279    }, 1500);
280  }
281
282  // Refresh iframe loader
283  if (data === 'refresh:area') {
284    const { eventSeats } = getNodes();
285    if (!eventSeats) return;
286    eventSeats.classList.remove('hide-loader');
287    setTimeout(() => {
288      const { infoWrapper } = getNodes();
289      if (infoWrapper) infoWrapper.classList.remove('hide');
290      setTimeout(() => eventSeats.classList.add('hide-loader'), 1000);
291    }, 2500);
292  }
293
294  // Show area section loader
295  if (data === 'show:area') {
296    const { eventSeats } = getNodes();
297    if (!eventSeats) return;
298    eventSeats.classList.remove('hide-loader');
299    setTimeout(() => {
300      const { infoWrapper } = getNodes();
301      if (infoWrapper) infoWrapper.classList.remove('hide');
302      setTimeout(() => eventSeats.classList.add('hide-loader'), 1000);
303    }, 2500);
304  }
305
306  // Before cart page loader
307  if (data === 'loading:cart') {
308    const { eventSeats } = getNodes();
309    if (!eventSeats) return;
310    eventSeats.classList.remove('hide-loader');
311    setTimeout(() => {
312      setTimeout(() => eventSeats.classList.add('hide-loader'), 1000);
313    }, 3000);
314  }
315}, false);
316
317function startAnimations() {
318  // AOS
319  if (window.AOS) {
320    AOS.init({ once: true, duration: 550 });
321  }
322
323  // GSAP + ScrollTrigger
324  if (window.gsap && window.ScrollTrigger) {
325    gsap.registerPlugin(ScrollTrigger);
326
327    const observer = new IntersectionObserver(entries => {
328      entries.forEach(entry => {
329        if (entry.isIntersecting) {
330          setTimeout(() => animateElement(entry.target), 150);
331          observer.unobserve(entry.target);
332        }
333      });
334    }, { threshold: 0.2 });
335
336    document.querySelectorAll('.bottom-top').forEach(el => {
337      gsap.set(el, { visibility: 'hidden' });
338      observer.observe(el);
339    });
340  }
341}
342
343let animationsStarted = false;
344function ensureAnimations() {
345  if (animationsStarted) return;
346  animationsStarted = true;
347  startAnimations();
348}
349
350if ('requestIdleCallback' in window) {
351  requestIdleCallback(ensureAnimations, { timeout: 2000 });
352} else {
353  const onScroll = () => { window.removeEventListener('scroll', onScroll); ensureAnimations(); };
354  window.addEventListener('scroll', onScroll, { once: true });
355  setTimeout(ensureAnimations, 2000);
356}
357
358// GSAP helper
359function animateElement(el) {
360  if (!window.gsap) return;
361  const tl = gsap.timeline();
362  gsap.set(el, { visibility: 'visible' });
363  tl.fromTo(
364    el,
365    { autoAlpha: 0, clipPath: 'polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%)' },
366    { autoAlpha: 1, clipPath: 'polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)', duration: 1.4, ease: 'power3.inOut' }
367  );
368}
369
370
371 // Seating svg
372document.addEventListener('DOMContentLoaded', function() {
373    const eventSeats = document.querySelector('.mpspx-event-seats');
374    const seatingMap = document.querySelector('.mpspx-choose-area-mapper');
375    var timeoutValue = window.innerWidth > 999 ? 2300 : 2300;
376
377    // Hide loader fallback
378    if (eventSeats) {
379//        console.log('test');
380      if (!eventSeats.classList.contains("hide-loader")) {
381        setTimeout(function() {
382          eventSeats.classList.add("hide-loader");
383        }, timeoutValue);
384      }
385    }
386
387    // Seating map loader
388    if (seatingMap) {
389    setTimeout(function() {
390        eventSeats.classList.add('hide-loader');
391    }, timeoutValue);
392    }
393});
394
395// Hide and show area
396window.addEventListener("message", function(event) {
397  var body = document.getElementsByTagName('body')[0];  
398    const infoWrapper = document.querySelector('.info-wrapper');
399    const eventSeats = document.querySelector('.mpspx-event-seats');
400    
401
402    // Membership in cart
403    if (event.data === "hide:membershipcta") {
404        body.classList.add('has-membership');
405    }
406
407    // Select seats loader
408    if (event.data === "loading:text") {
409    eventSeats.classList.remove('hide-loader');    
410    var timeoutValue = window.innerWidth > 999 ? 1000 : 1000;
411    setTimeout(function() {
412        eventSeats.classList.add('hide-loader');
413    }, timeoutValue);
414    }
415
416
417    // Hide area section loader
418  if (event.data === "hide:area") {
419    eventSeats.classList.remove('hide-loader');
420
421    setTimeout(function() {
422      const infoWrapper = document.querySelector('.info-wrapper');
423
424      infoWrapper.classList.add('hide');
425      setTimeout(function() {
426        eventSeats.classList.add('hide-loader');
427      }, 1000);
428    }, 1500);
429  }
430  // Refresh iframe loader
431  if (event.data === "refresh:area") {
432    eventSeats.classList.remove('hide-loader');
433    setTimeout(function() {
434      infoWrapper.classList.remove('hide');
435      setTimeout(function() {
436        eventSeats.classList.add('hide-loader');
437      }, 1000);
438    }, 2500);
439  }
440  // Show area section loader
441  if (event.data === "show:area") {
442    eventSeats.classList.remove('hide-loader');
443    setTimeout(function() {
444      infoWrapper.classList.remove('hide');
445      setTimeout(function() {
446        eventSeats.classList.add('hide-loader');
447      }, 1000);
448    }, 2500);
449  }
450  // Before cart page loader
451  if (event.data === "loading:cart") {
452    eventSeats.classList.remove('hide-loader');
453    setTimeout(function() {
454      setTimeout(function() {
455        eventSeats.classList.add('hide-loader');
456      }, 1000);
457    }, 3000);
458  }
459}, false);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.