Files
habitica/website/client/mixins/notifications.js
T
Keith Holliday 39d7581c6c Merge Develop onto Release (#9123)
* Some random quick (#9111)

* Switch group button directions

* Allowed admins to export challenges

* Added scoping to some stable styles

* Fixed challenge cloning

* Tasks tags (#9112)

* Added auto apply and exit

* Add challenge tag editing

* Fixed lint

* Skill fixes (#9113)

* Added local storage setting for spell drawer

* Added new spell styles

* Fixed typo

* Reset local creds if access is denied (#9114)

* various fixes: group leader's name at top of edit drop-down; Members List; etc (#9117)

* fix text describing location of subscription/gem gift box

* disable Copy As To-Do in Tavern, guilds, party because it's not working

* change members label on group pages to Member List

* remove outdated info about seeing number of Gems available to buy

* allow Danger Zone to be seen by players without local authentication

Also add an hr because the Danger Zone heading was crammed up against the button above it.

* put current group leader's name at top of Leader change drop-down

* Client Fixes (#9120)

* unduplicate logout code

* re-enable debug menu

* fix pets badge and equipping mounts

* close gift modal after sending gems

* armoire notifications

* Oct 1 fixes (#9121)

* Added default tags to task

* Added seasonal gear check and show spooky

* Disabled spooky sparkles

* Fixed challenge remove tasks modal

* Hid checklist

* Added group gems modal

* Purchase with amazon

* Added check for user health

* Added missing notification file
2017-10-01 20:42:02 -05:00

84 lines
2.4 KiB
JavaScript

import habiticaMarkdown from 'habitica-markdown';
import { mapState } from 'client/libs/store';
import { getDropClass } from 'client/libs/notifications';
export default {
computed: {
...mapState({notifications: 'notificationStore'}),
},
methods: {
coins (money) {
return this.round(money, 2);
},
crit (val) {
let message = `${this.$t('critBonus')} ${Math.round(val)} %`;
this.notify(message, 'crit', 'glyphicon glyphicon-certificate');
},
drop (val, item) {
let dropClass = getDropClass({key: item.key, type: item.type});
this.notify(val, 'drop', dropClass);
},
quest (type, val) {
this.notify(this.$t(type, { val }), 'success');
},
exp (val) {
if (val < -50) return; // don't show when they level up (resetting their exp)
let message = `${this.sign(val)} ${this.round(val)}`;
this.notify(message, 'xp', 'glyphicon glyphicon-star', this.sign(val));
},
error (error) {
this.notify(error, 'error', 'glyphicon glyphicon-exclamation-sign');
},
gp (val, bonus) {
this.notify(`${this.sign(val)} ${this.coins(val - bonus)}`, 'gp', '', this.sign(val));
},
hp (val) {
// don't show notifications if user dead
this.notify(`${this.sign(val)} ${this.round(val)}`, 'hp', 'glyphicon glyphicon-heart', this.sign(val));
},
lvl () {
this.notify(this.$t('levelUp'), 'lvl', 'glyphicon glyphicon-chevron-up');
},
markdown (val) {
if (!val) return;
let parsedMarkdown = habiticaMarkdown.render(val);
this.notify(parsedMarkdown, 'info');
},
mp (val) {
this.notify(`${this.sign(val)} ${this.round(val)}`, 'mp', 'glyphicon glyphicon-fire', this.sign(val));
},
purchased (itemName) {
this.text(this.$t('purchasedItem', {
itemName,
}));
},
streak (val) {
this.notify(`${this.$t('streaks')}: ${val}`, 'streak', 'glyphicon glyphicon-repeat');
},
text (val, onClick) {
if (!val) return;
this.notify(val, 'info', null, null, onClick);
},
sign (number) {
let sign = '+';
if (number && number < 0) {
sign = '-';
}
return sign;
},
round (number, nDigits) {
return Math.abs(number.toFixed(nDigits || 1));
},
notify (html, type, icon, sign) {
this.notifications.push({
title: '',
text: html,
type,
icon,
sign,
timeout: true,
});
},
},
};