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

1 line
7.2 KiB
JavaScript
Raw Normal View History

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