michaelsideways

Bloomerang General Donate Form

Feb 8th, 2018
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.77 KB | None | 0 0
  1.  
  2. <script type="text/javascript" id="bloomerangForm3331072"></script>
  3. <pre><script type="text/javascript">
  4. var insertForm3331072 = function() {
  5. var html3331072 = '<style text=\'text/css\'>' +
  6. '.donation-form label{color: #404040;' +
  7. ' display: block;}' +
  8. '' +
  9. '.donation-form label.error{color:#900;' +
  10. ' display: inline-block; ' +
  11. ' padding: 0 10px;}' +
  12. '' +
  13. '.donation-form section{padding: 5px;}' +
  14. '' +
  15. '.donation-form .field{padding: 4px 0;}' +
  16. '' +
  17. '.donation-form .field .required-star{color: #aa0000; ' +
  18. ' display: inline-block; ' +
  19. ' margin-left: 5px;}' +
  20. '' +
  21. '.donation-form .field .checkboxes{max-width:275px;' +
  22. ' border: 1px solid #A9A9A9;' +
  23. ' -webkit-transition: all .3s ease-out;' +
  24. ' -moz-transition: all .3s ease-out;' +
  25. ' transition: all .3s ease-out;}' +
  26. '' +
  27. '.donation-form .field .checkbox{display:block;' +
  28. ' position:relative;' +
  29. ' -moz-box-sizing:border-box;' +
  30. ' box-sizing:border-box;' +
  31. ' height:30px;' +
  32. ' line-height:26px;' +
  33. ' padding:2px 28px 2px 8px;' +
  34. ' border-bottom:1px solid rgba(0,0,0,0.1);' +
  35. ' color:#404040; ' +
  36. ' overflow:hidden;' +
  37. ' text-decoration:none; }' +
  38. '' +
  39. '.donation-form .field .checkbox input{opacity:0.01;' +
  40. ' position:absolute;' +
  41. ' left:-50px; ' +
  42. ' z-index:-5;}' +
  43. '' +
  44. '.donation-form .field .checkbox:last-child{border-bottom:none;}' +
  45. '' +
  46. '.donation-form .field .checkbox.selected{background: rgb(50, 142, 253);' +
  47. ' color:#fff; }' +
  48. '' +
  49. '.donation-form .field .checkbox.selected:before{color:#fff;' +
  50. ' text-shadow:1px 2px 1px rgba(0,0,0,0.25);' +
  51. ' line-height:30px;' +
  52. ' position:absolute;' +
  53. ' right:10px; }' +
  54. '' +
  55. '.donation-form .field input,' +
  56. ' .donation-form .field select,' +
  57. ' .donation-form .field textarea{padding: 4px; ' +
  58. ' width: 275px;}' +
  59. '' +
  60. '.donation-form .section.recurring{padding-left: 30px}' +
  61. '' +
  62. '.donation-form .field.radio label,' +
  63. ' .donation-form .field.checkbox label{display: block;' +
  64. ' padding-left: 9px;' +
  65. ' text-indent: -15px;}' +
  66. '' +
  67. '.donation-form .field.radio input,' +
  68. ' .donation-form .field.checkbox input{width: 25px;' +
  69. ' height: 13px;' +
  70. ' padding: 0;' +
  71. ' margin:0;' +
  72. ' vertical-align: bottom;' +
  73. ' position: relative;' +
  74. ' top: -4px;' +
  75. ' *overflow: hidden;}' +
  76. '' +
  77. '.donation-form #expiration-month,' +
  78. ' .donation-form #expiration-year{width: 85px;}' +
  79. '' +
  80. '.donation-form #security-code{width: 55px;}' +
  81. '' +
  82. '.donation-form .field .sidenote{color: #999;' +
  83. ' font-size: 10px; }' +
  84. '' +
  85. '.donation-form .field.other-option,' +
  86. ' .donation-form .field.other-amount,' +
  87. ' .donation-form .field.expiration-month,' +
  88. ' .donation-form .field.expiration-year{display: inline-block;}' +
  89. '' +
  90. '.donation-form .field.other-amount{padding-left: 6px;}' +
  91. '' +
  92. '.donation-form .field.expiration-year{padding-left: 20px;}' +
  93. '' +
  94. '.donation-form #other-amount{width: 65px;}' +
  95. '' +
  96. '.donation-form #frequency{width: 85px;}' +
  97. '' +
  98. '.donation-form #start-date{width: 150px;}' +
  99. '' +
  100. '.donation-form .errors{border: 1px solid #900;' +
  101. ' color: #900; ' +
  102. ' padding: 10px;}' +
  103. '' +
  104. '.donation-form .radio label.error{display: inline-block;' +
  105. ' padding-right: 86%; ' +
  106. ' float: right;}' +
  107. '' +
  108. '.donation-form .hidden{display: none;}' +
  109. '' +
  110. '.btn-group .btn-submit-donation{padding: 4px 10px;}' +
  111. '' +
  112. '</style>' +
  113. '' +
  114. '<div id="donation-form-container">' +
  115. ' <form id="express-form" class="donation-form" method="post" action="javascript:bloomerangSubmit()" onsubmit="bloomerangSubmit()">' +
  116. ' <div class="errors hidden"></div>' +
  117. ' <div class="section donation">' +
  118. ' <h3>Donation</h3>' +
  119. ' <div class="field text amount required">' +
  120. '<label for="donation-amount">Amount<span class="required-star">*</span></label>' +
  121. '<input id="donation-amount" name="donation-amount" class="currency required" type="text" placeholder="$0.00"></input>' +
  122. '</div>' +
  123. '' +
  124. '</div>' +
  125. ' <div class="section recurring">' +
  126. ' <div class="field checkbox recurring">' +
  127. '<label for="recurring"><input id="recurring" name="recurring" type="checkbox" maxlength="255"></input>I would like to make this a recurring donation, so Legacy can guarantee the ability to provide its vital services month-to-month</label>' +
  128. '</div>' +
  129. '<div class="field recurring">*Recurring donors will receive one donation receipt in December recognizing the total amount of their contribution that year</div>' +
  130. '<div class="field frequency required hidden">' +
  131. '<label for="frequency">Frequency<span class="required-star">*</span></label>' +
  132. '<select id="frequency" name="frequency" class="required"><option value=""></option>' +
  133. '<option value="Weekly">Weekly</option>' +
  134. '<option value="Monthly" selected>Monthly</option>' +
  135. '<option value="Quarterly">Quarterly</option>' +
  136. '<option value="Yearly">Yearly</option>' +
  137. '</select>' +
  138. '</div>' +
  139. '<div class="field date start-date required hidden">' +
  140. '<label for="start-date">Start Date<span class="required-star">*</span></label>' +
  141. '<input id="start-date" name="start-date" class="validDate required" type="date" placeholder="mm/dd/yyyy"></input>' +
  142. '</div>' +
  143. '' +
  144. '</div>' +
  145. ' ' +
  146. ' <div class="section contact">' +
  147. ' <h3>Contact Information</h3>' +
  148. ' <div class="field text first-name required">' +
  149. '<label for="first-name">First Name<span class="required-star">*</span></label>' +
  150. '<input id="first-name" name="first-name" class="required" type="text"></input>' +
  151. '</div>' +
  152. '<div class="field text last-name required">' +
  153. '<label for="last-name">Last Name<span class="required-star">*</span></label>' +
  154. '<input id="last-name" name="last-name" class="required" type="text"></input>' +
  155. '</div>' +
  156. '<div class="field email email-address required">' +
  157. '<label for="email-address">Email<span class="required-star">*</span></label>' +
  158. '<input id="email-address" name="email-address" class="email required" type="email" placeholder="[email protected]"></input>' +
  159. '</div>' +
  160. '' +
  161. '</div>' +
  162. ' <div class="section billing-address">' +
  163. ' <h3>Billing Address</h3>' +
  164. ' <div class="field street-address required">' +
  165. '<label for="street-address">Address<span class="required-star">*</span></label>' +
  166. '<textarea id="street-address" name="street-address" class="required"></textarea>' +
  167. '</div>' +
  168. '<div class="field text city required">' +
  169. '<label for="city">City<span class="required-star">*</span></label>' +
  170. '<input id="city" name="city" class="required" type="text"></input>' +
  171. '</div>' +
  172. '<div class="field state required">' +
  173. '<label for="state">State<span class="required-star">*</span></label>' +
  174. '<select id="state" name="state" class="required"><option value=""></option>' +
  175. '<option value="AL">Alabama</option>' +
  176. '<option value="AK">Alaska</option>' +
  177. '<option value="AZ">Arizona</option>' +
  178. '<option value="AR">Arkansas</option>' +
  179. '<option value="CA">California</option>' +
  180. '<option value="CO">Colorado</option>' +
  181. '<option value="CT">Connecticut</option>' +
  182. '<option value="DE">Delaware</option>' +
  183. '<option value="DC">District of Columbia</option>' +
  184. '<option value="FL">Florida</option>' +
  185. '<option value="GA">Georgia</option>' +
  186. '<option value="HI">Hawaii</option>' +
  187. '<option value="ID">Idaho</option>' +
  188. '<option value="IL">Illinois</option>' +
  189. '<option value="IN">Indiana</option>' +
  190. '<option value="IA">Iowa</option>' +
  191. '<option value="KS">Kansas</option>' +
  192. '<option value="KY">Kentucky</option>' +
  193. '<option value="LA">Louisiana</option>' +
  194. '<option value="ME">Maine</option>' +
  195. '<option value="MD">Maryland</option>' +
  196. '<option value="MA">Massachusetts</option>' +
  197. '<option value="MI">Michigan</option>' +
  198. '<option value="MN">Minnesota</option>' +
  199. '<option value="MS">Mississippi</option>' +
  200. '<option value="MO">Missouri</option>' +
  201. '<option value="MT">Montana</option>' +
  202. '<option value="NE">Nebraska</option>' +
  203. '<option value="NV">Nevada</option>' +
  204. '<option value="NH">New Hampshire</option>' +
  205. '<option value="NJ">New Jersey</option>' +
  206. '<option value="NM">New Mexico</option>' +
  207. '<option value="NY">New York</option>' +
  208. '<option value="NC">North Carolina</option>' +
  209. '<option value="ND">North Dakota</option>' +
  210. '<option value="OH">Ohio</option>' +
  211. '<option value="OK">Oklahoma</option>' +
  212. '<option value="OR">Oregon</option>' +
  213. '<option value="PA">Pennsylvania</option>' +
  214. '<option value="RI">Rhode Island</option>' +
  215. '<option value="SC">South Carolina</option>' +
  216. '<option value="SD">South Dakota</option>' +
  217. '<option value="TN">Tennessee</option>' +
  218. '<option value="TX">Texas</option>' +
  219. '<option value="UT">Utah</option>' +
  220. '<option value="VT">Vermont</option>' +
  221. '<option value="VA">Virginia</option>' +
  222. '<option value="WA">Washington</option>' +
  223. '<option value="WV">West Virginia</option>' +
  224. '<option value="WI">Wisconsin</option>' +
  225. '<option value="WY">Wyoming</option>' +
  226. '<option value="AS">American Samoa</option>' +
  227. '<option value="GU">Guam</option>' +
  228. '<option value="PR">Puerto Rico</option>' +
  229. '<option value="VI">US Virgin Islands</option>' +
  230. '</select>' +
  231. '</div>' +
  232. '<div class="field text postal-code required">' +
  233. '<label for="postal-code">Postal Code<span class="required-star">*</span></label>' +
  234. '<input id="postal-code" name="postal-code" class="zipcodeUS required" type="text" maxlength="10"></input>' +
  235. '</div>' +
  236. '<div class="field text phone-number">' +
  237. '<label for="phone-number">Phone</label>' +
  238. '<input id="phone-number" name="phone-number" class="phoneUS" type="text"></input>' +
  239. '</div>' +
  240. '' +
  241. '</div>' +
  242. ' <div class="section payment" style="display: none">' +
  243. ' <h3>Payment Information</h3>' +
  244. ' <div class="field text card-number required">' +
  245. '<label for="card-number">Card Number<span class="required-star">*</span></label>' +
  246. '<input id="card-number" name="card-number" class="creditcard required" type="text"></input>' +
  247. '</div>' +
  248. '<div class="field expiration-month required">' +
  249. '<label for="expiration-month">Month<span class="required-star">*</span></label>' +
  250. '<select id="expiration-month" name="expiration-month" class="required"><option value=""></option>' +
  251. '<option value="1">1</option>' +
  252. '<option value="2">2</option>' +
  253. '<option value="3">3</option>' +
  254. '<option value="4">4</option>' +
  255. '<option value="5">5</option>' +
  256. '<option value="6">6</option>' +
  257. '<option value="7">7</option>' +
  258. '<option value="8">8</option>' +
  259. '<option value="9">9</option>' +
  260. '<option value="10">10</option>' +
  261. '<option value="11">11</option>' +
  262. '<option value="12">12</option>' +
  263. '</select>' +
  264. '</div>' +
  265. '<div class="field text expiration-year required">' +
  266. '<label for="expiration-year">Year<span class="required-star">*</span></label>' +
  267. '<select id="expiration-year" name="expiration-year" class="required"><option value=""></option>' +
  268. '<option value="2014">2014</option>' +
  269. '<option value="2015">2015</option>' +
  270. '<option value="2016">2016</option>' +
  271. '<option value="2017">2017</option>' +
  272. '<option value="2018">2018</option>' +
  273. '<option value="2019">2019</option>' +
  274. '<option value="2020">2020</option>' +
  275. '<option value="2021">2021</option>' +
  276. '<option value="2022">2022</option>' +
  277. '<option value="2023">2023</option>' +
  278. '<option value="2024">2024</option>' +
  279. '<option value="2025">2025</option>' +
  280. '<option value="2026">2026</option>' +
  281. '<option value="2027">2027</option>' +
  282. '<option value="2028">2028</option>' +
  283. '<option value="2029">2029</option>' +
  284. '<option value="2030">2030</option>' +
  285. '<option value="2031">2031</option>' +
  286. '<option value="2032">2032</option>' +
  287. '<option value="2033">2033</option>' +
  288. '<option value="2034">2034</option>' +
  289. '<option value="2035">2035</option>' +
  290. '<option value="2036">2036</option>' +
  291. '<option value="2037">2037</option>' +
  292. '<option value="2038">2038</option>' +
  293. '<option value="2039">2039</option>' +
  294. '<option value="2040">2040</option>' +
  295. '<option value="2041">2041</option>' +
  296. '<option value="2042">2042</option>' +
  297. '</select>' +
  298. '</div>' +
  299. '<div class="field text security-code required">' +
  300. '<label for="security-code">Security Code<span class="required-star">*</span></label>' +
  301. '<input id="security-code" name="security-code" class="number required" type="text"></input>' +
  302. '</div>' +
  303. '' +
  304. '</div>' +
  305. ' <div class="section custom-fields">' +
  306. ' <h3>Additional Information</h3>' +
  307. ' <div class="field text CustomAccountField_3270656">' +
  308. '<label for="CustomAccountField_3270656">Donation Referral</label>' +
  309. '<select id="CustomAccountField_3270656" name="CustomAccountField_3270656"><option value=""></option>' +
  310. '<option value="3271680">Social Media (Facebook, Twitter, etc.)</option>' +
  311. '<option value="3272707">Website</option>' +
  312. '<option value="3272704">Email Newsletter</option>' +
  313. '<option value="3272705">Friend</option>' +
  314. '<option value="3271681">Client</option>' +
  315. '<option value="3272706">Other</option>' +
  316. '</select>' +
  317. '</div>' +
  318. '<div class="field text CustomAccountField_3832832">' +
  319. '<label for="CustomAccountField_3832832">I give permission to Legacy to recognize my donation in their social media (e.g., Facebook, Twitter, etc.).</label>' +
  320. '<select id="CustomAccountField_3832832" name="CustomAccountField_3832832"><option value=""></option>' +
  321. '<option value="3834880">No</option>' +
  322. '<option value="3833856">Yes</option>' +
  323. '</select>' +
  324. '</div>' +
  325. '<div class="field text CustomAccountField_3832833">' +
  326. '<label for="CustomAccountField_3832833">I would like to remain anonymous</label>' +
  327. '<select id="CustomAccountField_3832833" name="CustomAccountField_3832833"><option value=""></option>' +
  328. '<option value="3834881">No</option>' +
  329. '<option value="3833857">Yes</option>' +
  330. '</select>' +
  331. '</div>' +
  332. '' +
  333. '</div>' +
  334. ' <div class="section comment">' +
  335. ' <div class="field text comment">' +
  336. '<label for="comment">Comments</label>' +
  337. '<textarea id="comment" name="comment" type="text" value="Comments"></textarea>' +
  338. '</div>' +
  339. '' +
  340. '</div>' +
  341. ' <div class="btn-group">' +
  342. ' <input class="btn btn-submit btn-submit-donation" type="submit" value="Donate" id="express-submit" disabled="true" />' +
  343. ' </div>' +
  344. ' </form>' +
  345. '</div>' +
  346. '' +
  347. '' + '';var successHtml3331072 = '<div class=\'donation-success\'>' +
  348. ' <h2>Thank You for Your Donation!</h2>' +
  349. ' <p>Your generous gift has been processed. We truly appreciate your continued support.</p>' +
  350. ' ' +
  351. '</div>';( function($) {if (!Bloomerang.useDonationId('3331072')) {
  352. html3331072 = '<p style="color: red">Only one donation or event registration form can be used on each page.</p>';
  353. }if (jQuery('#bloomerangForm3331072').length) {
  354.  
  355. if (window.ActiveXObject) { // they are using IE < 11, which doesn't support TLS 1.1
  356. html3331072 = '<p style="color: red">​Your browser does not support the minimum security requirements for keeping your Credit Card information safe when processing payments. Please upgrade ​your browser or download the latest version of' +
  357. ' <a target=\'_blank\' href=\'https://www.google.com/chrome/browser/desktop/\'>Chrome</a> or <a target=\'_blank\' href=\'https://www.mozilla.org/en-US/firefox/new/\'>Firefox</a>.</p>';
  358. }
  359. jQuery('#bloomerangForm3331072').after(html3331072);
  360. if (!Bloomerang.SpreedlyScriptLoaded) {
  361. Bloomerang.Util.load('https://core.spreedly.com/iframe/express-2.min.js',
  362. function() { return SpreedlyExpress != undefined; },
  363. function() {
  364. SpreedlyExpress.onInit(function() { jQuery('#express-submit').attr('disabled', false); });
  365. Bloomerang.initSpreedly = function() {
  366. SpreedlyExpress.init('OqOMv1ksjPtXEYHtCYsVXzEpCbR', { 'company_name': 'Legacy Counseling Center' });
  367. };
  368. Bloomerang.initSpreedly();
  369. });
  370. }
  371. Bloomerang.SpreedlyScriptLoaded = true;
  372. };
  373. if (Bloomerang.paymentFormLoaded) {
  374. return false;
  375. }
  376. Bloomerang.paymentFormLoaded = true;
  377. window.captchaLoadCallback = function() {
  378. Bloomerang.gRecaptchaLoaded = true;
  379. };
  380. Bloomerang.Util.load('https://www.google.com/recaptcha/api.js?onload=captchaLoadCallback&render=explicit',
  381. function() { return Bloomerang.gRecaptchaLoaded; },
  382. function() {
  383. jQuery('.section.captcha').removeAttr('style');
  384. jQuery('form.donation-form').data('captcha-id', grecaptcha.render('captcha3331072', { 'sitekey' : '6LcXfScUAAAAAGdVKQy2GQsWIhNWTMtTboHvaaL4' }));
  385. },
  386. true,
  387. true);
  388. Bloomerang.transactionFee = 0.3; Bloomerang.transactionFeeRate = 0.022; Bloomerang.transactionFeeEft =
  389. Bloomerang.useKey('pub_51d2f830-16f8-11e3-a756-02a718d18e56');
  390.  
  391. // Register proper callbacks for various stages/outcomes of submission
  392. Bloomerang.Api.OnSubmit = Bloomerang.Widget.Donation.OnSubmit = function (args) {
  393. jQuery(".btn-submit-donation").val("Donating...").prop("disabled", true).addClass("disabled");
  394. var val = function (selector) { return jQuery(selector).val(); };
  395. Bloomerang.Account
  396. .individual()
  397. .firstName(val(".donation-form #first-name"))
  398. .middleName(val(".donation-form #middle-name"))
  399. .lastName(val(".donation-form #last-name"))
  400. .homeAddress(val(".donation-form #street-address"), val(".donation-form #city"), val(".donation-form #state"), val(".donation-form #postal-code"))
  401. .homeEmail(val(".donation-form #email-address"))
  402. .homePhone(val(".donation-form #phone-number"))
  403. .applyCustomFields();
  404.  
  405. var amount = val(".donation-form .section.donation input[name='donation-level']:checked") || val(".donation-form #donation-amount");
  406.  
  407. if (jQuery(".donation-form #recurring").prop("checked")) {
  408. Bloomerang.RecurringDonation
  409. .amount(amount)
  410. .fundId(val(".donation-form #fund"))
  411. .note(val(".donation-form #comment"))
  412. .frequency(val(".donation-form #frequency") || "Monthly")
  413. .startDate(val(".donation-form #start-date"))
  414. .applyCustomFields();
  415. } else {
  416. Bloomerang.Donation
  417. .amount(amount)
  418. .fundId(val(".donation-form #fund"))
  419. .note(val(".donation-form #comment"))
  420. .applyCustomFields();
  421. }
  422.  
  423. Bloomerang.CreditCard
  424.  
  425. .expirationMonth(val(".donation-form #expiration-month"))
  426. .expirationYear(val(".donation-form #expiration-year"))
  427. ;
  428.  
  429. };
  430. Bloomerang.Api.OnSuccess = Bloomerang.Widget.Donation.OnSuccess = function (response) {
  431. jQuery("#donation-form-container").html(successHtml3331072);
  432. };
  433. Bloomerang.Api.OnError = Bloomerang.Widget.Donation.OnError = function (response) {
  434. jQuery(".btn-submit-donation").prop("disabled", false).removeClass("disabled").val("Donate");
  435. jQuery("#donation-form-container .errors").removeClass("hidden").html(response.Message); Bloomerang.cancelFinancialSubmission($("#express-form"));
  436. window.scrollTo(0, 0);
  437. };
  438.  
  439. Bloomerang.Util.applyCustomFields = function (obj, type) {
  440.  
  441. // Clear any fields from a previous failed submission
  442. obj.clearCustomFields();
  443.  
  444. // Apply all <input> (not multiselect), <select> and <textarea> fields
  445. jQuery(".donation-form .section.custom-fields :input:not(a > input, select)[id*=" + type + "]").each(function() {
  446. if (jQuery(this).val().hasValue()) {
  447. obj.customFreeformField(jQuery(this).attr("id").toUntypedValue(), jQuery(this).val());
  448. }
  449. });
  450.  
  451. // Apply all <select> fields
  452. jQuery(".donation-form .section.custom-fields select[id*=" + type + "]").each(function() {
  453. if (jQuery(this).val().hasValue()) {
  454. obj.customPickField(jQuery(this).attr("id").toUntypedValue(), jQuery(this).val());
  455. }
  456. });
  457.  
  458. // Apply all multiselect fields
  459. jQuery(".donation-form .section.custom-fields .checkboxes[id*=" + type + "]").each(function() {
  460. obj.customPickField(jQuery(this).attr("id").toUntypedValue(),
  461. jQuery.map(jQuery(this).children(".checkbox.selected"), function(v) { return jQuery(v).attr("data-id"); }));
  462. });
  463. };
  464.  
  465. String.prototype.hasValue = function() {
  466. return (this && this.trim());
  467. };
  468.  
  469. Bloomerang.Account.applyCustomFields = function () {
  470. Bloomerang.Util.applyCustomFields(this, "Account");
  471. return this;
  472. };
  473.  
  474. Bloomerang.Donation.applyCustomFields = function () {
  475. Bloomerang.Util.applyCustomFields(this, "Transaction");
  476. return this;
  477. };
  478.  
  479. Bloomerang.RecurringDonation.applyCustomFields = function () {
  480. Bloomerang.Util.applyCustomFields(this, "Transaction");
  481. return this;
  482. };
  483.  
  484. String.prototype.toUntypedValue = function() {
  485. return this.substring(this.indexOf('_') + 1);
  486. };
  487.  
  488. Date.prototype.toDateInputValue = function() {
  489. var local = new Date(this);
  490. local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
  491. return local.toJSON().slice(0,10);
  492. };
  493.  
  494. jQuery(document).ready(function() {
  495. jQuery(".donation-form .field.start-date input").val(new Date().toDateInputValue());
  496. });
  497.  
  498. // Hide recurring donation options if recurring donation box is unchecked
  499. jQuery(".donation-form .field.recurring").change(function() {
  500. jQuery(".donation-form .field.recurring").siblings().each(function() {
  501. jQuery(this).toggleClass('hidden');
  502. });
  503. })
  504.  
  505. // The other-amount field is only equired when the "Other" donation-level is selected
  506. jQuery(".donation-form .section.donation input[name='donation-level']").change(function () {
  507. if (jQuery(this).attr('id') == "other-option") {
  508. jQuery(".donation-form #other-amount").addClass("required");
  509. } else {
  510. jQuery(".donation-form #other-amount").removeClass("required");
  511. }
  512. });
  513.  
  514. // Changing the value of other-amount should change the value of other-option
  515. jQuery(".donation-form #other-amount").change(function () {
  516. jQuery(".donation-form #other-option").val(jQuery(this).val());
  517. });
  518.  
  519. // Clicking into the other-amount field should select the other-option
  520. jQuery(".donation-form #other-amount").click(function() { jQuery(".donation-form #other-option").prop('checked',true); });
  521.  
  522. jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
  523. var digits = phone_number.replace(/\D/g, "");
  524. return this.optional(element) || digits.length == 7 || digits.length == 10 || digits.length == 11;
  525. }, "Please specify a valid phone number");
  526.  
  527. jQuery.validator.addMethod("zipcodeUS", function (value, element) {
  528. return this.optional(element) || /\d{5}-\d{4}$|^\d{5}$/.test(value)
  529. }, "The specified US ZIP Code is invalid");
  530.  
  531. jQuery.validator.addMethod("currency", function (value, element, options) {
  532. return !value ||
  533. value
  534. .replace("$", "")
  535. .replace(".", "")
  536. .split(",").join("")
  537. .match(/^\d+$/g);
  538. }, "Not a valid currency");
  539.  
  540. jQuery.validator.classRuleSettings.currency = { currency: true };
  541.  
  542. jQuery.validator.addMethod("number", function (value, element, options) {
  543. return !value ||
  544. value
  545. .replace(".", "")
  546. .split(",").join("")
  547. .match(/^\d+$/g);
  548. }, "Not a valid number");
  549.  
  550. jQuery.validator.classRuleSettings.number = { number: true };
  551.  
  552. jQuery.validator.addMethod("validYear", function (value, element, options) {
  553. try {
  554. return (!value || value.match(/^[1-9]\d\d\d$/)) ? true : false;
  555. }
  556. catch (e) {
  557. return false;
  558. }
  559. }, function () { return "Must be a 4 digit year"; });
  560.  
  561. jQuery.validator.classRuleSettings.validYear = { validYear: true };
  562.  
  563. // Intercept form submission to validate then submit via API
  564. bloomerangSubmit = function () {
  565. var form = jQuery('#express-form');
  566. if (!form.valid()) {
  567. return false;
  568. }
  569.  
  570. if (jQuery('#payment_method_token').length) {
  571. if (!Bloomerang.continueFinancialSubmission(form)) { return false; }
  572.  
  573. Bloomerang.Api.OnSubmit = Bloomerang.Widget.Donation.OnSubmit;
  574. Bloomerang.Api.OnSuccess = Bloomerang.Widget.Donation.OnSuccess;
  575. Bloomerang.Api.OnError = Bloomerang.Widget.Donation.OnError;
  576.  
  577. Bloomerang.CreditCard.spreedlyToken(jQuery('#payment_method_token').val());
  578.  
  579. var tmp = jQuery('.donation-form #recurring').prop('checked')
  580. ? Bloomerang.Api.recurringDonate()
  581. : Bloomerang.Api.donate();
  582. }
  583. else {
  584. var val = function (selector) { return jQuery(selector).val(); };
  585. var amount = val(".donation-form .section.donation input[name='donation-level']:checked") || val('.donation-form #donation-amount');
  586. var selectedDonationLevel = jQuery(".donation-form .section.donation input[name='donation-level']:checked").parent().text();
  587. selectedDonationLevel = (selectedDonationLevel.indexOf('-') == -1 ? '' : selectedDonationLevel.substr(selectedDonationLevel.indexOf('-') + 2) );
  588. jQuery('#express-script').attr('data-amount', '$' + amount)
  589. .attr('data-full-name', val('.donation-form #first-name') + ' ' + val('.donation-form #last-name'))
  590. .attr('data-email', val('.donation-form #email-address'))
  591. .attr('data-phone_number', val('.donation-form #phone-number'))
  592. .attr('data-address1', val('.donation-form #street-address'))
  593. .attr('data-city', val('.donation-form #city'))
  594. .attr('data-state', val('.donation-form #state'))
  595. .attr('data-zip', val('.donation-form #postal-code'))
  596. .attr('data-sidebar-bottom-description',selectedDonationLevel);
  597. continueToExpress = true;
  598. }
  599. }
  600.  
  601. })(jQuery);
  602. };
  603.  
  604. var startBloomerangLoad = function() {
  605. if (window.bloomerangLoadStarted == undefined) {
  606. window.bloomerangLoadStarted = true;
  607. var script = document.createElement('script');
  608. script.type = 'text/javascript';
  609. script.src = 'https://crm.bloomerang.co/Content/Scripts/Api/Bloomerang-v2.js?nocache=2017-10-17';
  610. document.getElementsByTagName('head')[0].appendChild(script);
  611. waitForBloomerangLoad(function() { Bloomerang.Util.requireJQueryValidation(function() { insertForm3331072(); })});
  612. }
  613. else {
  614. waitForBloomerangLoad(function() { Bloomerang.Util.requireJQueryValidation(function() { insertForm3331072(); })});
  615. }
  616. };
  617.  
  618. var waitForBloomerangLoad = function(callback) {
  619. if (typeof(Bloomerang) === 'undefined' || !Bloomerang._isReady) {
  620. setTimeout(function () { waitForBloomerangLoad(callback) }, 500);
  621. }
  622. else {
  623. if (true) {
  624. callback();
  625. } else {
  626. window.bloomerangLoadStarted = undefined;
  627. Bloomerang = undefined; // The version of Blomerang.js is not what we want. So blow it away and reload.
  628. startBloomerangLoad();
  629. }
  630. }
  631. };
  632.  
  633. startBloomerangLoad();
  634. </script></pre>
Advertisement
Add Comment
Please, Sign In to add comment