blob: 92d6994a4243a6a5370cd8bd71b5de7fe1393fb6 [file]
/**
* donate.js
*
* Copyright (c) 2015 Eclipse Foundation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christopher Guindon (Eclipse Foundation)- initial API and implementation
*/
(function( jQuery, window, document ) {
var payment_type = function () {
if ($('input:radio[name=type]:checked').val() === 'bitpay'){
$('#choose-amount-container-bitpay').show();
$('#choose-amount-container-paypal').hide();
$("#total-amount-sign").html('<i class="fa fa-btc"></i>');
update_amount($('#choose-amount-container-bitpay .btn-square.active'));
}
else {
$('#choose-amount-container-bitpay').hide();
$('#choose-amount-container-paypal').show();
$("#total-amount-sign").html('$');
update_amount($('#choose-amount-container-paypal .btn-square.active'));
}
}
var update_amount = function (e) {
$('.total-amount').val($(e).val());
$('#other-amount').val('');
}
jQuery(document).ready(function($) {
payment_type();
$('.btn-square').click(function() {
$(this).parent().children('.btn-square').removeClass('active');
$(this).addClass('active');
update_amount(this);
});
$('#other-amount').click(function() {
$('#other-amount').bind("keyup change", function(e) {
$('.total-amount').html($(this).val());
$('input[name=amount]').val($(this).val());
$('.btn-square').removeClass('active');
});
});
$('input:radio[name=type]').change(payment_type);
$(".num-only").keydown(function(e) {
// Allow: backspace, delete, tab, escape, enter and .
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
// Allow: Ctrl+A, Command+A
(e.keyCode == 65 && (e.ctrlKey === true || e.metaKey === true)) ||
// Allow: home, end, left, right, down, up
(e.keyCode >= 35 && e.keyCode <= 40)) {
// let it happen, don't do anything
return;
}
// Ensure that it is a number and stop the keypress
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
});
})(jQuery, window, document );