Skip to content

Instantly share code, notes, and snippets.

View bpalm's full-sized avatar

Brian Palmer bpalm

View GitHub Profile
@bpalm
bpalm / foreign_donor_prevention.js
Created May 11, 2021 18:05
JavaScript to prevent donations from foreign donors
{% if page.type_name == 'Donation' or page.type_name == 'Donation (v2)' %}
<!-- Script to prevent donations from foreign donors -->
<script>
$( document ).ready(function() {
$('.donation_form .submit-button').attr('disabled', 'disabled');
var selectedCountry1 = $('#donation_billing_address_country_code option:selected').val();
console.log(selectedCountry1);
if (selectedCountry1 == 'US') {
console.log('Local donor detected');
$('.donation_form .submit-button').attr('disabled', false);
@bpalm
bpalm / _custom_field.html
Last active July 27, 2020 13:42
HTML partial to easily request custom fields on NationBuilder pages
{% assign basetheme = sitetheme | downcase %}
{% assign realThemeName = theme.name | downcase %}
{% if basetheme.size > 0 %}{% else %}
{% if realThemeName contains 'action' %}
{% assign basetheme = 'action' %}
{% elsif realThemeName contains 'raise' %}
{% assign basetheme = 'raise' %}
{% elsif realThemeName contains 'aware' or realThemeName contains 'cityzen' or realThemeName contains 'publish' or realThemeName contains 'presence' or realThemeName contains 'verve' or realThemeName contains 'headliner' or realThemeName contains 'collective' or realThemeName contains 'victory again' %}
{% assign basetheme = 'aware' %}
{% endif %}
@bpalm
bpalm / _signup_page_template_custom.html
Created March 10, 2020 21:00
Site Location Liquid Solution
<div class="container">
<div class="row">
<div class="col-sm-6 col-lg-5 col-lg-offset-1">
{% if page.headline.size > 0 %}
<h2 class="headline">{{ page.headline }}</h2>
{% endif %}
<div id="content">
@bpalm
bpalm / sort_options_alphabetically.html
Created July 11, 2019 21:20
Javascript to automatically sort multiple choice options alphabetically
<script>
$("#signup_custom_values_chapter_custom").html($('#signup_custom_values_chapter_custom option').sort(function(x, y) {
return $(x).text().toUpperCase() < $(y).text().toUpperCase() ? -1 : 1;
}));
$("#signup_custom_values_chapter_custom").get(0).selectedIndex = 0;
e.preventDefault();
</script>
@bpalm
bpalm / _donation_frequency_toggle.html
Created February 28, 2019 18:03
Donation Frequency toggle for v1 donation
{% if page.parent.type_slug == 'donation' and page.parent.donation.donation_frequency != page.donation.donation_frequency %}
<div class="clearfix padtop">
<div class="radio-inline">
<a style="float:left; margin-right:10px;" class="btn {% if page.donation.donation_frequency == "one-time" %}btn-default {% else %}btn-ghost{% endif %}" href="{% if page.donation.donation_frequency == "one-time" %}#{% else %}{{ page.parent.full_url }}{% endif %}">One-time</a>
<a class="btn {% if page.donation.donation_frequency == "monthly" %}btn-default{% else %}btn-ghost{% endif %}" href="{% if page.donation.donation_frequency == "monthly" %}#{% else %}{{ page.parent.full_url }}{% endif %}">Monthly</a>
</div>
</div>
{% else %}
{% for child in page.children %}
{% if child.type_slug == 'donation' and child.donation.donation_frequency != page.donation.donation_fr
@bpalm
bpalm / _memberships_table.html
Created February 27, 2019 14:58
Table that displays the relationships between the logged-in user and organization profiles, along with other relationships that exist on that organization's profile
<table id="projectSpreadsheet" class="fixed_headers" style="width:875px;border:1px solid;">
<thead>
<tr>
<th>id</th>
<th>First<br>Name</th>
<th>Last<br>Name</th>
<th>Relationship<br>Type</th>
<th>Relationship<br>Description</th>
<th>Other Profile<br>ID</th>
<th>Other Profile<br>First Name</th>
@bpalm
bpalm / _double_optin_template.html
Last active October 17, 2018 18:14
Double Confirmation Page Template
<div id="content">
<div class="form-wrap">
<div class="form">
<h2 id="confirming">Confirming email address...</h2><br>
{% form_for signup %}
<div class="form-errors">{% error_messages_for signup %}</div>
@bpalm
bpalm / _donation_country.html
Created January 17, 2018 14:20
Country dropdown for donation page
<select id="donation_billing_address_country_code" name="donation[billing_address_attributes][country_code]"><option value="AF">Afghanistan</option><option value="AL">Albania</option><option value="DZ">Algeria</option><option value="AS">American Samoa</option><option value="AD">Andorra</option><option value="AO">Angola</option><option value="AI">Anguilla</option><option value="AQ">Antarctica</option><option value="AG">Antigua and Barbuda</option><option value="AR">Argentina</option><option value="AM">Armenia</option><option value="AW">Aruba</option><option value="AU">Australia</option><option value="AT">Austria</option><option value="AZ">Azerbaijan</option><option value="BS">Bahamas</option><option value="BH">Bahrain</option><option value="BD">Bangladesh</option><option value="BB">Barbados</option><option value="BY">Belarus</option><option value="BE">Belgium</option><option value="BZ">Belize</option><option value="BJ">Benin</option><option value="BM">Bermuda</option><option value="BT">Bhutan</option><option v
@bpalm
bpalm / brians_wysiwyg.html
Created December 13, 2017 18:23
HTML Source code of Brian's WYSIWYG
<p>This is a test of the WYSIWYG upgrade.</p>
<p style="color: red; background-color: #012792; font-weight: bold; padding: 45px; border: 3px solid black;">This text has formatting applied to it via inline CSS added through the "HTML source code" button.</p>
<p><br /><br />Below is an embedly youtube vid:<br /><br />https://www.youtube.com/watch?v=-4WKle-GQwk</p>
<p>&nbsp;</p>
<h2 id="bpalms" class="button">This headline has the class button and the ID bpalms</h2>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a>This link shouldn't work</a> <a href="#">This link should just link to a pound sign</a> <a href="#bpalms">This link is an anchor to the bpalms headline above</a></p>
<hr />
<p><strong>This text is bolded using a b tag</strong> <strong>This text is bolded using a strong tag</strong></p>
@bpalm
bpalm / clear_order_on_event_view.html
Last active August 29, 2017 20:07
Code to clear pending ticket order when viewing an event page
{% if request.template contains "pages_show_event" %} {% if request.current_order %}
<script>
window.location = "https://slug.nationbuilder.com/forms/donations/clear_order?page_id={{ page.id }}";
</script>
{% endif %}{% endif %}