r102424 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102423‎ | r102424 | r102425 >
Date:19:12, 8 November 2011
Author:kaldari
Status:ok
Tags:fundraising 
Comment:
better handling of errors by webitects globalcollect form (no more infinite spinny thing), some updates to lightbox form
Modified paths:
  • /trunk/extensions/DonationInterface/donationinterface.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/interface.i18n.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/lightbox1.html (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/webitects_2_3step.html (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/donationinterface.php
@@ -585,6 +585,7 @@
586586
587587 $wgResourceModules[ 'ext.donationInterface.errorMessages' ] = array(
588588 'messages' => array(
 589+ 'donate_interface-error-msg-general',
589590 'donate_interface-error-msg-js',
590591 'donate_interface-error-msg-invalid-amount',
591592 'donate_interface-error-msg-email',
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html
@@ -1,10 +1,12 @@
22 <!--[if lt IE 7]><style type="text/css">body{behavior:url("/w/skins-1.17/vector/csshover.min.htc")}</style><![endif]-->
33 <script type="text/javascript">
4 -mw.loader.load( 'jquery.ui.button' );
5 -mw.loader.load( 'jquery.ui.dialog' );
6 -var extensionPath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/DonationInterface';
7 -mw.loader.load( extensionPath + '/payflowpro_gateway/forms/js/lightbox1.js', 'text/javascript' );
8 -mw.loader.load( extensionPath + '/payflowpro_gateway/forms/css/lightbox1.css', 'text/css' );
 4+mw.loader.load('pfp.form.rapidhtml.lightbox');
 5+// these must go through RapidHTML and thus are inline
 6+var amountErrors = ['#general|escape','#retryMsg|escape','#amount|escape'];
 7+var billingErrors = ['#fname|escape','#lname|escape','#city|escape','#country|escape','#street|escape','#state|escape','#zip|escape','#emailAdd|escape'];
 8+var paymentErrors = ['#card_num|escape','#card_type|escape','#cvv|escape'];
 9+var actionURL = "@action";
 10+var scriptPath = "@script_path";
911 </script>
1012
1113 <div class="ltr">
@@ -16,7 +18,7 @@
1719
1820 <form method="post" name="paypalcontribution">
1921 <div style="display: block;" id="amount-content">
20 -
 22+ <div id="amtErrorMessages" class="small"></div>
2123 <table id="amount-table">
2224 <tr>
2325 <td><label><input type="radio" name="amountRadio" value="5" /> $5</label></td>
@@ -54,40 +56,8 @@
5557 </div>
5658 </div>
5759
58 - <h2 id="appeal-head"> <span class="mw-headline" id="From_Wikipedia_programmer_Brandon_Harris">From Wikipedia programmer Brandon Harris</span></h2>
59 - <div id="appeal-body" class="plainlinks">
60 - <p>I feel like I'm living the first line of my obituary.</p>
61 - <p>I don't think there will be anything else that I do in my
62 - life as important as what I do now for Wikipedia. We're not just
63 -building an encyclopedia, we're working to make people free. When we
64 -have access to free knowledge, we are better people. We understand the
65 -world is bigger than us, and we become infected with tolerance and
66 -understanding.</p>
67 - <p>Wikipedia is the 5th largest website in the world. I work
68 - at the small non-profit that keeps it on the web. We don't run ads
69 -because doing so would sacrifice our independence. The site is not and
70 -should never be a propaganda tool.</p>
71 - <p>Our work is possible because of donations from our
72 -readers. Will you help protect Wikipedia by donating $5, $10, $20 or
73 -whatever you can afford?</p>
74 - <p>I work at the Wikimedia Foundation because everything in
75 -my soul tells me it's the right thing to do. I've worked at huge tech
76 -companies, doing some job to build some crappy thing that's designed to
77 -steal money from some kid who doesn't know it. I would come home from
78 -work crushed.</p>
79 - <p>You might not know this, but the Wikimedia Foundation
80 -operates with a very small staff. Most other top-ten sites have tens of
81 -thousands of people and massive budgets. But they produce a fraction of
82 -what we pull off with sticks and wire.</p>
83 - <p>When you give to Wikipedia, you're supporting free
84 -knowledge around the world. You're not only leaving a legacy for your
85 -children and for their children, you're elevating people around the
86 -world who have access to this treasure. You're assuring that one day
87 -everyone else will too.</p>
88 - <p>Thank you,</p>
89 - <p><strong>Brandon Harris</strong><br></p>
90 - <p>Programmer, Wikimedia Foundation</p>
91 - </div>
 60+ <h2 id="appeal-head"> <span class="mw-headline">{{LanguageSwitch|2011FR/@appeal-title|@language}}</span></h2>
 61+ <div id="appeal-body" class="plainlinks">{{LanguageSwitch|2011FR/@appeal|@language}}</div>
9262 </div>
9363 </div>
9464
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
@@ -1,5 +1,45 @@
2 -$(function() {
 2+$( document ).ready( function () {
33
 4+ // check for RapidHtml errors and display, if any
 5+ var amountErrorString = "";
 6+ var billingErrorString = "";
 7+ var paymentErrorString = "";
 8+
 9+ // generate formatted errors to display
 10+ var temp = [];
 11+ for ( var e in amountErrors )
 12+ if ( amountErrors[e] != "" )
 13+ temp[temp.length] = amountErrors[e];
 14+ amountErrorString = temp.join( "<br />" );
 15+
 16+ temp = [];
 17+ for ( var f in billingErrors )
 18+ if ( billingErrors[f] != "" )
 19+ temp[temp.length] = billingErrors[f];
 20+ billingErrorString = temp.join( "<br />" );
 21+
 22+ temp = [];
 23+ for ( var g in paymentErrors )
 24+ if ( paymentErrors[g] != "" )
 25+ temp[temp.length] = paymentErrors[g];
 26+ paymentErrorString = temp.join( "<br />" );
 27+
 28+ // show the errors
 29+ var prevError = false;
 30+ if ( amountErrorString != "" ) {
 31+ $( "#amtErrorMessages" ).html( amountErrorString );
 32+ prevError = true;
 33+ }
 34+ if ( billingErrorString != "" ) {
 35+ $( "#billingErrorMessages" ).html( billingErrorString );
 36+ if ( !prevError ) {
 37+ prevError = true;
 38+ }
 39+ }
 40+ if ( paymentErrorString != "" ) {
 41+ $( "#paymentErrorMessages" ).html( paymentErrorString );
 42+ }
 43+
444 $( '#dialog' ).dialog( {
545 width: 600,
646 resizable: false,
Index: trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
@@ -13,10 +13,13 @@
1414 * LIGHTBOX
1515 */
1616 // RapidHtml lightbox form resources
17 -$wgResourceModules[ 'pfp.form.rapidhtml.lightbox.js' ] = array(
 17+$wgResourceModules[ 'pfp.form.rapidhtml.lightbox' ] = array(
1818 'scripts' => array(
1919 'js/lightbox1.js',
2020 ),
 21+ 'styles' => array(
 22+ 'css/lightbox1.css',
 23+ ),
2124 'dependencies' => array(
2225 'jquery.ui.core',
2326 'jquery.ui.widget',
@@ -32,18 +35,6 @@
3336 'position' => 'top',
3437 );
3538
36 -// RapidHtml lightbox form css resources (these are separate from the js
37 -// resources for a good reason but I forget what - I believe to facilitate
38 -// ensuring proper load order?
39 -$wgResourceModules[ 'pfp.form.rapidhtml.lightbox.css' ] = array(
40 - 'styles' => array(
41 - 'css/lightbox1.css',
42 - ),
43 - 'localBasePath' => dirname( __FILE__ ),
44 - 'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
45 - 'position' => 'top',
46 -);
47 -
4839 /**
4940 * webitects
5041 */
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/lightbox1.html
@@ -5,6 +5,7 @@
66 var extensionPath = mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/DonationInterface';
77 mw.loader.load( extensionPath + '/globalcollect_gateway/forms/js/lightbox1.js', 'text/javascript' );
88 mw.loader.load( extensionPath + '/globalcollect_gateway/forms/css/lightbox1.css', 'text/css' );
 9+var ajaxError = "%donate_interface-error-msg-general%";
910 </script>
1011
1112 <div class="ltr">
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/webitects_2_3step.html
@@ -6,6 +6,7 @@
77 var paymentErrors = ['#card_num|escape','#card_type|escape','#cvv|escape'];
88 var actionURL = "@action";
99 var scriptPath = "@script_path";
 10+ var ajaxError = "%donate_interface-error-msg-general%";
1011 </script>
1112 <!--[if lt IE 7]>
1213 <script type="text/javascript">
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.js
@@ -63,7 +63,11 @@
6464 'dataType': 'json',
6565 'type': 'GET',
6666 'success': function( data ) {
67 - if ( typeof data.result !== 'undefined' ) {
 67+ if ( typeof data.error !== 'undefined' ) {
 68+ alert( ajaxError );
 69+ $( "#paymentContinue" ).show(); // Show continue button in 2nd section
 70+ showStep1();
 71+ } else if ( typeof data.result !== 'undefined' ) {
6872 if ( data.result.errors ) {
6973 var errors = new Array();
7074 $.each( data.result.errors, function( index, value ) {
@@ -82,6 +86,10 @@
8387 }
8488 }
8589 }
 90+ },
 91+ 'error': function( xhr ) {
 92+ alert( ajaxError );
 93+ showStep1();
8694 }
8795 } );
8896 }
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/lightbox1.js
@@ -167,17 +167,31 @@
168168 'dataType': 'json',
169169 'type': 'GET',
170170 'success': function( data ) {
171 - if ( data.result.errors ) {
172 - var errors = new Array();
173 - for( var key in data.result.errors ){
174 - errors.push( data.result.errors[key] );
 171+ if ( typeof data.error !== 'undefined' ) {
 172+ alert( ajaxError );
 173+ // Send them back to the beginning
 174+ } else if ( typeof data.result !== 'undefined' ) {
 175+ if ( data.result.errors ) {
 176+ var errors = new Array();
 177+ $.each( data.result.errors, function( index, value ) {
 178+ alert( value ); // Show them the error
 179+ // Send them back to the beginning
 180+ } );
 181+ } else {
 182+ if ( data.result.formaction ) {
 183+ $( '#payment' ).empty();
 184+ // Insert the iframe into the form
 185+ $( '#payment' ).append(
 186+ '<iframe src="'+data.result.formaction+'" width="318" height="314" frameborder="0"></iframe>'
 187+ );
 188+
 189+ }
175190 }
176 - alert ( errors.join( '\r\n' ) );
177 - } else {
178 - if ( data.result.returnurl ) {
179 - window.location = data.result.returnurl;
180 - }
181191 }
 192+ },
 193+ 'error': function( xhr ) {
 194+ alert( ajaxError );
 195+ // Send them back to the beginning
182196 }
183197 } );
184198 //document.donationForm.action = $( "input[name='action']" ).val();
Index: trunk/extensions/DonationInterface/gateway_common/interface.i18n.php
@@ -157,6 +157,7 @@
158158 'donate_interface-card-name-mc' => 'Mastercard',
159159 'donate_interface-card-name-discover' => 'Discover',
160160 // The key names for the error messages should mostly match up with the donate_interface-donor keys above. (There are a few exceptions for backwards compat.)
 161+ 'donate_interface-error-msg-general' => 'There was an error processing your request.',
161162 '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.',
162163 'donate_interface-error-msg' => 'Please enter your $1',
163164 'donate_interface-error-msg-js' => 'Please enter your',
@@ -543,6 +544,7 @@
544545 'donate_interface-donor-submit' => '{{Identical|Donate}}',
545546 'donate_interface-donor-currency-msg' => '* $1 is 3 letter currency code',
546547 'donate_interface-card-name-discover' => "Trademark name of credit card Discover®, '''not''' the verb \"to discover\".",
 548+ 'donate_interface-error-msg-general' => 'A generic error message.',
547549 'donate_interface-error-msg-nopaypal' => 'Error message.',
548550 'donate_interface-error-msg' => "{{doc-important|If grammatical issues in your language prevent you from translating this literally, translate the following: \"The following field is required: \$1\".}}
549551

Follow-up revisions

RevisionCommit summaryAuthorDate
r102597MFT r102323, r102424, r102438, r102563, r102566awjrichards23:18, 9 November 2011
r102608MFT r102117, r102141, r102145, r102146, r102154, r102167, r102169, r102195, r...awjrichards23:43, 9 November 2011
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011

Status & tagging log