Echo Hollow

Gender-Bending Interactive Stories! :D

User Tools

Site Tools


smutbook:classes:inventory:inventoryui

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
smutbook:classes:inventory:inventoryui [2023/08/08 18:10] – created leesmutbook:classes:inventory:inventoryui [2023/08/09 17:20] (current) lee
Line 1: Line 1:
 ====== InventoryUI ====== ====== 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 ) =====
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
- +
-InventoryUI is a static container holding functions to render the inventory UI, as well as the object details UI (FIXME). +
- +
-==== 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). 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. 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:** Function 
 +  * **Arguments:**  
 +    * //config//: The configuration object, which controls how the UI is rendered.  See below. 
 +  * **Returns:** void 
 +  * **Throws:** Nothing 
 + 
 +===== The Configuration Object =====
  
-The configuration object can contain a number of fields.  The values of some of these fields can be a literal or a function.  In the case of a function it is called with the listed arguments and the return value is used as the configuration value.+**Type:** Plain Old Javascript Object (acting as an associative array)
  
-For more information, see the InventoryUI Macro source code.+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 ===+==== parentElement ====
 The parent element to render the UI into. The parent element to render the UI into.
-  * Type: jQuery DOM Element +  * **Type:** jQuery DOM Element 
-  * Default: DEFAULT +  * **Required**
-  Optional+
  
-=== leftInventory === +==== 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. +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
-  * Type: GeneralInventory or Person +  * **Type:** GeneralInventory or Person 
-  * Default: None +  * **Required**
-  * Required+
  
-=== rightInventory === +==== 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. +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
-  * Type: GeneralInventory or Person +  * **Type:** GeneralInventory or Person 
-  * Default: None +  * **Required**
-  * Required+
  
-=== onClose( config ) ===+==== 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. 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.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsVoid +  * **Arguments:**  
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryIU.render(). 
-  * Defaultundefined +  * **Returns:** void 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** undefined
  
-=== allowClose( config ) ===+==== 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. 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.
-  * Type: Function +  * **Type:** Function 
-  * Returns: String +  * **Arguments:**  
-  * Defaultundefined +    * //config//: The config object that was passed to InventoryIU.render(). 
-  * Optional+  * **Returns:** String 
 +  * **Throws:** Nothing 
 +  * **Default Value:** undefined
  
-=== actor ===+==== actor ====
 The Person interacting with the inventory. The Person interacting with the inventory.
-  * Type: Person or Function(config) returning Person +  * **Type:** Person or Function(config) returning Person 
-  * Default: undefined +  * **Default Value:** undefined
-  Optional+
  
-=== leftAction ===+==== leftAction ====
 The action label for moving item from left inventory. The action label for moving item from left inventory.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: "Drop" +  * **Default Value:** "Drop"
-  * Optional+
  
-=== leftActioned ===+==== leftActioned ====
 The left action success word.  "ObjectName: dropped." The left action success word.  "ObjectName: dropped."
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: "dropped" +  * **Default Value:** "dropped"
-  * Optional+
  
-=== rightAction ===+==== rightAction ====
 The action label for moving item from right inventory. The action label for moving item from right inventory.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: "Take" +  * **Default Value:** "Take"
-  * Optional+
  
-=== rightActioned ===+==== rightActioned ====
 The left action success word.  "ObjectName: taken." The left action success word.  "ObjectName: taken."
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: "taken" +  * **Default Value:** "taken"
-  * Optional+
  
-=== canShowOnLeft( item, config ) ===+==== canShowOnLeft( item, config ) ====
 Called to check if the object will be displayed in left inventory at all. Called to check if the object will be displayed in left inventory at all.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsBoolean +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show. +    * //item//: The item which we are checking whether or not we should show. 
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Defaulttrue +  * **Returns:** Boolean 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** true
  
-=== canShowOnRight( item, config ) ===+==== canShowOnRight( item, config ) ====
 Called to check if the object will be displayed in right inventory at all. Called to check if the object will be displayed in right inventory at all.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsBoolean +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show. +    * //item//: The item which we are checking whether or not we should show. 
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Defaulttrue +  * **Returns:** Boolean 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** true
  
-=== canMoveFromLeft( item, config ) ===+==== 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? The item will be shown in the left inventory, but will we show the control to move it to the right inventory?
-  * Type: Function +  * **Type:** Function 
-  * ReturnsBoolean +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item which we are checking whether or not we can move
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Defaulttrue +  * **Returns:** Boolean 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** true
  
-=== canMoveFromRight( item, config ) ===+==== 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? The item will be shown in the right inventory, but will we show the control to move it to the right inventory?
-  * Type: Function +  * **Type:** Function 
-  * ReturnsBoolean +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item which we are checking whether or not we can move
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Defaulttrue +  * **Returns:** Boolean 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** true
  
-=== getSortCategory( item, inventory, config ) ===+==== getSortCategory( item, inventory, config ) ====
 Return object category for the sort selector. Return object category for the sort selector.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsString +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item we are getting the sort category for
-  * //inventory//: The item which we are checking whether or not we should show+    * //inventory//: The inventory we are checking in
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Default: item.inventoryCategory "Other" +  * **Returns:** String 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** item.inventoryCategory or "Other" (if the item has no inventoryCategory).
  
-=== canShowLeftSelector ===+==== canShowLeftSelector ====
 Will the left selector be shown? Will the left selector be shown?
-  * Type: Boolean or Function(config) returning Boolean +  * **Type:** Boolean or Function(config) returning Boolean 
-  * Default: true +  * **Default Value:** true
-  Optional+
  
-=== canShowRightSelector ===+==== canShowRightSelector ====
 Will the right selector be shown? Will the right selector be shown?
-  * Type: Boolean or Function(config) returning Boolean +  * **Type:** Boolean or Function(config) returning Boolean 
-  * Default: true +  * **Default Value:** true
-  Optional+
  
-=== moveFromLeft( item, config ) ===+==== moveFromLeft( item, config ) ====
 Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used. Function to call to move item from left to right inventory. If undefined, the built-in implementation will be used.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsVoid +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item we are moving to the right-hand inventory
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Default: the builtin implementation is used if none is defined in the config object +  * **Returns:** void 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** the builtin implementationdefined in InventoryUI.js
  
-=== moveFromRight( item, config ) ===+==== moveFromRight( item, config ) ====
 Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used. Function to call to move item from right to left inventory. If undefined, the built-in implementation will be used.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsVoid +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item we are moving to the left-hand inventory
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Default: the builtin implementation is used if none is defined in the config object +  * **Returns:** void 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** the builtin implementationdefined in InventoryUI.js
  
-=== leftTitle ===+==== leftTitle ====
 Override the left title. Override the left title.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: if the left inventory is a Person then "Soandso (Inventory)", otherwise leftInventory.AName. +  * **Default Value:** if the left inventory is a Person then "Soandso (Inventory)", otherwise leftInventory.AName().
-  * Optional+
  
-=== rightTitle ===+==== rightTitle ====
 Override the right title. Override the right title.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: if the right inventory is a Person then "Soandso (Inventory)", otherwise rightInventory.AName. +  * **Default Value:** if the right inventory is a Person then "Soandso (Inventory)", otherwise rightInventory.AName().
-  * Optional+
  
-=== leftName( item, config ) ===+==== leftName( item, config ) ====
 Override the left label for item. Override the left label for item.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsString +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item we want the label for
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Default: the item'AName +  * **Returns:** String 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** the item.AName()
  
-=== rightName( item, config ) ===+==== rightName( item, config ) ====
 Override the right label for item. Override the right label for item.
-  * Type: Function +  * **Type:** Function 
-  * ReturnsString +  * **Arguments:**  
-  * //item//: The item which we are checking whether or not we should show+    * //item//: The item we want the label for
-  * //config//: The config object that was passed to InventoryIU.render(). +    * //config//: The config object that was passed to InventoryUI.render(). 
-  * Default: the item'AName +  * **Returns:** String 
-  * Optional+  * **Throws:** Nothing 
 +  * **Default Value:** the item.AName()
  
-=== outerTpl ===+==== outerTpl ====
 Override the builtin outer HTML template. Override the builtin outer HTML template.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: undefined +  * **Default Value:** undefined
-  Optional+
  
-=== listitemTplLeft ===+==== listitemTplLeft ====
 Override the builtin left list item HTML template. Override the builtin left list item HTML template.
-  * Type: String Function(config) returning String +  * **Type:** String or Function(config) returning String 
-  * Default: undefined +  * **Default Value:** undefined
-  Optional+
  
-=== listitemTplRight ===+==== listitemTplRight ====
 Override the builtin right list item HTML template. Override the builtin right list item HTML template.
-  * Type: String | Function(config) returning String +  * **Type:** String | Function(config) returning String 
-  * Default: undefined +  * **Default Value:** undefined
-  Optional+
  
-=== detailsTpl ===+==== detailsTpl ====
 Override the builtin item details HTML template. Override the builtin item details HTML template.
-  * Type: String | Function(config) returning String +  * **Type:** String | Function(config) returning String 
-  * Default: undefined +  * **Default Value:** undefined
-  Optional+
  
smutbook/classes/inventory/inventoryui.1691543405.txt.gz · Last modified: 2023/08/08 18:10 by lee