Files
habitica/website/client/mixins/guide.js
Keith Holliday 0233f7b486 More fixes (#8988)
* Links stay white on hover

* Fixed task icon color

* Disabled plus button when needed

* Fixed difficulty color

* Fixed task reward color

* Updated create styles

* Fixed group plan link

* Fixed second group test modal

* Added login incentives

* Fixed group notification clear

* Show baily correctly

* Styled armoire notification

* Fixed contributor achievement styles

* Fixed death

* Fixed drop styles

* Fixed invited friend modal

* Fixed joined challenge achievement style

* Fixed joined guild style

* Fixed level up styles

* Updated low health styles

* Fixed bailey styles

* Updated quest completed

* Added soem conditionals to hide modals

* Added rebirth styles

* Fixed rebirth enable styles

* Fixed streak styles

* Fixed testing modals

* Fixed ultimate gear achievement

* Fixed won challenge

* Set user to welcomed if created on mobile

* Removed old default tasks

* Began adding more options to avatar

* Added change class

* Inbox to messages

* Moved profile to menu

* Added user modal for viewing a user and send message

* Fixed conversations

* Fixed lint

* Fixed challenges sending to server

* Added challenge progress view

* Fixed group sync after pay

* Fixed some group accepting features

* Fixed initial chat loading

* Fixed some exitence errors

* Added user names to assigned

* Added upgrade link

* Began adding new payment flow

* Added default tasks

* Updated avatar styles

* Updated tutorial styles

* Rebuilt notifications and styles

* Updated upload script

* Fixed lint

* Added default tasks back to mobile and added updated tests

* More test fixes
2017-08-25 20:56:21 -06:00

185 lines
5.1 KiB
JavaScript

import times from 'lodash/times';
import Intro from 'intro.js/';
export default {
data () {
return {
TOUR_END: -2,
tour: {},
chapters: {},
loaded: false,
};
},
watch: {
$route () {
this.routeChange();
},
},
methods: {
initTour () {
if (this.loaded) return;
this.chapters = {
intro: [
[
{
intro: this.$t('introTour'),
scrollTo: 'tooltip',
},
],
],
classes: [
[
{
orphan: true,
intro: this.$t('classGearText'),
final: true,
state: 'options.inventory.equipment',
element: '.weapon',
title: this.$t('classGear'),
hideNavigation: true,
},
],
],
stats: [[
{
orphan: true,
intro: this.$t('tourStatsPage'),
final: true,
proceed: this.$t('tourOkay'),
hideNavigation: true,
},
]],
tavern: [[
{
orphan: true,
intro: this.$t('tourTavernPage'),
final: true,
proceed: this.$t('tourAwesome'),
hideNavigation: true,
},
]],
party: [[
{
orphan: true,
intro: this.$t('tourPartyPage'),
final: true,
proceed: this.$t('tourSplendid'),
hideNavigation: true,
},
]],
guilds: [[
{
intro: this.$t('tourGuildsPage'),
},
]],
challenges: [[
{
intro: this.$t('tourChallengesPage'),
},
]],
market: [[
{
intro: this.$t('tourMarketPage'),
},
]],
hall: [[
{
intro: this.$t('tourHallPage'),
},
]],
pets: [[
{
intro: this.$t('tourPetsPage'),
},
]],
mounts: [[
{
intro: this.$t('tourMountsPage'),
},
]],
equipment: [[
{
intro: this.$t('tourEquipmentPage'),
},
]],
};
this.loaded = true;
},
routeChange () {
this.initTour();
switch (this.$route.name) {
// case 'options.profile.avatar': return goto('intro', 5);
case 'stats': return this.goto('stats', 0);
case 'tavern': return this.goto('tavern', 0);
case 'party': return this.goto('party', 0);
case 'guildsDiscovery': return this.goto('guilds', 0);
case 'challenges': return this.goto('challenges', 0);
case 'patrons': return this.goto('hall', 0);
case 'items': return this.goto('market', 0);
case 'stable': return this.goto('pets', 0);
// @TODO: same page now case 'stable': return this.goto('mounts', 0);
case 'equipment': return this.goto('equipment', 0);
}
},
hoyo (user) {
// @TODO: What is was the timeout for?
window.amplitude.setUserId(user._id);
window.ga('set', {userId: user._id});
},
goto (chapter, page, force) {
if (chapter === 'intro' && this.user.flags.welcomed !== true) {
// @TODO: Add dispatch User.set({'flags.welcomed': true});
}
if (chapter === 'classes' && this.user.flags.tour.classes === -2) return;
if (page === -1) page = 0;
let curr = this.user.flags.tour[chapter];
if (page !== curr + 1 && !force) return;
let opts = {}; // @TODO: chap._options;
opts.steps = [];
page += 1;
times(page, (p) => {
opts.steps = opts.steps.concat(this.chapters[chapter][p]);
});
// @TODO: Do we always need to initialize here?
let intro = Intro.introJs();
intro.setOptions({steps: opts.steps});
intro.start();
intro.oncomplete(() => {
this.markTourComplete(chapter);
});
},
markTourComplete (chapter) {
let ups = {};
let lastKnownStep = this.user.flags.tour[chapter];
// Return early if user has already completed this tutorial
if (lastKnownStep === -2) {
return;
}
// if (true) { // -2 indicates complete
// if (chapter === 'intro') {
// // Manually show bunny scroll reward
// // let rewardData = {
// // reward: [Shared.content.quests.dustbunnies],
// // rewardKey: ['inventory_quest_scroll_dustbunnies'],
// // rewardText: Shared.content.quests.dustbunnies.text(),
// // message: this.$t('checkinEarned'),
// // nextRewardAt: 1,
// // };
// // @TODO: Notification.showLoginIncentive(this.user, rewardData, Social.loadWidgets);
// }
// Mark tour complete
ups[`flags.tour.${chapter}`] = -2; // @TODO: Move magic numbers to enum
// @TODO: Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'tutorial','eventLabel':k+'-web','eventValue':i+1,'complete':true})
// }
this.$store.dispatch('user:set', ups);
},
},
};