1// http://civicrm.org/licensing 2(function($, _) { 3 4 $(function() { 5 $.each(CRM.config.creditCardTypes, function(key, val) { 6 var html = '<a href="#" title="' + _.escape(val.label) + '" class="crm-credit_card_type-icon-' + val.css_key + '"><span>' + _.escape(val.label) + '</span></a>'; 7 $('.crm-credit_card_type-icons').append(html); 8 9 $('.crm-credit_card_type-icon-' + val.css_key).click(function() { 10 $('#credit_card_type').val(key); 11 $('.crm-container .credit_card_type-section a').css('opacity', 0.25); 12 $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 1); 13 return false; 14 }); 15 }); 16 17 // Hide the CC type field (redundant) 18 $('#credit_card_type, .label', '.crm-container .credit_card_type-section').hide(); 19 20 // set the card type value as default if any found 21 var cardtype = $('#credit_card_type').val(); 22 if (cardtype) { 23 $.each(CRM.config.creditCardTypes, function(key, val) { 24 // highlight the selected card type icon 25 if (key === cardtype) { 26 $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 1); 27 } 28 else { 29 $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + val.css_key).css('opacity', 0.25); 30 } 31 }); 32 } 33 34 // Select according to the number entered 35 $('.crm-container input#credit_card_number').change(function() { 36 var ccnumber = $(this).val(); 37 38 // Remove spaces and dashes 39 ccnumber = ccnumber.replace(/[- ]/g, ''); 40 $(this).val(ccnumber); 41 42 // Semi-hide all images, we will un-hide the right one afterwards 43 $('.crm-container .credit_card_type-section a').css('opacity', 0.25); 44 $('#credit_card_type').val(''); 45 46 setCardtype(ccnumber); 47 }); 48 49 function setCardtype(ccnumber) { 50 $.each(CRM.config.creditCardTypes, function(key, spec) { 51 if (ccnumber.match('^' + spec.pattern + '$')) { 52 $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + spec.css_key).css('opacity', 1); 53 $('select#credit_card_type').val(key); 54 return false; 55 } 56 }); 57 } 58 59 }); 60 61})(CRM.$, CRM._);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.