Table of Contents

InventoryUI

Type: Const Container Object

InventoryUI is a static container holding functions to render the inventory UI, as well as the object details UI (FIXME).

FIXME mention the CSS yadda yadda.

FIXME talk about how the default implementations function.

InventoryUI.render( config )

Given a configuration object, this function renders the inventory UI into a DOM container (which is passed as part of the config object).

This function is called by the InventoryUI macro (see the Macro documentation for more details). You probably don't want to use this function directly unless you are extending LibEcho itself.

The Configuration Object

Type: Plain Old Javascript Object (acting as an associative array)

The configuration object is just a plain old javascript object containing a number of configuration fields and their values. For more information, see the InventoryUI Macro source code.

parentElement

The parent element to render the UI into.

leftInventory

The GeneralInventory (or subclass) or Person that appears on the left side of the inventory UI. This is conventionally the inventory of the person who is picking things up, or the inventory that things are being picked up and put into, but it can actually be any inventory or person. FIXME It doesn't work on Person at the moment.

rightInventory

The GeneralInventory (or subclass) or Person that appears on the right side of the inventory UI. This is conventionally the inventory from which things are being taken, but it can actually be any inventory or person. FIXME It doesn't work on Person at the moment.

onClose( config )

Function to be called when inventory UI is closed. The InventoryUI macro uses this to evaluate the tweecode in the contents of the macro body when the InventoryUI dialog is closed.

allowClose( config )

If this function returns a String, that value will be printed in place of the “Done” link at the bottom of the inventory modal (preventing the modal from being closed). This can be used to prevent the inventory from being able to be closed until certain items have been taken or dropped, for example. If the return value is a falsy value, the regular “Done” link will be displayed, allowing the modal to be closed.

actor

The Person interacting with the inventory.

leftAction

The action label for moving item from left inventory.

leftActioned

The left action success word. “ObjectName: dropped.”

rightAction

The action label for moving item from right inventory.

rightActioned

The left action success word. “ObjectName: taken.”

canShowOnLeft( item, config )

Called to check if the object will be displayed in left inventory at all.

canShowOnRight( item, config )

Called to check if the object will be displayed in right inventory at all.

canMoveFromLeft( item, config )

The item will be shown in the left inventory, but will we show the control to move it to the right inventory?

canMoveFromRight( item, config )

The item will be shown in the right inventory, but will we show the control to move it to the right inventory?

getSortCategory( item, inventory, config )

Return object category for the sort selector.

canShowLeftSelector

Will the left selector be shown?

canShowRightSelector

Will the right selector be shown?

moveFromLeft( item, config )

Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used.

moveFromRight( item, config )

Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used.

leftTitle

Override the left title.

rightTitle

Override the right title.

leftName( item, config )

Override the left label for item.

rightName( item, config )

Override the right label for item.

outerTpl

Override the builtin outer HTML template.

listitemTplLeft

Override the builtin left list item HTML template.

listitemTplRight

Override the builtin right list item HTML template.

detailsTpl

Override the builtin item details HTML template.