http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99834
Revision: 99834
Author: kaldari
Date: 2011-10-15 01:33:10 +0000 (Sat, 15 Oct 2011)
Log Message:
-----------
fixing path for Form.css, adding lightbox1 form
Modified Paths:
--------------
branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php
Added Paths:
-----------
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/css/lightbox1.css
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/js/
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
Modified:
branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php
===================================================================
--- branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php
2011-10-15 00:12:54 UTC (rev 99833)
+++ branches/fundraising/extensions/DonationInterface/gateway_forms/Form.php
2011-10-15 01:33:10 UTC (rev 99834)
@@ -89,7 +89,7 @@
global $wgScriptPath;
if ( !$style_path ) {
// load the default form CSS if the style path not
explicitly set
- $style_path = $wgScriptPath .
'/extensions/DonationInterface/payflowpro_gateway/forms/css/Form.css';
+ $style_path = $wgScriptPath .
'/extensions/DonationInterface/gateway_forms/css/Form.css';
}
$this->style_path = $style_path;
}
Added:
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/css/lightbox1.css
===================================================================
---
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/css/lightbox1.css
(rev 0)
+++
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/css/lightbox1.css
2011-10-15 01:33:10 UTC (rev 99834)
@@ -0,0 +1,288 @@
+/* Pitch */
+#pitch {
+ height: 236px;
+ background-image:
url(http://upload.wikimedia.org/wikipedia/foundation/d/dc/Jimmy_Appeal_2009.jpg);
+ background-position: right top;
+ background-repeat: no-repeat;
+ background-color: #1e1e1e;
+ border: 1px solid gray;
+ border-bottom-width: 0;
+}
+#pitch-head {
+ width: 50%;
+ font-size: 1.75em;
+ line-height: 1.5em;
+ color: white;
+ margin-top: 16px;
+ margin-left: 24px;
+}
+#pitch-body {
+ width: 50%;
+ font-size: 1em;
+ line-height: 1.5em;
+ color: white;
+ margin-top: 16px;
+ margin-left: 24px;
+}
+
+#appeal-head {
+ font-size: 1.5em;
+ line-height: 1.125em;
+ padding-bottom: 0.5em;
+ padding-top: 0.125em;
+}
+#appeal-body {
+ padding: 0.2em 0em;
+ font-size: 1.125em;
+ margin-bottom: 1em;
+}
+/* Donate */
+#donate {
+ font-size: 16px;
+}
+#amount-table td {
+ font-size: 100%;
+ padding: 4px;
+}
+
+#donate-content {
+ background-color: #CCE7CD;
+ border: 1px solid #5eac58;
+}
+#donate-head {
+ font-size: 1.5em;
+ line-height: 1.125em;
+ padding-bottom: 0.5em;
+ padding-top: 0.125em;
+ border-color: #5eac58;
+}
+#donate-body {
+ font-size: 1.25em;
+}
+
+.donate-body-small {
+ font-size: .75em;
+ margin-bottom:1em;
+}
+.donate-options {
+ text-align: center;
+}
+.donate-options input {
+ width: 15em;
+}
+
+input.button, select#input_currency_code {
+ font-size: 95%;
+}
+
+table {
+ background-color: transparent;
+}
+
+#footer {
+ background-image: none !important;
+}
+
+#mw-head-base {
+ height: 1em !important;
+}
+
+#mw-panel div.portal {
+ display: none !important;
+}
+
+#p-namespaces, #p-views, #p-cactions, #p-search, #p-personal, #catlinks,
#firstHeading, #contentSub, #siteSub {
+ display: none;
+}
+
+div#content {
+ background-color: transparent !important;
+ background-image: none !important;
+}
+
+div#mw-head-base {
+ background-image: none !important;
+}
+
+.l {
+ float: left;
+}
+.r {
+ float: right;
+}
+hr {
+ margin: 1.5em 0 0.5em;
+}
+h3 span {
+ font-weight: normal;
+}
+#amount-table td {
+ white-space: nowrap;
+}
+.call-l {
+ float: left;
+ margin: 0.2em 1em 1em 0;
+}
+.call-l, .call-r {
+ background: none repeat scroll 0 0 #FFFFFF;
+ border: 1px solid #444444;
+ font-size: 13px;
+ padding: 15px 20px;
+}
+.call-l h3, .call-r h3 {
+ font-size: 17px;
+}
+.call-l .loading, .call-r .loading {
+ background-image: url("../images/loading-white.gif");
+}
+.call-r {
+ float: right;
+ margin: 0.2em 0 1em 1em;
+}
+#loading {
+ font-size: 12px;
+ margin-left: 0.5em;
+ vertical-align: middle;
+}
+.loading {
+ background: url("../images/loading-green.gif") no-repeat scroll 50% 50%
transparent;
+ padding: 10px;
+}
+.mute {
+ font-size: 12px;
+}
+
+/* Callouts */
+.call-l, .call-r { width: 310px; }
+
+/* Layout */
+.clear { clear: both; }
+
+/* Lightbox */
+div.ui-dialog {
+ width: 600px;
+ overflow: hidden;
+}
+.ui-dialog .ui-dialog-title {
+ font-size: 1em;
+ font-weight: normal;
+}
+.ui-widget {
+ font-size: 1em;
+}
+.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
+ font-size: 0.8em;
+}
+input.btn {
+ font-size: 15px;
+ margin-bottom: 3px;
+}
+#dialog{
+ overflow: hidden;
+}
+.ui-dialog .ui-dialog-content {
+ padding: 0;
+}
+#steps{
+ width:600px;
+ overflow:hidden;
+ font-family:sans-serif;
+}
+.step{
+ float:left;
+ width:600px;
+ position: relative;
+}
+.step-content {
+ padding: 20px;
+ height: 260px;
+}
+
+#steps form fieldset{
+ border:none;
+ padding: 0;
+ margin: 0;
+}
+#steps form legend{
+ text-align:left;
+ color:#666;
+ font-size:24px;
+ /* text-shadow:1px 1px 1px #aaa; */
+ font-weight:bold;
+ float:left;
+ width:580px;
+ padding:8px 0px 5px 20px;
+ margin:10px 0px;
+}
+#steps form div.stuff{
+ clear:both;
+ margin:3px 0px;
+ width:auto;
+ padding:5px 10px;
+ /*
+ background-color:#f4f4f4;
+ border:1px solid #fff;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+ -moz-box-shadow:0px 0px 3px #aaa;
+ -webkit-box-shadow:0px 0px 3px #aaa;
+ box-shadow:0px 0px 3px #aaa;
+ */
+}
+#steps form div.stuff label{
+ width:140px;
+ float:left;
+ text-align:right;
+ margin-right:12px;
+ line-height:26px;
+ color:#666;
+ /* text-shadow:1px 1px 1px #fff; */
+ font-weight:bold;
+ font-size: 15px;
+}
+#steps form input:not([type=radio]),
+#steps form textarea,
+#steps form select{
+ background: #ffffff;
+ border: 1px solid #ccc;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ outline: none;
+ padding: 5px;
+}
+#steps form input.widefield{
+ width: 200px;
+ float:left;
+}
+#steps form input.large{
+ font-size: 20px;
+ line-height: 22px;
+ width: 62px;
+}
+#steps form input:focus{
+ -moz-box-shadow:0px 0px 3px #aaa;
+ -webkit-box-shadow:0px 0px 3px #aaa;
+ box-shadow:0px 0px 3px #aaa;
+ background-color:#FFFEEF;
+}
+#steps form p.submit{
+ background:none;
+ border:none;
+ -moz-box-shadow:none;
+ -webkit-box-shadow:none;
+ box-shadow:none;
+}
+#steps form a.back-button {
+ position: absolute;
+ bottom: 25px;
+ left: 25px;
+ margin: 0 !important;
+}
+#steps form a.continue-button {
+ position: absolute;
+ bottom: 25px;
+ right: 25px;
+ margin: 0 !important;
+}
\ No newline at end of file
Added:
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html
===================================================================
---
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html
(rev 0)
+++
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/html/lightbox1.html
2011-10-15 01:33:10 UTC (rev 99834)
@@ -0,0 +1,248 @@
+<!--[if lt IE 7]><style
type="text/css">body{behavior:url("/w/skins-1.17/vector/csshover.min.htc")}</style><![endif]-->
+<script type="text/javascript">
+mw.loader.load( 'jquery.ui.button' );
+mw.loader.load( 'jquery.ui.dialog' );
+var extensionPath = mw.config.get( 'wgServer' ) + mw.config.get(
'wgScriptPath' ) + '/extensions/DonationInterface';
+mw.loader.load( extensionPath + '/payflowpro_gateway/forms/js/lightbox1.js',
"text/javascript" );
+mw.loader.load( extensionPath + '/payflowpro_gateway/forms/css/lightbox1.css',
"text/css" );
+</script>
+
+ <div class="ltr">
+ <div id="appeal">
+ <div id="appeal-content">
+ <div class="call-r">
+ <div id="donate">
+ <h3 id="amount-heading">Donate</h3>
+
+ <form method="post" name="paypalcontribution">
+ <div style="display: block;" id="amount-content">
+
+ <table id="amount-table">
+ <tr>
+ <td><label><input type="radio" name="amountRadio"
value="5" /> $5</label></td>
+ <td><label><input type="radio" name="amountRadio"
value="10" /> $10</label></td>
+ <td><label><input type="radio" name="amountRadio"
value="20" /> $20</label></td>
+ <td><label><input type="radio" name="amountRadio"
value="35" /> $35</label></td>
+ </tr>
+ <tr>
+ <td><label><input type="radio" name="amountRadio"
value="50" /> $50</label></td>
+ <td><label><input type="radio" name="amountRadio"
value="100" /> $100</label></td>
+ <td><label><input type="radio" name="amountRadio"
value="250" /> $250</label></td>
+ <td><input type="radio" name="amountRadio"
id="input_amount_other" value="other" /> <label>$<input type="text"
name="amountGiven" size="4" id="other-amount" placeholder="Other"
onfocus="this.form.input_amount_other.checked=true;"/></label></td>
+ </tr>
+ </table>
+
+ <p class="donate-options">
+ <input class="btn" id="cc" value="Donate by Credit Card"
type="button">
+ <br><input class="btn" id="pp" value="Donate via PayPal"
type="button"><span id="loading"></span>
+ </p>
+ </div>
+
+ </form>
+ </div>
+
+ <div id="callout-content">
+ <hr>
+ <h3>Where your donation goes</h3>
+ <p><strong>Technology:</strong> Servers, bandwidth,
+maintenance, development. Wikipedia is the #5 website in the world and
+it runs on a fraction of what other top websites spend.</p>
+ <p><strong>People:</strong> The other top 10 website
+have thousands of employees. We have fewer than 100, making your
+donation a great investment in a highly-efficient not-for-profit
+organization.</p>
+ </div>
+ </div>
+
+ <h2 id="appeal-head"> <span class="mw-headline"
id="From_Wikipedia_programmer_Brandon_Harris">From Wikipedia programmer Brandon
Harris</span></h2>
+ <div id="appeal-body" class="plainlinks">
+ <p>I feel like I'm living the first line of my obituary.</p>
+ <p>I don't think there will be anything else that I do in my
+ life as important as what I do now for Wikipedia. We're not just
+building an encyclopedia, we're working to make people free. When we
+have access to free knowledge, we are better people. We understand the
+world is bigger than us, and we become infected with tolerance and
+understanding.</p>
+ <p>Wikipedia is the 5th largest website in the world. I work
+ at the small non-profit that keeps it on the web. We don't run ads
+because doing so would sacrifice our independence. The site is not and
+should never be a propaganda tool.</p>
+ <p>Our work is possible because of donations from our
+readers. Will you help protect Wikipedia by donating $5, $10, $20 or
+whatever you can afford?</p>
+ <p>I work at the Wikimedia Foundation because everything in
+my soul tells me it's the right thing to do. I've worked at huge tech
+companies, doing some job to build some crappy thing that's designed to
+steal money from some kid who doesn't know it. I would come home from
+work crushed.</p>
+ <p>You might not know this, but the Wikimedia Foundation
+operates with a very small staff. Most other top-ten sites have tens of
+thousands of people and massive budgets. But they produce a fraction of
+what we pull off with sticks and wire.</p>
+ <p>When you give to Wikipedia, you're supporting free
+knowledge around the world. You're not only leaving a legacy for your
+children and for their children, you're elevating people around the
+world who have access to this treasure. You're assuring that one day
+everyone else will too.</p>
+ <p>Thank you,</p>
+ <p><strong>Brandon Harris</strong><br></p>
+ <p>Programmer, Wikimedia Foundation</p>
+ </div>
+ </div>
+ </div>
+
+ <hr>
+
+ <p>We do not store your credit card information, and your personal data
is subject to our <a target="_blank"
href="http://wikimediafoundation.org/wiki/Donor_policy"> donor privacy
policy</a>.</p>
+ <p><a href="http://wikipedia.webitects.com/wiki/Ways_to_Give/en">More
information or other ways to give</a><br><a
href="http://wikipedia.webitects.com/wiki/FAQ/en">Answers to frequently asked
questions</a></p>
+ </div>
+
+<div id="dialog">
+ <div id="steps">
+ <form id="donationForm" name="donationForm" action=""
method="post">
+ <fieldset class="step">
+ <legend>Personal Information</legend>
+ <input type="hidden" name="gateway"
value="payflowpro" id="gateway" />
+ <input type="hidden" name="returnto"
value="Thank_You/en" />
+ <input type="hidden" value="@action"
name="action" />
+ <input type="hidden" value="@amount"
name="amount" />
+ <input type="hidden" value="@country"
name="country" id="country" />
+ <input type="hidden" value="@expiration"
name="expiration" />
+ <input type="hidden" value="@currency_code"
name="currency" />
+ <input type="hidden" value="@utm_source"
name="utm_source"/>
+ <input type="hidden" value="@utm_medium"
name="utm_medium"/>
+ <input type="hidden" value="@utm_campaign"
name="utm_campaign"/>
+ <input type="hidden" value="@language"
name="language"/>
+ <input type="hidden" value="@referrer"
name="referrer"/>
+ <input type="hidden" value="@comment"
name="comment"/>
+ <input type="hidden" value="@comment-option"
name="comment-option"/>
+ <input type="hidden" value="@email-opt"
name="email-opt"/>
+ <input type="hidden" value="processed"
name="payment_method"/>
+ <input type="hidden" value="@token"
name="token"/>
+ <input type="hidden" value="@order_id"
name="order_id"/>
+ <input type="hidden" value="@numAttempt"
name="numAttempt"/>
+ <input type="hidden"
value="@contribution_tracking_id" name="contribution_tracking_id"/>
+ <input type="hidden" value="@data_hash"
name="data_hash"/>
+ <input type="hidden" value="@owa_session"
name="owa_session"/>
+ <input type="hidden" value="@owa_ref"
name="owa_ref"/>
+ <div class="step-content">
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="fname">Name</label>
+ </td>
+ <td>
+ <input
name="fname" placeholder="First name" size="25" value="@fname" type="text"
maxlength="30" class="required" id="fname" style="width: 136px;" /> <input
name="lname" placeholder="Last name" size="25" value="@lname" type="text"
maxlength="30" class="required" id="lname" style="width: 136px;" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="street">Billing Address</label>
+ </td>
+ <td>
+ <input
name="street" placeholder="Street" size="30" value="@street" type="text"
maxlength="100" class="required" id="street" style="width: 258px;" />
+ </td>
+ </tr>
+ <tr>
+ <td
class="label"> </td>
+ <td>
+ <input
name="city" placeholder="City" class="required" size="18" value="@city"
type="text" maxlength="40" id="city" style="width: 136px;"/>
+ <select
name="state" class="required" id="state" value="@state"><option value=""
/><option value="AK">AK</option><option value="AL">AL</option><option
value="AR">AR</option><option value="AZ">AZ</option><option
value="CA">CA</option><option value="CO">CO</option><option
value="CT">CT</option><option value="DC">DC</option><option
value="DE">DE</option><option value="FL">FL</option><option
value="GA">GA</option><option value="HI">HI</option><option
value="IA">IA</option><option value="ID">ID</option><option
value="IL">IL</option><option value="IN">IN</option><option
value="KS">KS</option><option value="KY">KY</option><option
value="LA">LA</option><option value="MA">MA</option><option
value="MD">MD</option><option value="ME">ME</option><option
value="MI">MI</option><option value="MN">MN</option><option
value="MO">MO</option><option value="MS">MS</option><option
value="MT">MT</option><option value="NC">NC</option><option
value="ND">ND</option><option value="NE">NE</option><option
value="NH">NH</option><option value="NJ">NJ</option><option
value="NM">NM</option><option value="NV">NV</option><option
value="NY">NY</option><option value="OH">OH</option><option
value="OK">OK</option><option value="OR">OR</option><option
value="PA">PA</option><option value="PR">PR</option><option
value="RI">RI</option><option value="SC">SC</option><option
value="SD">SD</option><option value="TN">TN</option><option
value="TX">TX</option><option value="UT">UT</option><option
value="VA">VA</option><option value="VT">VT</option><option
value="WA">WA</option><option value="WI">WI</option><option
value="WV">WV</option><option value="WY">WY</option><option
value="AA">AA</option><option value="AE">AE</option><option
value="AP">AP</option></select>
+ <input
name="zip" placeholder="Zip" class="required" size="5" value="@zip" type="text"
maxlength="10" id="zip" style="width: 48px;" /><input type="hidden" value="US"
name="country" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="email">Email</label>
+ </td>
+ <td>
+ <input
name="emailAdd" placeholder="Email address" size="30" value="@emailAdd"
type="text" maxlength="100" class="required" id="email" style="width: 258px;" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ <a href="#"
class="continue-button">Continue</a>
+ </div>
+ </fieldset>
+ <fieldset class="step">
+ <legend>Payment</legend>
+ <div class="step-content">
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="email">Card Number</label>
+ </td>
+ <td>
+ <input
name="card_num" size="30" value="@card_num" type="text" maxlength="100"
class="required" id="card_num" style="width: 258px;" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="expiration">Expiration Date</label>
+ </td>
+ <td>
+ <select
name="mos" id="expiration">
+ <option
value="01">1 (January)</option>
+ <option
value="02">2 (February)</option>
+ <option
value="03">3 (March)</option>
+ <option
value="04">4 (April)</option>
+ <option
value="05">5 (May)</option>
+ <option
value="06">6 (June)</option>
+ <option
value="07">7 (July)</option>
+ <option
value="08">8 (August)</option>
+ <option
value="09">9 (September)</option>
+ <option
value="10">10 (October)</option>
+ <option
value="11">11 (November)</option>
+ <option
value="12">12 (December)</option>
+ </select>
+ /
+ <select
name="year" id="year">
+ <option
value="2011">2011</option>
+ <option
value="2012">2012</option>
+ <option
value="2013">2013</option>
+ <option
value="2014">2014</option>
+ <option
value="2015">2015</option>
+ <option
value="2016">2016</option>
+ <option
value="2017">2017</option>
+ <option
value="2018">2018</option>
+ <option
value="2019">2019</option>
+ <option
value="2020">2020</option>
+ <option
value="2021">2021</option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="stuff">
+ <table>
+ <tr>
+ <td class="label">
+ <label
for="email">Security Code</label>
+ </td>
+ <td>
+ <input
name="cvv" size="30" value="@cvv" type="text" maxlength="100" class="required"
id="cvv" style="width: 50px;" />
+ </td>
+ </tr>
+ </table>
+ </div>
+ <a href="#" class="back-button"
id="goback">Back</a>
+ <a href="#" class="continue-button"
id="submitcreditcard">Continue</a>
+ </div>
+ </fieldset>
+ </form>
+ </div>
+</div>
Added:
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
===================================================================
---
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
(rev 0)
+++
branches/fundraising/extensions/DonationInterface/payflowpro_gateway/forms/js/lightbox1.js
2011-10-15 01:33:10 UTC (rev 99834)
@@ -0,0 +1,186 @@
+$(function() {
+
+ $( '#dialog' ).dialog( {
+ width: 600,
+ resizable: false,
+ autoOpen: false,
+ modal: true,
+ title: 'Donate by Credit Card'
+ } );
+ $( '#cc' ).click( function() {
+ if ( validateAmount( document.paypalcontribution ) ) {
+ $( '#dialog' ).dialog( 'open' );
+ }
+ });
+ $( '#pp' ).click( function() {
+ if ( validateAmount( document.paypalcontribution ) ) {
+ $( "input[name='gateway']" ).val( 'paypal' );
+ document.paypalcontribution.action =
"https://wikimediafoundation.org/wiki/Special:ContributionTracking/en";
+ $( '#loading' ).html( "<img src='../images/loading.gif'
/> Redirecting to PayPal..." );
+ document.paypalcontribution.submit();
+ }
+ });
+
+ /* Set selected amount to amount */
+ $( "input[name='amountRadio']" ).click( function() { setAmount( $( this
) ); } );
+ $( "#other-amount" ).change( function() { setAmount( $( this ) ); } );
+ function setAmount(e) { $("input[name='amount']").val( e.val() ); }
+
+ /* number of fieldsets */
+ var fieldsetCount = $( '#donationForm' ).children().length;
+
+ /* current position of fieldset / navigation link */
+ var current = 1;
+
+ /*
+ Sum and save the widths of each one of the fieldsets.
+ Set the final sum as the total width of the steps element.
+ */
+ var stepsWidth = 0;
+ var widths = new Array();
+ $( '#steps .step' ).each( function(i) {
+ var $step = $( this );
+ widths[i] = stepsWidth;
+ stepsWidth += 600; // Hard-coding as $.width() is not
working for some reason
+ } );
+ $( '#steps' ).width( stepsWidth );
+
+ /* To avoid problems in IE, focus the first input of the form */
+ $( '#donationForm' ).children( ':first' ).find( ':input:first'
).focus();
+
+ /* make continue buttons */
+ $( 'a.continue-button' ).button();
+ $( 'a.continue-button' ).click( function(e) {
+ var $this = $( this );
+ current = $( this ).parent().parent().index() + 1;
+ if ( current == fieldsetCount ) {
+ finalSubmit();
+ return false;
+ }
+ if ( validateStep( current ) === 1 ) {
+ current = current + 1;
+ $( '#steps' ).stop().animate( { marginLeft: '-' +
widths[current - 1] + 'px' }, 500,
+ function() {
+ $( '#donationForm' ).children( ':nth-child(' +
parseInt(current) + ')' ).find( ':input:first' ).focus();
+ }
+ );
+ } else {
+ $this.blur();
+ }
+
+ e.preventDefault();
+ });
+
+ /* Make back button */
+ $( 'a.back-button' ).button();
+ $( 'a.back-button' ).click( function(e) {
+ var $this = $( this );
+ /* Set current to 1 less than previous step */
+ current = $( this ).parent().parent().index();
+
+ $( '#steps' ).stop().animate( { marginLeft: '+' +
widths[current - 1] + 'px' }, 500 );
+
+ e.preventDefault();
+ });
+
+ /* Hitting tab on the last input of each fieldset makes the form slide
to the next step. */
+ $( '#donationForm > fieldset' ).each( function() {
+ var $fieldset = $( this );
+ $fieldset.find( ':input:last' ).keydown( function(e) {
+ if ( e.which == 9 ){ // 9 is the char code for tab
+ $fieldset.find( 'a.continue-button' ).click();
+ /* Force the blur for validation */
+ e.preventDefault();
+ }
+ });
+ });
+
+ /*
+ Validates errors on all the fieldsets.
+ Records if the form has errors in $( '#donationForm' ).data().
+ */
+ function validateSteps() {
+ var formErrors = false;
+ for( var i = 1; i < fieldsetCount; ++i ) {
+ var error = validateStep(i);
+ if ( error == -1 ) formErrors = true;
+ }
+ $( '#donationForm' ).data( 'errors', formErrors );
+ }
+
+ function finalSubmit() {
+ var formErrors = false;
+ for( var i = 1; i <= fieldsetCount; ++i ) {
+ var error = validateStep(i);
+ if ( error == -1 ) formErrors = true;
+ }
+ $( '#donationForm' ).data( 'errors', formErrors );
+
+ if ( $( '#donationForm' ).data( 'errors' ) ) {
+ alert( 'Please correct the errors in the form.' );
+ return false;
+ } else {
+ /* Set country to US */
+ $( "input[name='country']" ).val('US' );
+
+ /* Set expiration date */
+ $( "input[name='expiration']" ).val(
+ $( "select[name='mos']" ).val() + $(
"select[name='year']" ).val().substring( 2, 4 )
+ )
+
+ /* Submit the form */
+ document.donationForm.action = $(
"input[name='action']" ).val();
+ document.donationForm.submit();
+ }
+ }
+
+ /*
+ validates one fieldset
+ returns -1 if errors found, or 1 if not
+ */
+ function validateStep( step ) {
+ var error = 1;
+ $( '#donationForm' ).children( ':nth-child(' + parseInt(step) +
')' ).find( ':input:not(button).required' ).each( function() {
+ var $this = $( this );
+ var valueLength = jQuery.trim( $this.val() ).length;
+
+ if ( valueLength == '' ) {
+ error = -1;
+ $this.css( 'background-color', '#FFEDEF' );
+ } else {
+ $this.css( 'background-color', '#FFFFFF' );
+ }
+ });
+
+ return error;
+ }
+
+ function validateAmount(){
+ var minimums = {
+ 'USD' : 1
+ };
+ var error = true;
+ var amount = $( "input[name='amount']" ).val(); // get the
amount
+ var otherAmount = amount // create a working copy
+ otherAmount = otherAmount.replace( /[,.](\d)$/, '\:$10' );
+ otherAmount = otherAmount.replace( /[,.](\d)(\d)$/, '\:$1$2' );
+ otherAmount = otherAmount.replace( /[,.]/g, '' );
+ otherAmount = otherAmount.replace( /:/, '.' );
+ amount = otherAmount; // reset amount to working copy amount
+ $( "input[name='amount']" ).val( amount ); // set the new
amount back into the form
+
+ // Check amount is a real number, sets error as true (good) if
no issues
+ error = ( amount == null || isNaN( amount ) || amount.value <=
0 );
+ // Check amount is at least the minimum
+ var currency = 'USD'; // hard-coded for these forms and tests
+ $( "input[name='currency']" ).val( currency );
+ if ( typeof( minimums[currency] ) == 'undefined' ) {
+ minimums[currency] = 1;
+ }
+ if ( amount < minimums[currency] || error ) {
+ alert( 'You must contribute at least $1'.replace('$1',
minimums[currency] + ' ' + currency ) );
+ error = true;
+ }
+ return !error;
+ };
+});
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs