Made hero attribute reactive and iterated inventory UI
This commit is contained in:
@@ -37,7 +37,7 @@ this.GlobalUI = (function() {
|
||||
GlobalUI.showDetail = function(opts) {
|
||||
Session.set("global.ui.detailData", opts.data);
|
||||
Session.set("global.ui.detailTemplate", opts.template);
|
||||
GlobalUI.detailHero = opts.hero;
|
||||
Session.set("global.ui.detailHeroId", opts.heroId);
|
||||
Session.set("global.ui.detailShow", true);
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ this.GlobalUI = (function() {
|
||||
GlobalUI.setDetail = function(opts) {
|
||||
Session.set("global.ui.detailData", opts.data);
|
||||
Session.set("global.ui.detailTemplate", opts.template);
|
||||
GlobalUI.detailHero = opts.hero;
|
||||
Session.set("global.ui.detailHeroId", opts.heroId);
|
||||
};
|
||||
|
||||
GlobalUI.closeDetail = function(){
|
||||
@@ -108,21 +108,15 @@ Template.layout.events({
|
||||
} else {
|
||||
Session.set("global.ui.detailData", null);
|
||||
Session.set("global.ui.detailTemplate", null);
|
||||
//remove the hero attribute
|
||||
var heroElem = GlobalUI.detailHero;
|
||||
heroElem && heroElem.attr("hero", null);
|
||||
heroElem && heroElem.find("[hero-id]").attr("hero", null);
|
||||
GlobalUI.detailHero = null;
|
||||
Session.set("global.ui.detailHeroId", null);
|
||||
}
|
||||
},
|
||||
"core-animated-pages-transition-prepare": function(e) {
|
||||
var detailOpened = Session.get("global.ui.detailShow");
|
||||
if(detailOpened) {
|
||||
//add the hero attribute where needed
|
||||
var heroElem = GlobalUI.detailHero;
|
||||
heroElem && heroElem.attr("hero", "");
|
||||
heroElem && heroElem.find("[hero-id]").attr("hero", "");
|
||||
//set up the transition
|
||||
} else {
|
||||
//undo hack
|
||||
$("#mainContentSection").removeClass("fake-selected");
|
||||
}
|
||||
},
|
||||
|
||||
5
rpg-docs/client/globalHelpers/detailHero.js
Normal file
5
rpg-docs/client/globalHelpers/detailHero.js
Normal file
@@ -0,0 +1,5 @@
|
||||
Template.registerHelper("detailHero", function(){
|
||||
if ( Session.equals("global.ui.detailHeroId", this._id) ) {
|
||||
return "hero";
|
||||
}
|
||||
});
|
||||
6
rpg-docs/client/globalHelpers/round.js
Normal file
6
rpg-docs/client/globalHelpers/round.js
Normal file
@@ -0,0 +1,6 @@
|
||||
Template.registerHelper("round", function(value, decimalPlaces){
|
||||
decimalPlaces = +decimalPlaces || 2;
|
||||
var num = +value;
|
||||
var tens = Math.pow(10, decimalPlaces)
|
||||
return Math.round(num * tens) / tens;
|
||||
});
|
||||
Reference in New Issue
Block a user