diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js index 3d379139..90f617fb 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js @@ -40,6 +40,10 @@ Template.itemDialog.events({ }, }); +Template.itemEdit.onRendered(function(){ + updatePolymerInputs(this); +}); + Template.itemEdit.helpers({ ne1: function(num){ return num != 1; diff --git a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html index 1008a367..9af4fa71 100644 --- a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html +++ b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html @@ -1,75 +1,131 @@ + + + + \ No newline at end of file diff --git a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js index 8ee382a3..6894bd53 100644 --- a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js +++ b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js @@ -11,10 +11,61 @@ var spellLevels = [ { name: "Level 9", level: 9 }, ]; + +Template.spellDialog.onCreated(function(){ + this.editing = new ReactiveVar(false); +}); + Template.spellDialog.helpers({ spell: function(){ return Spells.findOne(this.spellId); }, + editing: function(){ + return Template.instance().editing.get(); + }, +}); + +Template.spellDialog.events({ + "color-change": function(event, instance){ + Spells.update(instance.data.spellId, {$set: {color: event.color}}); + }, + "tap #editButton": function(event, instance){ + instance.editing.set(true); + }, + "tap #doneEditingButton": function(event, instance){ + instance.editing.set(false); + }, + "tap #deleteButton": function(event, instance){ + Spells.softRemoveNode(instance.data.spellId); + GlobalUI.deletedToast(instance.data.spellId, "Spells", "Spell"); + GlobalUI.closeDetail(); + }, +}); + +Template.spellDetails.helpers({ + getComponents: function(){ + var components = ""; + if(this.components.concentration) components += "C"; + if(this.components.verbal) components += components.length? ", V" : "V"; + if(this.components.somatic) components += components.length? ", S" : "S"; + if(this.components.material) { + components += components.length? ", M" : "M"; + components += " (" + this.components.material + ")"; + } + return components; + }, + preparedString: function(){ + if(this.prepared === "prepared") return "prepared"; + if(this.prepared === "unprepared") return "unprepared"; + if(this.prepared === "always") return "always prepared"; + }, +}); + +Template.spellEdit.onRendered(function(){ + updatePolymerInputs(this); +}); + +Template.spellEdit.helpers({ spellLists: function(){ return SpellLists.find({charId: this.charId}, {fields: {name: 1}}); }, @@ -33,37 +84,29 @@ Template.spellDialog.helpers({ } }); -Template.spellDialog.events({ - "color-change": function(event, instance){ - Spells.update(instance.data.spellId, {$set: {color: event.color}}); - }, - "tap #deleteButton": function(event, instance){ - Spells.softRemoveNode(instance.data.spellId); - GlobalUI.deletedToast(instance.data.spellId, "Spells", "Spell"); - GlobalUI.closeDetail() - }, +Template.spellEdit.events({ "change #spellNameInput, input #spellNameInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {name: value}}); }, "change #castingTimeInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {castingTime: value}}); }, "change #rangeInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {range: value}}); }, "change #durationInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {duration: value}}); }, "change #materialInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {"components.material": value}}); }, "change #descriptionInput": function(event){ - var value = event.currentTarget.value + var value = event.currentTarget.value; Spells.update(this._id, {$set: {"description": value}}); }, "core-select #listDropdown": function(event){ diff --git a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js index 2aa8b367..63b3ac96 100644 --- a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js +++ b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js @@ -1,24 +1,14 @@ -Template.baseDialog.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(); - }) +Template.baseDialog.onRendered(function(){ + updatePolymerInputs(this); //after the dialog is built, open it if (!this.alreadyRendered){ Session.set("global.ui.detailShow", true); this.alreadyRendered = true; } -} +}); Template.baseDialog.events({ "tap #backButton": function(){ - GlobalUI.closeDetail() + GlobalUI.closeDetail(); } }); diff --git a/rpg-docs/lib/functions/updatePolymerInputs.js b/rpg-docs/lib/functions/updatePolymerInputs.js new file mode 100644 index 00000000..1967e106 --- /dev/null +++ b/rpg-docs/lib/functions/updatePolymerInputs.js @@ -0,0 +1,14 @@ +updatePolymerInputs = function(self){ + _.defer(function(){ + //update all autogrows after they've been filled + var pata = self.$("paper-autogrow-textarea"); + pata.each(function(index, el){ + el.update($(el).children().get(0)); + }); + //update all input fields as well + var input = self.$("paper-input"); + input.each(function(index, el){ + el.valueChanged(); + }); + }); +}; \ No newline at end of file