/** * @interface jibo.face.views.ActionData~ActionDescriptor * @description Interface for an Object to be turned into instance of an ActionData class. * @prop {String} type - The type of the action. * @prop {any} [data] - Additional data for action, requited data depends on type. */ /** * Use to pass actions across the view architecture. * @class ActionData * @memberof jibo.face.views */ /** * The type of the action. * Supported types are this class's constants. * @name jibo.face.views.ActionData#type * @type {String} */ /** * The data Object that is passed with the action. * Not all action types require data. * Refer to this class's constants for action type requirements. * @name jibo.face.views.ActionData#data * @type {Object} */ /** * Change view by specifying view change options. * Data requirements include [ChangeOptions]{@link jibo.face.views~ChangeOptions} * @example * JSON format * "action": { * "type": "changeView", * "data": { * "options": { * "removeAll": true, * "leaveEmpty": true * } * } * } * @constant jibo.face.views.ActionData.CHANGE_VIEW * @type {String} */ /** * Add a view. * Data requirements include a path to view configuration to be opened. * @example * JSON format * "action": { * "type": "openView", * "data": { * "configPath": "resources/menus/myMenu.json" * } * } * @constant jibo.face.views.ActionData.OPEN_VIEW * @type {String} * @readOnly */ /** * Remove the current view. * This action has no data requirements. * @example * JSON format * "action": { * "type": "closeView", * } * @constant jibo.face.views.ActionData.CLOSE_VIEW * @type {String} * @readOnly */ /** * Remove the current view and not open the next view in the hierarchy. * Will leave the display empty and the current view equal to null. * This action has no data requirements. * @example * JSON format * "action": { * "type": "closeViewEmpty", * } * @constant jibo.face.views.ActionData.CLOSE_VIEW_EMPTY * @type {String} * @readOnly */ /** * Remove all the views up to, but not including, the root view. * @example * JSON format * "action": { * "type": "closeAll" * } * @constant jibo.face.views.ActionData.CLOSE_ALL * @type {String} * @readOnly */ /** * Remove all the views and clear hierarchy up to but not including root, then add view. * Added view will be one above the root view. * Data requirements include a path to view configuration to be opened. * @example * JSON format * "action": { * "type": "closeAllOpen", * "data": { * "configPath": "resources/menus/myMenu.json" * } * } * @constant jibo.face.views.ActionData.CLOSE_ALL_OPEN * @type {String} * @readOnly */ /** * Close all the views and clear hierarchy up to but not including root, * but do not add the root view to the display. * Added view will be one above the root view. * Data requirements include a path to view configuration to be opened. * @example * JSON format * "action": { * "type": "closeAllEmpty" * } * @constant jibo.face.views.ActionData.CLOSE_ALL_EMPTY * @type {String} * @readOnly */ /** * Emulate a swipe right gesture. * @example * JSON format * "action": { * "type": "swipeRight" * } * @constant jibo.face.views.ActionData.SWIPE_RIGHT * @type {String} * @readOnly */ /** * Emulate a swipe left gesture. * @example * JSON format * "action": { * "type": "swipeLeft" * } * @constant jibo.face.views.ActionData.SWIPE_LEFT * @type {String} * @readOnly */ /** * Emulate a swipe down. * @example * JSON format * "action": { * "type": "swipeDown" * } * @constant jibo.face.views.ActionData.SWIPE_DOWN * @type {String} * @readOnly */ /** * Emulate a swipe up. * @example * JSON format * "action": { * "type": "swipeUp" * } * @constant jibo.face.views.ActionData.SWIPE_UP * @type {String} * @readOnly */ /** * Go to first page of a list. * Enact action on [List]{@link jibo.face.views.List} to take effect. * @example * JSON format * "action": { * "type": "goToBeginning" * } * @constant jibo.face.views.ActionData.GO_TO_BEGINNING * @type {String} * @readOnly */ /** * Go to last page of a list. * Enact action on [List]{@link jibo.face.views.List} to take effect. * @example * JSON format * "action": { * "type": "goToEnd" * } * @constant jibo.face.views.ActionData.GO_TO_END * @type {String} * @readOnly */ /** * Emit an event from the owning View when triggered. * Required data is an event string. * * @example * JSON format * "action": { * "type": "event", * "data": { * "event": "danceParty" * } * } * * @example * To listen for these events just add a listener to * the View that contains the action. * * myView.on('danceParty', getDown); * * @example * You must specify the event string for the event to fire, * but can include as much additional data as needed. * The entire data Object is returned when the event is fired. * Here we add another value to the data Object in JSON: * * "action": { * "type": "event", * "data": { * "event": "danceParty" * "dance": "funkyChicken" * } * } * * @example * Then in your code you can listen for the event, * which will pass back the data Object: * * myView.on('danceParty', (eventData) => { * if(eventData.dance === 'funkyChicken'){ * console.log('Booo'); * } * }); * * @constant jibo.face.views.ActionData.EVENT * @type {String} * @readOnly */ /** * Play a sound. * Within data, provide either the type of sound or the URI for the sound file. * @example * * JSON format. Playing a preloaded or gloabl sound by giving the the ID. * "action": { * "type": "sound", * "data": { * "id": "button" * } * } * @example * JSON format. Playing sound by just giving src of sound asset. * "action": { * "type": "sound", * "data": { * "src": "resources/sfx/button_sfx.m4a" * } * } * @example * JSON format. Loading a sound and giving it an ID for repeat usage. * "action": { * "type": "sound", * "data": { * "id": "unique_sound" * "src": "resources/sfx/button_sfx.m4a" * } * } * * @name jibo.face.views.ActionData#SOUND * @type {String} * @readOnly */ /** * Spoof an utterance that will be used as the result of the current MIM listen. Strings are * handled as the result intent, otherwise a properly formatted NLU result must be provided * @example * JSON format with string * "action": { * "type": "utterance", * "data": { * "utterance": "whatIsWeather" * } * } * @example * JSON format with full result * "action": { * "type": "utterance", * "data": { * "utterance": { * "intent": "whatIsWeather", * "entities": { * "time": "tomorrow" * } * } * } * @constant jibo.face.views.ActionData.UTTERANCE * @type {String} * @readOnly */ /** * Results passed from the MIM systems. * @example * JSON format for select elements on a page * "action": { * "type": "verbalCommand", * "data": { * "intent": "selectItem", * "entities": { * "itemPosition": "first" * } * } * } * * JSON format tp control pages * "action": { * "type": "verbalCommand", * "data": { * "intent": "right", * } * } * * * @constant jibo.face.views.ActionData.VERBAL_COMMAND * @type {String} * @readOnly */ /** * Immediately end the currently active MIM. * @example * JSON format for ending a MIM * "action": { * "type": "mimEnd" * } * * @constant jibo.face.views.ActionData.MIM_END * @type {String} * @readOnly */ /** * Immediately show the available GUI for the currently active MIM. * @example * JSON format for showing a MIM's GUI * "action": { * "type": "mimShowGUI" * } * * @constant jibo.face.views.ActionData.MIM_SHOW_GUI * @type {String} * @readOnly */ /** * Call a method when action is triggered. * Not something easily defined via JSON; more likely to be defined in code. * @example * Creating in code * new ActionData( ActionData.CALLBACK, { * callback: this.foo.bind(this) * }); * Adding to a Component * component.addAction(ActionData.CALLBACK, {callback: this.foo.bind(this)}); * @constant jibo.face.views.ActionData.CALLBACK * @type {String} * @readOnly */ /** * Create an ActionData object from a configuration Object. * Generally derived from JSON. * @method jibo.face.views.ActionData.createFromConfig * @example * JSON format * { * "type": "openView", * "data": { * "configPath": "assets/menu/myMenu.json" * } * } * @param {jibo.face.views.ActionData~ActionDescriptor} configData Object defining the action. * @returns {jibo.face.views.ActionData} A new ActionData with values specified by given configuration. */ /** * Constructor for ActionData. * @param {String} [type] The type of action. * @param {Object} [data] The data Object with action values. */ /** * Apply the configuration Object's values to this ActionData class. * @method jibo.face.views.ActionData#applyConfig * @param {jibo.face.views.ActionData~ActionDescriptor} configData Object defining the action. */