This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1fd4c1
commit 5ee4e78
Showing
8 changed files
with
132 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
Gratipay.payments = {}; | ||
|
||
Gratipay.payments.init = function() { | ||
|
||
Gratipay.forms.jsEdit({ | ||
confirmBeforeUnload: true, | ||
hideEditButton: true, | ||
root: $('.your-payment.js-edit'), | ||
success: function(data) { | ||
Gratipay.notification(data.msg, 'success'); | ||
Gratipay.payments.afterTipChange(data); | ||
} | ||
}); | ||
|
||
$('.your-payment button.edit').click(function() { | ||
$('.your-payment input').focus(); | ||
}); | ||
|
||
$('.your-payment button.stop').click(function() { | ||
$('.your-payment input').val('0'); | ||
$('.your-payment button.save').click(); | ||
}); | ||
|
||
$('.your-payment button.cancel').click(function() { | ||
$('.your-payment form').trigger('reset'); | ||
}); | ||
|
||
// Cancel if the user presses the Escape key | ||
$('.your-payment input').keyup(function(e) { | ||
if (e.keyCode === 27) | ||
$('.your-payment button.cancel').click(); | ||
}); | ||
}; | ||
|
||
|
||
Gratipay.payments.initSupportGratipay = function() { | ||
$('.support-gratipay button').click(function() { | ||
var amount = parseFloat($(this).attr('data-amount'), 10); | ||
Gratipay.payments.set('Gratipay', amount, function(data) { | ||
Gratipay.notification(data.msg, 'success'); | ||
$('.support-gratipay').slideUp(); | ||
|
||
// If you're on your own giving page ... | ||
var payment_on_giving = $('.your-payment[data-team="Gratipay"]'); | ||
if (payment_on_giving.length > 0) { | ||
payment_on_giving[0].defaultValue = amount; | ||
payment_on_giving.attr('value', amount.toFixed(2)); | ||
} | ||
}); | ||
}); | ||
|
||
$('.support-gratipay .no-thanks').click(function(event) { | ||
event.preventDefault(); | ||
jQuery.post('/ride-free.json') | ||
.success(function() { $('.support-gratipay').slideUp(); }) | ||
.fail(Gratipay.error) | ||
}); | ||
}; | ||
|
||
|
||
Gratipay.payments.afterTipChange = function(data) { | ||
$('.my-total-giving').text(data.total_giving_l); | ||
$('.total-receiving[data-team="'+data.team_id+'"]').text(data.total_receiving_team_l); | ||
$('#payment-prompt').toggleClass('needed', data.amount > 0); | ||
$('.nsupporters[data-team="'+data.team_id+'"]').text(data.nsupporters); | ||
|
||
var $your_payment = $('.your-payment[data-team="'+data.team_id+'"]'); | ||
if ($your_payment) { | ||
var $input = $your_payment.find('input'); | ||
$input[0].defaultValue = $input.val(); | ||
$your_payment.find('span.amount').text(data.amount_l); | ||
$your_payment.find('.edit').toggleClass('not-zero', data.amount > 0); | ||
$your_payment.find('.stop').toggleClass('zero', data.amount === 0); | ||
} | ||
}; | ||
|
||
|
||
Gratipay.payments.set = function(team, amount, callback) { | ||
|
||
// send request to set up a recurring payment | ||
$.post('/' + team + '/subscription.json', { amount: amount }, function(data) { | ||
if (callback) callback(data); | ||
Gratipay.payments.afterTipChange(data); | ||
}) | ||
.fail(Gratipay.error); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{% if user.ANON %} | ||
<div class="right"> | ||
{% include "templates/sign-in-using-to-give.html" %} | ||
</div> | ||
{% else %} | ||
<div class="cta"> | ||
{% set subscription = user.participant.get_subscription_to(team.slug) %} | ||
<h2>{{ _('Your Payment') }}</h2> | ||
<div class="js-edit your-payment {{ 'anon' if user.ANON }}" data-team="{{ team.id }}"> | ||
<div class="view"> | ||
<span class="amount">{{ format_currency(subscription.amount, 'USD') }}</span> | ||
<div class="per-week">{{ _("per week") }}</div> | ||
<button class="edit {{ 'not-zero' if subscription.amount > 0 }}"> | ||
<span class="zero">{{ _("Support {0}", team.name) }}</span> | ||
<span class="not-zero">{{ _("Edit") }}</span> | ||
</button> | ||
</div> | ||
<form class="edit" action="/{{ team.slug }}/subscription.json"> | ||
$ | ||
<input type="text" name="amount" class="amount" | ||
value="{{ format_decimal(subscription.amount) }}" | ||
min="0" max="1000"> | ||
<div class="per-week">{{ _("per week") }}</div> | ||
<button class="save">{{ _("Save") }}</button> | ||
<button class="cancel">{{ _("Cancel") }}</button> | ||
<button class="stop {{ 'zero' if not subscription.amount }}">{{ _("Stop Giving") }}</button> | ||
</form> | ||
</div> | ||
|
||
{% if not subscription.is_funded %} | ||
<div id="payment-prompt" class="{{ 'needed' if subscription.amount > 0 }}"> | ||
{{ _("Back your payment with a {0}credit card{1} to make sure it goes through!", | ||
"<a href='/~%s/routes/credit-card.html'>"|safe % user.participant.username, | ||
"</a>"|safe) }} | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endif %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.