From a04bc63b877588c40fecf1047c6dfe9410277317 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 18 Nov 2014 13:20:51 -0800 Subject: [PATCH] Equip hint and available header now are visible only when there are items to equip. --- app/templates/game-menu/inventory-modal.jade | 4 ++-- app/views/game-menu/InventoryModal.coffee | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/templates/game-menu/inventory-modal.jade b/app/templates/game-menu/inventory-modal.jade index e50d66156..5e59d658e 100644 --- a/app/templates/game-menu/inventory-modal.jade +++ b/app/templates/game-menu/inventory-modal.jade @@ -25,12 +25,12 @@ if itemGroups.availableItems.models.length h4#available-description(data-i18n="inventory.available_item") for item in itemGroups.availableItems.models - .item(class=item.classes, data-item-id=item.id) + .item.available(class=item.classes, data-item-id=item.id) img(src=item.getPortraitURL()) button.btn.equip-item(data-i18n="inventory.equip") .clearfix - #double-click-hint.alert.alert-info.secret(data-i18n="inventory.should_equip") + #double-click-hint.alert.alert-info(data-i18n="inventory.should_equip") if itemGroups.restrictedItems.models.length h4#restricted-description(data-i18n="inventory.restricted_title") diff --git a/app/views/game-menu/InventoryModal.coffee b/app/views/game-menu/InventoryModal.coffee index 692503bfb..b33ac180a 100644 --- a/app/views/game-menu/InventoryModal.coffee +++ b/app/views/game-menu/InventoryModal.coffee @@ -127,6 +127,7 @@ module.exports = class InventoryModal extends ModalView @insertSubView(@itemDetailsView) @requireLevelEquipment() @$el.find('.nano').nanoScroller({alwaysVisible: true}) + @onSelectionChanged() afterInsert: -> super() @@ -330,6 +331,10 @@ module.exports = class InventoryModal extends ModalView @$el.find('#unequipped .item.active') onSelectionChanged: -> + heroClass = @selectedHero?.get('heroClass') + itemsCanBeEquipped = @$el.find('#unequipped .item.available:not(.equipped)').filter('.'+heroClass).length + toShow = @$el.find('#double-click-hint, #available-description') + if itemsCanBeEquipped then toShow.removeClass('secret') else toShow.addClass('secret') @delegateEvents() @@ -393,7 +398,6 @@ module.exports = class InventoryModal extends ModalView @highlightElement availableSlotSelector, delay: 500, sides: ['right'], rotation: Math.PI / 2 @$el.find(availableSlotSelector).addClass 'should-equip' @$el.find("#equipped div[data-slot='#{slot}']").addClass 'should-equip' - @$el.find('#double-click-hint').removeClass('secret') @remainingRequiredEquipment.push slot: slot, item: gear[item] if hadRequired and not @remainingRequiredEquipment.length @endHighlight()