jenkins-bot has submitted this change and it was merged.

Change subject: js updates for mustache
......................................................................


js updates for mustache

Change-Id: I227687c96fc197f296be9495fe7c5ebb12c732dc
---
M adyen_gateway/forms/js/adyen.js
1 file changed, 31 insertions(+), 91 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/adyen_gateway/forms/js/adyen.js b/adyen_gateway/forms/js/adyen.js
index 28ea832..81613fd 100644
--- a/adyen_gateway/forms/js/adyen.js
+++ b/adyen_gateway/forms/js/adyen.js
@@ -2,8 +2,10 @@
        $( '#overlay' ).show();
        $( '#paymentContinueBtn' ).removeClass( 'enabled' );
 
-       var currencyField, currency_code, stateField, state, countryField, 
country, sendData,
-               $payment, $pForm,
+       var sendData,
+               $payment,
+               $pForm,
+               currency_code = 'USD',
                language = 'en', // default value is English
                matches = document.location.href.match(/uselang=(\w+)/i); // 
fine the real language
 
@@ -11,58 +13,31 @@
                language = matches[1];
        }
 
-       currencyField = document.getElementById( 'input_currency_code' );
-       currency_code = '';
-       if ( currencyField && currencyField.type === 'select-one' ) { // 
currency is a dropdown select
-               currency_code = $( 'select#input_currency_code option:selected' 
).val();
-       } else {
-               currency_code = $( 'input[name="currency_code"]' ).val();
-       }
-
-       stateField = document.getElementById( 'state' );
-       state = '';
-       if ( stateField && stateField.type === 'select-one' ) { // state is a 
dropdown select
-               state = $( 'select#state option:selected' ).val();
-       } else {
-               state = $( 'input[name="state"]' ).val();
-       }
-
-       countryField = document.getElementById( 'country' );
-       country = '';
-       if ( countryField && countryField.type === 'select-one' ) { // country 
is a dropdown select
-               country = $( 'select#country option:selected' ).val();
-       } else {
-               country = $( 'input[name="country"]' ).val();
-       }
-
        sendData = {
                action: 'donate',
                gateway: 'adyen',
                currency_code: currency_code,
-               amount: $( 'input[name="amount"]' ).val(),
-               fname: $( 'input[name="fname"]' ).val(),
-               lname: $( 'input[name="lname"]' ).val(),
-               street: $( 'input[name="street"]' ).val(),
-               city: $( 'input[name="city"]' ).val(),
-               state: state,
-               zip: $( 'input[name="zip"]' ).val(),
-               emailAdd: $( 'input[name="emailAdd"]' ).val(),
-               country: country,
+               amount: $( '#amount' ).val(),
+               fname: $( '#fname' ).val(),
+               lname: $( '#lname' ).val(),
+               street: $( '#street' ).val(),
+               city: $( '#city' ).val(),
+               state: $( '#state' ).val(),
+               zip: $( '#zip' ).val(),
+               email: $( '#email' ).val(),
+               country: $( '#country' ).val(),
                payment_method: 'cc',
                language: language,
-               contribution_tracking_id: $( 
'input[name="contribution_tracking_id"]' ).val(),
-               utm_source: $( 'input[name="utm_source"]' ).val(),
-               utm_campaign: $( 'input[name="utm_campaign"]' ).val(),
-               utm_medium: $( 'input[name="utm_medium"]' ).val(),
-               referrer: $( 'input[name="referrer"]' ).val(),
-               recurring: $( 'input[name="recurring"]' ).val(),
+               payment_submethod: $( 'input[name="payment_submethod"]:checked' 
).val().toLowerCase(),
+               contribution_tracking_id: $( '#contribution_tracking_id' 
).val(),
+               utm_source: $( '#utm_source' ).val(),
+               utm_campaign: $( '#utm_campaign' ).val(),
+               utm_medium: $( '#utm_medium' ).val(),
+               referrer: $( '#referrer' ).val(),
+               recurring: $( '#recurring' ).val(),
+               token: $( '#token' ).val(),
                format: 'json'
        };
-
-       // If the field, street_supplemental, exists add it to sendData
-       if ( $('input[name="street_supplemental"]').length ) {
-               sendData.street_supplemental = $( 
'input[name="street_supplemental"]' ).val();
-       }
 
        $.ajax( {
                url: mw.util.wikiScript( 'api' ),
@@ -117,52 +92,18 @@
        } );
 };
 
-/*
- * The following variable are declared inline in webitects_2_3step.html:
- *   amountErrors, billingErrors, paymentErrors, scriptPath, actionURL
- */
 $( document ).ready( function () {
+       if ( $( 'input[name="payment_submethod"]:checked' ).length > 0 ) {
+               $( '#paymentContinue' ).show();
+       }
 
-// TODO: mustache errors
-//     // check for RapidHtml errors and display, if any
-//     var temp, e, f, g,
-//             amountErrorString = '',
-//             billingErrorString = '',
-//             paymentErrorString = '';
-//
-//     // generate formatted errors to display
-//     temp = [];
-//     for ( e in amountErrors ) {
-//             if ( amountErrors[e] !== '' ) {
-//                     temp[temp.length] = amountErrors[e];
-//             }
-//     }
-//     amountErrorString = temp.join( '<br />' );
-//
-//     temp = [];
-//     for ( f in billingErrors ) {
-//             if ( billingErrors[f] !== '' ) {
-//                     temp[temp.length] = billingErrors[f];
-//             }
-//     }
-//     billingErrorString = temp.join( '<br />' );
-//
-//     temp = [];
-//     for ( g in paymentErrors ) {
-//             if ( paymentErrors[g] !== '' ) {
-//                     temp[temp.length] = paymentErrors[g];
-//             }
-//     }
-//     paymentErrorString = temp.join( '<br />' );
-//
-//     // show the errors
-//     if ( amountErrorString !== '' ) {
-//             $( '#topError' ).html( amountErrorString );
-//     } else if ( billingErrorString !== '' ) {
-//             $( '#topError' ).html( billingErrorString );
-//     } else if ( paymentErrorString !== '' ) {
-//             $( '#topError' ).html( paymentErrorString );
-//     }
+       $( 'input[name="payment_submethod"]' ).on( 'change', function () {
+               if ( window.validate_form( document.payment ) ) {
+                       window.displayCreditCardForm();
+               } else {
+                       $( '#paymentContinue' ).show();
+               }
+       } );
 
        $( '#paymentContinueBtn' ).on( 'click', function () {
                if ( window.validate_form( document.payment ) ) {
@@ -173,5 +114,4 @@
                }
        } );
 
-       $( '#paymentContinue' ).show(); // Show continue button in 2nd section
 } );

-- 
To view, visit https://gerrit.wikimedia.org/r/253485
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I227687c96fc197f296be9495fe7c5ebb12c732dc
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Cdentinger <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to