Generalised some dialogs

This commit is contained in:
Thaum
2015-02-27 06:14:34 +00:00
parent 56f8e95d81
commit 040d5a514b
50 changed files with 532 additions and 954 deletions

View File

@@ -1,29 +1,10 @@
Template.spellListDialog.rendered = function(){
var self = this;
//update all autogrows after they've been filled
var pata = this.$("paper-autogrow-textarea");
pata.each(function(index, el){
el.update($(el).children().get(0));
})
//update all input fields as well
var input = this.$("paper-input");
input.each(function(index, el){
el.valueChanged();
})
//after the dialog is built, open it
if (!this.alreadyRendered){
Session.set("global.ui.detailShow", true);
this.alreadyRendered = true;
}
}
Template.spellListDialog.events({
"tap #backButton": function(){
GlobalUI.closeDetail();
"color-change": function(event, instance){
SpellLists.update(instance.data.spellListId, {$set: {color: event.color}});
},
"tap #deleteSpellList": function(){
SpellLists.remove(this._id);
GlobalUI.closeDetail();
"tap #deleteButton": function(event, instance){
SpellLists.remove(instance.data.spellListId);
GlobalUI.closeDetail()
},
//TODO clean up String -> num here so they don't need casting by Schema.clean
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
@@ -43,20 +24,14 @@ Template.spellListDialog.events({
var value = event.currentTarget.value
SpellLists.update(this._id, {$set: {maxPrepared: value}});
},
//TODO change #spellListDescription
"core-select .colorDropdown": function(event){
var detail = event.originalEvent.detail;
if(!detail.isSelected) return;
var value = detail.item.getAttribute("name");
SpellLists.update(this._id, {$set: {color: value}});
}
"change #spellListDescriptionInput": function(event){
var value = event.currentTarget.value
SpellLists.update(this._id, {$set: {description: value}});
},
});
Template.spellListDialog.helpers({
spellList: function(){
return SpellLists.findOne(this.spellListId);
},
colorClass: function(){
return getColorClass(this.color)
}
});