use _items.next for the store, so we can access other _items

throughout the app
This commit is contained in:
Tyler Renelle 2013-05-10 16:42:21 +01:00
parent d696d1946d
commit fcebebc601
2 changed files with 18 additions and 19 deletions

View file

@ -78,6 +78,7 @@ _.each items.hatchingPotions, (hatchingPotion) -> hatchingPotion.notes = "Pour t
server exports
###
module.exports.server = (model) ->
model.set '_items', items
updateStore(model)
###
@ -127,6 +128,7 @@ module.exports.app = (appExports, model) ->
update store
###
module.exports.updateStore = updateStore = (model) ->
model.setNull '_items.next', {}
user = model.at('_user')
equipped = user.get('items')
@ -141,12 +143,9 @@ module.exports.updateStore = updateStore = (model) ->
else if i is items[type].length
showNext = false
model.set "_items.#{type}", if showNext then items[type][i] else {hide:true}
model.set '_items.potion', items.potion
model.set '_items.reroll', items.reroll
model.set '_items.pets', items.pets
model.set '_items.hatchingPotions', items.hatchingPotions
model.set "_items.next.#{type}", if showNext then items[type][i] else {hide:true}

View file

@ -36,12 +36,12 @@
<!-- Static Rewards -->
<ul class='items' style="{#unless _user.flags.itemsEnabled}display:none{/}">
{#with _items.weapon as :item}<app:rewards:item />{/}
{#with _items.armor as :item}<app:rewards:item />{/}
{#with _items.head as :item}<app:rewards:item />{/}
{#with _items.shield as :item}<app:rewards:item />{/}
{#with _items.potion as :item}<app:rewards:item />{/}
{#with _items.reroll as :item}<app:rewards:item reroll=true />{/}
<app:rewards:item item={_items.next.weapon} />
<app:rewards:item item={_items.next.armor} />
<app:rewards:item item={_items.next.head} />
<app:rewards:item item={_items.next.shield} />
<app:rewards:item item={_items.potion} />
<app:rewards:item item={_items.reroll} />
</ul>
<app:tasks:ads>
@ -61,24 +61,24 @@
<item:>
<li class="task reward-item {#if :item.hide}hide{/}">
<li class="task reward-item {#if @item.hide}hide{/}">
<!-- right-hand side control buttons -->
<div class="task-meta-controls">
<span rel="popover" data-trigger="hover" data-placement="left" data-content="{:item.notes}" data-original-title="{:item.text}" class='task-notes'><i class="icon-comment"></i></span>
<span rel="popover" data-trigger="hover" data-placement="left" data-content="{@item.notes}" data-original-title="{@item.text}" class='task-notes'><i class="icon-comment"></i></span>
</div>
<!-- left-hand size commands -->
<div class="task-controls">
{#if @reroll}
{#if equal(@item.type),'reroll')}
<a class="task-action-btn btn-reroll" data-toggle="modal" data-target="#reroll-modal"><i class='icon-repeat'></i></a>
{else}
<a class="money btn-buy item-btn" x-bind=click:buyItem data-type={:item.type} data-value={:item.value} data-index={:item.index}>
<span class="reward-cost">{:item.value}</span>
<a class="money btn-buy item-btn" x-bind=click:buyItem data-type={@item.type} data-value={@item.value} data-index={@item.index}>
<span class="reward-cost">{@item.value}</span>
<span class='shop_gold'></span>
</a>
{/}
</div>
<!-- main content -->
<span class="shop_{:item.classes} shop-sprite item-img"></span>
<p class="task-text">{:item.text}</p>
<span class="shop_{@item.classes} shop-sprite item-img"></span>
<p class="task-text">{@item.text}</p>
</li>