Source Code Documentation


s2member-pro\includes\separates\gateways\paypal\paypal.js


  1. /**
  2. * Core JavaScript routines for PayPal®.
  3. *
  4. * Copyright: © 2009-2011
  5. * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
  6. * ( coded in the USA )
  7. *
  8. * This WordPress® plugin ( s2Member Pro ) is comprised of two parts:
  9. *
  10. * o (1) Its PHP code is licensed under the GPL license, as is WordPress®.
  11. * You should have received a copy of the GNU General Public License,
  12. * along with this software. In the main directory, see: /licensing/
  13. * If not, see: {@link http://www.gnu.org/licenses/}.
  14. *
  15. * o (2) All other parts of ( s2Member Pro ); including, but not limited to:
  16. * the CSS code, some JavaScript code, images, and design;
  17. * are licensed according to the license purchased.
  18. * See: {@link http://www.s2member.com/prices/}
  19. *
  20. * Unless you have our prior written consent, you must NOT directly or indirectly license,
  21. * sub-license, sell, resell, or provide for free; part (2) of the s2Member Pro Module;
  22. * or make an offer to do any of these things. All of these things are strictly
  23. * prohibited with part (2) of the s2Member Pro Module.
  24. *
  25. * Your purchase of s2Member Pro includes free lifetime upgrades via s2Member.com
  26. * ( i.e. new features, bug fixes, updates, improvements ); along with full access
  27. * to our video tutorial library: {@link http://www.s2member.com/videos/}
  28. *
  29. * @package s2Member\PayPal
  30. * @since 1.5
  31. */
  32. jQuery(document).ready (function($)
  33. {
  34. var $clForm, $upForm, $rgForm, $spForm, $coForm, jumpToResponses, preloadAjaxLoader, ariaTrue = {'aria-required': 'true'}, ariaFalse = {'aria-required': 'false'}, disabled = {'disabled': 'disabled'}, ariaFalseDis = {'aria-required': 'false', 'disabled': 'disabled'};
  35. /**/
  36. preloadAjaxLoader = new Image (), preloadAjaxLoader.src = '<?php echo $vars["i"]; ?>/ajax-loader.gif';
  37. /**/
  38. if (($clForm = $('form#s2member-pro-paypal-cancellation-form')).length === 1)
  39. {
  40. var captchaSection = 'div#s2member-pro-paypal-cancellation-form-captcha-section', submissionSection = 'div#s2member-pro-paypal-cancellation-form-submission-section', $submissionButton = $(submissionSection + ' input#s2member-pro-paypal-cancellation-submit');
  41. /**/
  42. ws_plugin__s2member_animateProcessing($submissionButton, 'reset'), $submissionButton.removeAttr ('disabled');
  43. /**/
  44. $clForm.submit ( /* Form validation. */function()
  45. {
  46. var context = this, label = '', error = '', errors = '';
  47. /**/
  48. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  49. /**/
  50. $(':input', context).each ( /* Go through them all together. */function()
  51. {
  52. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
  53. /**/
  54. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  55. {
  56. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  57. errors += /* Collect errors. */ error + '\n\n';
  58. }
  59. });
  60. /**/
  61. if (errors = $.trim (errors))
  62. {
  63. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  64. /**/
  65. return false;
  66. }
  67. /**/
  68. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  69. {
  70. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Security Code missing. Please try again.", "s2member-front", "s2member")); ?>');
  71. /**/
  72. return false;
  73. }
  74. /**/
  75. $submissionButton.attr (disabled), ws_plugin__s2member_animateProcessing($submissionButton);
  76. /**/
  77. return true;
  78. });
  79. }
  80. /**/
  81. else if (($upForm = $('form#s2member-pro-paypal-update-form')).length === 1)
  82. {
  83. var handleBillingMethod, billingMethodSection = 'div#s2member-pro-paypal-update-form-billing-method-section', billingAddressSection = 'div#s2member-pro-paypal-update-form-billing-address-section', cardType = billingMethodSection + ' input[name="s2member_pro_paypal_update\[card_type\]"]', captchaSection = 'div#s2member-pro-paypal-update-form-captcha-section', submissionSection = 'div#s2member-pro-paypal-update-form-submission-section', $submissionButton = $(submissionSection + ' input#s2member-pro-paypal-update-submit');
  84. /**/
  85. ws_plugin__s2member_animateProcessing($submissionButton, 'reset'), $submissionButton.removeAttr ('disabled');
  86. /**/
  87. (handleBillingMethod = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  88. {
  89. var billingMethod = /* Billing Method. */ $(cardType + ':checked').val ();
  90. /**/
  91. if ($.inArray (billingMethod, ['Visa', 'MasterCard', 'Amex', 'Discover']) !== -1)
  92. {
  93. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div').show ();
  94. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaTrue);
  95. /**/
  96. $(billingMethodSection + ' > div#s2member-pro-paypal-update-form-card-start-date-issue-number-div').hide ();
  97. $(billingMethodSection + ' > div#s2member-pro-paypal-update-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  98. /**/
  99. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div').show ();
  100. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaTrue);
  101. /**/
  102. $(billingAddressSection).show (), (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-update-card-number').focus () : null;
  103. }
  104. else if ($.inArray (billingMethod, ['Maestro', 'Solo']) !== -1)
  105. {
  106. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div').show ();
  107. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaTrue);
  108. /**/
  109. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div').show ();
  110. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaTrue);
  111. /**/
  112. $(billingAddressSection).show (), (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-update-card-number').focus () : null;
  113. }
  114. else if /* Else there was no Billing Method supplied. */ (!billingMethod)
  115. {
  116. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div').hide ();
  117. $(billingMethodSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaFalse);
  118. /**/
  119. $(billingMethodSection + ' > div#s2member-pro-paypal-update-form-card-type-div').show ();
  120. $(billingMethodSection + ' > div#s2member-pro-paypal-update-form-card-type-div :input').attr (ariaTrue);
  121. /**/
  122. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div').hide ();
  123. $(billingAddressSection + ' > div.s2member-pro-paypal-update-form-div :input').attr (ariaFalse);
  124. /**/
  125. $(billingAddressSection).hide (), (eventTrigger) ? $(submissionSection + ' input#s2member-pro-paypal-update-submit').focus () : null;
  126. }
  127. }) ();
  128. /**/
  129. $(cardType).click (handleBillingMethod).change (handleBillingMethod);
  130. /**/
  131. $upForm.submit ( /* Form validation. */function()
  132. {
  133. var context = this, label = '', error = '', errors = '';
  134. /**/
  135. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  136. /**/
  137. if (!$(cardType + ':checked').val ())
  138. {
  139. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please choose a Billing Method.", "s2member-front", "s2member")); ?>');
  140. /**/
  141. return false;
  142. }
  143. /**/
  144. $(':input', context).each ( /* Go through them all together. */function()
  145. {
  146. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
  147. /**/
  148. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  149. {
  150. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  151. errors += /* Collect errors. */ error + '\n\n';
  152. }
  153. });
  154. /**/
  155. if (errors = $.trim (errors))
  156. {
  157. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  158. /**/
  159. return false;
  160. }
  161. /**/
  162. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  163. {
  164. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Security Code missing. Please try again.", "s2member-front", "s2member")); ?>');
  165. /**/
  166. return false;
  167. }
  168. /**/
  169. $submissionButton.attr (disabled), ws_plugin__s2member_animateProcessing($submissionButton);
  170. /**/
  171. return true;
  172. });
  173. }
  174. /**/
  175. else if (($rgForm = $('form#s2member-pro-paypal-registration-form')).length === 1)
  176. {
  177. var handleNameIssues, handlePasswordIssues, registrationSection = 'div#s2member-pro-paypal-registration-form-registration-section', captchaSection = 'div#s2member-pro-paypal-registration-form-captcha-section', submissionSection = 'div#s2member-pro-paypal-registration-form-submission-section', $submissionButton = $(submissionSection + ' input#s2member-pro-paypal-registration-submit');
  178. /**/
  179. ws_plugin__s2member_animateProcessing($submissionButton, 'reset'), $submissionButton.removeAttr ('disabled');
  180. /**/
  181. (handleNameIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  182. {
  183. if ($(submissionSection + ' input#s2member-pro-paypal-registration-names-not-required-or-not-possible').length)
  184. {
  185. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-first-name-div').hide ();
  186. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-first-name-div :input').attr (ariaFalseDis);
  187. /**/
  188. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-last-name-div').hide ();
  189. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-last-name-div :input').attr (ariaFalseDis);
  190. }
  191. }) ();
  192. /**/
  193. (handlePasswordIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  194. {
  195. if ($(submissionSection + ' input#s2member-pro-paypal-registration-password-not-required-or-not-possible').length)
  196. {
  197. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-password-div').hide ();
  198. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-password-div :input').attr (ariaFalseDis);
  199. }
  200. }) ();
  201. /**/
  202. $(registrationSection + ' > div#s2member-pro-paypal-registration-form-password-div :input').keyup (function()
  203. {
  204. ws_plugin__s2member_passwordStrength($(registrationSection + ' input#s2member-pro-paypal-registration-username'), $(registrationSection + ' input#s2member-pro-paypal-registration-password1'), $(registrationSection + ' input#s2member-pro-paypal-registration-password2'), $(registrationSection + ' div#s2member-pro-paypal-registration-form-password-strength'));
  205. });
  206. /**/
  207. $rgForm.submit ( /* Form validation. */function()
  208. {
  209. var context = this, label = '', error = '', errors = '';
  210. /**/
  211. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  212. /**/
  213. var $password1 = $(registrationSection + ' input#s2member-pro-paypal-registration-password1[aria-required="true"]');
  214. var $password2 = $(registrationSection + ' input#s2member-pro-paypal-registration-password2');
  215. /**/
  216. $(':input', context).each ( /* Go through them all together. */function()
  217. {
  218. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
  219. /**/
  220. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  221. {
  222. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  223. errors += /* Collect errors. */ error + '\n\n';
  224. }
  225. });
  226. /**/
  227. if (errors = $.trim (errors))
  228. {
  229. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  230. /**/
  231. return false;
  232. }
  233. /**/
  234. else if ($password1.length && $.trim ($password1.val ()) !== $.trim ($password2.val ()))
  235. {
  236. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');
  237. /**/
  238. return false;
  239. }
  240. /**/
  241. else if /* Enforce minimum length requirement here. */ ($password1.length && $.trim ($password1.val ()).length < 6)
  242. {
  243. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');
  244. /**/
  245. return false;
  246. }
  247. /**/
  248. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  249. {
  250. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Security Code missing. Please try again.", "s2member-front", "s2member")); ?>');
  251. /**/
  252. return false;
  253. }
  254. /**/
  255. $submissionButton.attr (disabled), ws_plugin__s2member_animateProcessing($submissionButton);
  256. /**/
  257. return true;
  258. });
  259. }
  260. /**/
  261. else if (($spForm = $('form#s2member-pro-paypal-sp-checkout-form')).length === 1)
  262. {
  263. var handleCouponIssues, handleTaxIssues, taxMayApply = true, calculateTax, cTaxDelay, cTaxTimeout, cTaxReq, cTaxLocation, handleExistingUsers, handleBillingMethod, couponSection = 'div#s2member-pro-paypal-sp-checkout-form-coupon-section', couponApplyButton = couponSection + ' input#s2member-pro-paypal-sp-checkout-coupon-apply', registrationSection = 'div#s2member-pro-paypal-sp-checkout-form-registration-section', billingMethodSection = 'div#s2member-pro-paypal-sp-checkout-form-billing-method-section', cardType = billingMethodSection + ' input[name="s2member_pro_paypal_sp_checkout\[card_type\]"]', billingAddressSection = 'div#s2member-pro-paypal-sp-checkout-form-billing-address-section', $ajaxTaxDiv = $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-ajax-tax-div'), captchaSection = 'div#s2member-pro-paypal-sp-checkout-form-captcha-section', submissionSection = 'div#s2member-pro-paypal-sp-checkout-form-submission-section', submissionNonceVerification = submissionSection + ' input#s2member-pro-paypal-sp-checkout-nonce', submissionButton = submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit';
  264. /**/
  265. var submitButton = '<input type="submit" id="s2member-pro-paypal-sp-checkout-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-sp-checkout-submit" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Submit Form", "s2member-front", "s2member"))); ?>" tabindex="500" />';
  266. var submitExpressCheckoutButton = '<input type="image" src="https://www.paypal.com/<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("en_US", "s2member-front paypal-button-lang-code", "s2member"))); ?>/i/btn/btn_xpressCheckout.gif" id="s2member-pro-paypal-sp-checkout-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-sp-checkout-submit" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Submit Form", "s2member-front", "s2member"))); ?>" tabindex="500" />';
  267. /**/
  268. ws_plugin__s2member_animateProcessing($(submissionButton), 'reset'), $(submissionButton).removeAttr ('disabled'), $(couponApplyButton).removeAttr ('disabled');
  269. /**/
  270. (handleCouponIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  271. {
  272. if ($(submissionSection + ' input#s2member-pro-paypal-sp-checkout-coupons-not-required-or-not-possible').length)
  273. {
  274. $(couponSection).hide /* Not accepting Coupons on this particular form. */ ();
  275. }
  276. else /* This is turned off by default for smoother loading. ( via: display:none ). */
  277. $(couponSection).show /* OK. So we need to display this now. */ ();
  278. }) ();
  279. /**/
  280. (handleTaxIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  281. {
  282. if ($(submissionSection + ' input#s2member-pro-paypal-sp-checkout-tax-not-required-or-not-possible').length)
  283. {
  284. $ajaxTaxDiv.hide (), taxMayApply = /* Tax does NOT even apply. */ false;
  285. }
  286. }) ();
  287. /**/
  288. (calculateTax = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  289. {
  290. if (taxMayApply && !(eventTrigger && eventTrigger.interval && document.activeElement.id === 's2member-pro-paypal-sp-checkout-country'))
  291. {
  292. var attr = $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-attr').val ();
  293. var state = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').val ());
  294. var country = $(billingAddressSection + ' select#s2member-pro-paypal-sp-checkout-country').val ();
  295. var zip = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-zip').val ());
  296. var thisTaxLocation = /* Three part location. */ state + '|' + country + '|' + zip;
  297. /**/
  298. if (state && country && zip && thisTaxLocation && (!cTaxLocation || cTaxLocation !== thisTaxLocation) && (cTaxLocation = thisTaxLocation))
  299. {
  300. (cTaxReq) ? /* Abort. */ cTaxReq.abort () : null, /* Clear. */ clearTimeout(cTaxTimeout), cTaxTimeout = null;
  301. /**/
  302. $ajaxTaxDiv.html ('<div><img src="<?php echo $vars["i"]; ?>/ajax-loader.gif" alt="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Calculating Sales Tax...", "s2member-front", "s2member"))); ?>" /> <?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("calculating sales tax...", "s2member-front", "s2member")); ?></div>');
  303. /**/
  304. cTaxTimeout = setTimeout( /* Create a new cTaxTimeout with a one second delay. */function()
  305. {
  306. cTaxReq = $.post ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (admin_url ("/admin-ajax.php")); ?>', {'action': 'ws_plugin__s2member_pro_paypal_ajax_tax', 'ws_plugin__s2member_pro_paypal_ajax_tax': '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (c_ws_plugin__s2member_utils_encryption::encrypt ("ws-plugin--s2member-pro-paypal-ajax-tax")); ?>', 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[attr]': attr, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[state]': state, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[country]': country, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[zip]': zip}, function(response)
  307. {
  308. clearTimeout /* Clear cTaxTimeout. */(cTaxTimeout), cTaxTimeout = null;
  309. /**/
  310. try /* Try/catch here. jQuery will sometimes return a successful response in IE, whenever the connection is aborted with a null response. */
  311. {
  312. /* translators: `Sales Tax (Today)` and `Total (Today)` The word `Today` is displayed when/if a trial period is offered. The word `Today` is translated elsewhere. */
  313. $ajaxTaxDiv.html ('<div>' + $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("<strong>Sales Tax%s:</strong> %s<br /><strong>— Total%s:</strong> %s", "s2member-front", "s2member")); ?>', ((response.trial) ? ' ' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Today", "s2member-front", "s2member")); ?>' : ''), ((response.tax_per) ? '<em>' + response.tax_per + '</em> ( ' + response.cur_symbol + '' + response.tax + ' )' : response.cur_symbol + '' + response.tax), ((response.trial) ? ' ' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Today", "s2member-front", "s2member")); ?>' : ''), response.cur_symbol + '' + response.total) + '</div>');
  314. }
  315. catch (e) {}
  316. /**/
  317. }, 'json');
  318. /**/
  319. }, ((eventTrigger && eventTrigger.keyCode) ? 1000 : 100));
  320. }
  321. /**/
  322. else if (!state || !country || !zip || !thisTaxLocation)
  323. $ajaxTaxDiv.html (''), cTaxLocation = null;
  324. }
  325. }) ();
  326. /**/
  327. cTaxDelay = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  328. {
  329. setTimeout( /* Trigger event handler with a brief delay. */function()
  330. {
  331. calculateTax(eventTrigger);
  332. }, 10); /* Brief delay. */
  333. }
  334. /**/
  335. $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  336. $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-zip').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  337. $(billingAddressSection + ' select#s2member-pro-paypal-sp-checkout-country').bind ('change', calculateTax);
  338. /**/
  339. setInterval( /* Helps with things like Google's Autofill feature. */function()
  340. {
  341. calculateTax /* Identify as interval trigger. */({interval: true});
  342. }, 1000);
  343. /**/
  344. (handleExistingUsers = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  345. {
  346. if /* If User/Member is already logged in. */ (S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
  347. {
  348. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-first-name').each (function()
  349. {
  350. var $this = $(this), val = $this.val ();
  351. (!val) ? $this.val (S2MEMBER_CURRENT_USER_FIRST_NAME) : null;
  352. });
  353. /**/
  354. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-last-name').each (function()
  355. {
  356. var $this = $(this), val = $this.val ();
  357. (!val) ? $this.val (S2MEMBER_CURRENT_USER_LAST_NAME) : null;
  358. });
  359. /**/
  360. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-email').each (function()
  361. {
  362. var $this = $(this), val = $this.val ();
  363. (!val) ? $this.val (S2MEMBER_CURRENT_USER_EMAIL) : null;
  364. });
  365. }
  366. }) ();
  367. /**/
  368. (handleBillingMethod = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  369. {
  370. var billingMethod = /* Billing Method. */ $(cardType + ':checked').val ();
  371. /**/
  372. if ($.inArray (billingMethod, ['Visa', 'MasterCard', 'Amex', 'Discover']) !== -1)
  373. {
  374. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  375. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  376. /**/
  377. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div').hide ();
  378. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  379. /**/
  380. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  381. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  382. /**/
  383. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  384. /**/
  385. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitButton);
  386. /**/
  387. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-sp-checkout-card-number').focus () : null;
  388. }
  389. else if ($.inArray (billingMethod, ['Maestro', 'Solo']) !== -1)
  390. {
  391. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  392. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  393. /**/
  394. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  395. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  396. /**/
  397. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  398. /**/
  399. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitButton);
  400. /**/
  401. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-sp-checkout-card-number').focus () : null;
  402. }
  403. else if ((!billingMethod || billingMethod === 'PayPal') && taxMayApply)
  404. {
  405. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  406. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  407. /**/
  408. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-number-div').hide ();
  409. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-number-div :input').attr (ariaFalse);
  410. /**/
  411. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-expiration-div').hide ();
  412. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-expiration-div :input').attr (ariaFalse);
  413. /**/
  414. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-verification-div').hide ();
  415. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-verification-div :input').attr (ariaFalse);
  416. /**/
  417. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div').hide ();
  418. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  419. /**/
  420. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  421. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  422. /**/
  423. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-street-div').hide ();
  424. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-street-div :input').attr (ariaFalse);
  425. /**/
  426. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-city-div').hide ();
  427. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-city-div :input').attr (ariaFalse);
  428. /**/
  429. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitExpressCheckoutButton);
  430. /**/
  431. (eventTrigger) ? $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').focus () : null;
  432. }
  433. else if (!billingMethod || billingMethod === 'PayPal')
  434. {
  435. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').hide ();
  436. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaFalse);
  437. /**/
  438. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-type-div').show ();
  439. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-type-div :input').attr (ariaTrue);
  440. /**/
  441. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').hide ();
  442. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaFalse);
  443. /**/
  444. $(billingAddressSection).hide (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitExpressCheckoutButton);
  445. /**/
  446. (eventTrigger) ? $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').focus () : null;
  447. }
  448. /**/
  449. handleTaxIssues /* Tax issues. */ ();
  450. }) ();
  451. /**/
  452. $(cardType).click (handleBillingMethod).change (handleBillingMethod);
  453. /**/
  454. $(couponApplyButton).click ( /* Only applying coupon. */function()
  455. {
  456. $(submissionNonceVerification).val ('apply-coupon'), $spForm.submit ();
  457. });
  458. /**/
  459. $spForm.submit ( /* Form validation. */function()
  460. {
  461. if ($(submissionNonceVerification).val () !== 'apply-coupon')
  462. {
  463. var context = this, label = '', error = '', errors = '';
  464. /**/
  465. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  466. /**/
  467. if (!$(cardType + ':checked').val ())
  468. {
  469. $(cardType).val (['PayPal']);
  470. }
  471. /**/
  472. $(':input', context).each ( /* Go through them all together. */function()
  473. {
  474. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
  475. /**/
  476. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  477. {
  478. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  479. errors += /* Collect errors. */ error + '\n\n';
  480. }
  481. });
  482. /**/
  483. if (errors = $.trim (errors))
  484. {
  485. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  486. /**/
  487. return false;
  488. }
  489. /**/
  490. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  491. {
  492. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Security Code missing. Please try again.", "s2member-front", "s2member")); ?>');
  493. /**/
  494. return false;
  495. }
  496. }
  497. /**/
  498. $(submissionButton).attr (disabled), ws_plugin__s2member_animateProcessing($(submissionButton)), $(couponApplyButton).attr (disabled);
  499. /**/
  500. return true;
  501. });
  502. }
  503. /**/
  504. else if (($coForm = $('form#s2member-pro-paypal-checkout-form')).length === 1)
  505. {
  506. var handleCouponIssues, handleTaxIssues, taxMayApply = true, calculateTax, cTaxDelay, cTaxTimeout, cTaxReq, cTaxLocation, handlePasswordIssues, handleBillingMethod, handleExistingUsers, couponSection = 'div#s2member-pro-paypal-checkout-form-coupon-section', couponApplyButton = couponSection + ' input#s2member-pro-paypal-checkout-coupon-apply', registrationSection = 'div#s2member-pro-paypal-checkout-form-registration-section', customFieldsSection = 'div#s2member-pro-paypal-checkout-form-custom-fields-section', billingMethodSection = 'div#s2member-pro-paypal-checkout-form-billing-method-section', cardType = billingMethodSection + ' input[name="s2member_pro_paypal_checkout\[card_type\]"]', billingAddressSection = 'div#s2member-pro-paypal-checkout-form-billing-address-section', $ajaxTaxDiv = $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-ajax-tax-div'), captchaSection = 'div#s2member-pro-paypal-checkout-form-captcha-section', submissionSection = 'div#s2member-pro-paypal-checkout-form-submission-section', submissionNonceVerification = submissionSection + ' input#s2member-pro-paypal-checkout-nonce', submissionButton = submissionSection + ' input#s2member-pro-paypal-checkout-submit';
  507. /**/
  508. var submitButton = '<input type="submit" id="s2member-pro-paypal-checkout-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-checkout-submit" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Submit Form", "s2member-front", "s2member"))); ?>" tabindex="600" />';
  509. var submitExpressCheckoutButton = '<input type="image" src="https://www.paypal.com/<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("en_US", "s2member-front paypal-button-lang-code", "s2member"))); ?>/i/btn/btn_xpressCheckout.gif" id="s2member-pro-paypal-checkout-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-checkout-submit" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Submit Form", "s2member-front", "s2member"))); ?>" tabindex="600" />';
  510. /**/
  511. ws_plugin__s2member_animateProcessing($(submissionButton), 'reset'), $(submissionButton).removeAttr ('disabled'), $(couponApplyButton).removeAttr ('disabled');
  512. /**/
  513. (handleCouponIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  514. {
  515. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-coupons-not-required-or-not-possible').length)
  516. {
  517. $(couponSection).hide /* Not accepting Coupons on this particular form. */ ();
  518. }
  519. else /* This is turned off by default for smoother loading. ( via: display:none ). */
  520. $(couponSection).show /* OK. So we need to display this now. */ ();
  521. }) ();
  522. /**/
  523. (handleTaxIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  524. {
  525. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-tax-not-required-or-not-possible').length)
  526. {
  527. $ajaxTaxDiv.hide (), taxMayApply = /* Tax does NOT even apply. */ false;
  528. }
  529. }) ();
  530. /**/
  531. (calculateTax = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  532. {
  533. if (taxMayApply && !(eventTrigger && eventTrigger.interval && document.activeElement.id === 's2member-pro-paypal-checkout-country'))
  534. {
  535. var attr = $(submissionSection + ' input#s2member-pro-paypal-checkout-attr').val ();
  536. var state = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').val ());
  537. var country = $(billingAddressSection + ' select#s2member-pro-paypal-checkout-country').val ();
  538. var zip = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-checkout-zip').val ());
  539. var thisTaxLocation = /* Three part location. */ state + '|' + country + '|' + zip;
  540. /**/
  541. if (state && country && zip && thisTaxLocation && (!cTaxLocation || cTaxLocation !== thisTaxLocation) && (cTaxLocation = thisTaxLocation))
  542. {
  543. (cTaxReq) ? /* Abort. */ cTaxReq.abort () : null, /* Clear. */ clearTimeout(cTaxTimeout), cTaxTimeout = null;
  544. /**/
  545. $ajaxTaxDiv.html ('<div><img src="<?php echo $vars["i"]; ?>/ajax-loader.gif" alt="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr (_x ("Calculating Sales Tax...", "s2member-front", "s2member"))); ?>" /> <?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("calculating sales tax...", "s2member-front", "s2member")); ?></div>');
  546. /**/
  547. cTaxTimeout = setTimeout( /* Create a new cTaxTimeout with a one second delay. */function()
  548. {
  549. cTaxReq = $.post ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (admin_url ("/admin-ajax.php")); ?>', {'action': 'ws_plugin__s2member_pro_paypal_ajax_tax', 'ws_plugin__s2member_pro_paypal_ajax_tax': '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (c_ws_plugin__s2member_utils_encryption::encrypt ("ws-plugin--s2member-pro-paypal-ajax-tax")); ?>', 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[attr]': attr, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[state]': state, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[country]': country, 'ws_plugin__s2member_pro_paypal_ajax_tax_vars[zip]': zip}, function(response, textStatus)
  550. {
  551. clearTimeout /* Clear cTaxTimeout. */(cTaxTimeout), cTaxTimeout = null;
  552. /**/
  553. try /* Try/catch here. jQuery will sometimes return a successful response in IE, whenever the connection is aborted with a null response. */
  554. {
  555. /* translators: `Sales Tax (Today)` and `Total (Today)` The word `Today` is displayed when/if a trial period is offered. The word `Today` is translated elsewhere. */
  556. $ajaxTaxDiv.html ('<div>' + $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("<strong>Sales Tax%s:</strong> %s<br /><strong>— Total%s:</strong> %s", "s2member-front", "s2member")); ?>', ((response.trial) ? ' ' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Today", "s2member-front", "s2member")); ?>' : ''), ((response.tax_per) ? '<em>' + response.tax_per + '</em> ( ' + response.cur_symbol + '' + response.tax + ' )' : response.cur_symbol + '' + response.tax), ((response.trial) ? ' ' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Today", "s2member-front", "s2member")); ?>' : ''), response.cur_symbol + '' + response.total) + '</div>');
  557. }
  558. catch (e) {}
  559. /**/
  560. }, 'json');
  561. /**/
  562. }, ((eventTrigger && eventTrigger.keyCode) ? 1000 : 100));
  563. }
  564. /**/
  565. else if (!state || !country || !zip || !thisTaxLocation)
  566. $ajaxTaxDiv.html (''), cTaxLocation = null;
  567. }
  568. }) ();
  569. /**/
  570. cTaxDelay = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  571. {
  572. setTimeout( /* Trigger event handler with a brief delay. */function()
  573. {
  574. calculateTax(eventTrigger);
  575. }, 10); /* Brief delay. */
  576. }
  577. /**/
  578. $(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  579. $(billingAddressSection + ' input#s2member-pro-paypal-checkout-zip').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  580. $(billingAddressSection + ' select#s2member-pro-paypal-checkout-country').bind ('change', calculateTax);
  581. /**/
  582. setInterval( /* Helps with things like Google's Autofill feature. */function()
  583. {
  584. calculateTax /* Identify as interval trigger. */({interval: true});
  585. }, 1000);
  586. /**/
  587. (handlePasswordIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  588. {
  589. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-password-not-required-or-not-possible').length)
  590. {
  591. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div').hide ();
  592. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').attr (ariaFalseDis);
  593. }
  594. }) ();
  595. /**/
  596. (handleExistingUsers = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  597. {
  598. if /* If User/Member is already logged in. */ (S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
  599. {
  600. $(registrationSection + ' input#s2member-pro-paypal-checkout-first-name').each (function()
  601. {
  602. var $this = $(this), val = $this.val ();
  603. (!val) ? $this.val (S2MEMBER_CURRENT_USER_FIRST_NAME) : null;
  604. });
  605. /**/
  606. $(registrationSection + ' input#s2member-pro-paypal-checkout-last-name').each (function()
  607. {
  608. var $this = $(this), val = $this.val ();
  609. (!val) ? $this.val (S2MEMBER_CURRENT_USER_LAST_NAME) : null;
  610. });
  611. /**/
  612. $(registrationSection + ' input#s2member-pro-paypal-checkout-email').val (S2MEMBER_CURRENT_USER_EMAIL).attr (ariaFalseDis);
  613. $(registrationSection + ' input#s2member-pro-paypal-checkout-username').val (S2MEMBER_CURRENT_USER_LOGIN).attr (ariaFalseDis);
  614. /**/
  615. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div').hide ();
  616. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').attr (ariaFalseDis);
  617. /**/
  618. if ($.trim ($(registrationSection + ' > div#s2member-pro-paypal-checkout-form-registration-section-title').html ()) === '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Create Profile", "s2member-front", "s2member")); ?>')
  619. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-registration-section-title').html ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Your Profile", "s2member-front", "s2member")); ?>');
  620. /**/
  621. $(customFieldsSection).hide (), $(customFieldsSection + ' :input').attr (ariaFalseDis);
  622. }
  623. }) ();
  624. /**/
  625. (handleBillingMethod = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  626. {
  627. var billingMethod = /* Billing Method. */ $(cardType + ':checked').val ();
  628. /**/
  629. if ($.inArray (billingMethod, ['Visa', 'MasterCard', 'Amex', 'Discover']) !== -1)
  630. {
  631. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  632. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  633. /**/
  634. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div').hide ();
  635. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  636. /**/
  637. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  638. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  639. /**/
  640. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  641. /**/
  642. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitButton);
  643. /**/
  644. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-checkout-card-number').focus () : null;
  645. }
  646. else if ($.inArray (billingMethod, ['Maestro', 'Solo']) !== -1)
  647. {
  648. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  649. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  650. /**/
  651. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  652. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  653. /**/
  654. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  655. /**/
  656. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitButton);
  657. /**/
  658. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-checkout-card-number').focus () : null;
  659. }
  660. else if ((!billingMethod || billingMethod === 'PayPal') && taxMayApply)
  661. {
  662. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  663. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  664. /**/
  665. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-number-div').hide ();
  666. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-number-div :input').attr (ariaFalse);
  667. /**/
  668. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-expiration-div').hide ();
  669. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-expiration-div :input').attr (ariaFalse);
  670. /**/
  671. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-verification-div').hide ();
  672. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-verification-div :input').attr (ariaFalse);
  673. /**/
  674. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div').hide ();
  675. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  676. /**/
  677. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  678. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  679. /**/
  680. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-street-div').hide ();
  681. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-street-div :input').attr (ariaFalse);
  682. /**/
  683. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-city-div').hide ();
  684. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-city-div :input').attr (ariaFalse);
  685. /**/
  686. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitExpressCheckoutButton);
  687. /**/
  688. (eventTrigger) ? $(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').focus () : null;
  689. }
  690. else if (!billingMethod || billingMethod === 'PayPal')
  691. {
  692. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').hide ();
  693. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaFalse);
  694. /**/
  695. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-type-div').show ();
  696. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-type-div :input').attr (ariaTrue);
  697. /**/
  698. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').hide ();
  699. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaFalse);
  700. /**/
  701. $(billingAddressSection).hide (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitExpressCheckoutButton);
  702. /**/
  703. (eventTrigger) ? $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').focus () : null;
  704. }
  705. }) ();
  706. /**/
  707. $(cardType).click (handleBillingMethod).change (handleBillingMethod);
  708. /**/
  709. $(couponApplyButton).click ( /* Only applying coupon. */function()
  710. {
  711. $(submissionNonceVerification).val ('apply-coupon'), $coForm.submit ();
  712. });
  713. /**/
  714. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').keyup (function()
  715. {
  716. ws_plugin__s2member_passwordStrength($(registrationSection + ' input#s2member-pro-paypal-checkout-username'), $(registrationSection + ' input#s2member-pro-paypal-checkout-password1'), $(registrationSection + ' input#s2member-pro-paypal-checkout-password2'), $(registrationSection + ' div#s2member-pro-paypal-checkout-form-password-strength'));
  717. });
  718. /**/
  719. $coForm.submit ( /* Form validation. */function()
  720. {
  721. if ($(submissionNonceVerification).val () !== 'apply-coupon')
  722. {
  723. var context = this, label = '', error = '', errors = '';
  724. /**/
  725. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  726. /**/
  727. var $password1 = $(registrationSection + ' input#s2member-pro-paypal-checkout-password1[aria-required="true"]');
  728. var $password2 = $(registrationSection + ' input#s2member-pro-paypal-checkout-password2');
  729. /**/
  730. if (!$(cardType + ':checked').val ())
  731. {
  732. $(cardType).val (['PayPal']);
  733. }
  734. /**/
  735. $(':input', context).each ( /* Go through them all together. */function()
  736. {
  737. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
  738. /**/
  739. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  740. {
  741. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  742. errors += /* Collect errors. */ error + '\n\n';
  743. }
  744. });
  745. /**/
  746. if (errors = $.trim (errors))
  747. {
  748. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  749. /**/
  750. return false;
  751. }
  752. /**/
  753. else if ($password1.length && $.trim ($password1.val ()) !== $.trim ($password2.val ()))
  754. {
  755. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');
  756. /**/
  757. return false;
  758. }
  759. /**/
  760. else if /* Enforce minimum length requirement here. */ ($password1.length && $.trim ($password1.val ()).length < 6)
  761. {
  762. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');
  763. /**/
  764. return false;
  765. }
  766. /**/
  767. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  768. {
  769. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Security Code missing. Please try again.", "s2member-front", "s2member")); ?>');
  770. /**/
  771. return false;
  772. }
  773. }
  774. /**/
  775. $(submissionButton).attr (disabled), ws_plugin__s2member_animateProcessing($(submissionButton)), $(couponApplyButton).attr (disabled);
  776. /**/
  777. return true;
  778. });
  779. }
  780. /**/
  781. (jumpToResponses = /* Jump to form responses. */ function()
  782. {
  783. $('div#s2member-pro-paypal-form-response').each (function()
  784. {
  785. var offset = $(this).offset ();
  786. window.scrollTo (0, offset.top - 100);
  787. });
  788. }) ();
  789. });

s2member-pro\includes\separates\gateways\paypal\paypal.js

Source Code Documentation