jQuery(".gfm-fundraisers").each(function (index) {
let indexNumber = index + 1;
jQuery(this).find("#gfm-fundraiser-grid").addClass(`list-${indexNumber}`);
jQuery(this).find(".gfm-fundraisers-list-wrapper").attr("id", `gfm-fundraisers-list-wrapper-${indexNumber}`);
/* Construct endpoint URL based on curated slugs.
-------------------------------------------------------------- */
const baseUrl = "https://gateway.gofundme.com/web-gateway/v1/feed/campaigns?";
// Get slugs from ACF field
let fundraiserSlugs = jQuery(this).find("#gfm-fundraiser-grid").attr("data-slugs");
// Convert to array and format
let fundraiserSlugsArray = fundraiserSlugs.split(",").map((slug) => `slugs=${slug}&`);
/* Get total number of fundraisers
-------------------------------------------------------------- */
let numberOfSlugs = fundraiserSlugsArray.length;
// Starts at 0 and will count up until equal to numberOfSlugs
let fundraisersShowing = 0;
let perPage = 12;
let lowNumber = 0;
let highNumber = perPage;
// Initialize an empty category list for each "gfm-fundraisers" section
const tabList = jQuery(this).find("#tab-list");
// This is a stateMap for mapping abbreviated states to their full name.
let stateMap = {
al: "Alabama",
ak: "Alaska",
az: "Arizona",
ar: "Arkansas",
ca: "California",
co: "Colorado",
ct: "Connecticut",
de: "Delaware",
dc: "Washington D.C.",
fl: "Florida",
ga: "Georgia",
hi: "Hawaii",
id: "Idaho",
il: "Illinois",
in: "Indiana",
ia: "Iowa",
ks: "Kansas",
ky: "Kentucky",
la: "Louisiana",
me: "Maine",
md: "Maryland",
ma: "Massachusetts",
mi: "Michigan",
mn: "Minnesota",
ms: "Mississippi",
mo: "Missouri",
mt: "Montana",
ne: "Nebraska",
nv: "Nevada",
nh: "New Hampshire",
nj: "New Jersey",
nm: "New Mexico",
ny: "New York",
nc: "North Carolina",
nd: "North Dakota",
oh: "Ohio",
ok: "Oklahoma",
or: "Oregon",
pa: "Pennsylvania",
ri: "Rhode Island",
sc: "South Carolina",
sd: "South Dakota",
tn: "Tennessee",
tx: "Texas",
ut: "Utah",
vt: "Vermont",
va: "Virginia",
wa: "Washington",
wv: "West Virginia",
wi: "Wisconsin",
wy: "Wyoming",
// Non US locals
on: "Ontario",
};
while (fundraisersShowing < numberOfSlugs) {
let showOnLoadString = fundraiserSlugsArray.slice(lowNumber, highNumber).join("").replace(/\s/g, "");
let finalUrl = baseUrl + showOnLoadString;
jQuery
.ajax({
method: "GET",
url: finalUrl,
dataType: "json",
async: true,
})
.done(function (fundraiserData) {
jQuery.each(fundraiserData.data, function (i, fundraiser) {
// Get correct currency based on fundraiser
let country = `${fundraiser.country}`;
let currencyCode = `${fundraiser.currency_code}`;
if (country === "US" || country === "CA" || country === "AU" || country === "GB") {
country = `EN-${fundraiser.country}`;
} else {
country = "EN-US";
}
// If currency_code JSON is null add manually
if (currencyCode === "") {
if (fundraiser.country === "GB") {
currencyCode = "GBP";
} else if (fundraiser.country === "DE" || fundraiser.country === "ES" || fundraiser.country === "FR" || fundraiser.country === "IT" || fundraiser.country === "NL" || fundraiser.country === "PT" || fundraiser.country === "IE") {
currencyCode = "EUR";
} else if (fundraiser.country === "CA") {
currencyCode = "CAD";
} else if (fundraiser.country === "AU") {
currencyCode = "AUD";
} else {
currencyCode = "USD";
}
}
// Format time since last donation. (Using moment.js)
let timeStamp = `${fundraiser.last_donation_at}`;
let currentTime = moment.tz("America/Los_Angeles").add(2, "hours");
let pastTime = moment.tz(timeStamp, "America/Los_Angeles");
let timeDifference = currentTime.diff(pastTime);
// Determine fill % of progress bar
const goalAmount = fundraiser.goal_amount;
const balance = fundraiser.balance;
const currentGoalPercentage = Math.round((100 * balance) / goalAmount);
// If location is null leave blank
let location = `${fundraiser.location}`;
if (location === "null") {
location = "";
}
let category = fundraiser.category;
let dataCategory = category.replace(/\s+/g, "-").toLowerCase();
let formattedCity = "";
let dataCity = "";
let formattedState = "";
let dataState = "";
let fullStateName = "";
if (!tabList.hasClass("notabs")) {
if (location.includes(",")) {
// Check if location contains a comma
formattedCity = location.substring(0, location.lastIndexOf(","));
dataCity = location.replace(/\s+/g, "-").toLowerCase().substring(0, location.lastIndexOf(","));
formattedState = location.split(",")[1].trim();
dataState = location.split(",")[1].trim().toLowerCase();
fullStateName = stateMap[dataState];
} else {
// If no comma, consider the entire location string as the city.
formattedCity = location;
dataCity = location.replace(/\s+/g, "-").toLowerCase();
formattedState = formattedCity; // Make formattedState same as formattedCity
}
}
// Fundraiser card markup
let thisFundraiserCard = `
`;
thisFundraiserCard += ``;
thisFundraiserCard += ``;
thisFundraiserCard += `

`;
thisFundraiserCard += `
`;
thisFundraiserCard += ``;
thisFundraiserCard += ``;
thisFundraiserCard += ``;
// Hide fundraisers that have met their goal
if (jQuery("#gfm-fundraiser-grid").hasClass("hide-met-goal")) {
if (currentGoalPercentage >= 100) {
thisFundraiserCard = "";
}
}
// Add each fundraiser to grid
jQuery("#gfm-fundraiser-grid.list-" + indexNumber).append(thisFundraiserCard);
if (!tabList.hasClass("notabs")) {
// Add items to #tab-list
if (tabList.hasClass("categories")) {
dataAttr = "data-category";
formattedData = dataCategory;
dataLabel = category;
} else if (tabList.hasClass("cities")) {
dataAttr = "data-city";
formattedData = dataCity;
dataLabel = formattedCity;
} else if (tabList.hasClass("states")) {
dataAttr = "data-state";
formattedData = dataState;
dataLabel = fullStateName;
}
if (!tabList.find(`li[${dataAttr}="${formattedData}"]`).length) {
tabList.append(`${dataLabel}`);
}
}
});
}); // End AJAX call
lowNumber += perPage;
highNumber += perPage;
fundraisersShowing += perPage;
} // end while loop
}); // end each loop
;
jQuery(window).on('load', function() {
// Set number of fundraisers per page
let perPage = '12';
// Define options for List.js list
let listOptions = {
valueNames: [
'name',
'location',
{ data: ['category'] },
{ data: ['city'] },
{ data: ['state'] },
{ data: ['fullState'] }
],
page: perPage,
pagination: [
{
item: '',
name: "gfm-pagination",
paginationClass: "gfm-pagination",
innerWindow: 1,
outerWindow: 1
}
]
};
// Loop through each block-fundraisers-v1 element on the page
jQuery('.block-fundraisers-v1').each(function(index) {
let $this = jQuery(this);
let blockId = index + 1;
let listContainer = "gfm-fundraisers-list-wrapper-" + blockId;
let numberOfFundraisers = $this.find('.gfm-fundraiser-grid > li').length;
// Function checks if search bar / pagination is necessary
function updatePagination() {
if (fundraiserList.matchingItems.length > perPage) {
$this.find('.gfm-search-nav').removeClass('no-pageing');
} else {
$this.find('.gfm-search-nav').addClass('no-pageing');
}
}
// Set up List.js list for current block-fundraisers-v1 element
let fundraiserList = new List(listContainer, listOptions);
// Update pagination on page load
updatePagination()
// Set up click event listener on each li in #tab-list
$this.find('#tab-list li').on('click', function() {
let category = jQuery(this).data('category');
let city = jQuery(this).data('city');
let state = jQuery(this).data('state');
let totalItems;
$this.find('#tab-list li').removeClass('active');
jQuery(this).addClass('active');
if (jQuery(this).hasClass('show-all')) {
// Remove all filters and get total number of items in list
fundraiserList.filter();
totalItems = fundraiserList.matchingItems.length;
} else {
// Filter the list based on clicked tab, and get the total number of items in the list
fundraiserList.filter(function(item) {
return item.values().category === category || item.values().city === city || item.values().state === state;
});
totalItems = fundraiserList.matchingItems.length;
}
// Update the list with the filtered items
fundraiserList.update();
// Show the first page of filtered results and reset pagination to page 1
fundraiserList.show(1, listOptions.page);
// Update pagination on page load
updatePagination();
});
});
});;
jQuery(document).ready(function (jQuery) {
// Smooth scroll for anchor links
jQuery(".greenhouse-departments a").on("click", function (event) {
event.preventDefault();
var target = jQuery(this.getAttribute("href"));
if (target.length) {
jQuery("html, body").animate(
{
scrollTop: target.offset().top - 25, // Offset by 25px
},
500 // Duration of the scroll animation in milliseconds
);
}
});
});
;
document.addEventListener('DOMContentLoaded', function () {
const searchInput = document.querySelector('#department-search');
const jobsContainer = document.querySelector('.greenhouse-jobs');
// Ensure search input and jobs container exist
if (!searchInput || !jobsContainer) {
console.error('Search input or jobs container not found.');
return;
}
const departments = jobsContainer.querySelectorAll('[id^="department-"]');
searchInput.addEventListener('input', function () {
const filter = searchInput.value.toLowerCase();
departments.forEach(function (department) {
const jobs = department.querySelectorAll('ul li');
let hasVisibleJobs = false;
jobs.forEach(function (job) {
const jobTitle = job.querySelector('a').textContent.toLowerCase();
const jobLocation = job.textContent.split('-')[1]?.trim().toLowerCase() || '';
const matches =
jobTitle.includes(filter) || jobLocation.includes(filter);
// Show or hide the job based on the filter
job.style.display = matches ? 'block' : 'none';
if (matches) hasVisibleJobs = true;
});
// Show or hide the department based on whether it has visible jobs
department.style.display = hasVisibleJobs ? 'block' : 'none';
});
});
});
;
function wordCountResize(e,t){jQuery("."+e).each(function(){let e=0;jQuery(this).find("p, h1").each(function(){e+=jQuery(this).text().split(/\s+/).length}),e>=t&&jQuery(this).addClass("modify-text")})}function smoothScroll(n=50){jQuery('a[href*="#"]').on("click",function(e){var t=jQuery(this).attr("href"),t=t.substring(t.indexOf("#"));1'+e.title+"";n+=s}),s.webTicker("update",n,e)})}function l(s,n){if(s.children("li").length<1)return window.console,!1;var r=s.data("settings");r.duplicateLoops=r.duplicateLoops||0,s.width("auto");var a=0;s.children("li").each(function(){a+=i(this).outerWidth(!0)});var c,l=s.find("li:first").height();if(r.duplicate){c=e(s);for(var o=0;a-c0?s.find(".ticker-spacer").width(h):s.append('')}r.startEmpty&&n&&s.prepend(''),a=0,a=t(s),s.width(a+200);var f=0;for(f=t(s);f>=s.width();)s.width(s.width()+200),f=0,f=t(s);return!0}var o=function(){var i=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(""===i.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in i)return!0;return!1}(),d={init:function(t){return t=jQuery.extend({speed:50,direction:"left",moving:!0,startEmpty:!0,duplicate:!1,rssurl:!1,hoverpause:!0,rssfrequency:0,updatetype:"reset",transition:"linear",height:"30px",maskleft:"",maskright:"",maskwidth:0},t),this.each(function(){jQuery(this).data("settings",t);var e=jQuery(this),s=e.wrap('');s.after(' ');var n,d=e.parent().wrap('');if(i(window).resize(function(){clearTimeout(n),n=setTimeout(function(){console.log("window was resized"),l(e,!1)},500)}),e.children("li").css("white-space","nowrap"),e.children("li").css("float",t.direction),e.children("li").css("padding","0 7px"),e.children("li").css("line-height",t.height),s.css("position","relative"),s.css("overflow","hidden"),e.closest(".tickercontainer").css("height",t.height),e.closest(".tickercontainer").css("overflow","hidden"),e.css("float",t.direction),e.css("position","relative"),e.css("font","bold 10px Verdana"),e.css("list-style-type","none"),e.css("margin","0"),e.css("padding","0"),""!==t.maskleft&&""!==t.maskright){var h='url("'+t.maskleft+'")';d.find(".tickeroverlay-left").css("background-image",h),d.find(".tickeroverlay-left").css("display","block"),d.find(".tickeroverlay-left").css("pointer-events","none"),d.find(".tickeroverlay-left").css("position","absolute"),d.find(".tickeroverlay-left").css("z-index","30"),d.find(".tickeroverlay-left").css("height",t.height),d.find(".tickeroverlay-left").css("width",t.maskwidth),d.find(".tickeroverlay-left").css("top","0"),d.find(".tickeroverlay-left").css("left","-2px"),h='url("'+t.maskright+'")',d.find(".tickeroverlay-right").css("background-image",h),d.find(".tickeroverlay-right").css("display","block"),d.find(".tickeroverlay-right").css("pointer-events","none"),d.find(".tickeroverlay-right").css("position","absolute"),d.find(".tickeroverlay-right").css("z-index","30"),d.find(".tickeroverlay-right").css("height",t.height),d.find(".tickeroverlay-right").css("width",t.maskwidth),d.find(".tickeroverlay-right").css("top","0"),d.find(".tickeroverlay-right").css("right","-2px")}else d.find(".tickeroverlay-left").css("display","none"),d.find(".tickeroverlay-right").css("display","none");e.children("li").last().addClass("last");var f=l(e,!0);t.rssurl&&(c(t.rssurl,t.type,e),t.rssfrequency>0&&window.setInterval(function(){c(t.rssurl,t.type,e)},1e3*t.rssfrequency*60)),o?(e.css("transition-timing-function",t.transition),e.css("transition-duration","0s").css(t.direction,"0"),f&&a(e,!1),e.on("transitionend webkitTransitionEnd oTransitionEnd otransitionend",function(t){return!!e.is(t.target)&&void a(i(this),!0)})):f&&r(i(this)),t.hoverpause&&e.hover(function(){if(o){var e=i(this).css(t.direction);i(this).css("transition-duration","0s").css(t.direction,e)}else jQuery(this).stop()},function(){jQuery(this).data("settings").moving&&(o?a(i(this),!1):r(e))})})},stop:function(){var t=i(this).data("settings");if(t.moving)return t.moving=!1,this.each(function(){if(o){var e=i(this).css(t.direction);i(this).css("transition-duration","0s").css(t.direction,e)}else i(this).stop()})},cont:function(){var t=i(this).data("settings");if(!t.moving)return t.moving=!0,this.each(function(){o?a(i(this),!1):r(i(this))})},transition:function(t){var e=i(this);o&&e.css("transition-timing-function",t)},update:function(e,s,n,r){s=s||"reset","undefined"==typeof n&&(n=!0),"undefined"==typeof r&&(r=!1),"string"==typeof e&&(e=i(e));var a=i(this);a.webTicker("stop");var c=i(this).data("settings");if("reset"===s)a.html(e),l(a,!0);else if("swap"===s){var o,d,h,f;if(window.console,a.children("li").length<1)a.html(e),a.css(c.direction,"0"),l(a,!0);else if(c.duplicate===!0){a.children("li").addClass("old");for(var p=e.length-1;p>=0;p--)o=i(e[p]).data("update"),d=a.find('[data-update="'+o+'"]'),d.length<1?n&&(0===a.find(".ticker-spacer:first-child").length&&a.find(".ticker-spacer").length>0?a.children("li.ticker-spacer").before(e[p]):(h=i(e[p]),p===e.length-1&&h.addClass("last"),a.find("last").after(h),a.find("last").removeClass("last"))):a.find('[data-update="'+o+'"]').replaceWith(e[p]);a.children("li.webticker-init, li.ticker-spacer").removeClass("old"),r&&a.children("li").remove(".old"),f=0,f=t(a),a.width(f+200),a.find("li.webticker-init").length<1&&(c.startEmpty=!1),a.html(e),a.children("li").css("white-space","nowrap"),a.children("li").css("float",c.direction),a.children("li").css("padding","0 7px"),a.children("li").css("line-height",c.height),l(a,!0)}else{a.children("li").addClass("old");for(var u=0;u0?a.children("li.ticker-spacer").before(e[u]):(h=i(e[u]),u===e.length-1&&h.addClass("last"),a.find(".old.last").after(h),a.find(".old.last").removeClass("last"))):a.find('[data-update="'+o+'"]').replaceWith(e[u]);a.children("li.webticker-init, li.ticker-spacer").removeClass("old"),a.children("li").css("white-space","nowrap"),a.children("li").css("float",c.direction),a.children("li").css("padding","0 7px"),a.children("li").css("line-height",c.height),r&&a.children("li").remove(".old"),f=0,f=t(a),a.width(f+200)}}a.webTicker("cont")}};i.fn.webTicker=function(t){return d[t]?d[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void i.error("Method "+t+" does not exist on jQuery.webTicker"):d.init.apply(this,arguments)}}(jQuery);
;