feat(sharing): Opt Out WIP

First draft of support for opting out of future modal display on specific events, and adds the second barebones target page for sharing.
This commit is contained in:
Sabe Jones
2015-10-28 16:36:47 -04:00
parent 27e3797307
commit f4ea6c1d5d
10 changed files with 97 additions and 17 deletions

View File

@@ -14,6 +14,11 @@
"startCollapsedPop": "With this option set, the list of task tags will be hidden when you first open a task for editing.",
"startAdvCollapsed": "Advanced Options in tasks start collapsed",
"startAdvCollapsedPop": "With this option set, Advanced Options will be hidden when you first open a task for editing.",
"dontShowAgain": "Don't show this again",
"suppressLevelUpModal": "Don't show popup when gaining a level",
"suppressHatchPetModal": "Don't show popup when hatching a pet",
"suppressRaisePetModal": "Don't show popup when raising a pet into a mount",
"suppressStreakModal": "Don't show popup when attaining a Streak achievement",
"showTour": "Show Tour",
"restartTour": "Restart the introductory tour from when you first joined Habitica.",
"showBailey": "Show Bailey",

View File

@@ -1,6 +1,6 @@
'use strict';
describe('Inventory Controller', function() {
describe.only('Inventory Controller', function() {
var scope, ctrl, user, rootScope;
beforeEach(function() {
@@ -18,6 +18,9 @@ describe('Inventory Controller', function() {
food: { Meat: 1 },
pets: {},
mounts: {}
},
preferences: {
suppressModals: {}
}
});
@@ -53,6 +56,11 @@ describe('Inventory Controller', function() {
expect(scope.selectedPotion.key).to.eql('Base');
});
describe('Hatching Pets', function(){
beforeEach(function() {
sandbox.stub(rootScope, 'openModal');
});
it('hatches a pet', function(){
scope.chooseEgg('Cactus');
scope.choosePotion('Base');
@@ -63,6 +71,23 @@ describe('Inventory Controller', function() {
expect(scope.selectedPotion).to.eql(null);
});
it('shows a modal for pet hatching', function(){
scope.chooseEgg('Cactus');
scope.choosePotion('Base');
expect(rootScope.openModal).to.have.been.calledOnce;
expect(rootScope.openModal).to.have.been.calledWith('hatchPet');
});
it('does not show pet hatching modal if user has opted out', function(){
user.preferences.suppressModals.hatchPet = true;
scope.chooseEgg('Cactus');
scope.choosePotion('Base');
expect(rootScope.openModal).to.not.be.called;
});
});
it('sells an egg', function(){
scope.chooseEgg('Cactus');
scope.sellInventory();

View File

@@ -112,8 +112,10 @@ habitrpg.controller("InventoryCtrl",
var potName = Content.hatchingPotions[potion.key].text();
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.openModal('hatchPet', {controller: 'InventoryCtrl', size: 'sm'});
}
$scope.selectedEgg = null;
$scope.selectedPotion = null;

View File

@@ -377,6 +377,12 @@ var UserSchema = new Schema({
// Those importantAnnouncements are in fact the recapture emails
importantAnnouncements: {type: Boolean, 'default': true},
weeklyRecaps: {type: Boolean, 'default': true}
},
suppressModals: {
levelUp: {type: Boolean, 'default': false},
hatchPet: {type: Boolean, 'default': false},
raisePet: {type: Boolean, 'default': false},
streak: {type: Boolean, 'default': false}
}
},
profile: {

View File

@@ -33,7 +33,7 @@ _.each(pages, function(name){
// -------- Social Media Sharing --------
var shareables = ['level-up'];
var shareables = ['level-up','hatch-pet'];
_.each(shareables, function(name){
router.get('/social/' + name, i18n.getUserLanguage, locals, function(req, res) {

View File

@@ -75,7 +75,18 @@ script(type='text/ng-template', id='partials/options.settings.settings.html')
label
input(type='checkbox', ng-model='user.preferences.displayInviteToPartyWhenPartyIs1', ng-change='set({"preferences.displayInviteToPartyWhenPartyIs1": user.preferences.displayInviteToPartyWhenPartyIs1 ? true : false})')
span.hint(popover-trigger='mouseenter', popover-placement='right', popover=env.t('displayInviteToPartyWhenPartyIs1'))=env.t('displayInviteToPartyWhenPartyIs1')
// button.btn.btn-default(ng-click='showTour()', popover-placement='right', popover-trigger='mouseenter', popover=env.t('restartTour'))= env.t('showTour')
.checkbox
label=env.t('suppressLevelUpModal')
input(type='checkbox', ng-model='user.preferences.suppressModals.levelUp', ng-change='set({"preferences.suppressModals.levelUp": user.preferences.suppressModals.levelUp?true: false})')
.checkbox
label=env.t('suppressHatchPetModal')
input(type='checkbox', ng-model='user.preferences.suppressModals.hatchPet', ng-change='set({"preferences.suppressModals.hatchPet": user.preferences.suppressModals.hatchPet?true: false})')
.checkbox
label=env.t('suppressRaisePetModal')
input(type='checkbox', ng-model='user.preferences.suppressModals.raisePet', ng-change='set({"preferences.suppressModals.raisePet": user.preferences.suppressModals.raisePet?true: false})')
.checkbox
label=env.t('suppressStreakModal')
input(type='checkbox', ng-model='user.preferences.suppressModals.streak', ng-change='set({"preferences.suppressModals.streak": user.preferences.suppressModals.streak?true: false})')
hr

View File

@@ -1,8 +1,9 @@
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
.modal-body.text-center(style='padding-bottom:0')
h3(style='margin-bottom: 0')=env.t('hatchedPet',{egg:'{{::hatchedPet.egg}}', potion:'{{::hatchedPet.potion}}'})
.container-fluid
.row(style='margin-bottom:1em', ng-controller='UserCtrl')
@@ -15,6 +16,18 @@ script(type='text/ng-template', id='modals/hatchPet.html')
.character-sprites(style='width:0; margin-top:.5em')
+generatedAvatar
p=env.t('earnedCompanion')
.modal-footer(style='margin-top:0')
br
button.btn.btn-primary(ng-click='choosePet(hatchedPet.egg, 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')
input(type='checkbox', ng-model='user.preferences.suppressModals.hatchPet', ng-change='set({"preferences.suppressModals.hatchPet": user.preferences.suppressModals.hatchPet?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+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')
a.tumblr-share-button(data-href='https://habitrpg-gamma.herokuapp.com/social/hatch-pet', data-notes='none')

View File

@@ -17,6 +17,9 @@ script(type='text/ng-template', id='modals/levelUp.html')
p=env.t('fullyHealed')
br
button.btn.btn-primary(ng-click='$close()')=env.t('huzzah')
.checkbox
label(style='display:inline-block')=env.t('dontShowAgain')
input(type='checkbox', ng-model='user.preferences.suppressModals.levelUp', ng-change='set({"preferences.suppressModals.levelUp": user.preferences.suppressModals.levelUp?true: false})')
.modal-footer(style='margin-top:0', ng-init='loadWidgets()')
.container-fluid
.row

View File

@@ -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='New Pet!')
meta(name='twitter:description' content='In Habitica, you earn cute companions as you accomplish real-world tasks. I\'ve worked hard and gotten myself a new pet!')
meta(name='twitter:image' content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo.png')
meta(property='og:url', content='https://habitica.com/social/hatch-pet')
meta(property='og:type', content='website')
meta(property='og:title', content='Level Up!')
meta(property='og:description', content='In Habitica, you earn cute companions as you accomplish real-world tasks. I\'ve worked hard and gotten myself a new pet!')
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')

View File

@@ -5,11 +5,11 @@ html
meta(name='twitter:site' content='@habitica')
meta(name='twitter:title' content='Level Up!')
meta(name='twitter:description' content='In Habitica, your avatar grows in strength as you improve your real-life habits. I\'ve attained a new level with what I\'ve accomplished!')
meta(name='twitter:image' content='')
meta(name='twitter:image' content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo.png')
meta(property='og:url', content='https://habitica.com/social/level-up')
meta(property='og:type', content='website')
meta(property='og:title', content='Level Up!')
meta(property='og:description', content='In Habitica, your avatar grows in strength as you improve your real-life habits. I\'ve attained a new level with what I\'ve accomplished!')
meta(property='og:site_name', content='Habitica')
meta(property='og:image', content='')
meta(property='og:image', content='https://s3.amazonaws.com/habitica-assets/assets/gryphon_logo_300x300.png')
meta(property='fb:app_id', content='128307497299777')