laipower/wp-content/plugins/easy-digital-downloads/assets/js/vendor/jquery.payment.min.js

1 line
8.2 KiB
JavaScript
Raw Normal View History

(function(){var t,e,n,r,a,o,i,l,u,s,c,h,p,v,f,g,d,m,y,C,T,w,$,D,S=[].slice,k=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};(t=window.jQuery||window.Zepto||window.$).payment={},t.payment.fn={},t.fn.payment=function(){var e,n;return n=arguments[0],e=2<=arguments.length?S.call(arguments,1):[],t.payment.fn[n].apply(this,e)},a=/(\d{1,4})/g,t.payment.cards=r=[{type:"maestro",patterns:[5018,502,503,506,56,58,639,6220,67],format:a,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:a,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:a,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:a,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:a,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:a,length:[16],cvcLength:[3],luhn:!0}],e=function(t){var e,n,a,o,i,l,u;for(t=(t+"").replace(/\D/g,""),a=0,i=r.length;i>a;a++)for(o=0,l=(u=(e=r[a]).patterns).length;l>o;o++)if(n=u[o]+"",t.substr(0,n.length)===n)return e},n=function(t){var e,n,a;for(n=0,a=r.length;a>n;n++)if((e=r[n]).type===t)return e},p=function(t){var e,n,r,a,o,i;for(r=!0,a=0,o=0,i=(n=(t+"").split("").reverse()).length;i>o;o++)e=n[o],e=parseInt(e,10),(r=!r)&&(e*=2),e>9&&(e-=9),a+=e;return a%10==0},h=function(t){var e;return null!=t.prop("selectionStart")&&t.prop("selectionStart")!==t.prop("selectionEnd")||!(null==("undefined"!=typeof document&&null!==document&&null!=(e=document.selection)?e.createRange:void 0)||!document.selection.createRange().text)},$=function(t,e){var n,r,a,o,i;try{r=e.prop("selectionStart")}catch(t){r=null}return o=e.val(),e.val(t),null!==r&&e.is(":focus")?(r===o.length&&(r=t.length),o!==t&&(i=o.slice(r-1,+r+1||9e9),n=t.slice(r-1,+r+1||9e9),a=t[r],/\d/.test(a)&&i===a+" "&&n===" "+a&&(r+=1)),e.prop("selectionStart",r),e.prop("selectionEnd",r)):void 0},m=function(t){var e,n,r,a,o,i;for(null==t&&(t=""),a="",o=0,i=(e=t.split("")).length;i>o;o++)n=e[o],(r="".indexOf(n))>-1&&(n="0123456789"[r]),a+=n;return a},d=function(e){var n;return n=t(e.currentTarget),setTimeout((function(){var t;return t=n.val(),t=(t=m(t)).replace(/\D/g,""),$(t,n)}))},f=function(e){var n;return n=t(e.currentTarget),setTimeout((function(){var e;return e=n.val(),e=m(e),e=t.payment.formatCardNumber(e),$(e,n)}))},l=function(n){var r,a,o,i,l,u,s;return o=String.fromCharCode(n.which),!/^\d+$/.test(o)||(r=t(n.currentTarget),s=r.val(),a=e(s+o),i=(s.replace(/\D/g,"")+o).length,u=16,a&&(u=a.length[a.length.length-1]),i>=u||null!=r.prop("selectionStart")&&r.prop("selectionStart")!==s.length)?void 0:(l=a&&"amex"===a.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/).test(s)?(n.preventDefault(),setTimeout((function(){return r.val(s+" "+o)}))):l.test(s+o)?(n.preventDefault(),setTimeout((function(){return r.val(s+o+" ")}))):void 0},o=function(e){var n,r;return n=t(e.currentTarget),r=n.val(),8!==e.which||null!=n.prop("selectionStart")&&n.prop("selectionStart")!==r.length?void 0:/\d\s$/.test(r)?(e.preventDefault(),setTimeout((function(){return n.val(r.replace(/\d\s$/,""))}))):/\s\d?$/.test(r)?(e.preventDefault(),setTimeout((function(){return n.val(r.replace(/\d$/,""))}))):void 0},g=function(e){var n;return n=t(e.currentTarget),setTimeout((function(){var e;return e=n.val(),e=m(e),e=t.payment.formatExpiry(e),$(e,n)}))},u=function(e){var n,r,a;return r=String.fromCharCode(e.which),/^\d+$/.test(r)?(n=t(e.currentTarget),a=n.val()+r,/^\d$/.test(a)&&"0"!==a&&"1"!==a?(e.preventDefault(),setTimeout((function(){return n.val("0"+a+" / ")}))):/^\d\d$/.test(a)?(e.preventDefault(),setT