X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=templates%2FCRM%2FCore%2FBillingBlock.js;h=98469c9a756d08c7965709567e992722bc9f2fb5;hb=555a1550bfb13580ebb34286563080c6f9f2b50a;hp=388394849714c8c32c476615ea58a55c235ff3af;hpb=960327c9fbbb2dc52f8f67a1bf94edc40281c1f0;p=civicrm-core.git
diff --git a/templates/CRM/Core/BillingBlock.js b/templates/CRM/Core/BillingBlock.js
index 3883948497..98469c9a75 100644
--- a/templates/CRM/Core/BillingBlock.js
+++ b/templates/CRM/Core/BillingBlock.js
@@ -10,13 +10,13 @@
function civicrm_billingblock_creditcard_helper() {
$(function() {
$.each(CRM.config.creditCardTypes, function(key, val) {
- var html = '' + val + '';
+ var html = '' + val.label + '';
$('.crm-credit_card_type-icons').append(html);
- $('.crm-credit_card_type-icon-' + key).click(function() {
- $('#credit_card_type').val(val);
+ $('.crm-credit_card_type-icon-' + val.css_key).click(function() {
+ $('#credit_card_type').val(key);
$('.crm-container .credit_card_type-section a').css('opacity', 0.25);
- $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
+ $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 1);
return false;
});
});
@@ -27,13 +27,13 @@
// set the card type value as default if any found
var cardtype = $('#credit_card_type').val();
if (cardtype) {
- $.each(CRM.config.creditCardTypes, function(key, value) {
+ $.each(CRM.config.creditCardTypes, function(key, val) {
// highlight the selected card type icon
- if (value == cardtype) {
- $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
+ if (key === cardtype) {
+ $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 1);
}
else {
- $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 0.25);
+ $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 0.25);
}
});
}
@@ -56,33 +56,12 @@
}
function civicrm_billingblock_set_card_type(ccnumber) {
- // Based on http://davidwalsh.name/validate-credit-cards
- // See also https://en.wikipedia.org/wiki/Credit_card_numbers
- var card_types = {
- 'mastercard': '(5[1-5][0-9]{2}|2[3-6][0-9]{2}|22[3-9][0-9]|222[1-9]|27[0-1][0-9]|2720)[0-9]{12}',
- 'visa': '4(?:[0-9]{12}|[0-9]{15})',
- 'amex': '3[47][0-9]{13}',
- 'dinersclub': '3(?:0[0-5][0-9]{11}|[68][0-9]{12})',
- 'carteblanche': '3(?:0[0-5][0-9]{11}|[68][0-9]{12})',
- 'discover': '6011[0-9]{12}',
- 'jcb': '(?:3[0-9]{15}|(2131|1800)[0-9]{11})',
- 'unionpay': '62(?:[0-9]{14}|[0-9]{17})'
- };
-
var card_values = CRM.config.creditCardTypes;
-
- $.each(card_types, function(key, pattern) {
- if (ccnumber.match('^' + pattern + '$')) {
- var value = card_values[key];
- //$.each(CRM.config.creditCardTypes, function(key2, val) {
- // if (value == val) {
- $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
- $('select#credit_card_type').val(value);
- return false;
- // }
- // else {
- // $
- // });
+ $.each(card_values, function(key, spec) {
+ if (ccnumber.match('^' + spec.pattern + '$')) {
+ $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + spec.css_key).css('opacity', 1);
+ $('select#credit_card_type').val(key);
+ return false;
}
});
}