blob: b02a6efa6f48b8c4e2df6b7e61e1f824b4618b6c [file] [log] [blame]
/**
* 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 update_amount = function (e) {
$('.total-amount').val($(e).val());
$('#other-amount').val('');
}
jQuery(document).ready(function($) {
$('.btn-square').click(function() {
$('.btn-square, .amount-body, .highlight-amount-body').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');
});
});
$(".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 );