From 22caaa7eda5898d5249c1dab99ac615c4b7e4b90 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Wed, 28 Oct 2015 17:48:16 -0400 Subject: [PATCH] feat(sharing): More opt outs Also fixes a bug where "Display Now" didn't work for pets with a space in their name. --- website/public/js/controllers/inventoryCtrl.js | 4 ++-- .../public/js/controllers/notificationCtrl.js | 2 +- website/src/routes/pages.js | 2 +- website/views/shared/modals/hatch-pet.jade | 5 ++--- website/views/shared/modals/level-up.jade | 3 +-- website/views/shared/modals/raise-pet.jade | 17 ++++++++++++++--- website/views/social/raise-pet.jade | 15 +++++++++++++++ 7 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 website/views/social/raise-pet.jade diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index 0fc8a04c8b..75a9955286 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -116,7 +116,7 @@ habitrpg.controller("InventoryCtrl", if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return; user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}}); if (!user.preferences.suppressModals.hatchPet) { - $rootScope.hatchedPet = {egg: eggName, potion: potName, pet: 'Pet-' + egg.key + '-' + potion.key}; + $rootScope.hatchedPet = {egg: eggName, potion: potName, eggKey: egg.key, pet: 'Pet-' + egg.key + '-' + potion.key}; $rootScope.openModal('hatchPet', {controller: 'InventoryCtrl', size: 'sm'}); } $scope.selectedEgg = null; @@ -160,7 +160,7 @@ habitrpg.controller("InventoryCtrl", $scope.selectedFood = null; _updateDropAnimalCount(user.items); - if ($scope.mountCount > startingMounts) { + if ($scope.mountCount > startingMounts && !user.preferences.suppressModals.raisePet) { $rootScope.raisedPet = {displayName: petDisplayName, spriteName: pet, egg: egg, potion: potion} $rootScope.openModal('raisePet', {controller:'InventoryCtrl',size:'sm'}); } diff --git a/website/public/js/controllers/notificationCtrl.js b/website/public/js/controllers/notificationCtrl.js index 3063f70594..bbaf4925a8 100644 --- a/website/public/js/controllers/notificationCtrl.js +++ b/website/public/js/controllers/notificationCtrl.js @@ -65,7 +65,7 @@ habitrpg.controller('NotificationCtrl', if (after > before) { Notification.lvl(); $rootScope.playSound('Level_Up'); - $rootScope.openModal('levelUp', {controller:'UserCtrl', size:'sm'}); + if (!User.user.preferences.suppressModals.levelUp) $rootScope.openModal('levelUp', {controller:'UserCtrl', size:'sm'}); } }); diff --git a/website/src/routes/pages.js b/website/src/routes/pages.js index 1504ef1701..05ef2f9574 100644 --- a/website/src/routes/pages.js +++ b/website/src/routes/pages.js @@ -33,7 +33,7 @@ _.each(pages, function(name){ // -------- Social Media Sharing -------- -var shareables = ['level-up','hatch-pet']; +var shareables = ['level-up','hatch-pet','raise-pet']; _.each(shareables, function(name){ router.get('/social/' + name, i18n.getUserLanguage, locals, function(req, res) { diff --git a/website/views/shared/modals/hatch-pet.jade b/website/views/shared/modals/hatch-pet.jade index b3b6993ae9..2baf86f018 100644 --- a/website/views/shared/modals/hatch-pet.jade +++ b/website/views/shared/modals/hatch-pet.jade @@ -1,7 +1,6 @@ include ../avatar/generated_avatar script(type='text/ng-template', id='modals/hatchPet.html') - div(id='fb-root') .modal-content(style='min-width:28em') .modal-body.text-center(style='padding-bottom:0') h3(style='margin-bottom: 0')=env.t('hatchedPet',{egg:'{{::hatchedPet.egg}}', potion:'{{::hatchedPet.potion}}'}) @@ -17,7 +16,7 @@ script(type='text/ng-template', id='modals/hatchPet.html') +generatedAvatar p=env.t('earnedCompanion') br - button.btn.btn-primary(ng-click='choosePet(hatchedPet.egg, hatchedPet.potion); $close()')=env.t('displayNow') + button.btn.btn-primary(ng-click='choosePet(hatchedPet.eggKey, hatchedPet.potion); $close()')=env.t('displayNow') button.btn.btn-default(ng-click='$close()')=env.t('displayLater') .checkbox label(style='display:inline-block')=env.t('dontShowAgain') @@ -26,7 +25,7 @@ script(type='text/ng-template', id='modals/hatchPet.html') .container-fluid .row .col-xs-3 - a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I+just+hatched+a+{{::hatchedPet.potion}}+{{::hatchedPet.egg}}+by+completing+my+real-life+tasks!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/hatch-pet&count=none')=env.t('tweet') + a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I just hatched a {{::hatchedPet.potion}} {{::hatchedPet.egg}} by completing my real-life tasks!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/hatch-pet&count=none')=env.t('tweet') .col-xs-4(style='margin-left:.8em') .fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/hatch-pet', data-layout='button') .col-xs-4(style='margin-left:.8em') diff --git a/website/views/shared/modals/level-up.jade b/website/views/shared/modals/level-up.jade index 378e4607c7..43fdf73db3 100644 --- a/website/views/shared/modals/level-up.jade +++ b/website/views/shared/modals/level-up.jade @@ -1,7 +1,6 @@ include ../avatar/generated_avatar script(type='text/ng-template', id='modals/levelUp.html') - div(id='fb-root') .modal-content(style='min-width:28em') .modal-body.text-center(style='padding-bottom:0') h3(style='margin-bottom: 0')=env.t('gainedLevel') @@ -24,7 +23,7 @@ script(type='text/ng-template', id='modals/levelUp.html') .container-fluid .row .col-xs-3 - a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I+got+to+Level+{{::user.stats.lvl}}+in+Habitica+by+improving+my+real-life+habits!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/level-up&count=none')=env.t('tweet') + a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I got to Level {{::user.stats.lvl}} in Habitica by improving my real-life habits!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/level-up&count=none')=env.t('tweet') .col-xs-4(style='margin-left:.8em') .fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/level-up', data-layout='button') .col-xs-4(style='margin-left:.8em') diff --git a/website/views/shared/modals/raise-pet.jade b/website/views/shared/modals/raise-pet.jade index b1fe946ea7..ba6be7eae5 100644 --- a/website/views/shared/modals/raise-pet.jade +++ b/website/views/shared/modals/raise-pet.jade @@ -2,7 +2,7 @@ include ../avatar/generated_avatar script(type='text/ng-template', id='modals/raisePet.html') .modal-content(style='min-width:28em') - .modal-body.text-center + .modal-body.text-center(style='padding-bottom:0') h3(style='margin-bottom: 0')=env.t('raisedPet',{pet:'{{::raisedPet.displayName}}'}) .container-fluid .row(style='margin-bottom:1em', ng-controller='UserCtrl') @@ -15,7 +15,18 @@ script(type='text/ng-template', id='modals/raisePet.html') +generatedAvatar span(class='Mount_Head_{{::raisedPet.spriteName}}') p=env.t('earnedSteed') - .modal-footer(style='margin-top:0') + br button.btn.btn-primary(ng-click='chooseMount(raisedPet.egg, raisedPet.potion); $close()')=env.t('rideNow') button.btn.btn-default(ng-click='$close()')=env.t('rideLater') - + .checkbox + label(style='display:inline-block')=env.t('dontShowAgain') + input(type='checkbox', ng-model='user.preferences.suppressModals.raisePet', ng-change='set({"preferences.suppressModals.raisePet": user.preferences.suppressModals.raisePet?true: false})') + .modal-footer(style='margin-top:0', ng-init='loadWidgets()') + .container-fluid + .row + .col-xs-3 + a.twitter-share-button(href='https://twitter.com/intent/tweet?text=I just raised a {{::raisedPet.displayName}} mount by completing my real-life tasks!&via=habitica&url=https://habitrpg-gamma.herokuapp.com/social/raise-pet&count=none')=env.t('tweet') + .col-xs-4(style='margin-left:.8em') + .fb-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/raise-pet', data-layout='button') + .col-xs-4(style='margin-left:.8em') + a.tumblr-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/raise-pet', data-notes='none') diff --git a/website/views/social/raise-pet.jade b/website/views/social/raise-pet.jade new file mode 100644 index 0000000000..1d3f39ac51 --- /dev/null +++ b/website/views/social/raise-pet.jade @@ -0,0 +1,15 @@ +doctype html +html + head + meta(name='twitter:card' content='summary') + meta(name='twitter:site' content='@habitica') + meta(name='twitter:title' content='Raised a Pet into a Mount!') + meta(name='twitter:description' content='In Habitica, collectible pets grow along with you as you advance you real-life goals. My progress has turned a pet into a trusty mount!') + meta(name='twitter:image' content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo.png') + meta(property='og:url', content='https://habitica.com/social/raise-pet') + meta(property='og:type', content='website') + meta(property='og:title', content='Level Up!') + meta(property='og:description', content='In Habitica, collectible pets grow along with you as you advance you real-life goals. My progress has turned a pet into a trusty mount!') + meta(property='og:site_name', content='Habitica') + meta(property='og:image', content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo_300x300.png') + meta(property='fb:app_id', content='128307497299777')