Index: trunk/extensions/DonationInterface/donationinterface.php |
— | — | @@ -627,8 +627,8 @@ |
628 | 628 | $wgResourceModules[ 'pfp.form.core.validate' ] = array( |
629 | 629 | 'scripts' => 'validate_input.js', |
630 | 630 | 'dependencies' => array( 'pfp.form.core.pfp_css', 'ext.donationInterface.errorMessages' ), |
631 | | - 'localBasePath' => $donationinterface_dir . 'payflowpro_gateway', |
632 | | - 'remoteExtPath' => 'DonationInterface/payflowpro_gateway' |
| 631 | + 'localBasePath' => $donationinterface_dir . 'modules', |
| 632 | + 'remoteExtPath' => 'DonationInterface/modules' |
633 | 633 | ); |
634 | 634 | |
635 | 635 | // form placeholders |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/validate_input.js |
— | — | @@ -1,203 +0,0 @@ |
2 | | -window.addEvent = function(obj, evType, fn) { |
3 | | - if (obj.addEventListener){ |
4 | | - obj.addEventListener(evType, fn, false); |
5 | | - return true; |
6 | | - } else if (obj.attachEvent){ |
7 | | - var r = obj.attachEvent("on"+evType, fn); |
8 | | - return r; |
9 | | - } else { |
10 | | - return false; |
11 | | - } |
12 | | -}; |
13 | | - |
14 | | -window.getIfSessionSet = function() { |
15 | | - sajax_do_call( 'efPayflowGatewayCheckSession', [], checkSession ); |
16 | | -}; |
17 | | - |
18 | | -window.clearField = function( field, defaultValue ) { |
19 | | - if (field.value == defaultValue) { |
20 | | - field.value = ''; |
21 | | - field.style.color = 'black'; |
22 | | - } |
23 | | -}; |
24 | | -window.clearField2 = function( field, defaultValue ) { |
25 | | - if (field.value != defaultValue) { |
26 | | - field.value = ''; |
27 | | - field.style.color = 'black'; |
28 | | - } |
29 | | -}; |
30 | | - |
31 | | -window.switchToPayPal = function() { |
32 | | - document.getElementById('payflow-table-cc').style.display = 'none'; |
33 | | - document.getElementById('payflowpro_gateway-form-submit').style.display = 'none'; |
34 | | - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'block'; |
35 | | -}; |
36 | | -window.switchToCreditCard = function() { |
37 | | - document.getElementById('payflow-table-cc').style.display = 'table'; |
38 | | - document.getElementById('payflowpro_gateway-form-submit').style.display = 'block'; |
39 | | - document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none'; |
40 | | -}; |
41 | | - |
42 | | -/* |
43 | | - * Validates the personal information fields |
44 | | - * |
45 | | - * @input form The form containing the inputs to be checked |
46 | | - * |
47 | | - * @return boolean true if no errors, false otherwise (also uses an alert() to notify the user) |
48 | | - */ |
49 | | -window.validate_personal = function( form ){ |
50 | | - |
51 | | - // TODO: this form should only report a single error for the email address? |
52 | | - |
53 | | - var output = ''; |
54 | | - var currField = ''; |
55 | | - var i = 0; |
56 | | - var fields = [ 'fname','lname','street','city','zip', 'emailAdd' ], |
57 | | - numFields = fields.length; |
58 | | - for( i = 0; i < numFields; i++ ) { |
59 | | - if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) { |
60 | | - currField = mw.msg( 'donate_interface-error-msg-' + fields[i] ); |
61 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n'; |
62 | | - } |
63 | | - } |
64 | | - var stateField = document.getElementById( 'state' ); |
65 | | - var selectedState = stateField.options[stateField.selectedIndex].value; |
66 | | - var countryField = document.getElementById( 'country' ); |
67 | | - if( selectedState == 'YY' || selectedState == '' ) { |
68 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-state-province' ) + '.\r\n'; |
69 | | - } |
70 | | - |
71 | | - if( countryField.type == "select" ){ // country is a dropdown select |
72 | | - if( countryField.options[countryField.selectedIndex].value == '' ) { |
73 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
74 | | - } |
75 | | - } |
76 | | - else{ // country is a hidden or text input |
77 | | - if( countryField.value == '' ) { |
78 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
79 | | - } |
80 | | - } |
81 | | - |
82 | | - //set state to "outside us" |
83 | | - if ( form.country.value != 'US' ) { |
84 | | - form.state.value = 'XX'; |
85 | | - } |
86 | | - |
87 | | - // validate email address |
88 | | - var apos = form.emailAdd.value.indexOf("@"); |
89 | | - var dotpos = form.emailAdd.value.lastIndexOf("."); |
90 | | - |
91 | | - if( apos < 1 || dotpos-apos < 2 ) { |
92 | | - output += mw.msg( 'donate_interface-error-msg-email' ); |
93 | | - } |
94 | | - |
95 | | - if( output ) { |
96 | | - alert( output ); |
97 | | - return false; |
98 | | - } |
99 | | - |
100 | | - return true; |
101 | | -}; |
102 | | - |
103 | | -window.validate_form = function( form ) { |
104 | | - if( form == null ){ |
105 | | - form = document.payment |
106 | | - } |
107 | | - |
108 | | - var output = ''; |
109 | | - var currField = ''; |
110 | | - var i = 0; |
111 | | - var fields = ["emailAdd","fname","lname","street","city","zip","card_num","cvv" ], |
112 | | - numFields = fields.length; |
113 | | - for( i = 0; i < numFields; i++ ) { |
114 | | - if( document.getElementById( fields[i] ).value == '' ) { |
115 | | - currField = mw.msg( 'donate_interface-error-msg-' + fields[i] ); |
116 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n'; |
117 | | - } |
118 | | - } |
119 | | - var stateField = document.getElementById( 'state' ); |
120 | | - var countryField = document.getElementById( 'country' ); |
121 | | - if( stateField.options[stateField.selectedIndex].value == 'YY' ) { |
122 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-state-province' ) + '.\r\n'; |
123 | | - } |
124 | | - |
125 | | - if( countryField.type == "select" ){ // country is a dropdown select |
126 | | - if( countryField.options[countryField.selectedIndex].value == '' ) { |
127 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
128 | | - } |
129 | | - } |
130 | | - else{ // country is a hidden or text input |
131 | | - if( countryField.value == '' ) { |
132 | | - output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
133 | | - } |
134 | | - } |
135 | | - |
136 | | - //set state to "outside us" |
137 | | - if ( form.country.value != 'US' ) { |
138 | | - form.state.value = 'XX'; |
139 | | - } |
140 | | - |
141 | | - // validate email address |
142 | | - var apos = form.emailAdd.value.indexOf("@"); |
143 | | - var dotpos = form.emailAdd.value.lastIndexOf("."); |
144 | | - |
145 | | - if( apos < 1 || dotpos-apos < 2 ) { |
146 | | - output += mw.msg( 'donate_interface-error-msg-email' ); |
147 | | - } |
148 | | - |
149 | | - if( output ) { |
150 | | - alert( output ); |
151 | | - return false; |
152 | | - } |
153 | | - |
154 | | - return true; |
155 | | -}; |
156 | | - |
157 | | -window.submit_form = function( ccform ) { |
158 | | - if ( validate_form( ccform )) { |
159 | | - // weird hack!!!!!! for some reason doing just ccform.submit() throws an error.... |
160 | | - $j(ccform).submit(); |
161 | | - } |
162 | | - return true; |
163 | | -}; |
164 | | - |
165 | | -window.disableStates = function( form ) { |
166 | | - |
167 | | - if ( document.payment.country.value != 'US' ) { |
168 | | - document.payment.state.value = 'XX'; |
169 | | - } else { |
170 | | - document.payment.state.value = 'YY'; |
171 | | - } |
172 | | - |
173 | | - return true; |
174 | | -}; |
175 | | - |
176 | | -window.showCards = function() { |
177 | | - if ( document.getElementById('four_cards') && document.getElementById('two_cards') ) { |
178 | | - var index = document.getElementById('input_currency_code').selectedIndex; |
179 | | - if ( document.getElementById('input_currency_code').options[index].value == 'USD' ) { |
180 | | - document.getElementById('four_cards').style.display = 'table-row'; |
181 | | - document.getElementById('two_cards').style.display = 'none'; |
182 | | - } else { |
183 | | - document.getElementById('four_cards').style.display = 'none'; |
184 | | - document.getElementById('two_cards').style.display = 'table-row'; |
185 | | - } |
186 | | - } |
187 | | -}; |
188 | | - |
189 | | -window.cvv = ''; |
190 | | - |
191 | | -window.PopupCVV = function() { |
192 | | - cvv = window.open("", 'cvvhelp','scrollbars=yes,resizable=yes,width=600,height=400,left=200,top=100'); |
193 | | - cvv.document.write( payflowproGatewayCVVExplain ); |
194 | | - cvv.focus(); |
195 | | -}; |
196 | | - |
197 | | -window.CloseCVV = function() { |
198 | | - if (cvv) { |
199 | | - if (!cvv.closed) cvv.close(); |
200 | | - cvv = null; |
201 | | - } |
202 | | -}; |
203 | | - |
204 | | -window.onfocus = CloseCVV; |
Index: trunk/extensions/DonationInterface/modules/validate_input.js |
— | — | @@ -0,0 +1,203 @@ |
| 2 | +window.addEvent = function(obj, evType, fn) { |
| 3 | + if (obj.addEventListener){ |
| 4 | + obj.addEventListener(evType, fn, false); |
| 5 | + return true; |
| 6 | + } else if (obj.attachEvent){ |
| 7 | + var r = obj.attachEvent("on"+evType, fn); |
| 8 | + return r; |
| 9 | + } else { |
| 10 | + return false; |
| 11 | + } |
| 12 | +}; |
| 13 | + |
| 14 | +window.getIfSessionSet = function() { |
| 15 | + sajax_do_call( 'efPayflowGatewayCheckSession', [], checkSession ); |
| 16 | +}; |
| 17 | + |
| 18 | +window.clearField = function( field, defaultValue ) { |
| 19 | + if (field.value == defaultValue) { |
| 20 | + field.value = ''; |
| 21 | + field.style.color = 'black'; |
| 22 | + } |
| 23 | +}; |
| 24 | +window.clearField2 = function( field, defaultValue ) { |
| 25 | + if (field.value != defaultValue) { |
| 26 | + field.value = ''; |
| 27 | + field.style.color = 'black'; |
| 28 | + } |
| 29 | +}; |
| 30 | + |
| 31 | +window.switchToPayPal = function() { |
| 32 | + document.getElementById('payflow-table-cc').style.display = 'none'; |
| 33 | + document.getElementById('payflowpro_gateway-form-submit').style.display = 'none'; |
| 34 | + document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'block'; |
| 35 | +}; |
| 36 | +window.switchToCreditCard = function() { |
| 37 | + document.getElementById('payflow-table-cc').style.display = 'table'; |
| 38 | + document.getElementById('payflowpro_gateway-form-submit').style.display = 'block'; |
| 39 | + document.getElementById('payflowpro_gateway-form-submit-paypal').style.display = 'none'; |
| 40 | +}; |
| 41 | + |
| 42 | +/* |
| 43 | + * Validates the personal information fields |
| 44 | + * |
| 45 | + * @input form The form containing the inputs to be checked |
| 46 | + * |
| 47 | + * @return boolean true if no errors, false otherwise (also uses an alert() to notify the user) |
| 48 | + */ |
| 49 | +window.validate_personal = function( form ){ |
| 50 | + |
| 51 | + // TODO: this form should only report a single error for the email address? |
| 52 | + |
| 53 | + var output = ''; |
| 54 | + var currField = ''; |
| 55 | + var i = 0; |
| 56 | + var fields = ['fname','lname','street','city','zip', 'emailAdd'], |
| 57 | + numFields = fields.length; |
| 58 | + for( i = 0; i < numFields; i++ ) { |
| 59 | + // See if the field is empty or equal to the placeholder |
| 60 | + if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) { |
| 61 | + currField = mw.msg( 'donate_interface-error-msg-' + fields[i] ); |
| 62 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n'; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + var stateField = document.getElementById( 'state' ); |
| 67 | + if ( stateField && stateField.type == 'select-one' ) { // state is a dropdown select |
| 68 | + var selectedState = stateField.options[stateField.selectedIndex].value; |
| 69 | + if ( selectedState == 'YY' || selectedState == '' ) { |
| 70 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-state-province' ) + '.\r\n'; |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + var countryField = document.getElementById( 'country' ); |
| 75 | + if ( countryField && countryField.type == 'select-one' ) { // country is a dropdown select |
| 76 | + if ( countryField.options[countryField.selectedIndex].value == '' ) { |
| 77 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
| 78 | + } |
| 79 | + } else { // country is a hidden or text input |
| 80 | + if ( countryField.value == '' ) { |
| 81 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + // validate email address |
| 86 | + var apos = form.emailAdd.value.indexOf("@"); |
| 87 | + var dotpos = form.emailAdd.value.lastIndexOf("."); |
| 88 | + |
| 89 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 90 | + output += mw.msg( 'donate_interface-error-msg-email' ); |
| 91 | + } |
| 92 | + |
| 93 | + if( output ) { |
| 94 | + alert( output ); |
| 95 | + return false; |
| 96 | + } |
| 97 | + |
| 98 | + return true; |
| 99 | +}; |
| 100 | + |
| 101 | +window.validate_form = function( form ) { |
| 102 | + if( form == null ){ |
| 103 | + form = document.payment |
| 104 | + } |
| 105 | + |
| 106 | + var output = ''; |
| 107 | + var currField = ''; |
| 108 | + var i = 0; |
| 109 | + var fields = ['fname','lname','street','city','zip', 'emailAdd', 'card_num','cvv'], |
| 110 | + numFields = fields.length; |
| 111 | + for( i = 0; i < numFields; i++ ) { |
| 112 | + // See if the field is empty or equal to the placeholder |
| 113 | + if( document.getElementById( fields[i] ).value == '' || document.getElementById( fields[i] ).value == mw.msg( 'donate_interface-donor-'+fields[i] ) ) { |
| 114 | + currField = mw.msg( 'donate_interface-error-msg-' + fields[i] ); |
| 115 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + currField + '.\r\n'; |
| 116 | + } |
| 117 | + } |
| 118 | + |
| 119 | + var stateField = document.getElementById( 'state' ); |
| 120 | + console.debug(stateField); |
| 121 | + console.debug(stateField.type); |
| 122 | + if ( stateField && stateField.type == 'select-one' ) { // state is a dropdown select |
| 123 | + var selectedState = stateField.options[stateField.selectedIndex].value; |
| 124 | + console.debug(selectedState); |
| 125 | + if ( selectedState == 'YY' || selectedState == '' ) { |
| 126 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-state-province' ) + '.\r\n'; |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + var countryField = document.getElementById( 'country' ); |
| 131 | + if ( countryField && countryField.type == 'select-one' ) { // country is a dropdown select |
| 132 | + if ( countryField.options[countryField.selectedIndex].value == '' ) { |
| 133 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
| 134 | + } |
| 135 | + } else { // country is a hidden or text input |
| 136 | + if ( countryField.value == '' ) { |
| 137 | + output += mw.msg( 'donate_interface-error-msg-js' ) + ' ' + mw.msg( 'donate_interface-error-msg-country' ) + '.\r\n'; |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + // validate email address |
| 142 | + var apos = form.emailAdd.value.indexOf("@"); |
| 143 | + var dotpos = form.emailAdd.value.lastIndexOf("."); |
| 144 | + |
| 145 | + if( apos < 1 || dotpos-apos < 2 ) { |
| 146 | + output += mw.msg( 'donate_interface-error-msg-email' ); |
| 147 | + } |
| 148 | + |
| 149 | + if( output ) { |
| 150 | + alert( output ); |
| 151 | + return false; |
| 152 | + } |
| 153 | + |
| 154 | + return true; |
| 155 | +}; |
| 156 | + |
| 157 | +window.submit_form = function( ccform ) { |
| 158 | + if ( validate_form( ccform )) { |
| 159 | + // weird hack!!!!!! for some reason doing just ccform.submit() throws an error.... |
| 160 | + $j(ccform).submit(); |
| 161 | + } |
| 162 | + return true; |
| 163 | +}; |
| 164 | + |
| 165 | +window.disableStates = function( form ) { |
| 166 | + |
| 167 | + if ( document.payment.country.value != 'US' ) { |
| 168 | + document.payment.state.value = 'XX'; |
| 169 | + } else { |
| 170 | + document.payment.state.value = 'YY'; |
| 171 | + } |
| 172 | + |
| 173 | + return true; |
| 174 | +}; |
| 175 | + |
| 176 | +window.showCards = function() { |
| 177 | + if ( document.getElementById('four_cards') && document.getElementById('two_cards') ) { |
| 178 | + var index = document.getElementById('input_currency_code').selectedIndex; |
| 179 | + if ( document.getElementById('input_currency_code').options[index].value == 'USD' ) { |
| 180 | + document.getElementById('four_cards').style.display = 'table-row'; |
| 181 | + document.getElementById('two_cards').style.display = 'none'; |
| 182 | + } else { |
| 183 | + document.getElementById('four_cards').style.display = 'none'; |
| 184 | + document.getElementById('two_cards').style.display = 'table-row'; |
| 185 | + } |
| 186 | + } |
| 187 | +}; |
| 188 | + |
| 189 | +window.cvv = ''; |
| 190 | + |
| 191 | +window.PopupCVV = function() { |
| 192 | + cvv = window.open("", 'cvvhelp','scrollbars=yes,resizable=yes,width=600,height=400,left=200,top=100'); |
| 193 | + cvv.document.write( payflowproGatewayCVVExplain ); |
| 194 | + cvv.focus(); |
| 195 | +}; |
| 196 | + |
| 197 | +window.CloseCVV = function() { |
| 198 | + if (cvv) { |
| 199 | + if (!cvv.closed) cvv.close(); |
| 200 | + cvv = null; |
| 201 | + } |
| 202 | +}; |
| 203 | + |
| 204 | +window.onfocus = CloseCVV; |
Property changes on: trunk/extensions/DonationInterface/modules/validate_input.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 205 | + native |