woocommerce/assets/js/jquery-payment/jquery.payment.min.js

1 line
7.6 KiB
JavaScript
Raw Normal View History

2015-02-02 16:20:00 +00:00
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v=[].slice,w=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};$=jQuery,$.payment={},$.payment.fn={},$.fn.payment=function(){var a,b;return b=arguments[0],a=2<=arguments.length?v.call(arguments,1):[],$.payment.fn[b].apply(this,a)},d=/(\d{1,4})/g,$.payment.cards=c=[{type:"visaelectron",pattern:/^4(026|17500|405|508|844|91[37])/,format:d,length:[16],cvcLength:[3],luhn:!0},{type:"maestro",pattern:/^(5(018|0[23]|[68])|6(39|7))/,format:d,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",pattern:/^600/,format:d,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",pattern:/^5019/,format:d,length:[16],cvcLength:[3],luhn:!0},{type:"visa",pattern:/^4/,format:d,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",pattern:/^5[0-5]/,format:d,length:[16],cvcLength:[3],luhn:!0},{type:"amex",pattern:/^3[47]/,format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"dinersclub",pattern:/^3[0689]/,format:d,length:[14],cvcLength:[3],luhn:!0},{type:"discover",pattern:/^6([045]|22)/,format:d,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",pattern:/^(62|88)/,format:d,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",pattern:/^35/,format:d,length:[16],cvcLength:[3],luhn:!0}],a=function(a){var b,d,e;for(a=(a+"").replace(/\D/g,""),d=0,e=c.length;e>d;d++)if(b=c[d],b.pattern.test(a))return b},b=function(a){var b,d,e;for(d=0,e=c.length;e>d;d++)if(b=c[d],b.type===a)return b},l=function(a){var b,c,d,e,f,g;for(d=!0,e=0,c=(a+"").split("").reverse(),f=0,g=c.length;g>f;f++)b=c[f],b=parseInt(b,10),(d=!d)&&(b*=2),b>9&&(b-=9),e+=b;return e%10===0},k=function(a){var b;return null!=a.prop("selectionStart")&&a.prop("selectionStart")!==a.prop("selectionEnd")?!0:null!=("undefined"!=typeof document&&null!==document&&null!=(b=document.selection)?b.createRange:void 0)&&document.selection.createRange().text?!0:!1},p=function(a){return setTimeout(function(){var b,c;return b=$(a.currentTarget),c=b.val(),c=c.replace(/\D/g,""),b.val(c)})},n=function(a){return setTimeout(function(){var b,c;return b=$(a.currentTarget),c=b.val(),c=$.payment.formatCardNumber(c),b.val(c)})},g=function(b){var c,d,e,f,g,h,i;return e=String.fromCharCode(b.which),!/^\d+$/.test(e)||(c=$(b.currentTarget),i=c.val(),d=a(i+e),f=(i.replace(/\D/g,"")+e).length,h=16,d&&(h=d.length[d.length.length-1]),f>=h||null!=c.prop("selectionStart")&&c.prop("selectionStart")!==i.length)?void 0:(g=d&&"amex"===d.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/,g.test(i)?(b.preventDefault(),setTimeout(function(){return c.val(i+" "+e)})):g.test(i+e)?(b.preventDefault(),setTimeout(function(){return c.val(i+e+" ")})):void 0)},e=function(a){var b,c;return b=$(a.currentTarget),c=b.val(),8!==a.which||null!=b.prop("selectionStart")&&b.prop("selectionStart")!==c.length?void 0:/\d\s$/.test(c)?(a.preventDefault(),setTimeout(function(){return b.val(c.replace(/\d\s$/,""))})):/\s\d?$/.test(c)?(a.preventDefault(),setTimeout(function(){return b.val(c.replace(/\d$/,""))})):void 0},o=function(a){return setTimeout(function(){var b,c;return b=$(a.currentTarget),c=b.val(),c=$.payment.formatExpiry(c),b.val(c)})},h=function(a){var b,c,d;return c=String.fromCharCode(a.which),/^\d+$/.test(c)?(b=$(a.currentTarget),d=b.val()+c,/^\d$/.test(d)&&"0"!==d&&"1"!==d?(a.preventDefault(),setTimeout(function(){return b.val("0"+d+" / ")})):/^\d\d$/.test(d)?(a.preventDefault(),setTimeout(function(){return b.val(""+d+" / ")})):void 0):void 0},i=function(a){var b,c,d;return c=String.fromCharCode(a.which),/^\d+$/.test(c)?(b=$(a.currentTarget),d=b.val(),/^\d\d$/.test(d)?b.val(""+d+" / "):void 0):void 0},j=function(a){var b,c,d;return d=String.fromCharCode(a.which),"/"===d||" "===d?(b=$(a.currentTarget),c=b.val(),/^\d$/.test(c)&&"0"!==c?b.val("0"+c+" / "):void 0):void 0},f=function(a){var b,c;return b=$(a.currentTarget),c=b.val(),8!==a.which||null!=b.prop("selectionStart")&&b.prop("selectionStart")!==c.length?void 0:/\d\s\/\s$/.test(c)?(a.preventDefault(),setTimeout(function(){retur