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

1 line
8.5 KiB
JavaScript
Raw Normal View History

2016-06-01 10:33:53 +00:00
jQuery(function(a){(function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=[].slice,z=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};a=window.jQuery||window.Zepto||window.$,a.payment={},a.payment.fn={},a.fn.payment=function(){var b,c;return c=arguments[0],b=2<=arguments.length?y.call(arguments,1):[],a.payment.fn[c].apply(this,b)},e=/(\d{1,4})/g,a.payment.cards=d=[{type:"visaelectron",patterns:[4026,417500,4405,4508,4844,4913,4917],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"maestro",patterns:[5018,502,503,506,56,58,639,6220,67],format:e,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"elo",patterns:[4011,4312,4389,4514,4573,4576,5041,5066,5067,509,6277,6362,6363,650,6516,6550],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:e,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"amex",patterns:[34,37],format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"dinersclub",patterns:[30,36,38,39],format:/(\d{1,4})(\d{1,6})?(\d{1,4})?/,length:[14],cvcLength:[3],luhn:!0},{type:"discover",patterns:[60,64,65,622],format:e,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:e,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:e,length:[16],cvcLength:[3],luhn:!0}],b=function(a){var b,c,e,f,g,h,i,j;for(a=(a+"").replace(/\D/g,""),f=0,h=d.length;h>f;f++)for(b=d[f],j=b.patterns,g=0,i=j.length;i>g;g++)if(e=j[g],c=e+"",a.substr(0,c.length)===c)return b},c=function(a){var b,c,e;for(c=0,e=d.length;e>c;c++)if(b=d[c],b.type===a)return b},m=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},l=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)},w=function(a,b){var c,d,e,f,g,h;try{d=b.prop("selectionStart")}catch(i){f=i,d=null}return g=b.val(),b.val(a),null!==d&&b.is(":focus")?(d===g.length&&(d=a.length),g!==a&&(h=g.slice(d-1,+d+1||9e9),c=a.slice(d-1,+d+1||9e9),e=a[d],/\d/.test(e)&&h===""+e+" "&&c===" "+e&&(d+=1)),b.prop("selectionStart",d),b.prop("selectionEnd",d)):void 0},r=function(a){var b,c,d,e,f,g,h,i;for(null==a&&(a=""),d="",e="0123456789",g="",b=a.split(""),h=0,i=b.length;i>h;h++)c=b[h],f=d.indexOf(c),f>-1&&(c=e[f]),g+=c;return g},q=function(b){var c;return c=a(b.currentTarget),setTimeout(function(){var a;return a=c.val(),a=r(a),a=a.replace(/\D/g,""),w(a,c)})},o=function(b){var c;return c=a(b.currentTarget),setTimeout(function(){var b;return b=c.val(),b=r(b),b=a.payment.formatCardNumber(b),w(b,c)})},h=function(c){var d,e,f,g,h,i,j;return f=String.fromCharCode(c.which),!/^\d+$/.test(f)||(d=a(c.currentTarget),j=d.val(),e=b(j+f),g=(j.replace(/\D/g,"")+f).length,i=16,e&&(i=e.length[e.length.length-1]),g>=i||null!=d.prop("selectionStart")&&d.prop("selectionStart")!==j.length)?void 0:(h=e&&"amex"===e.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/,h.test(j)?(c.preventDefault(),setTimeout(function(){return d.val(j+" "+f)})):h.test(j+f)?(c.preventDefault(),setTimeout(function(){return d.val(j+f+" ")})):void 0)},f=function(b){var c,d;return c=a(b.currentTarget),d=c.val(),8!==b.which||null!=c.prop("selectionStart")&&c.prop("selectionStart")!==d.length?void 0:/\d\s$/.test(d)?(b.preventDefault(),setTimeout(function(){return c.val(d.replace(/\d\s$/,""))})):/\s\d?$/.test(d)?(b.preventDefault(),setTimeout(function(){return c.val(d.replace(/\d$/,""))})):void 0},p=function(b){var c;return c=a(b.currentTarget),setTimeout(function(){var b;return b=c.val(),b=r(b),b=a.