Added XP, changed spellslot display

This commit is contained in:
Thaum
2015-02-20 10:09:53 +00:00
parent 93578709cd
commit bd86c1608e
18 changed files with 355 additions and 45 deletions

View File

@@ -1,22 +1,47 @@
Template.journal.created = function(){
var self = this;
self.experiencesLimit = new ReactiveVar(self.data.settings && self.data.settings.experiencesInc || 10);
};
Template.journal.helpers({
notes: function(){
return Notes.find({charId: this._id}, {sort: {color: 1, name: 1}});
},
experiences: function(){
return Experiences.find({charId: this._id}, {sort: {dateAdded: -1}, limit: Template.instance().experiencesLimit.get()});
},
notMoreExperiences: function(){
return Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get();
},
cantCollapse: function(){
return Template.instance().experiencesLimit.get() <= (this.settings && this.settings.experiencesInc || 10);
},
moreExperiencesOrCollapse: function(){
return (!(Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get())) ||
Template.instance().experiencesLimit.get() > (this.settings && this.settings.experiencesInc || 10);
}
});
Template.journal.events({
"tap .containerTop": function(event){
"tap .noteTop": function(event){
GlobalUI.setDetail({
template: "noteDialog",
data: {noteId: this._id, charId: this.charId},
heroId: this._id
});
},
"tap .experience": function(event){
GlobalUI.setDetail({
template: "experienceDialog",
data: {experienceId: this._id, charId: this.charId},
heroId: this._id
});
},
"tap #addNote": function(event){
var charId = this.charId;
var charId = this._id;
Notes.insert({
name: "New Note",
charId: this._id
charId: charId
}, function(error, id){
if(!error){
GlobalUI.setDetail({
@@ -28,21 +53,32 @@ Template.journal.events({
});
},
"tap #addXP": function(event){
var charId = this.charId;
var listId = this.listId;
throw new Error("not implemented")/*
Spells.insert({
name: "New Spell",
charId: this._id,
listId: SpellLists.findOne({charId: this._id})._id
var charId = this._id;
Experiences.insert({
charId: charId
}, function(error, id){
if(!error){
GlobalUI.setDetail({
template: "spellDialog",
data: {spellId: id, charId: charId, listId: listId},
heroId: id
template: "experienceDialog",
data: {experienceId: id, charId: charId},
heroId: id
});
}
});*/
})
},
"tap #moreExperiences": function(event){
var inst = Template.instance();
inst.experiencesLimit.set(inst.experiencesLimit.get() + (this.settings && this.settings.experiencesInc || 10));
},
"tap #lessExperiences": function(event){
var inst = Template.instance();
inst.experiencesLimit.set(this.settings && this.settings.experiencesInc || 10);
//scroll to the top of the div
inst.$(".scroll-y").animate({
scrollTop: inst.$(".scroll-y").scrollTop() + inst.$(".experiencesCard").position().top - 8
}, 300);
//HACK giggle the columns :( to workaround chrome bug that stops .containers height from updating
var cs = inst.$(".containers").removeClass("containers");
_.defer(function(){cs.addClass("containers")});
}
});