Skip to content

Instantly share code, notes, and snippets.

Avatar

CrowdfundHQ crowdfundhq

View GitHub Profile
@crowdfundhq
crowdfundhq / api_usage.html
Last active Oct 26, 2016
An example of how to use the CrowdfundHQ API from within your site
View api_usage.html
<script>
// Enable 'Sessions enabled' in Manage Site > Configuration > Settings > API
// Then use this script in Manage Site > Design > Pages or Scripts to fetch users
document.addEventListener('DOMContentLoaded', function(){
// Define variables
var url = '/api/v1/user/list', result, list, user;
// Do ajax call using hq.js
hq.ajax(url, {
success: function(json) {
@crowdfundhq
crowdfundhq / setup_froala_editor.html
Last active Nov 9, 2016
How to set up the Froala editor on existing CrowdfundHQ sites
View setup_froala_editor.html
<!-- How to set up the Froala editor (https://froala.com) on CrowdfundHQ (https://crowdfundhq.com) if it's not working -->
<!-- First go to Manage Site > Configuration > Settings > General and make sure Text Editor is set to Froala -->
<!-- Froala requires FontAwesome (http://fontawesome.io) and jQuery (https://jquery.com), install them if you don't have them already -->
<!-- Include jQuery by pasting the following line into Manage Site > Design > Scripts -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Include FontAwesome by pasting the following line into Manage Site > Design > Libraries -->
View about_to_top_mobile.html
<script>
document.addEventListener('DOMContentLoaded', function(){
if(hq.isMobile()) {
var campaignContent = document.getElementById('campaign_content');
if(campaignContent) {
var campaignSidebar = document.getElementById('campaign_sidebar');
var stats = document.getElementById('stats');
campaignSidebar.insertBefore(campaignContent, stats);
campaignContent.style.marginBottom = '2em';
}
View set_contribution_reward_amount.html
<script>
// Add this to the bottom of the contribution/new liquid template
var inputs = document.querySelectorAll('#selectable input');
var amount = document.querySelector('#contribution_amount');
// Sets the amount to be the same as the reward you chose
var select = function (event) {
var input = event.target;
var value = input.getAttribute('data-amount');
if (value) {
View advanced_search_liquid.liquid
{% comment %} Search by custom field {% endcomment %}
{% assign campaigns = current_site.campaigns | where: 'custom_fields.phone', '555-1234' | all %}
View country_select_options.liquid
{% Options for the option_list filter %}
<!-- Default, no options -->
{{ settings.countries | option_list }}
<!-- With empty prompt -->
{{ settings.countries | option_list: prompt: true }}
<!-- With selected -->
{{ settings.countries | option_list: selected: 'BR' }}
View redirect_if_already_contributed.liquid
{% if current_user %}
{% assign contributed = campaign.contributions | where: user_id: current_user.id | first %}
{% if contributed %}
Already contributed!
<script>
// Redirect back
window.location = '{{ request.referer }}'
</script>
{% else %}
Not contributed.
View api_update_contribution_jquery.html
<!-- This is an example on how to update contributions with jQuery from within your site -->
<p>The API says:</p>
<div id="response"></div>
<div id="error"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var response = document.getElementById('response')
@crowdfundhq
crowdfundhq / hash_page_in_url.html
Last active Oct 7, 2018
Add page to CrowdfundHQ using hash in URL
View hash_page_in_url.html
<div class="normal">
<h3>Normal content</h3>
<p>This is what the user normally sees</p>
<a href="/test/liquid#invite">Invite</a>
</div>
<div class="invite" style="display:none">
<h3>Invite form</h3>
<p>The invite page</p>
<a href="/test/liquid#">Back</a>
View customize_redirects.html
<script>
window.hq.postDialog = function(form){
var params = hq.serialize(form);
var center = hq.initDialog();
window.hq.post(form.action, center, params);
};
// General post ajax method
window.hq.post = function(url, el, params){
if(!el){ el = document.getElementById('content');}
hq.ajax(url, {
You can’t perform that action at this time.