From 38ea6ca5614f424fb1a6ac844b45c327f0c5611f Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 21 Oct 2013 09:23:48 +1100 Subject: [PATCH] Fixed jquery.payment formatting not applying to more than one set of gateway fields on the payments page Conflicts: frontend/app/assets/javascripts/store/checkout.js.coffee --- .../app/assets/javascripts/store/checkout.js.coffee | 2 +- .../javascripts/store/checkout/payment.js.coffee | 10 +++++----- .../app/views/spree/checkout/payment/_gateway.html.erb | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/app/assets/javascripts/store/checkout.js.coffee b/frontend/app/assets/javascripts/store/checkout.js.coffee index aafd51b2159..add80c78b5a 100644 --- a/frontend/app/assets/javascripts/store/checkout.js.coffee +++ b/frontend/app/assets/javascripts/store/checkout.js.coffee @@ -8,4 +8,4 @@ Spree.disableSaveOnClick = -> ($ this).find(':submit, :image').attr('disabled', true).removeClass('primary').addClass 'disabled' Spree.ready ($) -> - Spree.Checkout = {} + Spree.Checkout = {} \ No newline at end of file diff --git a/frontend/app/assets/javascripts/store/checkout/payment.js.coffee b/frontend/app/assets/javascripts/store/checkout/payment.js.coffee index 9785101fe8a..4322da2e6e7 100644 --- a/frontend/app/assets/javascripts/store/checkout/payment.js.coffee +++ b/frontend/app/assets/javascripts/store/checkout/payment.js.coffee @@ -1,12 +1,12 @@ Spree.ready ($) -> if ($ '#checkout_form_payment').is('*') - $("#card_number").payment('formatCardNumber') - $("#card_expiry").payment('formatCardExpiry') - $("#card_code").payment('formatCardCVC') + $(".cardNumber").payment('formatCardNumber') + $(".cardExpiry").payment('formatCardExpiry') + $(".cardCode").payment('formatCardCVC') - $("#card_number").change -> - $("#cc_type").val($.payment.cardType(@value)) + $(".cardNumber").change -> + $(this).parent().siblings(".ccType").val($.payment.cardType(@value)) ($ 'input[type="radio"][name="order[payments_attributes][][payment_method_id]"]').click(-> ($ '#payment-methods li').hide() diff --git a/frontend/app/views/spree/checkout/payment/_gateway.html.erb b/frontend/app/views/spree/checkout/payment/_gateway.html.erb index 5210b8d25bf..26a351ad36f 100644 --- a/frontend/app/views/spree/checkout/payment/_gateway.html.erb +++ b/frontend/app/views/spree/checkout/payment/_gateway.html.erb @@ -4,7 +4,7 @@

<%= label_tag "card_number", Spree.t(:card_number) %>*
<% options_hash = Rails.env.production? ? {:autocomplete => 'off'} : {} %> - <%= text_field_tag "#{param_prefix}[number]", '', options_hash.merge(:id => 'card_number', :class => 'required', :size => 19, :maxlength => 19, :autocomplete => "off") %> + <%= text_field_tag "#{param_prefix}[number]", '', options_hash.merge(:id => 'card_number', :class => 'required cardNumber', :size => 19, :maxlength => 19, :autocomplete => "off") %>  

- <%= label_tag "card_month", Spree.t(:expiration) %>*
- <%= text_field_tag "#{param_prefix}[expiry]", '', :id => 'card_expiry', :class => "required", :placeholder => "MM / YY" %> + <%= label_tag "card_expiry", Spree.t(:expiration) %>*
+ <%= text_field_tag "#{param_prefix}[expiry]", '', :id => 'card_expiry', :class => "required cardExpiry", :placeholder => "MM / YY" %>

<%= label_tag "card_code", Spree.t(:card_code) %>*
- <%= text_field_tag "#{param_prefix}[verification_value]", '', options_hash.merge(:id => 'card_code', :class => 'required', :size => 5) %> + <%= text_field_tag "#{param_prefix}[verification_value]", '', options_hash.merge(:id => 'card_code', :class => 'required cardCode', :size => 5) %> <%= link_to "(#{Spree.t(:what_is_this)})", spree.content_path('cvv'), :target => '_blank', "data-hook" => "cvv_link", :id => "cvv_link" %>

-<%= hidden_field_tag "#{param_prefix}[cc_type]", '', :id => "cc_type" %> +<%= hidden_field_tag "#{param_prefix}[cc_type]", '', :id => "cc_type", :class => 'ccType' %> <%= hidden_field param_prefix, 'first_name', :value => @order.billing_firstname %> <%= hidden_field param_prefix, 'last_name', :value => @order.billing_lastname %>