Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js |
— | — | @@ -104,28 +104,3 @@ |
105 | 105 | $( "#selected-amount" ).html( "$" + e.val() + "" ); |
106 | 106 | $( "#change-amount" ).show(); |
107 | 107 | } |
108 | | -window.validateAmount = function() { |
109 | | - var error = true; |
110 | | - var amount = $( 'input[name="amount"]' ).val(); // get the amount |
111 | | - // Normalize weird amount formats. |
112 | | - // Don't mess with these unless you know what you're doing. |
113 | | - amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
114 | | - amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' ); |
115 | | - amount = amount.replace( /[,.]/g, '' ); |
116 | | - amount = amount.replace( /:/, '.' ); |
117 | | - $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
118 | | - |
119 | | - // Check amount is a real number, sets error as true (good) if no issues |
120 | | - error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
121 | | - |
122 | | - // Check amount is at least the minimum |
123 | | - var currency_code = $( 'input[name="currency_code"]' ).val(); |
124 | | - if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
125 | | - wgCurrencyMinimums[currency_code] = 1; |
126 | | - } |
127 | | - if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
128 | | - alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
129 | | - error = true; |
130 | | - } |
131 | | - return !error; |
132 | | -} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.bt.js |
— | — | @@ -120,28 +120,3 @@ |
121 | 121 | $( "#selected-amount" ).html( + e.val() + " " + $( 'input[name="currency_code"]' ).val() ); |
122 | 122 | $( "#change-amount" ).show(); |
123 | 123 | } |
124 | | -function validateAmount() { |
125 | | - var error = true; |
126 | | - var amount = $( 'input[name="amount"]' ).val(); // get the amount |
127 | | - // Normalize weird amount formats. |
128 | | - // Don't mess with these unless you know what you're doing. |
129 | | - amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
130 | | - amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' ); |
131 | | - amount = amount.replace( /[,.]/g, '' ); |
132 | | - amount = amount.replace( /:/, '.' ); |
133 | | - $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
134 | | - |
135 | | - // Check amount is a real number, sets error as true (good) if no issues |
136 | | - error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
137 | | - |
138 | | - // Check amount is at least the minimum |
139 | | - var currency_code = $( 'input[name="currency_code"]' ).val(); |
140 | | - if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
141 | | - wgCurrencyMinimums[currency_code] = 1; |
142 | | - } |
143 | | - if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
144 | | - alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
145 | | - error = true; |
146 | | - } |
147 | | - return !error; |
148 | | -} |
\ No newline at end of file |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects2nd.js |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | } ); |
52 | 52 | |
53 | 53 | $( "#bt-continueBtn" ).live( "click", function() { |
54 | | - if ( validateAmount() && validate_personal( document.paypalcontribution ) ) { |
| 54 | + if ( validate_personal( document.paypalcontribution ) && validateAmount() ) { |
55 | 55 | document.paypalcontribution.action = actionURL; |
56 | 56 | document.paypalcontribution.submit(); |
57 | 57 | } |
— | — | @@ -154,31 +154,7 @@ |
155 | 155 | $( "#selected-amount" ).html( + e.val() + " " + $( 'input[name="currency_code"]' ).val() ); |
156 | 156 | $( "#change-amount" ).show(); |
157 | 157 | } |
158 | | -function validateAmount() { |
159 | | - var error = true; |
160 | | - var amount = $( 'input[name="amount"]' ).val(); // get the amount |
161 | | - // Normalize weird amount formats. |
162 | | - // Don't mess with these unless you know what you're doing. |
163 | | - amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
164 | | - amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' ); |
165 | | - amount = amount.replace( /[,.]/g, '' ); |
166 | | - amount = amount.replace( /:/, '.' ); |
167 | | - $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
168 | 158 | |
169 | | - // Check amount is a real number, sets error as true (good) if no issues |
170 | | - error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
171 | | - |
172 | | - // Check amount is at least the minimum |
173 | | - var currency_code = $( 'input[name="currency_code"]' ).val(); |
174 | | - if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
175 | | - wgCurrencyMinimums[currency_code] = 1; |
176 | | - } |
177 | | - if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
178 | | - alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
179 | | - error = true; |
180 | | - } |
181 | | - return !error; |
182 | | -} |
183 | 159 | window.showStep1 = function() { |
184 | 160 | // show the correct sections |
185 | 161 | $( "#step1wrapper" ).slideDown(); |
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects2nd-US.js |
— | — | @@ -112,11 +112,7 @@ |
113 | 113 | } ); |
114 | 114 | |
115 | 115 | $( "#step1header" ).click( function() { |
116 | | - // show the correct sections |
117 | | - $( "#step1wrapper" ).slideDown(); |
118 | | - $( "#step2wrapper" ).slideDown(); |
119 | | - $( "#step3wrapper" ).slideUp(); |
120 | | - $( "#change-amount" ).hide(); |
| 116 | + showStep1(); |
121 | 117 | } ); |
122 | 118 | |
123 | 119 | |
— | — | @@ -150,31 +146,7 @@ |
151 | 147 | $( "#selected-amount" ).html( "$" + e.val() ); |
152 | 148 | $( "#change-amount" ).show(); |
153 | 149 | } |
154 | | -function validateAmount() { |
155 | | - var error = true; |
156 | | - var amount = $( 'input[name="amount"]' ).val(); // get the amount |
157 | | - // Normalize weird amount formats. |
158 | | - // Don't mess with these unless you know what you're doing. |
159 | | - amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
160 | | - amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' ); |
161 | | - amount = amount.replace( /[,.]/g, '' ); |
162 | | - amount = amount.replace( /:/, '.' ); |
163 | | - $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
164 | 150 | |
165 | | - // Check amount is a real number, sets error as true (good) if no issues |
166 | | - error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
167 | | - |
168 | | - // Check amount is at least the minimum |
169 | | - var currency_code = $( 'input[name="currency_code"]' ).val(); |
170 | | - if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
171 | | - wgCurrencyMinimums[currency_code] = 1; |
172 | | - } |
173 | | - if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
174 | | - alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
175 | | - error = true; |
176 | | - } |
177 | | - return !error; |
178 | | -} |
179 | 151 | window.showStep1 = function() { |
180 | 152 | // show the correct sections |
181 | 153 | $( "#step1wrapper" ).slideDown(); |
Index: trunk/extensions/DonationInterface/modules/validate_input.js |
— | — | @@ -38,7 +38,48 @@ |
39 | 39 | document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none'; |
40 | 40 | }; |
41 | 41 | |
42 | | -/* |
| 42 | +/** |
| 43 | + * Validate the donation amount to make sure it is formatted correctly and at least a minimum amount. |
| 44 | + */ |
| 45 | +window.validateAmount = function() { |
| 46 | + var error = true; |
| 47 | + var amount = $( 'input[name="amount"]' ).val(); // get the amount |
| 48 | + // Normalize weird amount formats. |
| 49 | + // Don't mess with these unless you know what you're doing. |
| 50 | + amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
| 51 | + amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' ); |
| 52 | + amount = amount.replace( /[,.]/g, '' ); |
| 53 | + amount = amount.replace( /:/, '.' ); |
| 54 | + $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
| 55 | + |
| 56 | + // Check amount is a real number, sets error as true (good) if no issues |
| 57 | + error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
| 58 | + |
| 59 | + // Check amount is at least the minimum |
| 60 | + var currency_code = $( 'input[name="currency_code"]' ).val(); |
| 61 | + if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
| 62 | + wgCurrencyMinimums[currency_code] = 1; |
| 63 | + } |
| 64 | + if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
| 65 | + alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
| 66 | + error = true; |
| 67 | + // See if we're on a webitects accordian form |
| 68 | + if ( $( '#step1wrapper' ).length ) { |
| 69 | + $( "#step1wrapper" ).slideDown(); |
| 70 | + $( "#paymentContinue" ).show(); |
| 71 | + // If we're on a GlobalCollect iframe form, slide up the 3rd step to force the user to |
| 72 | + // generate a new iframe after they change the form. |
| 73 | + if ( $( '#payment iframe' ).length ) { |
| 74 | + $( "#step3wrapper" ).slideUp(); |
| 75 | + } |
| 76 | + } |
| 77 | + $( '#other-amount' ).val( '' ); |
| 78 | + $( '#other-amount' ).focus(); |
| 79 | + } |
| 80 | + return !error; |
| 81 | +} |
| 82 | + |
| 83 | +/** |
43 | 84 | * Validates the personal information fields |
44 | 85 | * |
45 | 86 | * @input form The form containing the inputs to be checked |
— | — | @@ -47,8 +88,6 @@ |
48 | 89 | */ |
49 | 90 | window.validate_personal = function( form ){ |
50 | 91 | |
51 | | - // TODO: this form should only report a single error for the email address? |
52 | | - |
53 | 92 | var output = ''; |
54 | 93 | var currField = ''; |
55 | 94 | var i = 0; |