You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.7 KiB

9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
  1. $(function () {
  2. var prices = [2, 5, 10, 15, 20, 25, 50, 100];
  3. var initialPrice = parseInt($("#pricing-value").text());
  4. var priceIdx = prices.indexOf(initialPrice);
  5. function updateDisplayPrice(price) {
  6. $("#pricing-value").text(price);
  7. $(".selected-price").val(price);
  8. $("#pww-switch-btn").text("Switch to $" + price + " / mo");
  9. if (price == initialPrice) {
  10. $("#pww-selected-btn").show();
  11. $("#pww-switch-btn").hide();
  12. } else {
  13. $("#pww-selected-btn").hide();
  14. $("#pww-switch-btn").show();
  15. }
  16. }
  17. $("#pay-plus").click(function() {
  18. if (priceIdx > 6)
  19. return;
  20. priceIdx += 1;
  21. updateDisplayPrice(prices[priceIdx]);
  22. $("#piggy").removeClass().addClass("tada animated").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
  23. $(this).removeClass();
  24. });;
  25. });
  26. $("#pay-minus").click(function() {
  27. if (priceIdx <= 0)
  28. return;
  29. priceIdx -= 1;
  30. updateDisplayPrice(prices[priceIdx]);
  31. $("#piggy").removeClass().addClass("tadaIn animated").one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){
  32. $(this).removeClass();
  33. });;
  34. });
  35. $("#pww-create-payment-method").click(function() {
  36. $.getJSON("/pricing/get_client_token/", function(data) {
  37. var $modal = $("#payment-method-modal");
  38. braintree.setup(data.client_token, "dropin", {
  39. container: "payment-form"
  40. });
  41. $modal.modal("show");
  42. })
  43. });
  44. $("#payment-method-cancel").click(function() {
  45. location.reload();
  46. });
  47. });