From 5de0c928fe423b183beac951406ae1ad8f2ca51f Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 12 Oct 2013 16:47:49 -0700 Subject: [PATCH] paypal: conslidate buy gems modals --- public/css/index.styl | 6 ++++- public/js/controllers/groupsCtrl.js | 2 +- public/js/controllers/marketCtrl.js | 2 +- public/js/controllers/rootCtrl.js | 37 ++++++++++++++--------------- views/shared/gems.jade | 2 +- views/shared/modals/buy-gems.jade | 21 ++++++++++++++++ views/shared/modals/index.jade | 3 +-- views/shared/modals/more-gems.jade | 10 -------- views/shared/modals/reroll.jade | 2 +- views/shared/modals/why-ads.jade | 12 ---------- views/tasks/ads.jade | 5 +--- 11 files changed, 50 insertions(+), 52 deletions(-) create mode 100644 views/shared/modals/buy-gems.jade delete mode 100644 views/shared/modals/more-gems.jade delete mode 100644 views/shared/modals/why-ads.jade diff --git a/public/css/index.styl b/public/css/index.styl index 48530c87da..729328f19d 100644 --- a/public/css/index.styl +++ b/public/css/index.styl @@ -168,4 +168,8 @@ a word-wrap: break-word .btn - margin-right: 5px \ No newline at end of file + margin-right: 5px + +.buy-gems-list + margin-left: 10px; + padding-left: 10px; \ No newline at end of file diff --git a/public/js/controllers/groupsCtrl.js b/public/js/controllers/groupsCtrl.js index f52291cf82..81b18f8dde 100644 --- a/public/js/controllers/groupsCtrl.js +++ b/public/js/controllers/groupsCtrl.js @@ -114,7 +114,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Groups', '$http', 'A $scope.create = function(group){ if (User.user.balance < 1) { - return $rootScope.modals.moreGems = true; + return $rootScope.modals.buyGems = true; // $('#more-gems-modal').modal('show'); } diff --git a/public/js/controllers/marketCtrl.js b/public/js/controllers/marketCtrl.js index 68b11b79bc..c0cf429539 100644 --- a/public/js/controllers/marketCtrl.js +++ b/public/js/controllers/marketCtrl.js @@ -12,7 +12,7 @@ habitrpg.controller("MarketCtrl", ['$rootScope', '$scope', 'User', 'API_URL', '$ storePath = type === 'egg' ? 'items.eggs' : 'items.hatchingPotions' if(gems < item.value){ - return $rootScope.modals.moreGems = true; + return $rootScope.modals.buyGems = true; } var message = "Buy this " + (type == 'egg' ? 'egg' : 'hatching potion') + " with " + item.value + " of your " + gems + " Gems?" diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index d73cdfe6c4..052a52b778 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -42,25 +42,24 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ } $rootScope.showStripe = function() { - var disableAds = User.user.flags.ads == 'hide' ? '' : 'Disable Ads, '; - StripeCheckout.open({ - key: window.env.STRIPE_PUB_KEY, - address: false, - amount: 500, - name: "Checkout", - description: "Buy 20 Gems, " + disableAds + "Support the Developers", - panelLabel: "Checkout", - token: function(data) { - $scope.$apply(function(){ - $http.post("/api/v1/user/buy-gems", data) - .success(function() { - window.location.href = "/"; - }).error(function(err) { - alert(err); - }); - }) - } - }); + StripeCheckout.open({ + key: window.env.STRIPE_PUB_KEY, + address: false, + amount: 500, + name: "Checkout", + //description: "Buy 20 Gems, Disable Ads, Support the Developers", + panelLabel: "Checkout", + token: function(data) { + $scope.$apply(function(){ + $http.post("/api/v1/user/buy-gems", data) + .success(function() { + window.location.href = "/"; + }).error(function(err) { + alert(err); + }); + }) + } + }); } } ]); diff --git a/views/shared/gems.jade b/views/shared/gems.jade index f276a47528..af75287f13 100644 --- a/views/shared/gems.jade +++ b/views/shared/gems.jade @@ -1,5 +1,5 @@ a.pull-right.gem-wallet(popover-trigger='mouseenter', popover-title='Gems', popover="Used for buying special items (reroll, eggs, hatching potions, etc). You'll need to unlock those features before being able to use Gems.", popover-placement='bottom') - span.task-action-btn.tile.flush.bright.add-gems-btn(ng-click='showStripe()') + + span.task-action-btn.tile.flush.bright.add-gems-btn(ng-click='modals.buyGems = true') + span.task-action-btn.tile.flush.neutral .Gems | {{user.balance * 4 | number:0}} Gems \ No newline at end of file diff --git a/views/shared/modals/buy-gems.jade b/views/shared/modals/buy-gems.jade new file mode 100644 index 0000000000..8562d0e754 --- /dev/null +++ b/views/shared/modals/buy-gems.jade @@ -0,0 +1,21 @@ +div(modal='modals.buyGems') + .modal-header + h3 Buy Gems / Donate + + .modal-body + include ../gems + p $5 USD will: + ul.buy-gems-list + li Add 20 gems to your account, which are used to buy special items. + li Disable ads. + li Donate to the developers (as an open source project, we can us all the help we can get). + .row-fluid + .span6.well + h3 Pay with Card + .btn.btn-primary(ng-click='showStripe()') Pay with Card + .span6.well + h3 Pay with PayPal + script(src='/bower_components/JavaScriptButtons/dist/paypal-button.min.js?merchant=tylerrenelle-facilitator@gmail.com', data-button='buynow', data-name='20 Gems, Disable Ads, Donation to the Developers', data-quantity='1', data-amount='.1', data-currency='USD', data-shipping='0', data-tax='0', data-callback='#{env.BASE_URL}/api/v1/user/buy-gems/paypal-ipn', data-env='sandbox', data-custom='?uid={{user._id}}&apiToken={{user.apiToken}}') + + .modal-footer + button.btn.btn-default.cancel(ng-click='modals.buyGems = false') Cancel \ No newline at end of file diff --git a/views/shared/modals/index.jade b/views/shared/modals/index.jade index 4bf003b160..6d15f517b7 100644 --- a/views/shared/modals/index.jade +++ b/views/shared/modals/index.jade @@ -3,8 +3,7 @@ include ./login include ./reroll include ./death include ./new-stuff -include ./why-ads -include ./more-gems +include ./buy-gems include ./members include ./settings include ./pets \ No newline at end of file diff --git a/views/shared/modals/more-gems.jade b/views/shared/modals/more-gems.jade deleted file mode 100644 index b33d4dd87f..0000000000 --- a/views/shared/modals/more-gems.jade +++ /dev/null @@ -1,10 +0,0 @@ -div(modal='modals.moreGems', header='Out Of Gems') - .modal-header - h3 Out Of Gems - .modal-body - include ../gems - p. - Oops, out of Gems, which are used to buy special items! Habit is an open source project, and can use all the help - it can get - buy more Gems to receive this pet, and consider it a donation to the contributors. - .modal-footer - button.btn.btn-default.cancel(ng-click='modals.moreGems = false') Cancel \ No newline at end of file diff --git a/views/shared/modals/reroll.jade b/views/shared/modals/reroll.jade index 4f48f8f4a6..0941593b32 100644 --- a/views/shared/modals/reroll.jade +++ b/views/shared/modals/reroll.jade @@ -11,7 +11,7 @@ div(modal='modals.reroll') .modal-footer span(ng-if='user.balance < 1') - a.btn.btn-success.btn-large(ng-click="showStripe()") Buy More Gems + a.btn.btn-success.btn-large(ng-click="modals.buyGems = true") Buy More Gems span.gem-cost Not enough Gems span(ng-if='user.balance >= 1', ng-controller='SettingsCtrl') a.btn.btn-danger.btn-large(ng-click='reroll()') Re-Roll diff --git a/views/shared/modals/why-ads.jade b/views/shared/modals/why-ads.jade deleted file mode 100644 index 2e35033178..0000000000 --- a/views/shared/modals/why-ads.jade +++ /dev/null @@ -1,12 +0,0 @@ -div(modal='modals.whyAds') - .modal-header - h3 Why Ads? - .modal-body - p. - Habit is an open source project, and can use all the help it can get - consider this a donation to the contributors. You also get 20 Gems from the purchase, which you can use to buy special items. - p. - "Hey, I backed the Kickstarter!" - follow these instructions. - script(src='/bower_components/JavaScriptButtons/dist/paypal-button.min.js?merchant=tylerrenelle-facilitator@gmail.com', data-button='buynow', data-name='20 Gems, Disable Ads, Donation to the Developers', data-quantity='1', data-amount='.1', data-currency='USD', data-shipping='0', data-tax='0', data-callback='#{env.BASE_URL}/api/v1/user/buy-gems/paypal-ipn', data-env='sandbox', data-custom='?uid={{user._id}}&apiToken={{user.apiToken}}') - - .modal-footer - button.btn.btn-default.cancel(ng-click='modals.whyAds = false') Ok \ No newline at end of file diff --git a/views/tasks/ads.jade b/views/tasks/ads.jade index 4337c96f8f..f86d0bb5f6 100644 --- a/views/tasks/ads.jade +++ b/views/tasks/ads.jade @@ -1,10 +1,7 @@ div(ng-if='authenticated() && user.flags.ads!="hide"') span.pull-right(ng-if='list.type!="reward"') - a(ng-click='showStripe()', tooltip='Remove Ads') + a(ng-click='modals.buyGems=true', tooltip='Remove Ads') i.icon-remove - br - a(ng-click='modals.whyAds=true', tooltip='Why Ads?') - i.icon-question-sign div(ng-if='list.type=="habit"', habitrpg-adsense) script(async='async', src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js')