Class: chatUI

chatUI(container) → {object}

new chatUI(container) → {object}

chatUI constructor
Parameters:
Name Type Description
container d3-selection Container for the chat interface.
Source:
Returns:
chatUI object
Type
object

Methods

(static) module.addBubble(options, callback) → {integer}

Parameters:
Name Type Description
options object object containing configs {type:string (e.g. 'text' or 'select'), class:string ('human' || 'bot'), value:depends on type}
callback function function to be called after everything is done
Source:
Returns:
id - id of the bubble
Type
integer

(static) module.appendText(bubble, options, callback)

Helper Function for adding text to a bubble
Parameters:
Name Type Description
bubble d3-selection d3 selection of the bubble container
options object object containing configs {type:'text', class:string ('human' || 'bot'), value:string (e.g. 'Hello World')}
callback function function to be called after everything is done
Source:

(static) module.getBubble(id) → {object}

Remove all bubbles until the bubble with 'id' from the chat
Parameters:
Name Type Description
id integer id of bubble provided by addBubble
Source:
Returns:
obj - {el:d3-selection, obj:bubble-data}
Type
object

(static) module.removeBubble(id)

Remove a bubble from the chat
Parameters:
Name Type Description
id integer id of bubble provided by addBubble
Source:

(static) module.removeBubbles(id)

Remove all bubbles until the bubble with 'id' from the chat
Parameters:
Name Type Description
id integer id of bubble provided by addBubble
Source:

(static) module.scrollTo(position)

Scroll chat flow
Parameters:
Name Type Description
position string where to scroll either 'start' or 'end'
Source:

(static) module.showInput(submitCallback, typeCallback)

Showing the input module and set cursor into input field
Parameters:
Name Type Description
submitCallback function function to be called when user presses enter or submits through the submit-button
typeCallback function function to when user enters text (on change)
Source:

(static) module.types.select(bubble, options, callback)

Parameters:
Name Type Description
bubble d3-selection d3 selection of the bubble container
options object object containing configs {type:'text', class:string ('human' || 'bot'), value:array of objects (e.g. [{label:'yes'}])}
callback function function to be called after everything is done
Source:

(static) module.types.text(bubble, options, callback)

Parameters:
Name Type Description
bubble d3-selection d3 selection of the bubble container
options object object containing configs {type:'text', class:string ('human' || 'bot'), value:string (e.g. 'Hello World')}
callback function function to be called after everything is done
Source:

(static) module.updateContainer()

updateContainer should be called when height or width changes of the container changes
Source: