2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
|
// Generated by CoffeeScript 1.4.0
|
||
|
(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b=[].slice,w=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},E=this;e=jQuery;e.payment={};e.payment.fn={};e.fn.payment=function(){var t,n;n=arguments[0],t=2<=arguments.length?b.call(arguments,1):[];return e.payment.fn[n].apply(this,t)};i=/(\d{1,4})/g;r=[{type:"maestro",pattern:/^(5018|5020|5038|6304|6759|676[1-3])/,format:i,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"dinersclub",pattern:/^(36|38|30[0-5])/,format:i,length:[14],cvcLength:[3],luhn:!0},{type:"laser",pattern:/^(6706|6771|6709)/,format:i,length:[16,17,18,19],cvcLength:[3],luhn:!0},{type:"jcb",pattern:/^35/,format:i,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",pattern:/^62/,format:i,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"discover",pattern:/^(6011|65|64[4-9]|622)/,format:i,length:[16],cvcLength:[3],luhn:!0},{type:"mastercard",pattern:/^5[1-5]/,format:i,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:"visa",pattern:/^4/,format:i,length:[13,14,15,16],cvcLength:[3],luhn:!0}];t=function(e){var t,n,i;e=(e+"").replace(/\D/g,"");for(n=0,i=r.length;n<i;n++){t=r[n];if(t.pattern.test(e))return t}};n=function(e){var t,n,i;for(n=0,i=r.length;n<i;n++){t=r[n];if(t.type===e)return t}};h=function(e){var t,n,r,i,s,o;r=!0;i=0;n=(e+"").split("").reverse();for(s=0,o=n.length;s<o;s++){t=n[s];t=parseInt(t,10);if(r=!r)t*=2;t>9&&(t-=9);i+=t}return i%10===0};c=function(e){var t;return e.prop("selectionStart")!=null&&e.prop("selectionStart")!==e.prop("selectionEnd")?!0:(typeof document!="undefined"&&document!==null?(t=document.selection)!=null?typeof t.createRange=="function"?t.createRange().text:void 0:void 0:void 0)?!0:!1};p=function(t){var n=this;return setTimeout(function(){var n,r;n=e(t.currentTarget);r=n.val();r=e.payment.formatCardNumber(r);return n.val(r)})};u=function(n){var r,i,s,o,u,a,f;s=String.fromCharCode(n.which);if(!/^\d+$/.test(s))return;r=e(n.currentTarget);f=r.val();i=t(f+s);o=(f.replace(/\D/g,"")+s).length;a=16;i&&(a=i.length[i.length.length-1]);if(o>=a)return;if(r.prop("selectionStart")!=null&&r.prop("selectionStart")!==f.length)return;i&&i.type==="amex"?u=/^(\d{4}|\d{4}\s\d{6})$/:u=/(?:^|\s)(\d{4})$/;if(u.test(f)){n.preventDefault();return r.val(f+" "+s)}if(u.test(f+s)){n.preventDefault();return r.val(f+s+" ")}};s=function(t){var n,r;n=e(t.currentTarget);r=n.val();if(t.meta)return;if(t.which!==8)return;if(n.prop("selectionStart")!=null&&n.prop("selectionStart")!==r.length)return;if(/\d\s$/.test(r)){t.preventDefault();return n.val(r.replace(/\d\s$/,""))}if(/\s\d?$/.test(r)){t.preventDefault();return n.val(r.replace(/\s\d?$/,""))}};a=function(t){var n,r,i;r=String.fromCharCode(t.which);if(!/^\d+$/.test(r))return;n=e(t.currentTarget);i=n.val()+r;if(/^\d$/.test(i)&&i!=="0"&&i!=="1"){t.preventDefault();return n.val("0"+i+" / ")}if(/^\d\d$/.test(i)){t.preventDefault();return n.val(""+i+" / ")}};f=function(t){var n,r,i;r=String.fromCharCode(t.which);if(!/^\d+$/.test(r))return;n=e(t.currentTarget);i=n.val();if(/^\d\d$/.test(i))return n.val(""+i+" / ")};l=function(t){var n,r,i;r=String.fromCharCode(t.which);if(r!=="/")return;n=e(t.currentTarget);i=n.val();if(/^\d$/.test(i)&&i!=="0")return n.val("0"+i+" / ")};o=function(t){var n,r;if(t.meta)return;n=e(t.currentTarget);r=n.val();if(t.which!==8)return;if(n.prop("selectionStart")!=null&&n.prop("selectionStart")!==r.length)return;if(/\d(\s|\/)+$/.test(r)){t.preventDefault();return n.val(r.replace(/\d(\s|\/)*$/,""))}if(/\s\/\s?\d?$/.test(r)){t.preventDefault();return n.val(r.replace(/\s\/\s?\d?$/,""))}};g=function(e){var t;if(e.metaKey||e.ctrlKey)return!0;if(e.which===32)return!1;if(e.which===0)return!0;if(e.which<33)return!0;t=String.fromCharCode(e.which);return!!/[\d\s]/.test(t)};v=function(n){var r,i,s,o;r=e(n.currentTarget);s=String.fromCharCode(n.which);if(!/^\d+$/.test(s))return;if(c(r))return;o=(r.val()+s).replace(/\D/g,"");i=t(o);return i?o.length<=i.length[i.length.length-1]:o.le
|