r102698 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102697‎ | r102698 | r102699 >
Date:22:04, 10 November 2011
Author:pgehres
Status:ok (Comments)
Tags:
Comment:
Adding rtbt-ideal and adding js for rtbt that allows for amount selection on 2nd step
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/rtbt/rtbt-ideal.html (added) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.bt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/rapidhtml/RapidHtmlResources.php
@@ -116,16 +116,36 @@
117117 'localBasePath' => dirname( __FILE__ ).'/../../payflowpro_gateway/forms',
118118 'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
119119 );
 120+$wgResourceModules[ 'pfp.form.rapidhtml.webitects.2nd' ] = array(
 121+ 'styles' => '',
 122+ 'scripts' => 'js/webitects2nd.js',
 123+ 'dependencies' => array(
 124+ 'di.form.rapidhtml.webitects',
 125+ 'di.form.core.validate'
 126+ ),
 127+ 'localBasePath' => dirname( __FILE__ ).'/../../payflowpro_gateway/forms',
 128+ 'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
 129+);
120130 $wgResourceModules[ 'pfp.form.rapidhtml.webitects_2step' ] = array(
121131 'styles' => '',
122132 'scripts' => 'js/webitects_2_2step.js',
123133 'dependencies' => array(
124 - 'di.form.rapidhtml.webitects',
 134+ 'di.form.rapidhtml.webitects.2nd',
125135 'di.form.core.validate'
126136 ),
127137 'localBasePath' => dirname( __FILE__ ).'/../../payflowpro_gateway/forms',
128138 'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
129139 );
 140+$wgResourceModules[ 'pfp.form.rapidhtml.webitects_2stepB' ] = array(
 141+ 'styles' => '',
 142+ 'scripts' => 'js/webitects_2_2stepB.js',
 143+ 'dependencies' => array(
 144+ 'di.form.core.validate',
 145+ 'di.form.rapidhtml.webitects'
 146+ ),
 147+ 'localBasePath' => dirname( __FILE__ ).'/../../payflowpro_gateway/forms',
 148+ 'remoteExtPath' => $wgPayflowRapidHtmlRemoteExtPath,
 149+);
130150 $wgResourceModules[ 'pfp.form.rapidhtml.webitects.ie6' ] = array(
131151 'dependencies' => array(
132152 'di.form.rapidhtml.webitects.ie6',
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/rtbt/rtbt-ideal.html
@@ -0,0 +1,175 @@
 2+<script type="text/javascript">
 3+ mw.loader.load('gc.form.rapidhtml.webitects.bt');
 4+ // these must go through RapidHTML and thus are inline
 5+ var amountErrors = ["#general|escape",'#retryMsg|escape','#amount|escape'];
 6+ var billingErrors = ['#fname|escape','#lname|escape','#city|escape','#country|escape','#street|escape','#state|escape','#zip|escape','#emailAdd|escape'];
 7+ var paymentErrors = ['#card_num|escape','#card_type|escape','#cvv|escape'];
 8+ var actionURL = "@action";
 9+ var scriptPath = "@script_path";
 10+</script>
 11+<!--[if lt IE 7]>
 12+<script type="text/javascript">
 13+ mw.loader.load('gc.form.rapidhtml.webitects.ie6');
 14+</script>
 15+<style type="text/css">
 16+ body{
 17+ behavior: url("@script_path/skins/vector/csshover.min.htc");
 18+ }
 19+</style><![endif]-->
 20+<!--[if IE 7]>
 21+<style>
 22+ .gainlayout {
 23+ zoom: 1;
 24+ height: 1%;
 25+ }
 26+</style>
 27+<![endif]-->
 28+
 29+<div class="ltr">
 30+ <table id="layouttable">
 31+ <tr>
 32+ <td>
 33+ <div id="appeal">
 34+ <div id="appeal-content">
 35+ <h2 id="appeal-head"> <span class="mw-headline">{{LanguageSwitch|2011FR/@appeal-title|@language}}</span></h2>
 36+ <div id="appeal-body" class="plainlinks">{{LanguageSwitch|2011FR/@appeal|@language}}</div>
 37+ </div>
 38+ </div>
 39+ </td>
 40+ <td>
 41+ <div id="donate">
 42+ <div id="donate-content">
 43+ <div id="donate-body" style="padding: 0 1em;">
 44+ <form method="post" name="paypalcontribution">
 45+ <div id="step1header"><h3>%donate_interface-amount-legend% <span id="selected-amount"></span> <span class="mute" id="change-amount" style="display: none;">(<a href="#">%donate_interface-change%</a>)</span></h3></div>
 46+ <div id="step1wrapper" style="display: none;">
 47+ <div id="amtErrorMessages" class="small"></div>
 48+ <table id="amount-table-white">
 49+ <tr>
 50+ <td><label><input id="amountRadio0" type="radio" name="amountRadio" value="5" /> <span id="amountSpan0">5</span></label></td>
 51+ <td><label><input id="amountRadio1" type="radio" name="amountRadio" value="10" /> <span id="amountSpan1">10</span></label></td>
 52+ <td><label><input id="amountRadio2" type="radio" name="amountRadio" value="20" /> <span id="amountSpan2">20</span></label></td>
 53+ <td><label><input id="amountRadio3" type="radio" name="amountRadio" value="40" /> <span id="amountSpan3">40</span></label></td>
 54+ </tr>
 55+ <tr>
 56+ <td><label><input id="amountRadio4" type="radio" name="amountRadio" value="55" /> <span id="amountSpan4">55</span></label></td>
 57+ <td><label><input id="amountRadio5" type="radio" name="amountRadio" value="75" /> <span id="amountSpan5">75</span></label></td>
 58+ <td><label><input id="amountRadio6" type="radio" name="amountRadio" value="180" /> <span id="amountSpan6">180</span></label></td>
 59+ <td><input type="radio" name="amountRadio" id="input_amount_other" value="other" /> <label><span id="amountSpanOther"></span><input type="text" class="txt-sm hint" name="amountGiven" size="4" id="other-amount" title="%donate_interface-other%" placeholder="%donate_interface-other%" onfocus="this.form.input_amount_other.checked=true;"/></label></td>
 60+ </tr>
 61+ </table>
 62+ </div>
 63+
 64+
 65+ <div id="step2header"><h3>%donate_interface-billing-address% <span class="mute" id="change-billing" style="display: none;">(<a href="#">%donate_interface-change%</a>)</span></h3></div>
 66+ <div id="step2wrapper">
 67+ <div id="billing-content" class="gainlayout">
 68+ <div id="billingErrorMessages" class="small"></div>
 69+ <div id="paymentErrorMessages" class="small"></div>
 70+ <div class="name-fields">
 71+ <span class="name-first"><input class="txt" id="fname" name="fname" title="%donate_interface-donor-fname%" value="@fname" placeholder="%donate_interface-donor-fname%"/></span>
 72+ <span class="name-last"><input class="txt" id="lname" name="lname" title="%donate_interface-donor-lname%" value="@lname" placeholder="%donate_interface-donor-lname%"/></span>
 73+ </div>
 74+ <div class="loc-fields nostate">
 75+ <span class="loc-street"><input class="txt" id="street" name="street" title="%donate_interface-donor-street%" value="@street" placeholder="%donate_interface-donor-street%"/></span>
 76+ <span class="loc-postal"><input class="txt" id="zip" name="zip" title="%donate_interface-donor-postal%" value="@zip" placeholder="%donate_interface-donor-postal%"/></span>
 77+ <span class="loc-city"><input class="txt" id="city" name="city" title="%donate_interface-donor-city%" value="@city" placeholder="%donate_interface-donor-city%"/></span>
 78+ <!--<span class="loc-country">-->
 79+ <!--<select class="txt" id="country" name="country" value="@country" placeholder="%donate_interface-country%">-->
 80+ <!--<option value="">%donate_interface-select-country%</option>-->
 81+ <!--<option value="AT">%donate_interface-country-dropdown-AT%</option>-->
 82+ <!--</select>-->
 83+ <!--</span>-->
 84+ </div>
 85+ <p><input class="txt" title="%donate_interface-donor-email%" id="emailAdd" name="emailAdd" value="@emailAdd" placeholder="%donate_interface-donor-email%"/> </p>
 86+ <table style="margin-top: 10px;" >
 87+ <tr><td>
 88+ <select style="margin-top: 15px;" id="issuer_id" name="issuer_id" value="@issuer_id">
 89+ <option value="">%donate_interface-rtbt-issuer_id%...</option>
 90+ <optgroup>
 91+ <option value="31">ABN Amro</option>
 92+ <option value="81">Fortis</option>
 93+ <option value="91">Friesland Bank</option>
 94+ <option value="721">ING</option>
 95+ <option value="21">Rabobank</option>
 96+ <option value="751">SNS Bank</option>
 97+ </optgroup>
 98+ <optgroup label="%donate_interface-rtbt-issuer_id-longlist%">
 99+ <option value="761">ASN Bank</option>
 100+ <option value="771">RegioBank</option>
 101+ <option value="511">Triodos Bank</option>
 102+ <option value="161">Van Lanschot Bankiers</option>
 103+ </optgroup>
 104+ </select>
 105+
 106+ <div id="bt-continue" style="margin-top: 15px;"> <input class="btn" id="bt-continueBtn" type="button" value="%donate_interface-continue%" /></div>
 107+ </td><td>
 108+ <img style="margin-left: 25px;" src="@script_path/extensions/DonationInterface/gateway_forms/includes/IDEAL-klein.gif" alt="IDEAL klein">
 109+ </td></tr>
 110+ </table>
 111+
 112+ </div>
 113+ </div>
 114+
 115+
 116+ <input type="hidden" name="returnto" value="Thank_You/en" />
 117+ <input type="hidden" value="0" name="PaypalRedirect" id="PaypalRedirect">
 118+
 119+ <input type="hidden" value="@amount" name="amount" />
 120+ <input type="hidden" value="NL" name="country" id="country" />
 121+ <input type="hidden" value="EUR" name="currency_code" />
 122+ <input type="hidden" value="@utm_source" name="utm_source"/>
 123+ <input type="hidden" value="@utm_medium" name="utm_medium"/>
 124+ <input type="hidden" value="@utm_campaign" name="utm_campaign"/>
 125+ <input type="hidden" value="@language" name="language"/>
 126+ <input type="hidden" value="@referrer" name="referrer"/>
 127+ <input type="hidden" value="@comment" name="comment"/>
 128+ <input type="hidden" value="@comment-option" name="comment-option"/>
 129+ <input type="hidden" value="1" name="email-opt"/>
 130+ <input type="hidden" value="@token" name="token"/>
 131+ <input type="hidden" value="@order_id" name="order_id"/>
 132+ <input type="hidden" value="@numAttempt" name="numAttempt"/>
 133+ <input type="hidden" value="@contribution_tracking_id" name="contribution_tracking_id"/>
 134+ <input type="hidden" value="@data_hash" name="data_hash"/>
 135+ <input type="hidden" value="@owa_session" name="owa_session"/>
 136+ <input type="hidden" value="@owa_ref" name="owa_ref"/>
 137+ <!-- new required fields -->
 138+ <input type="hidden" value="@gateway" name="gateway"/>
 139+ <input type="hidden" value="@payment_method" name="payment_method"/>
 140+ <!-- required fields for bt and dd -->
 141+ <input type="hidden" value="rtbt" name="payment_method"/>
 142+ <input type="hidden" value="rtbt_ideal" name="payment_submethod"/>
 143+ <!-- required fields omitted above -->
 144+ <input type="hidden" value="XX" name="state"/>
 145+ </form>
 146+ <div id="where-content">
 147+ {{LanguageSwitch|2011FR/core-appeal-whitebox-nodiv|@language}}
 148+ </div>
 149+ </div>
 150+ </div>
 151+ <p id="informationsharing">%donate_interface-informationsharing|url%</p>
 152+ <table>
 153+ <tr>
 154+ <td>
 155+ <ul id="moreinfolinks">
 156+ <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>
 157+ <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>
 158+ <li><a href="http://wikimediafoundation.org/wiki/Special:LandingCheck?landing_page=FAQ&language=@language&uselang=@language&country=@country">%donate_interface-faqs%</a></li>
 159+ <!--<li><a href="">%donate_interface-tax-info%</a></li>--><!-- TODO: localize the link -->
 160+ </ul>
 161+ </td>
 162+ <td>@verisign_logo</td>
 163+ </tr>
 164+ </table>
 165+ </div>
 166+ </td>
 167+ </tr>
 168+ </table>
 169+
 170+
 171+
 172+</div>
 173+
 174+<!-- Wikimedia Project logo
 175+<li id="footer-copyrightico"><a href="https://www.mediawiki.org//wikimediafoundation.org/"><img src="//bits.wikimedia.org/images/wikimedia-button.png" width="88" height="31" alt="Wikimedia Foundation"/></a></li>
 176+ -->
Property changes on: trunk/extensions/DonationInterface/globalcollect_gateway/forms/html/rtbt/rtbt-ideal.html
___________________________________________________________________
Added: svn:eol-style
1177 + native
Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/js/webitects.bt.js
@@ -39,9 +39,88 @@
4040 showAmount( $( 'input[name="amount"]' ) ); // lets go ahead and assume there is something to show
4141 }
4242 $( "#bt-continueBtn" ).live( "click", function() {
43 - if ( validate_personal( document.paypalcontribution ) ) {
 43+ if ( validateAmount() && validate_personal( document.paypalcontribution ) ) {
4444 document.paypalcontribution.action = actionURL;
4545 document.paypalcontribution.submit();
4646 }
4747 } );
48 -} );
\ No newline at end of file
 48+
 49+
 50+ // check to see if amount was passed from the previous step
 51+ var amount = $( 'input[name="amount"]' ); // get the amount field
 52+ if( amount == null || isNaN( amount.val() ) || amount.val() <= 0 ){
 53+ // the amount is not set
 54+ $( "#step1wrapper" ).slideDown();
 55+ $( "#selected-amount" ).html( '(EUR)' )
 56+
 57+ } else {
 58+ showAmount( $( 'input[name="amount"]' ) );
 59+ }
 60+
 61+ // Set selected amount to amount
 62+ $( 'input[name="amountRadio"]' ).click( function() {
 63+ setAmount( $( this ) );
 64+ } );
 65+ // reset the amount field when "other" is changed
 66+ $( "#other-amount" ).change( function() {
 67+ setAmount( $( this ) );
 68+ } );
 69+
 70+ $( "#step1header" ).click( function() {
 71+ $( "#step1wrapper" ).slideDown();
 72+ $( "#change-amount" ).hide();
 73+ } );
 74+
 75+
 76+ // If the form is being reloaded, restore the amount
 77+ var previousAmount = $( 'input[name="amount"]' ).val();
 78+ if ( previousAmount && previousAmount > 0 ) {
 79+ var matched = false;
 80+ $( 'input[name="amountRadio"]' ).each( function( index ) {
 81+ if ( $( this ).val() == previousAmount ) {
 82+ $( this ).attr( 'checked', true );
 83+ matched = true;
 84+ }
 85+ } );
 86+ if ( !matched ) {
 87+ $( 'input#input_amount_other' ).attr( 'checked', true );
 88+ $( 'input#other-amount' ).val( previousAmount );
 89+ }
 90+ }
 91+
 92+} );
 93+
 94+// set the hidden amount input to the value of the selected element
 95+function setAmount( e ) {
 96+ $( 'input[name="amount"]' ).val( e.val() );
 97+}
 98+// Display selected amount
 99+function showAmount( e ) {
 100+ $( "#selected-amount" ).html( + e.val() + " " + $( 'input[name="currency_code"]' ).val() );
 101+ $( "#change-amount" ).show();
 102+}
 103+function validateAmount() {
 104+ var error = true;
 105+ var amount = $( 'input[name="amount"]' ).val(); // get the amount
 106+ // Normalize weird amount formats.
 107+ // Don't mess with these unless you know what you're doing.
 108+ amount = amount.replace( /[,.](\d)$/, '\:$10' );
 109+ amount = amount.replace( /[,.](\d)(\d)$/, '\:$1$2' );
 110+ amount = amount.replace( /[,.]/g, '' );
 111+ amount = amount.replace( /:/, '.' );
 112+ $( 'input[name="amount"]' ).val( amount ); // set the new amount back into the form
 113+
 114+ // Check amount is a real number, sets error as true (good) if no issues
 115+ error = ( amount == null || isNaN( amount ) || amount.value <= 0 );
 116+
 117+ // Check amount is at least the minimum
 118+ var currency_code = $( 'input[name="currency_code"]' ).val();
 119+ if ( typeof( wgCurrencyMinimums[currency_code] ) == 'undefined' ) {
 120+ wgCurrencyMinimums[currency_code] = 1;
 121+ }
 122+ if ( amount < wgCurrencyMinimums[currency_code] || error ) {
 123+ alert( 'You must contribute at least $1'.replace( '$1', wgCurrencyMinimums[currency_code] + ' ' + currency_code ) );
 124+ error = true;
 125+ }
 126+ return !error;
 127+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011
r102839Sorry khorn. FU r102698 Adding webitects2nd.jspgehres01:35, 12 November 2011

Comments

#Comment by Khorn (WMF) (talk | contribs)   01:24, 12 November 2011

All references to 'js/webitects2nd.js' in RapidHTMLResources.php are currently causing my php error log to fill up with stack traces... File Not There.

#Comment by Pgehres (WMF) (talk | contribs)   01:36, 12 November 2011

Sigh. I hate RapidHtmlResources.php. Too many concurrent forms and cherry picking of things to commit. Fixed in r102839.

#Comment by Khorn (WMF) (talk | contribs)   01:38, 12 November 2011

And so it is. Thanks!

Status & tagging log