Source Code Documentation


pro\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 paypalLangCode = $.trim($('input#s2member-pro-paypal-lang-attr').val());
  266. 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" />';
  267. var submitExpressCheckoutButton = '<input type="image" src="https://www.paypal.com/'+((paypalLangCode) ? paypalLangCode : '<?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" />';
  268.  
  269. ws_plugin__s2member_animateProcessing($(submissionButton), 'reset'), $(submissionButton).removeAttr ('disabled'), $(couponApplyButton).removeAttr ('disabled');
  270.  
  271. (handleCouponIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  272. {
  273. if ($(submissionSection + ' input#s2member-pro-paypal-sp-checkout-coupons-not-required-or-not-possible').length)
  274. {
  275. $(couponSection).hide /* Not accepting Coupons on this particular form. */ ();
  276. }
  277. else // This is turned off by default for smoother loading. (via: display:none).
  278. $(couponSection).show /* OK. So we need to display this now. */ ();
  279. }) ();
  280.  
  281. (handleTaxIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  282. {
  283. if ($(submissionSection + ' input#s2member-pro-paypal-sp-checkout-tax-not-required-or-not-possible').length)
  284. {
  285. $ajaxTaxDiv.hide (), taxMayApply = /* Tax does NOT even apply. */ false;
  286. }
  287. }) ();
  288.  
  289. (calculateTax = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  290. {
  291. if (taxMayApply && !(eventTrigger && eventTrigger.interval && document.activeElement.id === 's2member-pro-paypal-sp-checkout-country'))
  292. {
  293. var attr = $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-attr').val ();
  294. var state = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').val ());
  295. var country = $(billingAddressSection + ' select#s2member-pro-paypal-sp-checkout-country').val ();
  296. var zip = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-zip').val ());
  297. var thisTaxLocation = /* Three part location. */ state + '|' + country + '|' + zip;
  298.  
  299. if (state && country && zip && thisTaxLocation && (!cTaxLocation || cTaxLocation !== thisTaxLocation) && (cTaxLocation = thisTaxLocation))
  300. {
  301. (cTaxReq) ? /* Abort. */ cTaxReq.abort () : null, /* Clear. */ clearTimeout(cTaxTimeout), cTaxTimeout = null;
  302.  
  303. $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>');
  304.  
  305. cTaxTimeout = setTimeout( /* Create a new cTaxTimeout with a one second delay. */function()
  306. {
  307. 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)
  308. {
  309. clearTimeout /* Clear cTaxTimeout. */(cTaxTimeout), cTaxTimeout = null;
  310.  
  311. try // Try/catch here. jQuery will sometimes return a successful response in IE, whenever the connection is aborted with a null response.
  312. {
  313. /* 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. */
  314. $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>');
  315. }
  316. catch (e) {}
  317.  
  318. }, 'json');
  319.  
  320. }, ((eventTrigger && eventTrigger.keyCode) ? 1000 : 100));
  321. }
  322.  
  323. else if (!state || !country || !zip || !thisTaxLocation)
  324. $ajaxTaxDiv.html (''), cTaxLocation = null;
  325. }
  326. }) ();
  327.  
  328. cTaxDelay = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  329. {
  330. setTimeout( /* Trigger event handler with a brief delay. */function()
  331. {
  332. calculateTax(eventTrigger);
  333. }, 10); // Brief delay.
  334. }
  335.  
  336. $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  337. $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-zip').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  338. $(billingAddressSection + ' select#s2member-pro-paypal-sp-checkout-country').bind ('change', calculateTax);
  339.  
  340. setInterval( /* Helps with things like Google's Autofill feature. */function()
  341. {
  342. calculateTax /* Identify as interval trigger. */({interval: true});
  343. }, 1000);
  344.  
  345. (handleExistingUsers = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  346. {
  347. if /* If User/Member is already logged in. */ (S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
  348. {
  349. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-first-name').each (function()
  350. {
  351. var $this = $(this), val = $this.val ();
  352. (!val) ? $this.val (S2MEMBER_CURRENT_USER_FIRST_NAME) : null;
  353. });
  354.  
  355. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-last-name').each (function()
  356. {
  357. var $this = $(this), val = $this.val ();
  358. (!val) ? $this.val (S2MEMBER_CURRENT_USER_LAST_NAME) : null;
  359. });
  360.  
  361. $(registrationSection + ' input#s2member-pro-paypal-sp-checkout-email').each (function()
  362. {
  363. var $this = $(this), val = $this.val ();
  364. (!val) ? $this.val (S2MEMBER_CURRENT_USER_EMAIL) : null;
  365. });
  366. }
  367. }) ();
  368.  
  369. (handleBillingMethod = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  370. {
  371. var billingMethod = /* Billing Method. */ $(cardType + ':checked').val ();
  372.  
  373. if ($.inArray (billingMethod, ['Visa', 'MasterCard', 'Amex', 'Discover']) !== -1)
  374. {
  375. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  376. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  377.  
  378. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div').hide ();
  379. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  380.  
  381. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  382. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  383.  
  384. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  385.  
  386. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitButton);
  387.  
  388. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-sp-checkout-card-number').focus () : null;
  389. }
  390. else if ($.inArray (billingMethod, ['Maestro', 'Solo']) !== -1)
  391. {
  392. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  393. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  394.  
  395. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  396. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  397.  
  398. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  399.  
  400. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitButton);
  401.  
  402. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-sp-checkout-card-number').focus () : null;
  403. }
  404. else if ((!billingMethod || billingMethod === 'PayPal') && taxMayApply)
  405. {
  406. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  407. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  408.  
  409. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-number-div').hide ();
  410. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-number-div :input').attr (ariaFalse);
  411.  
  412. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-expiration-div').hide ();
  413. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-expiration-div :input').attr (ariaFalse);
  414.  
  415. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-verification-div').hide ();
  416. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-verification-div :input').attr (ariaFalse);
  417.  
  418. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div').hide ();
  419. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  420.  
  421. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').show ();
  422. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaTrue);
  423.  
  424. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-street-div').hide ();
  425. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-street-div :input').attr (ariaFalse);
  426.  
  427. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-city-div').hide ();
  428. $(billingAddressSection + ' > div#s2member-pro-paypal-sp-checkout-form-city-div :input').attr (ariaFalse);
  429.  
  430. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitExpressCheckoutButton);
  431.  
  432. (eventTrigger) ? $(billingAddressSection + ' input#s2member-pro-paypal-sp-checkout-state').focus () : null;
  433. }
  434. else if (!billingMethod || billingMethod === 'PayPal')
  435. {
  436. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').hide ();
  437. $(billingMethodSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaFalse);
  438.  
  439. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-type-div').show ();
  440. $(billingMethodSection + ' > div#s2member-pro-paypal-sp-checkout-form-card-type-div :input').attr (ariaTrue);
  441.  
  442. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div').hide ();
  443. $(billingAddressSection + ' > div.s2member-pro-paypal-sp-checkout-form-div :input').attr (ariaFalse);
  444.  
  445. $(billingAddressSection).hide (), $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').replaceWith (submitExpressCheckoutButton);
  446.  
  447. (eventTrigger) ? $(submissionSection + ' input#s2member-pro-paypal-sp-checkout-submit').focus () : null;
  448. }
  449.  
  450. handleTaxIssues /* Tax issues. */ ();
  451. }) ();
  452.  
  453. $(cardType).click (handleBillingMethod).change (handleBillingMethod);
  454.  
  455. $(couponApplyButton).click ( /* Only applying coupon. */function()
  456. {
  457. $(submissionNonceVerification).val ('apply-coupon'), $spForm.submit ();
  458. });
  459.  
  460. $spForm.submit ( /* Form validation. */function()
  461. {
  462. if ($(submissionNonceVerification).val () !== 'apply-coupon')
  463. {
  464. var context = this, label = '', error = '', errors = '';
  465.  
  466. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  467.  
  468. if (!$(cardType + ':checked').val ())
  469. {
  470. $(cardType).val (['PayPal']);
  471. }
  472.  
  473. $(':input', context).each ( /* Go through them all together. */function()
  474. {
  475. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/---[0-9]+$/g, '');
  476.  
  477. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  478. {
  479. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  480. errors += /* Collect errors. */ error + '\n\n';
  481. }
  482. });
  483.  
  484. if (errors = $.trim (errors))
  485. {
  486. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  487.  
  488. return false;
  489. }
  490.  
  491. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  492. {
  493. 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")); ?>');
  494.  
  495. return false;
  496. }
  497. }
  498.  
  499. $(submissionButton).attr (disabled), ws_plugin__s2member_animateProcessing($(submissionButton)), $(couponApplyButton).attr (disabled);
  500.  
  501. return true;
  502. });
  503. }
  504.  
  505. else if (($coForm = $('form#s2member-pro-paypal-checkout-form')).length === 1)
  506. {
  507. 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';
  508.  
  509. var paypalLangCode = $.trim($('input#s2member-pro-paypal-lang-attr').val());
  510. 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" />';
  511. var submitExpressCheckoutButton = '<input type="image" src="https://www.paypal.com/'+((paypalLangCode) ? paypalLangCode : '<?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" />';
  512.  
  513. ws_plugin__s2member_animateProcessing($(submissionButton), 'reset'), $(submissionButton).removeAttr ('disabled'), $(couponApplyButton).removeAttr ('disabled');
  514.  
  515. (handleCouponIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  516. {
  517. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-coupons-not-required-or-not-possible').length)
  518. {
  519. $(couponSection).hide /* Not accepting Coupons on this particular form. */ ();
  520. }
  521. else // This is turned off by default for smoother loading. (via: display:none).
  522. $(couponSection).show /* OK. So we need to display this now. */ ();
  523. }) ();
  524.  
  525. (handleTaxIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  526. {
  527. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-tax-not-required-or-not-possible').length)
  528. {
  529. $ajaxTaxDiv.hide (), taxMayApply = /* Tax does NOT even apply. */ false;
  530. }
  531. }) ();
  532.  
  533. (calculateTax = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  534. {
  535. if (taxMayApply && !(eventTrigger && eventTrigger.interval && document.activeElement.id === 's2member-pro-paypal-checkout-country'))
  536. {
  537. var attr = $(submissionSection + ' input#s2member-pro-paypal-checkout-attr').val ();
  538. var state = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').val ());
  539. var country = $(billingAddressSection + ' select#s2member-pro-paypal-checkout-country').val ();
  540. var zip = $.trim ($(billingAddressSection + ' input#s2member-pro-paypal-checkout-zip').val ());
  541. var thisTaxLocation = /* Three part location. */ state + '|' + country + '|' + zip;
  542.  
  543. if (state && country && zip && thisTaxLocation && (!cTaxLocation || cTaxLocation !== thisTaxLocation) && (cTaxLocation = thisTaxLocation))
  544. {
  545. (cTaxReq) ? /* Abort. */ cTaxReq.abort () : null, /* Clear. */ clearTimeout(cTaxTimeout), cTaxTimeout = null;
  546.  
  547. $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>');
  548.  
  549. cTaxTimeout = setTimeout( /* Create a new cTaxTimeout with a one second delay. */function()
  550. {
  551. 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)
  552. {
  553. clearTimeout /* Clear cTaxTimeout. */(cTaxTimeout), cTaxTimeout = null;
  554.  
  555. try // Try/catch here. jQuery will sometimes return a successful response in IE, whenever the connection is aborted with a null response.
  556. {
  557. /* 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. */
  558. $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>');
  559. }
  560. catch (e) {}
  561.  
  562. }, 'json');
  563.  
  564. }, ((eventTrigger && eventTrigger.keyCode) ? 1000 : 100));
  565. }
  566.  
  567. else if (!state || !country || !zip || !thisTaxLocation)
  568. $ajaxTaxDiv.html (''), cTaxLocation = null;
  569. }
  570. }) ();
  571.  
  572. cTaxDelay = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  573. {
  574. setTimeout( /* Trigger event handler with a brief delay. */function()
  575. {
  576. calculateTax(eventTrigger);
  577. }, 10); // Brief delay.
  578. }
  579.  
  580. $(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  581. $(billingAddressSection + ' input#s2member-pro-paypal-checkout-zip').bind ('keyup blur', calculateTax).bind ('cut paste', cTaxDelay);
  582. $(billingAddressSection + ' select#s2member-pro-paypal-checkout-country').bind ('change', calculateTax);
  583.  
  584. setInterval( /* Helps with things like Google's Autofill feature. */function()
  585. {
  586. calculateTax /* Identify as interval trigger. */({interval: true});
  587. }, 1000);
  588.  
  589. (handlePasswordIssues = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  590. {
  591. if ($(submissionSection + ' input#s2member-pro-paypal-checkout-password-not-required-or-not-possible').length)
  592. {
  593. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div').hide ();
  594. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').attr (ariaFalseDis);
  595. }
  596. }) ();
  597.  
  598. (handleExistingUsers = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  599. {
  600. if /* If User/Member is already logged in. */ (S2MEMBER_CURRENT_USER_IS_LOGGED_IN)
  601. {
  602. $(registrationSection + ' input#s2member-pro-paypal-checkout-first-name').each (function()
  603. {
  604. var $this = $(this), val = $this.val ();
  605. (!val) ? $this.val (S2MEMBER_CURRENT_USER_FIRST_NAME) : null;
  606. });
  607.  
  608. $(registrationSection + ' input#s2member-pro-paypal-checkout-last-name').each (function()
  609. {
  610. var $this = $(this), val = $this.val ();
  611. (!val) ? $this.val (S2MEMBER_CURRENT_USER_LAST_NAME) : null;
  612. });
  613.  
  614. $(registrationSection + ' input#s2member-pro-paypal-checkout-email').val (S2MEMBER_CURRENT_USER_EMAIL).attr (ariaFalseDis);
  615. $(registrationSection + ' input#s2member-pro-paypal-checkout-username').val (S2MEMBER_CURRENT_USER_LOGIN).attr (ariaFalseDis);
  616.  
  617. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div').hide ();
  618. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').attr (ariaFalseDis);
  619.  
  620. 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")); ?>')
  621. $(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")); ?>');
  622.  
  623. $(customFieldsSection).hide (), $(customFieldsSection + ' :input').attr (ariaFalseDis);
  624. }
  625. }) ();
  626.  
  627. (handleBillingMethod = /* eventTrigger is passed by jQuery for DOM events. */ function(eventTrigger)
  628. {
  629. var billingMethod = /* Billing Method. */ $(cardType + ':checked').val ();
  630.  
  631. if ($.inArray (billingMethod, ['Visa', 'MasterCard', 'Amex', 'Discover']) !== -1)
  632. {
  633. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  634. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  635.  
  636. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div').hide ();
  637. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  638.  
  639. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  640. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  641.  
  642. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  643.  
  644. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitButton);
  645.  
  646. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-checkout-card-number').focus () : null;
  647. }
  648. else if ($.inArray (billingMethod, ['Maestro', 'Solo']) !== -1)
  649. {
  650. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  651. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  652.  
  653. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  654. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  655.  
  656. (!taxMayApply) ? /* Tax does NOT even apply. */ $ajaxTaxDiv.hide () : null;
  657.  
  658. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitButton);
  659.  
  660. (eventTrigger) ? $(billingMethodSection + ' input#s2member-pro-paypal-checkout-card-number').focus () : null;
  661. }
  662. else if ((!billingMethod || billingMethod === 'PayPal') && taxMayApply)
  663. {
  664. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  665. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  666.  
  667. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-number-div').hide ();
  668. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-number-div :input').attr (ariaFalse);
  669.  
  670. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-expiration-div').hide ();
  671. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-expiration-div :input').attr (ariaFalse);
  672.  
  673. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-verification-div').hide ();
  674. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-verification-div :input').attr (ariaFalse);
  675.  
  676. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div').hide ();
  677. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-start-date-issue-number-div :input').attr (ariaFalse);
  678.  
  679. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').show ();
  680. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaTrue);
  681.  
  682. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-street-div').hide ();
  683. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-street-div :input').attr (ariaFalse);
  684.  
  685. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-city-div').hide ();
  686. $(billingAddressSection + ' > div#s2member-pro-paypal-checkout-form-city-div :input').attr (ariaFalse);
  687.  
  688. $(billingAddressSection).show (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitExpressCheckoutButton);
  689.  
  690. (eventTrigger) ? $(billingAddressSection + ' input#s2member-pro-paypal-checkout-state').focus () : null;
  691. }
  692. else if (!billingMethod || billingMethod === 'PayPal')
  693. {
  694. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div').hide ();
  695. $(billingMethodSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaFalse);
  696.  
  697. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-type-div').show ();
  698. $(billingMethodSection + ' > div#s2member-pro-paypal-checkout-form-card-type-div :input').attr (ariaTrue);
  699.  
  700. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div').hide ();
  701. $(billingAddressSection + ' > div.s2member-pro-paypal-checkout-form-div :input').attr (ariaFalse);
  702.  
  703. $(billingAddressSection).hide (), $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').replaceWith (submitExpressCheckoutButton);
  704.  
  705. (eventTrigger) ? $(submissionSection + ' input#s2member-pro-paypal-checkout-submit').focus () : null;
  706. }
  707. }) ();
  708.  
  709. $(cardType).click (handleBillingMethod).change (handleBillingMethod);
  710.  
  711. $(couponApplyButton).click ( /* Only applying coupon. */function()
  712. {
  713. $(submissionNonceVerification).val ('apply-coupon'), $coForm.submit ();
  714. });
  715.  
  716. $(registrationSection + ' > div#s2member-pro-paypal-checkout-form-password-div :input').keyup (function()
  717. {
  718. 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'));
  719. });
  720.  
  721. $coForm.submit ( /* Form validation. */function()
  722. {
  723. if ($(submissionNonceVerification).val () !== 'apply-coupon')
  724. {
  725. var context = this, label = '', error = '', errors = '';
  726.  
  727. var $recaptchaResponse = $(captchaSection + ' input#recaptcha_response_field');
  728.  
  729. var $password1 = $(registrationSection + ' input#s2member-pro-paypal-checkout-password1[aria-required="true"]');
  730. var $password2 = $(registrationSection + ' input#s2member-pro-paypal-checkout-password2');
  731.  
  732. if (!$(cardType + ':checked').val ())
  733. {
  734. $(cardType).val (['PayPal']);
  735. }
  736.  
  737. $(':input', context).each ( /* Go through them all together. */function()
  738. {
  739. var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/---[0-9]+$/g, '');
  740.  
  741. if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
  742. {
  743. if (error = ws_plugin__s2member_validationErrors(label, this, context))
  744. errors += /* Collect errors. */ error + '\n\n';
  745. }
  746. });
  747.  
  748. if (errors = $.trim (errors))
  749. {
  750. alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
  751.  
  752. return false;
  753. }
  754.  
  755. else if ($password1.length && $.trim ($password1.val ()) !== $.trim ($password2.val ()))
  756. {
  757. 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")); ?>');
  758.  
  759. return false;
  760. }
  761.  
  762. else if /* Enforce minimum length requirement here. */ ($password1.length && $.trim ($password1.val ()).length < 6)
  763. {
  764. 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")); ?>');
  765.  
  766. return false;
  767. }
  768.  
  769. else if ($recaptchaResponse.length && !$recaptchaResponse.val ())
  770. {
  771. 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")); ?>');
  772.  
  773. return false;
  774. }
  775. }
  776.  
  777. $(submissionButton).attr (disabled), ws_plugin__s2member_animateProcessing($(submissionButton)), $(couponApplyButton).attr (disabled);
  778.  
  779. return true;
  780. });
  781. }
  782.  
  783. (jumpToResponses = /* Jump to form responses. */ function()
  784. {
  785. $('div#s2member-pro-paypal-form-response').each (function()
  786. {
  787. var offset = $(this).offset ();
  788. window.scrollTo (0, offset.top - 100);
  789. });
  790. }) ();
  791. });

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

Source Code Documentation