From adcb796975c81fcfd9c19f968edbd79e1f0e4827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 2 Oct 2023 15:02:29 +0200 Subject: [PATCH 1/3] Fixes for copying vendor file --- vite.config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 66e3f520b4..a03c2f8036 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -25,7 +25,6 @@ export default defineConfig({ 'resources/js/clients/quotes/approve.js', 'resources/js/clients/payments/stripe-credit-card.js', 'resources/js/setup/setup.js', - 'node_modules/card-js/card-js.min.js', 'resources/js/clients/shared/pdf.js', 'resources/js/clients/shared/multiple-downloads.js', 'resources/js/clients/linkify-urls.js', @@ -54,6 +53,10 @@ export default defineConfig({ ]), viteStaticCopy({ targets: [ + { + src: 'node_modules/card-js/card-js.min.js', + dest: 'public/js/card-js.min.js', + }, { src: 'node_modules/card-js/card-js.min.css', dest: 'public/css/card-js.min.css', From 7a3e21689c5a4932527d7d194c0b4e0075df7ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 2 Oct 2023 15:02:39 +0200 Subject: [PATCH 2/3] Update usage of card-js --- .../gateways/authorize/credit_card/authorize.blade.php | 4 ++-- .../ninja2020/gateways/authorize/credit_card/pay.blade.php | 4 ++-- .../ninja2020/gateways/mollie/credit_card/pay.blade.php | 4 ++-- .../ninja2020/gateways/wepay/authorize/authorize.blade.php | 4 ++-- .../portal/ninja2020/gateways/wepay/credit_card/pay.blade.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/authorize/credit_card/authorize.blade.php b/resources/views/portal/ninja2020/gateways/authorize/credit_card/authorize.blade.php index 3f97396177..9cae6921c5 100644 --- a/resources/views/portal/ninja2020/gateways/authorize/credit_card/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/authorize/credit_card/authorize.blade.php @@ -9,9 +9,9 @@ - @vite('node_modules/card-js/card-js.min.js') - + + @endsection @section('gateway_content') diff --git a/resources/views/portal/ninja2020/gateways/authorize/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/authorize/credit_card/pay.blade.php index b37989f894..cf5b098168 100644 --- a/resources/views/portal/ninja2020/gateways/authorize/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/authorize/credit_card/pay.blade.php @@ -5,10 +5,10 @@ - @vite('node_modules/card-js/card-js.min.js') - + + @endsection @section('gateway_content') diff --git a/resources/views/portal/ninja2020/gateways/mollie/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/mollie/credit_card/pay.blade.php index 7a470d7b96..8939c3b2cd 100644 --- a/resources/views/portal/ninja2020/gateways/mollie/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/mollie/credit_card/pay.blade.php @@ -6,9 +6,9 @@ ctrans('texts.credit_card')]) - @vite('node_modules/card-js/card-js.min.js') - + + @endsection @section('gateway_content') diff --git a/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php b/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php index 6da24e6c65..e76d6d64c4 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php @@ -10,9 +10,9 @@ - @vite('node_modules/card-js/card-js.min.js') - + + @endsection diff --git a/resources/views/portal/ninja2020/gateways/wepay/credit_card/pay.blade.php b/resources/views/portal/ninja2020/gateways/wepay/credit_card/pay.blade.php index 39b0897441..5ae37085ed 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/credit_card/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/credit_card/pay.blade.php @@ -9,9 +9,9 @@ - @vite('node_modules/card-js/card-js.min.js') - + + @endsection From ea264ef3f7019d3a3c4cc628324f4e4bd5fae541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 2 Oct 2023 15:02:52 +0200 Subject: [PATCH 3/3] Assets production build --- public/build/assets/card-js.min-7d4742dc.js | 1 - public/build/manifest.json | 5 ----- public/build/public/js/card-js.min.js/card-js.min.js | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 public/build/assets/card-js.min-7d4742dc.js create mode 100644 public/build/public/js/card-js.min.js/card-js.min.js diff --git a/public/build/assets/card-js.min-7d4742dc.js b/public/build/assets/card-js.min-7d4742dc.js deleted file mode 100644 index 526d22ec3e..0000000000 --- a/public/build/assets/card-js.min-7d4742dc.js +++ /dev/null @@ -1 +0,0 @@ -function t(e){this.elem=jQuery(e),this.captureName=this.elem.data("capture-name")?this.elem.data("capture-name"):!1,this.iconColour=this.elem.data("icon-colour")?this.elem.data("icon-colour"):!1,this.stripe=this.elem.data("stripe")?this.elem.data("stripe"):!1,this.stripe&&(this.captureName=!1),this.initCardNumberInput(),this.initNameInput(),this.initExpiryMonthInput(),this.initExpiryYearInput(),this.initCvcInput(),this.elem.empty(),this.setupCardNumberInput(),this.setupNameInput(),this.setupExpiryInput(),this.setupCvcInput(),this.iconColour&&this.setIconColour(this.iconColour),this.refreshCreditCardTypeIcon()}(function(e){var r={init:function(){return this.data("cardjs",new t(this)),this},cardNumber:function(){return this.data("cardjs").getCardNumber()},cardType:function(){return this.data("cardjs").getCardType()},name:function(){return this.data("cardjs").getName()},expiryMonth:function(){return this.data("cardjs").getExpiryMonth()},expiryYear:function(){return this.data("cardjs").getExpiryYear()},cvc:function(){return this.data("cardjs").getCvc()}};e.fn.CardJs=function(n){return r[n]?r[n].apply(this,Array.prototype.slice.call(arguments,1)):typeof n!="object"&&n?void e.error("Method "+n+" does not exist on jQuery.CardJs"):r.init.apply(this,arguments)}})(jQuery),$(function(){$(".card-js").each(function(e,r){$(r).CardJs()})}),t.prototype.constructor=t,t.KEYS={0:48,9:57,NUMPAD_0:96,NUMPAD_9:105,DELETE:46,BACKSPACE:8,ARROW_LEFT:37,ARROW_RIGHT:39,ARROW_UP:38,ARROW_DOWN:40,HOME:36,END:35,TAB:9,A:65,X:88,C:67,V:86},t.CREDIT_CARD_NUMBER_DEFAULT_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_VISA_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_MASTERCARD_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_DISCOVER_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_JCB_MASK="XXXX XXXX XXXX XXXX",t.CREDIT_CARD_NUMBER_AMEX_MASK="XXXX XXXXXX XXXXX",t.CREDIT_CARD_NUMBER_DINERS_MASK="XXXX XXXX XXXX XX",t.prototype.creditCardNumberMask=t.CREDIT_CARD_NUMBER_DEFAULT_MASK,t.CREDIT_CARD_NUMBER_PLACEHOLDER="Card number",t.NAME_PLACEHOLDER="Name on card",t.EXPIRY_MASK="XX / XX",t.EXPIRY_PLACEHOLDER="MM / YY",t.EXPIRY_USE_DROPDOWNS=!1,t.EXPIRY_NUMBER_OF_YEARS=10,t.CVC_MASK_3="XXX",t.CVC_MASK_4="XXXX",t.CVC_PLACEHOLDER="CVC",t.CREDIT_CARD_SVG='',t.LOCK_SVG='',t.CALENDAR_SVG='',t.USER_SVG='',t.MAIL_SVG='',t.INFORMATION_SVG='',t.keyCodeFromEvent=function(e){return e.which||e.keyCode},t.keyIsCommandFromEvent=function(e){return e.ctrlKey||e.metaKey},t.keyIsNumber=function(e){return t.keyIsTopNumber(e)||t.keyIsKeypadNumber(e)},t.keyIsTopNumber=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS[0]&&r<=t.KEYS[9]},t.keyIsKeypadNumber=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS.NUMPAD_0&&r<=t.KEYS.NUMPAD_9},t.keyIsDelete=function(e){return t.keyCodeFromEvent(e)==t.KEYS.DELETE},t.keyIsBackspace=function(e){return t.keyCodeFromEvent(e)==t.KEYS.BACKSPACE},t.keyIsDeletion=function(e){return t.keyIsDelete(e)||t.keyIsBackspace(e)},t.keyIsArrow=function(e){var r=t.keyCodeFromEvent(e);return r>=t.KEYS.ARROW_LEFT&&r<=t.KEYS.ARROW_DOWN},t.keyIsNavigation=function(e){var r=t.keyCodeFromEvent(e);return r==t.KEYS.HOME||r==t.KEYS.END},t.keyIsKeyboardCommand=function(e){var r=t.keyCodeFromEvent(e);return t.keyIsCommandFromEvent(e)&&(r==t.KEYS.A||r==t.KEYS.X||r==t.KEYS.C||r==t.KEYS.V)},t.keyIsTab=function(e){return t.keyCodeFromEvent(e)==t.KEYS.TAB},t.copyAllElementAttributes=function(e,r){$.each(e[0].attributes,function(n,i){r.attr(i.nodeName,i.nodeValue)})},t.numbersOnlyString=function(e){for(var r="",n=0;nr||r>e.length)return 0;for(var i=0;ir||r>e.length)return 0;for(var i=0;i=t.KEYS[0]&&e<=t.KEYS[9]?e-t.KEYS[0]:e>=t.KEYS.NUMPAD_0&&e<=t.KEYS.NUMPAD_9?e-t.KEYS.NUMPAD_0:null},t.handleMaskedNumberInputKey=function(e,r){t.filterNumberOnlyKey(e);var n=e.which||e.keyCode,i=e.target,a=t.caretStartPosition(i),o=t.caretEndPosition(i),s=t.normaliseCaretPosition(r,a),d=t.normaliseCaretPosition(r,o),c=a,h=t.keyIsNumber(e),u=t.keyIsDelete(e),l=t.keyIsBackspace(e);if(h||u||l){e.preventDefault();var y=$(i).val(),p=t.numbersOnlyString(y),v=t.digitFromKeyCode(n),C=d>s;C&&(p=p.slice(0,s)+p.slice(d)),a!=r.length&&(h&&y.length<=r.length&&(p=p.slice(0,s)+v+p.slice(s),c=Math.max(t.denormaliseCaretPosition(r,s+1),t.denormaliseCaretPosition(r,s+2)-1)),u&&(p=p.slice(0,s)+p.slice(s+1))),a!=0&&l&&!C&&(p=p.slice(0,s-1)+p.slice(s),c=t.denormaliseCaretPosition(r,s-1)),$(i).val(t.applyFormatMask(p,r)),t.setCaretPosition(i,c)}},t.handleCreditCardNumberKey=function(e,r){t.handleMaskedNumberInputKey(e,r)},t.handleCreditCardNumberChange=function(e){},t.handleExpiryKey=function(e){t.handleMaskedNumberInputKey(e,t.EXPIRY_MASK)},t.prototype.getCardNumber=function(){return this.cardNumberInput.val()},t.prototype.getCardType=function(){return t.cardTypeFromNumber(this.getCardNumber())},t.prototype.getName=function(){return this.nameInput.val()},t.prototype.getExpiryMonth=function(){return this.expiryMonthInput.val()},t.prototype.getExpiryYear=function(){return this.expiryYearInput.val()},t.prototype.getCvc=function(){return this.cvcInput.val()},t.prototype.setIconColour=function(e){this.elem.find(".icon .svg").css({fill:e})},t.prototype.setIconColour=function(e){this.elem.find(".icon .svg").css({fill:e})},t.prototype.refreshCreditCardTypeIcon=function(){this.setCardTypeIconFromNumber(t.numbersOnlyString(this.cardNumberInput.val()))},t.prototype.clearCardTypeIcon=function(){this.elem.find(".card-number-wrapper .card-type-icon").removeClass("show")},t.prototype.setCardTypeIconAsVisa=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show visa")},t.prototype.setCardTypeIconAsMasterCard=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show master-card")},t.prototype.setCardTypeIconAsAmericanExpress=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show american-express")},t.prototype.setCardTypeIconAsDiscover=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show discover")},t.prototype.setCardTypeIconAsDiners=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show diners")},t.prototype.setCardTypeIconAsJcb=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show jcb")},t.prototype.setCardTypeIconFromNumber=function(e){switch(t.cardTypeFromNumber(e)){case"Visa Electron":case"Visa":this.setCardTypeAsVisa();break;case"Mastercard":this.setCardTypeAsMasterCard();break;case"AMEX":this.setCardTypeAsAmericanExpress();break;case"Discover":this.setCardTypeAsDiscover();break;case"Diners - Carte Blanche":case"Diners":this.setCardTypeAsDiners();break;case"JCB":this.setCardTypeAsJcb();break;default:this.clearCardType()}},t.prototype.setCardMask=function(e){this.creditCardNumberMask=e,this.cardNumberInput.attr("maxlength",e.length)},t.prototype.setCvc3=function(){this.cvcInput.attr("maxlength",t.CVC_MASK_3.length)},t.prototype.setCvc4=function(){this.cvcInput.attr("maxlength",t.CVC_MASK_4.length)},t.prototype.clearCardType=function(){this.clearCardTypeIcon(),this.setCardMask(t.CREDIT_CARD_NUMBER_DEFAULT_MASK),this.setCvc3()},t.prototype.setCardTypeAsVisa=function(){this.setCardTypeIconAsVisa(),this.setCardMask(t.CREDIT_CARD_NUMBER_VISA_MASK),this.setCvc3()},t.prototype.setCardTypeAsMasterCard=function(){this.setCardTypeIconAsMasterCard(),this.setCardMask(t.CREDIT_CARD_NUMBER_MASTERCARD_MASK),this.setCvc3()},t.prototype.setCardTypeAsAmericanExpress=function(){this.setCardTypeIconAsAmericanExpress(),this.setCardMask(t.CREDIT_CARD_NUMBER_AMEX_MASK),this.setCvc4()},t.prototype.setCardTypeAsDiscover=function(){this.setCardTypeIconAsDiscover(),this.setCardMask(t.CREDIT_CARD_NUMBER_DISCOVER_MASK),this.setCvc3()},t.prototype.setCardTypeAsDiners=function(){this.setCardTypeIconAsDiners(),this.setCardMask(t.CREDIT_CARD_NUMBER_DINERS_MASK),this.setCvc3()},t.prototype.setCardTypeAsJcb=function(){this.setCardTypeIconAsJcb(),this.setCardMask(t.CREDIT_CARD_NUMBER_JCB_MASK),this.setCvc3()},t.prototype.initCardNumberInput=function(){var e=this;this.cardNumberInput=this.elem.find(".card-number"),this.cardNumberInput[0]?this.cardNumberInput.detach():this.cardNumberInput=$(""),this.cardNumberInput.attr("type","tel"),this.cardNumberInput.attr("placeholder")||this.cardNumberInput.attr("placeholder",t.CREDIT_CARD_NUMBER_PLACEHOLDER),this.cardNumberInput.attr("maxlength",this.creditCardNumberMask.length),this.cardNumberInput.attr("x-autocompletetype","cc-number"),this.cardNumberInput.attr("autocompletetype","cc-number"),this.cardNumberInput.attr("autocorrect","off"),this.cardNumberInput.attr("spellcheck","off"),this.cardNumberInput.attr("autocapitalize","off"),this.cardNumberInput.keydown(function(r){t.handleCreditCardNumberKey(r,e.creditCardNumberMask)}),this.cardNumberInput.keyup(function(r){e.refreshCreditCardTypeIcon()}),this.cardNumberInput.change(t.handleCreditCardNumberChange)},t.prototype.initNameInput=function(){this.nameInput=this.elem.find(".name"),this.nameInput[0]?(this.captureName=!0,this.nameInput.detach()):this.nameInput=$(""),this.nameInput.attr("placeholder")||this.nameInput.attr("placeholder",t.NAME_PLACEHOLDER)},t.prototype.initExpiryMonthInput=function(){this.expiryMonthInput=this.elem.find(".expiry-month"),this.expiryMonthInput[0]?this.expiryMonthInput.detach():this.expiryMonthInput=$("")},t.prototype.initExpiryYearInput=function(){this.expiryYearInput=this.elem.find(".expiry-year"),this.expiryYearInput[0]?this.expiryYearInput.detach():this.expiryYearInput=$("")},t.prototype.initCvcInput=function(){this.cvcInput=this.elem.find(".cvc"),this.cvcInput[0]?this.cvcInput.detach():this.cvcInput=$(""),this.cvcInput.attr("type","tel"),this.cvcInput.attr("placeholder")||this.cvcInput.attr("placeholder",t.CVC_PLACEHOLDER),this.cvcInput.attr("maxlength",t.CVC_MASK_3.length),this.cvcInput.attr("x-autocompletetype","cc-csc"),this.cvcInput.attr("autocompletetype","cc-csc"),this.cvcInput.attr("autocorrect","off"),this.cvcInput.attr("spellcheck","off"),this.cvcInput.attr("autocapitalize","off"),this.cvcInput.keydown(t.filterNumberOnlyKey)},t.prototype.setupCardNumberInput=function(){this.stripe&&this.cardNumberInput.attr("data-stripe","number"),this.elem.append("
");var e=this.elem.find(".card-number-wrapper");e.append(this.cardNumberInput),e.append("
"),e.append("
"),e.find(".icon").append(t.CREDIT_CARD_SVG)},t.prototype.setupNameInput=function(){if(this.captureName){this.elem.append("
");var e=this.elem.find(".name-wrapper");e.append(this.nameInput),e.append("
"),e.find(".icon").append(t.USER_SVG)}},t.prototype.setupExpiryInput=function(){this.elem.append("
");var e,r=this.elem.find(".expiry-wrapper");if(this.EXPIRY_USE_DROPDOWNS){e=$("
");var n=$(""),i=this.expiryMonthInput;t.copyAllElementAttributes(i,n),this.expiryMonthInput.remove(),this.expiryMonthInput=n;for(var a=$(""),o=parseInt(new Date().getFullYear().toString().substring(2,4)),s=0;s"+o+""),o=(o+1)%100;var d=this.expiryYearInput;t.copyAllElementAttributes(d,a),this.expiryYearInput.remove(),this.expiryYearInput=a,e.append(this.expiryMonthInput),e.append(this.expiryYearInput)}else{e=$("
"),this.expiryMonthInput=$(""),this.expiryYearInput=$(""),this.stripe&&(this.expiryMonthInput.attr("data-stripe","exp-month"),this.expiryYearInput.attr("data-stripe","exp-year")),this.expiryMonthYearInput=$(""),this.expiryMonthYearInput.attr("type","tel"),this.expiryMonthYearInput.attr("placeholder")||this.expiryMonthYearInput.attr("placeholder",t.EXPIRY_PLACEHOLDER),this.expiryMonthYearInput.attr("maxlength",t.EXPIRY_MASK.length),this.expiryMonthYearInput.attr("x-autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocorrect","off"),this.expiryMonthYearInput.attr("spellcheck","off"),this.expiryMonthYearInput.attr("autocapitalize","off");var c=this;this.expiryMonthYearInput.keydown(function(h){t.handleExpiryKey(h);var u=c.expiryMonthYearInput.val();u.length==1&&parseInt(u)>1&&t.keyIsNumber(h)&&c.expiryMonthYearInput.val(t.applyFormatMask("0"+u,t.EXPIRY_MASK)),c.EXPIRY_USE_DROPDOWNS||c.expiryMonthYearInput==null||(c.expiryMonthInput.val(c.expiryMonth()),c.expiryYearInput.val(u.length==7?u.substr(5,2):null))}),this.expiryMonthYearInput.blur(function(h){c.refreshExpiryMonthValidation()}),e.append(this.expiryMonthYearInput),e.append(this.expiryMonthInput),e.append(this.expiryYearInput)}r.append(e),r.append("
"),r.find(".icon").append(t.CALENDAR_SVG)},t.prototype.setupCvcInput=function(){this.stripe&&this.cvcInput.attr("data-stripe","cvc"),this.elem.append("
");var e=this.elem.find(".cvc-wrapper");e.append(this.cvcInput),e.append("
"),e.find(".icon").append(t.LOCK_SVG)},t.prototype.expiryMonth=function(){if(!this.EXPIRY_USE_DROPDOWNS&&this.expiryMonthYearInput!=null){var e=this.expiryMonthYearInput.val();return e.length>=2?parseInt(e.substr(0,2)):null}return null},t.isValidMonth=function(e){return e>=1&&12>=e},t.isExpiryValid=function(e,r){var n=new Date,i=n.getMonth()+1,a=""+n.getFullYear();return(""+r).length==2&&(r=a.substring(0,2)+""+r),i=parseInt(i),a=parseInt(a),e=parseInt(e),r=parseInt(r),t.isValidMonth(e)&&(r>a||r==a&&e>=i)},t.prototype.refreshExpiryMonthValidation=function(){t.isExpiryValid(this.getExpiryMonth(),this.getExpiryYear())?this.setExpiryMonthAsValid():this.setExpiryMonthAsInvalid()},t.prototype.setExpiryMonthAsValid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().removeClass("has-error")},t.prototype.setExpiryMonthAsInvalid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().addClass("has-error")}; diff --git a/public/build/manifest.json b/public/build/manifest.json index 03b624eee4..6db392895b 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -8,11 +8,6 @@ "__commonjsHelpers-725317a4.js" ] }, - "node_modules/card-js/card-js.min.js": { - "file": "assets/card-js.min-7d4742dc.js", - "isEntry": true, - "src": "node_modules/card-js/card-js.min.js" - }, "resources/js/app.js": { "file": "assets/app-253efa47.js", "imports": [ diff --git a/public/build/public/js/card-js.min.js/card-js.min.js b/public/build/public/js/card-js.min.js/card-js.min.js new file mode 100644 index 0000000000..0b469b41f3 --- /dev/null +++ b/public/build/public/js/card-js.min.js/card-js.min.js @@ -0,0 +1 @@ +function CardJs(elem){this.elem=jQuery(elem),this.captureName=this.elem.data("capture-name")?this.elem.data("capture-name"):!1,this.iconColour=this.elem.data("icon-colour")?this.elem.data("icon-colour"):!1,this.stripe=this.elem.data("stripe")?this.elem.data("stripe"):!1,this.stripe&&(this.captureName=!1),this.initCardNumberInput(),this.initNameInput(),this.initExpiryMonthInput(),this.initExpiryYearInput(),this.initCvcInput(),this.elem.empty(),this.setupCardNumberInput(),this.setupNameInput(),this.setupExpiryInput(),this.setupCvcInput(),this.iconColour&&this.setIconColour(this.iconColour),this.refreshCreditCardTypeIcon()}!function($){var methods={init:function(){return this.data("cardjs",new CardJs(this)),this},cardNumber:function(){return this.data("cardjs").getCardNumber()},cardType:function(){return this.data("cardjs").getCardType()},name:function(){return this.data("cardjs").getName()},expiryMonth:function(){return this.data("cardjs").getExpiryMonth()},expiryYear:function(){return this.data("cardjs").getExpiryYear()},cvc:function(){return this.data("cardjs").getCvc()}};$.fn.CardJs=function(methodOrOptions){return methods[methodOrOptions]?methods[methodOrOptions].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof methodOrOptions&&methodOrOptions?void $.error("Method "+methodOrOptions+" does not exist on jQuery.CardJs"):methods.init.apply(this,arguments)}}(jQuery),$(function(){$(".card-js").each(function(i,obj){$(obj).CardJs()})}),CardJs.prototype.constructor=CardJs,CardJs.KEYS={0:48,9:57,NUMPAD_0:96,NUMPAD_9:105,DELETE:46,BACKSPACE:8,ARROW_LEFT:37,ARROW_RIGHT:39,ARROW_UP:38,ARROW_DOWN:40,HOME:36,END:35,TAB:9,A:65,X:88,C:67,V:86},CardJs.CREDIT_CARD_NUMBER_DEFAULT_MASK="XXXX XXXX XXXX XXXX",CardJs.CREDIT_CARD_NUMBER_VISA_MASK="XXXX XXXX XXXX XXXX",CardJs.CREDIT_CARD_NUMBER_MASTERCARD_MASK="XXXX XXXX XXXX XXXX",CardJs.CREDIT_CARD_NUMBER_DISCOVER_MASK="XXXX XXXX XXXX XXXX",CardJs.CREDIT_CARD_NUMBER_JCB_MASK="XXXX XXXX XXXX XXXX",CardJs.CREDIT_CARD_NUMBER_AMEX_MASK="XXXX XXXXXX XXXXX",CardJs.CREDIT_CARD_NUMBER_DINERS_MASK="XXXX XXXX XXXX XX",CardJs.prototype.creditCardNumberMask=CardJs.CREDIT_CARD_NUMBER_DEFAULT_MASK,CardJs.CREDIT_CARD_NUMBER_PLACEHOLDER="Card number",CardJs.NAME_PLACEHOLDER="Name on card",CardJs.EXPIRY_MASK="XX / XX",CardJs.EXPIRY_PLACEHOLDER="MM / YY",CardJs.EXPIRY_USE_DROPDOWNS=!1,CardJs.EXPIRY_NUMBER_OF_YEARS=10,CardJs.CVC_MASK_3="XXX",CardJs.CVC_MASK_4="XXXX",CardJs.CVC_PLACEHOLDER="CVC",CardJs.CREDIT_CARD_SVG='',CardJs.LOCK_SVG='',CardJs.CALENDAR_SVG='',CardJs.USER_SVG='',CardJs.MAIL_SVG='',CardJs.INFORMATION_SVG='',CardJs.keyCodeFromEvent=function(e){return e.which||e.keyCode},CardJs.keyIsCommandFromEvent=function(e){return e.ctrlKey||e.metaKey},CardJs.keyIsNumber=function(e){return CardJs.keyIsTopNumber(e)||CardJs.keyIsKeypadNumber(e)},CardJs.keyIsTopNumber=function(e){var keyCode=CardJs.keyCodeFromEvent(e);return keyCode>=CardJs.KEYS[0]&&keyCode<=CardJs.KEYS[9]},CardJs.keyIsKeypadNumber=function(e){var keyCode=CardJs.keyCodeFromEvent(e);return keyCode>=CardJs.KEYS.NUMPAD_0&&keyCode<=CardJs.KEYS.NUMPAD_9},CardJs.keyIsDelete=function(e){return CardJs.keyCodeFromEvent(e)==CardJs.KEYS.DELETE},CardJs.keyIsBackspace=function(e){return CardJs.keyCodeFromEvent(e)==CardJs.KEYS.BACKSPACE},CardJs.keyIsDeletion=function(e){return CardJs.keyIsDelete(e)||CardJs.keyIsBackspace(e)},CardJs.keyIsArrow=function(e){var keyCode=CardJs.keyCodeFromEvent(e);return keyCode>=CardJs.KEYS.ARROW_LEFT&&keyCode<=CardJs.KEYS.ARROW_DOWN},CardJs.keyIsNavigation=function(e){var keyCode=CardJs.keyCodeFromEvent(e);return keyCode==CardJs.KEYS.HOME||keyCode==CardJs.KEYS.END},CardJs.keyIsKeyboardCommand=function(e){var keyCode=CardJs.keyCodeFromEvent(e);return CardJs.keyIsCommandFromEvent(e)&&(keyCode==CardJs.KEYS.A||keyCode==CardJs.KEYS.X||keyCode==CardJs.KEYS.C||keyCode==CardJs.KEYS.V)},CardJs.keyIsTab=function(e){return CardJs.keyCodeFromEvent(e)==CardJs.KEYS.TAB},CardJs.copyAllElementAttributes=function(source,destination){$.each(source[0].attributes,function(idx,attr){destination.attr(attr.nodeName,attr.nodeValue)})},CardJs.numbersOnlyString=function(string){for(var numbersOnlyString="",i=0;icaretPosition||caretPosition>mask.length)return 0;for(var i=0;icaretPosition||caretPosition>mask.length)return 0;for(var i=0;i=CardJs.KEYS[0]&&keyCode<=CardJs.KEYS[9]?keyCode-CardJs.KEYS[0]:keyCode>=CardJs.KEYS.NUMPAD_0&&keyCode<=CardJs.KEYS.NUMPAD_9?keyCode-CardJs.KEYS.NUMPAD_0:null},CardJs.handleMaskedNumberInputKey=function(e,mask){CardJs.filterNumberOnlyKey(e);var keyCode=e.which||e.keyCode,element=e.target,caretStart=CardJs.caretStartPosition(element),caretEnd=CardJs.caretEndPosition(element),normalisedStartCaretPosition=CardJs.normaliseCaretPosition(mask,caretStart),normalisedEndCaretPosition=CardJs.normaliseCaretPosition(mask,caretEnd),newCaretPosition=caretStart,isNumber=CardJs.keyIsNumber(e),isDelete=CardJs.keyIsDelete(e),isBackspace=CardJs.keyIsBackspace(e);if(isNumber||isDelete||isBackspace){e.preventDefault();var rawText=$(element).val(),numbersOnly=CardJs.numbersOnlyString(rawText),digit=CardJs.digitFromKeyCode(keyCode),rangeHighlighted=normalisedEndCaretPosition>normalisedStartCaretPosition;rangeHighlighted&&(numbersOnly=numbersOnly.slice(0,normalisedStartCaretPosition)+numbersOnly.slice(normalisedEndCaretPosition)),caretStart!=mask.length&&(isNumber&&rawText.length<=mask.length&&(numbersOnly=numbersOnly.slice(0,normalisedStartCaretPosition)+digit+numbersOnly.slice(normalisedStartCaretPosition),newCaretPosition=Math.max(CardJs.denormaliseCaretPosition(mask,normalisedStartCaretPosition+1),CardJs.denormaliseCaretPosition(mask,normalisedStartCaretPosition+2)-1)),isDelete&&(numbersOnly=numbersOnly.slice(0,normalisedStartCaretPosition)+numbersOnly.slice(normalisedStartCaretPosition+1))),0!=caretStart&&isBackspace&&!rangeHighlighted&&(numbersOnly=numbersOnly.slice(0,normalisedStartCaretPosition-1)+numbersOnly.slice(normalisedStartCaretPosition),newCaretPosition=CardJs.denormaliseCaretPosition(mask,normalisedStartCaretPosition-1)),$(element).val(CardJs.applyFormatMask(numbersOnly,mask)),CardJs.setCaretPosition(element,newCaretPosition)}},CardJs.handleCreditCardNumberKey=function(e,cardMask){CardJs.handleMaskedNumberInputKey(e,cardMask)},CardJs.handleCreditCardNumberChange=function(e){},CardJs.handleExpiryKey=function(e){CardJs.handleMaskedNumberInputKey(e,CardJs.EXPIRY_MASK)},CardJs.prototype.getCardNumber=function(){return this.cardNumberInput.val()},CardJs.prototype.getCardType=function(){return CardJs.cardTypeFromNumber(this.getCardNumber())},CardJs.prototype.getName=function(){return this.nameInput.val()},CardJs.prototype.getExpiryMonth=function(){return this.expiryMonthInput.val()},CardJs.prototype.getExpiryYear=function(){return this.expiryYearInput.val()},CardJs.prototype.getCvc=function(){return this.cvcInput.val()},CardJs.prototype.setIconColour=function(colour){this.elem.find(".icon .svg").css({fill:colour})},CardJs.prototype.setIconColour=function(colour){this.elem.find(".icon .svg").css({fill:colour})},CardJs.prototype.refreshCreditCardTypeIcon=function(){this.setCardTypeIconFromNumber(CardJs.numbersOnlyString(this.cardNumberInput.val()))},CardJs.prototype.clearCardTypeIcon=function(){this.elem.find(".card-number-wrapper .card-type-icon").removeClass("show")},CardJs.prototype.setCardTypeIconAsVisa=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show visa")},CardJs.prototype.setCardTypeIconAsMasterCard=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show master-card")},CardJs.prototype.setCardTypeIconAsAmericanExpress=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show american-express")},CardJs.prototype.setCardTypeIconAsDiscover=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show discover")},CardJs.prototype.setCardTypeIconAsDiners=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show diners")},CardJs.prototype.setCardTypeIconAsJcb=function(){this.elem.find(".card-number-wrapper .card-type-icon").attr("class","card-type-icon show jcb")},CardJs.prototype.setCardTypeIconFromNumber=function(number){switch(CardJs.cardTypeFromNumber(number)){case"Visa Electron":case"Visa":this.setCardTypeAsVisa();break;case"Mastercard":this.setCardTypeAsMasterCard();break;case"AMEX":this.setCardTypeAsAmericanExpress();break;case"Discover":this.setCardTypeAsDiscover();break;case"Diners - Carte Blanche":case"Diners":this.setCardTypeAsDiners();break;case"JCB":this.setCardTypeAsJcb();break;default:this.clearCardType()}},CardJs.prototype.setCardMask=function(cardMask){this.creditCardNumberMask=cardMask,this.cardNumberInput.attr("maxlength",cardMask.length)},CardJs.prototype.setCvc3=function(){this.cvcInput.attr("maxlength",CardJs.CVC_MASK_3.length)},CardJs.prototype.setCvc4=function(){this.cvcInput.attr("maxlength",CardJs.CVC_MASK_4.length)},CardJs.prototype.clearCardType=function(){this.clearCardTypeIcon(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_DEFAULT_MASK),this.setCvc3()},CardJs.prototype.setCardTypeAsVisa=function(){this.setCardTypeIconAsVisa(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_VISA_MASK),this.setCvc3()},CardJs.prototype.setCardTypeAsMasterCard=function(){this.setCardTypeIconAsMasterCard(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_MASTERCARD_MASK),this.setCvc3()},CardJs.prototype.setCardTypeAsAmericanExpress=function(){this.setCardTypeIconAsAmericanExpress(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_AMEX_MASK),this.setCvc4()},CardJs.prototype.setCardTypeAsDiscover=function(){this.setCardTypeIconAsDiscover(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_DISCOVER_MASK),this.setCvc3()},CardJs.prototype.setCardTypeAsDiners=function(){this.setCardTypeIconAsDiners(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_DINERS_MASK),this.setCvc3()},CardJs.prototype.setCardTypeAsJcb=function(){this.setCardTypeIconAsJcb(),this.setCardMask(CardJs.CREDIT_CARD_NUMBER_JCB_MASK),this.setCvc3()},CardJs.prototype.initCardNumberInput=function(){var $this=this;this.cardNumberInput=this.elem.find(".card-number"),this.cardNumberInput[0]?this.cardNumberInput.detach():this.cardNumberInput=$(""),this.cardNumberInput.attr("type","tel"),this.cardNumberInput.attr("placeholder")||this.cardNumberInput.attr("placeholder",CardJs.CREDIT_CARD_NUMBER_PLACEHOLDER),this.cardNumberInput.attr("maxlength",this.creditCardNumberMask.length),this.cardNumberInput.attr("x-autocompletetype","cc-number"),this.cardNumberInput.attr("autocompletetype","cc-number"),this.cardNumberInput.attr("autocorrect","off"),this.cardNumberInput.attr("spellcheck","off"),this.cardNumberInput.attr("autocapitalize","off"),this.cardNumberInput.keydown(function(e){CardJs.handleCreditCardNumberKey(e,$this.creditCardNumberMask)}),this.cardNumberInput.keyup(function(e){$this.refreshCreditCardTypeIcon()}),this.cardNumberInput.change(CardJs.handleCreditCardNumberChange)},CardJs.prototype.initNameInput=function(){this.nameInput=this.elem.find(".name"),this.nameInput[0]?(this.captureName=!0,this.nameInput.detach()):this.nameInput=$(""),this.nameInput.attr("placeholder")||this.nameInput.attr("placeholder",CardJs.NAME_PLACEHOLDER)},CardJs.prototype.initExpiryMonthInput=function(){this.expiryMonthInput=this.elem.find(".expiry-month"),this.expiryMonthInput[0]?this.expiryMonthInput.detach():this.expiryMonthInput=$("")},CardJs.prototype.initExpiryYearInput=function(){this.expiryYearInput=this.elem.find(".expiry-year"),this.expiryYearInput[0]?this.expiryYearInput.detach():this.expiryYearInput=$("")},CardJs.prototype.initCvcInput=function(){this.cvcInput=this.elem.find(".cvc"),this.cvcInput[0]?this.cvcInput.detach():this.cvcInput=$(""),this.cvcInput.attr("type","tel"),this.cvcInput.attr("placeholder")||this.cvcInput.attr("placeholder",CardJs.CVC_PLACEHOLDER),this.cvcInput.attr("maxlength",CardJs.CVC_MASK_3.length),this.cvcInput.attr("x-autocompletetype","cc-csc"),this.cvcInput.attr("autocompletetype","cc-csc"),this.cvcInput.attr("autocorrect","off"),this.cvcInput.attr("spellcheck","off"),this.cvcInput.attr("autocapitalize","off"),this.cvcInput.keydown(CardJs.filterNumberOnlyKey)},CardJs.prototype.setupCardNumberInput=function(){this.stripe&&this.cardNumberInput.attr("data-stripe","number"),this.elem.append("
");var wrapper=this.elem.find(".card-number-wrapper");wrapper.append(this.cardNumberInput),wrapper.append("
"),wrapper.append("
"),wrapper.find(".icon").append(CardJs.CREDIT_CARD_SVG)},CardJs.prototype.setupNameInput=function(){if(this.captureName){this.elem.append("
");var wrapper=this.elem.find(".name-wrapper");wrapper.append(this.nameInput),wrapper.append("
"),wrapper.find(".icon").append(CardJs.USER_SVG)}},CardJs.prototype.setupExpiryInput=function(){this.elem.append("
");var expiryInput,wrapper=this.elem.find(".expiry-wrapper");if(this.EXPIRY_USE_DROPDOWNS){expiryInput=$("
");var expiryMonthNew=$(""),expiryMonthOld=this.expiryMonthInput;CardJs.copyAllElementAttributes(expiryMonthOld,expiryMonthNew),this.expiryMonthInput.remove(),this.expiryMonthInput=expiryMonthNew;for(var expiryYearNew=$(""),currentYear=parseInt((new Date).getFullYear().toString().substring(2,4)),i=0;i"+currentYear+""),currentYear=(currentYear+1)%100;var expiryYearOld=this.expiryYearInput;CardJs.copyAllElementAttributes(expiryYearOld,expiryYearNew),this.expiryYearInput.remove(),this.expiryYearInput=expiryYearNew,expiryInput.append(this.expiryMonthInput),expiryInput.append(this.expiryYearInput)}else{expiryInput=$("
"),this.expiryMonthInput=$(""),this.expiryYearInput=$(""),this.stripe&&(this.expiryMonthInput.attr("data-stripe","exp-month"),this.expiryYearInput.attr("data-stripe","exp-year")),this.expiryMonthYearInput=$(""),this.expiryMonthYearInput.attr("type","tel"),this.expiryMonthYearInput.attr("placeholder")||this.expiryMonthYearInput.attr("placeholder",CardJs.EXPIRY_PLACEHOLDER),this.expiryMonthYearInput.attr("maxlength",CardJs.EXPIRY_MASK.length),this.expiryMonthYearInput.attr("x-autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocompletetype","cc-exp"),this.expiryMonthYearInput.attr("autocorrect","off"),this.expiryMonthYearInput.attr("spellcheck","off"),this.expiryMonthYearInput.attr("autocapitalize","off");var $this=this;this.expiryMonthYearInput.keydown(function(e){CardJs.handleExpiryKey(e);var val=$this.expiryMonthYearInput.val();1==val.length&&parseInt(val)>1&&CardJs.keyIsNumber(e)&&$this.expiryMonthYearInput.val(CardJs.applyFormatMask("0"+val,CardJs.EXPIRY_MASK)),$this.EXPIRY_USE_DROPDOWNS||null==$this.expiryMonthYearInput||($this.expiryMonthInput.val($this.expiryMonth()),$this.expiryYearInput.val(7==val.length?val.substr(5,2):null))}),this.expiryMonthYearInput.blur(function(e){$this.refreshExpiryMonthValidation()}),expiryInput.append(this.expiryMonthYearInput),expiryInput.append(this.expiryMonthInput),expiryInput.append(this.expiryYearInput)}wrapper.append(expiryInput),wrapper.append("
"),wrapper.find(".icon").append(CardJs.CALENDAR_SVG)},CardJs.prototype.setupCvcInput=function(){this.stripe&&this.cvcInput.attr("data-stripe","cvc"),this.elem.append("
");var wrapper=this.elem.find(".cvc-wrapper");wrapper.append(this.cvcInput),wrapper.append("
"),wrapper.find(".icon").append(CardJs.LOCK_SVG)},CardJs.prototype.expiryMonth=function(){if(!this.EXPIRY_USE_DROPDOWNS&&null!=this.expiryMonthYearInput){var val=this.expiryMonthYearInput.val();return val.length>=2?parseInt(val.substr(0,2)):null}return null},CardJs.isValidMonth=function(expiryMonth){return expiryMonth>=1&&12>=expiryMonth},CardJs.isExpiryValid=function(month,year){var today=new Date,currentMonth=today.getMonth()+1,currentYear=""+today.getFullYear();return 2==(""+year).length&&(year=currentYear.substring(0,2)+""+year),currentMonth=parseInt(currentMonth),currentYear=parseInt(currentYear),month=parseInt(month),year=parseInt(year),CardJs.isValidMonth(month)&&(year>currentYear||year==currentYear&&month>=currentMonth)},CardJs.prototype.refreshExpiryMonthValidation=function(){CardJs.isExpiryValid(this.getExpiryMonth(),this.getExpiryYear())?this.setExpiryMonthAsValid():this.setExpiryMonthAsInvalid()},CardJs.prototype.setExpiryMonthAsValid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().removeClass("has-error")},CardJs.prototype.setExpiryMonthAsInvalid=function(){this.EXPIRY_USE_DROPDOWNS||this.expiryMonthYearInput.parent().addClass("has-error")}; \ No newline at end of file