File: /home/accemeff/vendor/craftcms/cms/lib/jquery.payment/jquery.payment.js
(function(){var u,s,a,c,t,e,n,r,i,o,l,h,p,f,g,v,d,m,y,C,T,w,$,D,S=[].slice,k=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};(u=window.jQuery||window.Zepto||window.$).payment={},u.payment.fn={},u.fn.payment=function(){var t,e;return e=arguments[0],t=2<=arguments.length?S.call(arguments,1):[],u.payment.fn[e].apply(this,t)},t=/(\d{1,4})/g,u.payment.cards=c=[{type:"maestro",patterns:[5018,502,503,506,56,58,639,6220,67],format:t,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:t,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:t,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:t,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:t,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:t,length:[16],cvcLength:[3],luhn:!0}],s=function(t){var e,n,r,a,i,o,l;for(t=(t+"").replace(/\D/g,""),r=0,i=c.length;r<i;r++)for(a=0,o=(l=(e=c[r]).patterns).length;a<o;a++)if(n=l[a]+"",t.substr(0,n.length)===n)return e},a=function(t){var e,n,r;for(n=0,r=c.length;n<r;n++)if((e=c[n]).type===t)return e},p=function(t){var e,n,r,a,i,o;for(r=!0,i=a=0,o=(n=(t+"").split("").reverse()).length;i<o;i++)e=n[i],e=parseInt(e,10),(r=!r)&&(e*=2),9<e&&(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,i,o;try{r=e.prop("selectionStart")}catch(t){t,r=null}if(i=e.val(),e.val(t),null!==r&&e.is(":focus"))return r===i.length&&(r=t.length),i!==t&&(o=i.slice(r-1,+r+1||9e9),n=t.slice(r-1,+r+1||9e9),a=t[r],/\d/.test(a)&&o===a+" "&&n===" "+a&&(r+=1)),e.prop("selectionStart",r),e.prop("selectionEnd",r)},m=function(t){var e,n,r,a,i,o;for(null==t&&(t=""),"0123456789","0123456789",a="",i=0,o=(e=t.split("")).length;i<o;i++)n=e[i],-1<(r="0123456789".indexOf(n))&&(n="0123456789"[r]),a+=n;return a},d=function(t){var e;return e=u(t.currentTarget),setTimeout(function(){var t;return t=e.val(),t=(t=m(t)).replace(/\D/g,""),$(t,e)})},g=function(t){var e;return e=u(t.currentTarget),setTimeout(function(){var t;return t=e.val(),t=m(t),t=u.payment.formatCardNumber(t),$(t,e)})},r=function(t){var e,n,r,a,i,o,l;if(r=String.fromCharCode(t.which),/^\d+$/.test(r)&&(e=u(t.currentTarget),l=e.val(),n=s(l+r),a=(l.replace(/\D/g,"")+r).length,o=16,n&&(o=n.length[n.length.length-1]),!(o<=a||null!=e.prop("selectionStart")&&e.prop("selectionStart")!==l.length)))return(i=n&&"amex"===n.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/).test(l)?(t.preventDefault(),setTimeout(function(){return e.val(l+" "+r)})):i.test(l+r)?(t.preventDefault(),setTimeout(function(){return e.val(l+r+" ")})):void 0},e=function(t){var e,n;if(e=u(t.currentTarget),n=e.val(),8===t.which&&(null==e.prop("selectionStart")||e.prop("selectionStart")===n.length))return/\d\s$/.test(n)?(t.preventDefault(),setTimeout(function(){return e.val(n.replace(/\d\s$/,""))})):/\s\d?$/.test(n)?(t.preventDefault(),setTimeout(function(){return e.val(n.replace(/\d$/,""))})):void 0},v=function(t){var e;return e=u(t.currentTarget),setTimeout(function(){var t;return t=e.val(),t=m(t),t=u.payment.formatExpiry(t),$(t,e)})},i=function(t){var n,e,r;if(e=String.fromCharCode(t.which),/^\d+$/.test(e))return n=u(t.currentTarget),r=n.val()+e,/^\d$/.test(r)&&"0"!==r&&"1"!==r?(t.preventDefault(),setTimeout(function(){return n.val("0"+r+" / ")})):/^\d\d$/.test(r)?(t.preventDefault(),setTimeout(function(){var t,e;return t=parseInt(r[0],10),2<(e=parseInt(r[1],10))&&0!==t?n.val("0"+t+" / "+e):n.val(r+" / ")})):void 0},o=function(t){var e,n,r;if(n=String.fromCharCode(t.which),/^\d+$/.test(n))return r=(e=u(t.currentTarget)).val(),/^\d\d$/.test(r)?e.val(r+" / "):void 0},l=function(t){var e,n,r;if("/"===(r=String.fromCharCode(t.which))||" "===r)return n=(e=u(t.currentTarget)).val(),/^\d$/.test(n)&&"0"!==n?e.val("0"+n+" / "):void 0},n=function(t){var e,n;if(e=u(t.currentTarget),n=e.val(),8===t.which&&(null==e.prop("selectionStart")||e.prop("selectionStart")===n.length))return/\d\s\/\s$/.test(n)?(t.preventDefault(),setTimeout(function(){return e.val(n.replace(/\d\s\/\s$/,""))})):void 0},f=function(t){var e;return e=u(t.currentTarget),setTimeout(function(){var t;return t=e.val(),t=(t=m(t)).replace(/\D/g,"").slice(0,4),$(t,e)})},w=function(t){var e;return!(!t.metaKey&&!t.ctrlKey)||32!==t.which&&(0===t.which||(t.which<33||(e=String.fromCharCode(t.which),!!/[\d\s]/.test(e))))},C=function(t){var e,n,r,a;if(e=u(t.currentTarget),r=String.fromCharCode(t.which),/^\d+$/.test(r)&&!h(e))return a=(e.val()+r).replace(/\D/g,""),(n=s(a))?a.length<=n.length[n.length.length-1]:a.length<=16},T=function(t){var e,n;if(e=u(t.currentTarget),n=String.fromCharCode(t.which),/^\d+$/.test(n)&&!h(e))return!(6<(e.val()+n).replace(/\D/g,"").length)&&void 0},y=function(t){var e,n;if(e=u(t.currentTarget),n=String.fromCharCode(t.which),/^\d+$/.test(n)&&!h(e))return(e.val()+n).length<=4},D=function(t){var e,n,r,a,i;if(i=(e=u(t.currentTarget)).val(),a=u.payment.cardType(i)||"unknown",!e.hasClass(a))return n=function(){var t,e,n;for(n=[],t=0,e=c.length;t<e;t++)r=c[t],n.push(r.type);return n}(),e.removeClass("unknown"),e.removeClass(n.join(" ")),e.addClass(a),e.toggleClass("identified","unknown"!==a),e.trigger("payment.cardType",a)},u.payment.fn.formatCardCVC=function(){return this.on("keypress",w),this.on("keypress",y),this.on("paste",f),this.on("change",f),this.on("input",f),this},u.payment.fn.formatCardExpiry=function(){return this.on("keypress",w),this.on("keypress",T),this.on("keypress",i),this.on("keypress",l),this.on("keypress",o),this.on("keydown",n),this.on("change",v),this.on("input",v),this},u.payment.fn.formatCardNumber=function(){return this.on("keypress",w),this.on("keypress",C),this.on("keypress",r),this.on("keydown",e),this.on("keyup",D),this.on("paste",g),this.on("change",g),this.on("input",g),this.on("input",D),this},u.payment.fn.restrictNumeric=function(){return this.on("keypress",w),this.on("paste",d),this.on("change",d),this.on("input",d),this},u.payment.fn.cardExpiryVal=function(){return u.payment.cardExpiryVal(u(this).val())},u.payment.cardExpiryVal=function(t){var e,n,r;return e=(r=t.split(/[\s\/]+/,2))[0],2===(null!=(n=r[1])?n.length:void 0)&&/^\d+$/.test(n)&&(n=(new Date).getFullYear().toString().slice(0,2)+n),{month:e=parseInt(e,10),year:n=parseInt(n,10)}},u.payment.validateCardNumber=function(t){var e,n;return t=(t+"").replace(/\s+|-/g,""),!!/^\d+$/.test(t)&&(!!(e=s(t))&&(n=t.length,0<=k.call(e.length,n)&&(!1===e.luhn||p(t))))},u.payment.validateCardExpiry=function(t,e){var n,r,a;return"object"==typeof t&&"month"in t&&(t=(a=t).month,e=a.year),!(!t||!e)&&(t=u.trim(t),e=u.trim(e),!!/^\d+$/.test(t)&&(!!/^\d+$/.test(e)&&(1<=t&&t<=12&&(2===e.length&&(e=e<70?"20"+e:"19"+e),4===e.length&&(r=new Date(e,t),n=new Date,r.setMonth(r.getMonth()-1),r.setMonth(r.getMonth()+1,1),n<r)))))},u.payment.validateCardCVC=function(t,e){var n,r;return t=u.trim(t),!!/^\d+$/.test(t)&&(null!=(n=a(e))?(r=t.length,0<=k.call(n.cvcLength,r)):3<=t.length&&t.length<=4)},u.payment.cardType=function(t){var e;return t&&(null!=(e=s(t))?e.type:void 0)||null},u.payment.formatCardNumber=function(t){var e,n,r,a;return t=t.replace(/\D/g,""),(e=s(t))?(r=e.length[e.length.length-1],t=t.slice(0,r),e.format.global?null!=(a=t.match(e.format))?a.join(" "):void 0:null!=(n=e.format.exec(t))?(n.shift(),(n=u.grep(n,function(t){return t})).join(" ")):void 0):t},u.payment.formatExpiry=function(t){var e,n,r,a;return(n=t.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/))?(e=n[1]||"",r=n[2]||"",0<(a=n[3]||"").length?r=" / ":" /"===r?(e=e.substring(0,1),r=""):2===e.length||0<r.length?r=" / ":1===e.length&&"0"!==e&&"1"!==e&&(e="0"+e,r=" / "),e+r+a):""}}).call(this);
//# sourceMappingURL=jquery.payment.js.map