Index: trunk/extensions/DonationInterface/donationinterface.php |
— | — | @@ -585,8 +585,11 @@ |
586 | 586 | |
587 | 587 | $wgResourceModules[ 'ext.donationInterface.errorMessages' ] = array( |
588 | 588 | 'messages' => array( |
| 589 | + 'donate_interface-noscript-msg', |
| 590 | + 'donate_interface-noscript-redirect-msg', |
589 | 591 | 'donate_interface-error-msg-general', |
590 | 592 | 'donate_interface-error-msg-js', |
| 593 | + 'donate_interface-error-msg-validation', |
591 | 594 | 'donate_interface-error-msg-invalid-amount', |
592 | 595 | 'donate_interface-error-msg-email', |
593 | 596 | 'donate_interface-error-msg-card-num', |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | <div id="donate"> |
18 | 18 | <noscript> |
19 | 19 | <div id="noscript"> |
20 | | - <p id="noscript-msg">It appears that you do not have JavaScript enabled, or your browser does not support it. In order to provide a safe, secure and pleasant experience, our donation form requires JavaScript.</p><p id="noscript-redirect-msg">If you cannot or do not wish to enable JavaScript, you may still contribute by visiting:</p><p id="noscript-redirect-link"><a href="http://wikimediafoundation.org/wiki/DonateNonJS/en">http://wikimediafoundation.org/wiki/DonateNonJS/en</a></p> |
| 20 | + <p id="noscript-msg">%donate_interface-noscript-msg%</p> |
| 21 | + <p id="noscript-redirect-msg">%donate_interface-noscript-redirect-msg%</p> |
| 22 | + <p id="noscript-redirect-link"><a href="http://wikimediafoundation.org/wiki/DonateNonJS/en">http://wikimediafoundation.org/wiki/DonateNonJS/en</a></p> |
21 | 23 | </div> |
22 | 24 | </noscript> |
23 | | - |
| 25 | + <div id="topError" class="creditcard-error-msg"></div> |
24 | 26 | <h3 id="amount-heading">%donate_interface-amount-legend%</h3> |
25 | | - |
26 | | - <p id="topError" class="creditcard-error-msg"></p> |
27 | 27 | <form method="post" name="paypalcontribution"> |
28 | 28 | <div style="display: block;" id="amount-content"> |
29 | 29 | <div id="amtErrorMessages" class="small"></div> |
— | — | @@ -42,37 +42,37 @@ |
43 | 43 | </table> |
44 | 44 | |
45 | 45 | <p class="donate-options"> |
46 | | - <input class="btn" id="cc" value="%donate_interface-cc-button%" type="button"/> |
47 | | - <br><input class="btn" id="pp" value="%donate_interface-paypal-button%" type="button"><span id="loading"></span> |
| 46 | + <input class="btn" id="cc" value="%donate_interface-ccdc-button%" type="button"/><br/> |
| 47 | + <input class="btn" id="pp" value="%donate_interface-paypal-button%" type="button"/> |
48 | 48 | </p> |
49 | 49 | </div> |
50 | 50 | </form> |
51 | 51 | </div> |
52 | | - |
| 52 | + <hr/> |
53 | 53 | <div id="callout-content"> |
54 | | - <hr/> |
55 | 54 | <p id="informationsharing">%donate_interface-informationsharing|url%</p> |
| 55 | + <div id="secure-logo">@verisign_logo</div> |
| 56 | + <ul id="moreinfolinks"> |
| 57 | + <li><a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=Monthly_donations&language=@language&uselang=@language&country=@country">%donate_interface-monthly-donation%</a></li> |
| 58 | + <li><a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=Ways_to_Give&language=@language&uselang=@language&country=@country">%donate_interface-otherways-short%</a></li> |
| 59 | + <li><a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=FAQ&language=@language&uselang=@language&country=@country">%donate_interface-faqs%</a></li> |
| 60 | + <li><a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=Tax_Deductibility&language=@language&uselang=@language&country=@country">%donate_interface-tax-info%</a></li> |
| 61 | + </ul> |
56 | 62 | </div> |
57 | 63 | </div> |
58 | | - |
| 64 | + <!-- The appeal --> |
59 | 65 | <h2 id="appeal-head"><span class="mw-headline">{{LanguageSwitch|2011FR/@appeal-title|@language}}</span></h2> |
60 | 66 | <div id="appeal-body" class="plainlinks">{{LanguageSwitch|2011FR/@appeal|@language}}</div> |
61 | 67 | </div> |
62 | 68 | </div> |
63 | | - |
64 | | - <hr/> |
65 | | - |
66 | | - <p> |
67 | | - <a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=Ways_to_Give&language=@language&uselang=@language&country=@country">%donate_interface-otherways-short%</a><br/> |
68 | | - <a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=FAQ&language=@language&uselang=@language&country=@country">%donate_interface-faqs%</a> |
69 | | - </p> |
| 69 | + |
70 | 70 | </div> |
71 | 71 | |
72 | 72 | <div id="dialog"> |
73 | 73 | <div id="steps"> |
74 | 74 | <form id="donationForm" name="donationForm" action="" method="post"> |
75 | 75 | <fieldset class="step"> |
76 | | - <legend>%donate_interface-billing-address%</legend> |
| 76 | + <legend>%donate_interface-cc-form-header-personal%</legend> |
77 | 77 | <input type="hidden" name="gateway" value="payflowpro" id="gateway" /> |
78 | 78 | <input type="hidden" name="returnto" value="Thank_You/en" /> |
79 | 79 | <input type="hidden" value="@action" name="action" /> |
— | — | @@ -141,11 +141,11 @@ |
142 | 142 | </tr> |
143 | 143 | </table> |
144 | 144 | </div> |
145 | | - <a href="#" class="continue-button">Continue</a> |
| 145 | + <a href="#" id="personal-continue" class="continue-button">Continue</a> |
146 | 146 | </div> |
147 | 147 | </fieldset> |
148 | 148 | <fieldset class="step"> |
149 | | - <legend>Payment</legend> |
| 149 | + <legend>%donate_interface-cc-form-header-payment%</legend> |
150 | 150 | <div class="step-content"> |
151 | 151 | <div class="stuff"> |
152 | 152 | <div id="card-errors"></div> |
— | — | @@ -206,13 +206,15 @@ |
207 | 207 | <label for="email">Security Code</label> |
208 | 208 | </td> |
209 | 209 | <td> |
210 | | - <input name="cvv" size="30" value="@cvv" type="text" maxlength="100" class="required" id="cvv" style="width: 50px;" /> |
| 210 | + <input name="cvv" size="30" value="@cvv" type="text" maxlength="100" class="required" id="cvv" style="width: 50px;" />  |
| 211 | + <a href="#" onclick="PopupCVV(); return false;" id="cvv-link">What is this?</a> |
211 | 212 | </td> |
212 | 213 | </tr> |
213 | 214 | </table> |
214 | 215 | </div> |
215 | 216 | <a href="#" class="back-button" id="goback">Back</a> |
216 | | - <a href="#" class="continue-button" id="submitcreditcard">Continue</a> |
| 217 | + <a href="#" id="cc-continue" class="continue-button">Continue</a> |
| 218 | + <div id="spinner"><img src="@script_path/extensions/DonationInterface/gateway_forms/includes/loading-white.gif"/></div> |
217 | 219 | </div> |
218 | 220 | </fieldset> |
219 | 221 | </form> |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/lightbox1.css |
— | — | @@ -135,6 +135,8 @@ |
136 | 136 | .call-r { |
137 | 137 | float: right; |
138 | 138 | margin: 0.2em 0 1em 1em; |
| 139 | + background-color: #CCE7CD; |
| 140 | + border: 1px solid #5EAC58; |
139 | 141 | } |
140 | 142 | #loading { |
141 | 143 | font-size: 12px; |
— | — | @@ -171,8 +173,9 @@ |
172 | 174 | font-size: 0.8em; |
173 | 175 | } |
174 | 176 | input.btn { |
175 | | - font-size: 15px; |
| 177 | + font-size: 14px; |
176 | 178 | margin-bottom: 4px; |
| 179 | + width: 18em; |
177 | 180 | } |
178 | 181 | #dialog{ |
179 | 182 | overflow: hidden; |
— | — | @@ -283,6 +286,15 @@ |
284 | 287 | right: 25px; |
285 | 288 | margin: 0 !important; |
286 | 289 | } |
| 290 | +#spinner { |
| 291 | + position: absolute; |
| 292 | + width: 16px; |
| 293 | + height: 16px; |
| 294 | + bottom: 37px; |
| 295 | + right: 133px; |
| 296 | + z-index: 2000; |
| 297 | + display: none; |
| 298 | +} |
287 | 299 | #steps #card-errors { |
288 | 300 | font-size: 13px; |
289 | 301 | line-height: 15px; |
— | — | @@ -295,3 +307,13 @@ |
296 | 308 | font-size: 11px; |
297 | 309 | line-height: 13px; |
298 | 310 | } |
| 311 | +#secure-logo { |
| 312 | + float: right; |
| 313 | +} |
| 314 | +#moreinfolinks { |
| 315 | + font-size: 12px; |
| 316 | +} |
| 317 | +#cvv-link { |
| 318 | + color: #2779AA; |
| 319 | + font-size: 0.8em; |
| 320 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js |
— | — | @@ -25,27 +25,20 @@ |
26 | 26 | paymentErrorString = temp.join( "<br />" ); |
27 | 27 | |
28 | 28 | // show the errors |
29 | | - var prevError = false; |
30 | 29 | if ( amountErrorString != "" ) { |
31 | | - $( "#amtErrorMessages" ).html( amountErrorString ); |
32 | | - prevError = true; |
| 30 | + $( "#topError" ).html( amountErrorString ); |
| 31 | + } else if ( billingErrorString != "" ) { |
| 32 | + $( "#topError" ).html( billingErrorString ); |
| 33 | + } else if ( paymentErrorString != "" ) { |
| 34 | + $( "#topError" ).html( paymentErrorString ); |
33 | 35 | } |
34 | | - if ( billingErrorString != "" ) { |
35 | | - $( "#billingErrorMessages" ).html( billingErrorString ); |
36 | | - if ( !prevError ) { |
37 | | - prevError = true; |
38 | | - } |
39 | | - } |
40 | | - if ( paymentErrorString != "" ) { |
41 | | - $( "#paymentErrorMessages" ).html( paymentErrorString ); |
42 | | - } |
43 | 36 | |
44 | 37 | $( '#dialog' ).dialog( { |
45 | 38 | width: 600, |
46 | 39 | resizable: false, |
47 | 40 | autoOpen: false, |
48 | 41 | modal: true, |
49 | | - title: mw.msg( 'donate_interface-cc-button' ) |
| 42 | + title: mw.msg( 'donate_interface-ccdc-button' ) |
50 | 43 | } ); |
51 | 44 | |
52 | 45 | // If the form is being reloaded, restore the amount |
— | — | @@ -65,22 +58,52 @@ |
66 | 59 | } |
67 | 60 | |
68 | 61 | $( '#cc' ).click( function() { |
| 62 | + |
| 63 | + // Make sure cookies are enabled |
| 64 | + document.cookie = 'wmf_test=1;'; |
| 65 | + if ( document.cookie.indexOf( 'wmf_test=1' ) != -1 ) { |
| 66 | + document.cookie = 'wmf_test=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; // unset the cookie |
| 67 | + } else { |
| 68 | + alert( mw.msg( 'donate_interface-error-msg-cookies' ) ); // display error |
| 69 | + return false; |
| 70 | + } |
| 71 | + |
69 | 72 | if ( validateAmount() ) { |
70 | 73 | $( '#dialog' ).dialog( 'open' ); |
| 74 | + $( "#spinner" ).hide(); // just in case |
71 | 75 | } |
72 | 76 | }); |
73 | 77 | $( '#pp' ).click( function() { |
74 | 78 | if ( validateAmount() ) { |
75 | 79 | //$( 'input#pp' ).attr( 'disabled', 'disabled' ); |
76 | 80 | $( "input[name='gateway']" ).val( 'paypal' ); |
77 | | - document.paypalcontribution.action = "https://wikimediafoundation.org/wiki/Special:ContributionTracking/en"; |
| 81 | + $( 'input[name="PaypalRedirect"]' ).val( "1" ); |
| 82 | + document.paypalcontribution.action = actionURL; |
78 | 83 | document.paypalcontribution.submit(); |
79 | 84 | } |
80 | 85 | }); |
81 | 86 | |
82 | | - /* Set selected amount to amount */ |
83 | | - $( "input[name='amountRadio']" ).click( function() { setAmount( $( this ) ); } ); |
84 | | - $( "#other-amount" ).change( function() { setAmount( $( this ) ); } ); |
| 87 | + // Set amount when a radio button is clicked |
| 88 | + $( 'input[name="amountRadio"]' ).click( function() { |
| 89 | + if ( !isNaN( $( this ).val() ) ) { |
| 90 | + setAmount( $( this ) ); |
| 91 | + } |
| 92 | + if ( $( this ).val() == 'other' ) { |
| 93 | + setAmount( $( '#other-amount' ) ); |
| 94 | + } |
| 95 | + } ); |
| 96 | + // Change the amount when "other" is focused |
| 97 | + $( "#other-amount" ).focus( function() { |
| 98 | + $( '#input_amount_other' ).attr( 'checked', true ); |
| 99 | + setAmount( $( '#other-amount' ) ); |
| 100 | + } ); |
| 101 | + // Reset the amount field when "other" is changed |
| 102 | + $( "#other-amount" ).keyup( function() { |
| 103 | + if ( $( '#input_amount_other' ).is( ':checked' ) ) { |
| 104 | + setAmount( $( this ) ); |
| 105 | + } |
| 106 | + } ); |
| 107 | + |
85 | 108 | function setAmount(e) { $("input[name='amount']").val( e.val() ); } |
86 | 109 | |
87 | 110 | /* number of fieldsets */ |
— | — | @@ -94,10 +117,7 @@ |
95 | 118 | Set the final sum as the total width of the steps element. |
96 | 119 | */ |
97 | 120 | var stepsWidth = 0; |
98 | | - var widths = new Array(); |
99 | 121 | $( '#steps .step' ).each( function(i) { |
100 | | - var $step = $( this ); |
101 | | - widths[i] = stepsWidth; |
102 | 122 | stepsWidth += 600; // Hard-coding as $.width() is not working for some reason |
103 | 123 | } ); |
104 | 124 | $( '#steps' ).width( stepsWidth ); |
— | — | @@ -107,37 +127,33 @@ |
108 | 128 | |
109 | 129 | /* make continue buttons */ |
110 | 130 | $( 'a.continue-button' ).button(); |
111 | | - $( 'a.continue-button' ).click( function(e) { |
112 | | - var $this = $( this ); |
113 | | - current = $( this ).parent().parent().index() + 1; |
114 | | - if ( current == fieldsetCount ) { |
115 | | - finalSubmit(); |
116 | | - return false; |
117 | | - } |
118 | | - if ( validateStep( current ) === 1 ) { |
119 | | - current = current + 1; |
120 | | - $( '#steps' ).stop().animate( { marginLeft: '-' + widths[current - 1] + 'px' }, 500, |
| 131 | + $( 'a#personal-continue' ).click( function(e) { |
| 132 | + if ( validatePersonal() ) { |
| 133 | + // Advance to the next step |
| 134 | + $( '#steps' ).stop().animate( { marginLeft: '-600px' }, 500, |
121 | 135 | function() { |
122 | | - $( '#donationForm' ).children( ':nth-child(' + parseInt(current) + ')' ).find( ':input:first' ).focus(); |
| 136 | + $( '#donationForm' ).children( ':nth-child(1)' ).find( ':input:first' ).focus(); |
123 | 137 | } |
124 | 138 | ); |
125 | | - } else { |
126 | | - $this.blur(); |
127 | 139 | } |
128 | | - |
129 | | - e.preventDefault(); |
| 140 | + $( this ).blur(); |
| 141 | + e.preventDefault(); |
| 142 | + return false; |
130 | 143 | }); |
| 144 | + $( 'a#cc-continue' ).click( function(e) { |
| 145 | + finalSubmit(); |
| 146 | + e.preventDefault(); |
| 147 | + return false; |
| 148 | + }); |
131 | 149 | |
132 | 150 | /* Make back button */ |
133 | 151 | $( 'a.back-button' ).button(); |
134 | 152 | $( 'a.back-button' ).click( function(e) { |
135 | | - var $this = $( this ); |
136 | 153 | /* Set current to 1 less than previous step */ |
137 | 154 | current = $( this ).parent().parent().index(); |
138 | | - |
139 | | - $( '#steps' ).stop().animate( { marginLeft: '+' + widths[current - 1] + 'px' }, 500 ); |
140 | | - |
141 | | - e.preventDefault(); |
| 155 | + $( '#steps' ).stop().animate( { marginLeft: '0px' }, 500 ); |
| 156 | + $( this ).blur(); |
| 157 | + e.preventDefault(); |
142 | 158 | }); |
143 | 159 | |
144 | 160 | /* Hitting tab on the last input of each fieldset makes the form slide to the next step. */ |
— | — | @@ -152,37 +168,42 @@ |
153 | 169 | }); |
154 | 170 | }); |
155 | 171 | |
156 | | - /* |
157 | | - Validates errors on all the fieldsets. |
158 | | - Records if the form has errors in $( '#donationForm' ).data(). |
159 | | - */ |
160 | | - function validateSteps() { |
161 | | - var formErrors = false; |
162 | | - for( var i = 1; i < fieldsetCount; ++i ) { |
163 | | - var error = validateStep(i); |
164 | | - if ( error == -1 ) formErrors = true; |
165 | | - } |
166 | | - $( '#donationForm' ).data( 'errors', formErrors ); |
167 | | - } |
168 | | - |
169 | 172 | function finalSubmit() { |
170 | | - |
171 | | - // Reset the error display |
172 | | - $( '#card-errors' ).empty(); |
| 173 | + var step = 2; |
| 174 | + var errors = false; |
173 | 175 | |
174 | | - var formErrors = false; |
175 | | - for( var i = 1; i <= fieldsetCount; ++i ) { |
176 | | - var error = validateStep(i); |
177 | | - if ( error == -1 ) formErrors = true; |
| 176 | + $( '#donationForm' ).children( ':nth-child(' + step + ')' ).find( ':input:not(button).required' ).each( function() { |
| 177 | + var $this = $( this ); |
| 178 | + var valueLength = $.trim( $this.val() ).length; |
| 179 | + if ( valueLength == 0 ) { |
| 180 | + errors = true; |
| 181 | + $this.css( 'background-color', '#FFEDEF' ); |
| 182 | + } else { |
| 183 | + $this.css( 'background-color', '#FFFFFF' ); |
| 184 | + } |
| 185 | + }); |
| 186 | + |
| 187 | + // Validate credit card number |
| 188 | + cardNumber = $( '#card_num' ).val(); |
| 189 | + cardNumber = $.trim( cardNumber ); |
| 190 | + if ( cardNumber != '' ) { |
| 191 | + cardNumber = cardNumber.replace(/ /g,''); // remove any spaces |
| 192 | + // Make sure it contains only digits |
| 193 | + var ccCheckRegExp = /[^\d]/; |
| 194 | + if ( ccCheckRegExp.test(cardNumber) ) { |
| 195 | + errors = true; |
| 196 | + $( '#card_num' ).css( 'background-color', '#FFEDEF' ); |
| 197 | + } else { |
| 198 | + $( '#card_num' ).css( 'background-color', '#FFFFFF' ); |
| 199 | + } |
178 | 200 | } |
179 | | - $( '#donationForm' ).data( 'errors', formErrors ); |
180 | 201 | |
181 | | - if ( $( '#donationForm' ).data( 'errors' ) ) { |
182 | | - alert( 'Please correct the errors in the form.' ); |
| 202 | + if ( errors ) { |
| 203 | + //alert( mw.msg( 'donate_interface-error-msg-validation' ) ); |
183 | 204 | return false; |
184 | 205 | } else { |
185 | 206 | /* Set country to US */ |
186 | | - $( "input[name='country']" ).val('US' ); |
| 207 | + $( "input[name='country']" ).val( 'US' ); |
187 | 208 | |
188 | 209 | /* Set expiration date */ |
189 | 210 | $( "input[name='expiration']" ).val( |
— | — | @@ -190,81 +211,55 @@ |
191 | 212 | ) |
192 | 213 | |
193 | 214 | /* Submit the form */ |
194 | | - var sendData = { |
195 | | - 'action': 'donate', |
196 | | - 'gateway': 'payflowpro', |
197 | | - 'currency_code': 'USD', |
198 | | - 'amount': $( "input[name='amount']" ).val(), |
199 | | - 'fname': $( "input[name='fname']" ).val(), |
200 | | - 'lname': $( "input[name='lname']" ).val(), |
201 | | - 'street': $( "input[name='street']" ).val(), |
202 | | - 'city': $( "input[name='city']" ).val(), |
203 | | - 'state': $( 'select#state option:selected' ).val(), |
204 | | - 'zip': $( "input[name='zip']" ).val(), |
205 | | - 'emailAdd': $( "input[name='emailAdd']" ).val(), |
206 | | - 'country': $( "input[name='country']" ).val(), |
207 | | - 'payment_method': 'cc', |
208 | | - 'language': 'en', |
209 | | - |
210 | | - 'expiration': $( "input[name='expiration']" ).val(), |
211 | | - 'card_num': $( "input[name='card_num']" ).val(), |
212 | | - 'cvv': $( "input[name='cvv']" ).val(), |
213 | | - 'card_type': '', |
214 | | - |
215 | | - 'format': 'json' |
216 | | - }; |
217 | | - |
218 | | - $.ajax( { |
219 | | - 'url': mw.util.wikiScript( 'api' ), |
220 | | - 'data': sendData, |
221 | | - 'dataType': 'json', |
222 | | - 'type': 'POST', |
223 | | - 'success': function( data ) { |
224 | | - console.debug( data ); |
225 | | - if ( data.result.errors ) { |
226 | | - var errors = new Array(); |
227 | | - $.each( data.result.errors, function( index, value ) { |
228 | | - $( '#card-errors' ).append( '<div class="error-msg">'+value+'</div>' ); |
229 | | - } ); |
230 | | - } else { |
231 | | - if ( data.result.returnurl ) { |
232 | | - window.location = data.result.returnurl; |
233 | | - } |
234 | | - } |
235 | | - } |
236 | | - } ); |
237 | | - //document.donationForm.action = $( "input[name='action']" ).val(); |
| 215 | + document.donationForm.action = $( "input[name='action']" ).val(); |
| 216 | + $( "#spinner" ).show(); |
238 | 217 | //document.donationForm.submit(); |
239 | 218 | } |
240 | 219 | } |
241 | | - |
242 | | - /* |
243 | | - validates one fieldset |
244 | | - returns -1 if errors found, or 1 if not |
245 | | - */ |
246 | | - function validateStep( step ) { |
247 | | - var error = 1; |
248 | | - $( '#donationForm' ).children( ':nth-child(' + parseInt(step) + ')' ).find( ':input:not(button).required' ).each( function() { |
| 220 | + |
| 221 | + function validatePersonal() { |
| 222 | + var step = 1; |
| 223 | + var errors = false; |
| 224 | + |
| 225 | + $( '#donationForm' ).children( ':nth-child(' + step + ')' ).find( ':input:not(button).required' ).each( function() { |
249 | 226 | var $this = $( this ); |
250 | | - var valueLength = jQuery.trim( $this.val() ).length; |
251 | | - |
252 | | - if ( valueLength == '' ) { |
253 | | - error = -1; |
| 227 | + var valueLength = $.trim( $this.val() ).length; |
| 228 | + if ( valueLength == 0 ) { |
| 229 | + errors = true; |
254 | 230 | $this.css( 'background-color', '#FFEDEF' ); |
255 | 231 | } else { |
256 | 232 | $this.css( 'background-color', '#FFFFFF' ); |
257 | 233 | } |
258 | 234 | }); |
259 | | - |
260 | | - return error; |
| 235 | + |
| 236 | + // Validate email address |
| 237 | + email = $( '#email' ).val(); |
| 238 | + email = $.trim( email ); |
| 239 | + if( email != '' ) { |
| 240 | + var apos = email.indexOf("@"); |
| 241 | + var dotpos = email.lastIndexOf("."); |
| 242 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 243 | + errors = true; |
| 244 | + $( '#email' ).css( 'background-color', '#FFEDEF' ); |
| 245 | + } else { |
| 246 | + $( '#email' ).css( 'background-color', '#FFFFFF' ); |
| 247 | + } |
| 248 | + } |
| 249 | + |
| 250 | + if ( errors ) { |
| 251 | + return false; |
| 252 | + } else { |
| 253 | + return true; |
| 254 | + } |
261 | 255 | } |
262 | 256 | |
263 | 257 | /** |
264 | 258 | * Validate the donation amount to make sure it is formatted correctly and at least a minimum amount. |
265 | 259 | */ |
266 | 260 | function validateAmount() { |
267 | | - var error = true; |
| 261 | + var errors = false; |
268 | 262 | var amount = $( "input[name='amount']" ).val(); // get the amount |
| 263 | + |
269 | 264 | // Normalize weird amount formats. |
270 | 265 | // Don't mess with these unless you know what you're doing. |
271 | 266 | amount = amount.replace( /[,.](\d)$/, '\:$10' ); |
— | — | @@ -273,8 +268,8 @@ |
274 | 269 | amount = amount.replace( /:/, '.' ); |
275 | 270 | $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form |
276 | 271 | |
277 | | - // Check amount is a real number, sets error as true (good) if no issues |
278 | | - error = ( amount == null || isNaN( amount ) || amount.value <= 0 ); |
| 272 | + // Check amount is a real number greater than 0 |
| 273 | + errors = ( amount == null || isNaN( amount ) || parseFloat( amount ) <= 0 ); |
279 | 274 | |
280 | 275 | // Find out the currency code |
281 | 276 | if ( $( 'input[name="currency_code"]' ).val() == '' ) { |
— | — | @@ -288,12 +283,16 @@ |
289 | 284 | if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) { |
290 | 285 | wgCurrencyMinimums[currency_code] = 1; |
291 | 286 | } |
292 | | - if ( amount < wgCurrencyMinimums[currency_code] || error ) { |
| 287 | + if ( amount < wgCurrencyMinimums[currency_code] || errors ) { |
| 288 | + errors = true; |
293 | 289 | alert( mw.msg( 'donate_interface-smallamount-error' ).replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) ); |
294 | | - error = true; |
295 | 290 | $( '#other-amount' ).val( '' ); |
296 | 291 | $( '#other-amount' ).focus(); |
297 | 292 | } |
298 | | - return !error; |
| 293 | + if ( errors ) { |
| 294 | + return false; |
| 295 | + } else { |
| 296 | + return true; |
| 297 | + } |
299 | 298 | }; |
300 | 299 | }); |
Index: trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php |
— | — | @@ -28,9 +28,11 @@ |
29 | 29 | 'jquery.ui.resizable', |
30 | 30 | 'jquery.ui.button', |
31 | 31 | 'jquery.ui.dialog', |
| 32 | + 'ext.donationInterface.errorMessages', |
32 | 33 | ), |
33 | 34 | 'messages' => array( |
34 | 35 | 'donate_interface-cc-button', |
| 36 | + 'donate_interface-ccdc-button', |
35 | 37 | 'donate_interface-paypal-button', |
36 | 38 | ), |
37 | 39 | 'localBasePath' => dirname( __FILE__ ).'/../../payflowpro_gateway/forms', |
Index: trunk/extensions/DonationInterface/gateway_forms/Form.php |
— | — | @@ -959,9 +959,9 @@ |
960 | 960 | */ |
961 | 961 | protected function getSmallSecureLogo() { |
962 | 962 | |
963 | | - $form = '<table id="secureLogo" width="135" border="0" cellpadding="2" cellspacing="0" title=' . wfMsg('donate_interface-securelogo-title') . '>'; |
| 963 | + $form = '<table id="secureLogo" width="130" border="0" cellpadding="2" cellspacing="0" title=' . wfMsg('donate_interface-securelogo-title') . '>'; |
964 | 964 | $form .= '<tr>'; |
965 | | - $form .= '<td width="135" align="center" valign="top"><script type="text/javascript" src="https://seal.verisign.com/getseal?host_name=payments.wikimedia.org&size=S&use_flash=NO&use_transparent=NO&lang=en"></script><br /><a href="http://www.verisign.com/ssl-certificate/" target="_blank" style="color:#000000; text-decoration:none; font:bold 7px verdana,sans-serif; letter-spacing:.5px; text-align:center; margin:0px; padding:0px;">' . wfMsg('donate_interface-secureLogo-text') . '</a></td>'; |
| 965 | + $form .= '<td width="130" align="center" valign="top"><script type="text/javascript" src="https://seal.verisign.com/getseal?host_name=payments.wikimedia.org&size=S&use_flash=NO&use_transparent=NO&lang=en"></script><br /><a href="http://www.verisign.com/ssl-certificate/" target="_blank" style="color:#000000; text-decoration:none; font:bold 7px verdana,sans-serif; letter-spacing:.5px; text-align:center; margin:0px; padding:0px;">' . wfMsg('donate_interface-secureLogo-text') . '</a></td>'; |
966 | 966 | $form .= '</tr>'; |
967 | 967 | $form .= '</table>'; |
968 | 968 | return $form; |
Index: trunk/extensions/DonationInterface/gateway_common/interface.i18n.php |
— | — | @@ -166,6 +166,7 @@ |
167 | 167 | 'donate_interface-error-msg-nopaypal' => 'Due to a technical error, we cannot send your request to PayPal. Please try using our regular credit card donation form.', |
168 | 168 | 'donate_interface-error-msg' => 'Please enter your $1', |
169 | 169 | 'donate_interface-error-msg-js' => 'Please enter your', |
| 170 | + 'donate_interface-error-msg-validation' => 'Please correct the errors in the form.', |
170 | 171 | 'donate_interface-error-msg-invalid-amount' => 'Please enter a valid amount', |
171 | 172 | 'donate_interface-error-msg-email' => 'Please enter a valid e-mail address', |
172 | 173 | 'donate_interface-error-msg-card-num' => 'Please enter a valid credit card number for one of the accepted credit card types', |
— | — | @@ -603,6 +604,7 @@ |
604 | 605 | An alternative to 'field' in the translation could be 'information'. |
605 | 606 | |
606 | 607 | This is an error message which appears if one or more of the above fields is left empty.", |
| 608 | + 'donate_interface-error-msg-validation' => 'Generic error message for form validation failure', |
607 | 609 | 'donate_interface-error-msg-invalid-amount' => 'Error message for invalid amount (e.g. if you put a letter in the amount field).', |
608 | 610 | 'donate_interface-error-msg-email' => 'Error message if the e-mail address is not valid (e.g. non-ASCII characters, spaces or lacking @).', |
609 | 611 | 'donate_interface-error-msg-card-num' => 'The stars are to attract attention to the message in a drop-down box. The stars are not interpreted as wiki code when in use in the extension.', |