Difference between revisions of "WID/Current/SDK/Toaster-combined"
(Published) |
(Published) |
||
Line 3: | Line 3: | ||
|DisplayName=Toaster | |DisplayName=Toaster | ||
|TocName=Toaster | |TocName=Toaster | ||
+ | |Context=Learn how to use a toast view control that widgets can inject their UI into. | ||
+ | |ComingSoon=No | ||
|Platform=PureEngage | |Platform=PureEngage | ||
− | | | + | |Prereq= |
− | |||
|Section={{Section | |Section={{Section | ||
|sectionHeading=Overview | |sectionHeading=Overview | ||
− | | | + | |anchor= |
− | |||
|alignment=Vertical | |alignment=Vertical | ||
+ | |Media= | ||
+ | |image= | ||
|structuredtext=The Toaster plugin provides a toast view control that widgets can inject their UI into, accepting the HTML UI, placing it inside a toast view, and displaying the UI onscreen in the lower-bottom-right of the screen. When it is opened, it slides up from the bottom. When it is closed, it slides down until it is offscreen. | |structuredtext=The Toaster plugin provides a toast view control that widgets can inject their UI into, accepting the HTML UI, placing it inside a toast view, and displaying the UI onscreen in the lower-bottom-right of the screen. When it is opened, it slides up from the bottom. When it is closed, it slides down until it is offscreen. | ||
Toaster provides these benefits: | Toaster provides these benefits: | ||
− | * Shows UI as a slide-up toast view in the lower-bottom-right of the screen. | + | |
− | * Open and close transition animations. | + | *Shows UI as a slide-up toast view in the lower-bottom-right of the screen. |
− | * No overlapping toasts, only one at a time. Automatically managed by the Toaster plugin. | + | *Open and close transition animations. |
+ | *No overlapping toasts, only one at a time. Automatically managed by the Toaster plugin. | ||
===Usage=== | ===Usage=== | ||
− | Toaster is easy to use | + | Toaster is easy to use; you simply open and close it. When you call Toaster.open, you pass in the HTML content you want to show. If you call Toaster.open again while a toast is already open, it will automatically close the previous toast before showing yours (unless the previous toast has reserved the view to prevent new toasts). |
{{NoteFormat|Only one toast can be shown at a time. If you attempt to open a second toast, the first toast will be dismissed automatically before showing the second toast.}} | {{NoteFormat|Only one toast can be shown at a time. If you attempt to open a second toast, the first toast will be dismissed automatically before showing the second toast.}} | ||
Line 41: | Line 44: | ||
===Mobile Support=== | ===Mobile Support=== | ||
Toaster does not have mobile-specific styles at this time. | Toaster does not have mobile-specific styles at this time. | ||
− | | | + | |structuredtextwide= |
+ | |FAQHeading= | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
|sectionHeading=Configuration | |sectionHeading=Configuration | ||
− | | | + | |anchor= |
− | |||
|alignment=Vertical | |alignment=Vertical | ||
+ | |Media= | ||
+ | |image= | ||
|structuredtext=Toaster does not have configuration options. | |structuredtext=Toaster does not have configuration options. | ||
− | | | + | |structuredtextwide= |
+ | |FAQHeading= | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
|sectionHeading=Localization | |sectionHeading=Localization | ||
− | | | + | |anchor= |
− | |||
|alignment=Vertical | |alignment=Vertical | ||
+ | |Media= | ||
+ | |image= | ||
|structuredtext=Toaster does not have localization options. | |structuredtext=Toaster does not have localization options. | ||
− | | | + | |structuredtextwide= |
+ | |FAQHeading= | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
|sectionHeading=API Commands | |sectionHeading=API Commands | ||
|anchor=commands | |anchor=commands | ||
− | |||
− | |||
|alignment=Vertical | |alignment=Vertical | ||
+ | |Media= | ||
+ | |image= | ||
|structuredtext=Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus. | |structuredtext=Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus. | ||
Line 70: | Line 78: | ||
− | <source lang= | + | <source lang="javascript">var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin'); |
oMyPlugin.command('Toaster.close');</source> | oMyPlugin.command('Toaster.close');</source> | ||
Line 76: | Line 84: | ||
Opens the Toaster UI. | Opens the Toaster UI. | ||
====Example==== | ====Example==== | ||
− | <source lang= | + | <source lang="javascript"> |
oMyPlugin.command('Toaster.open', { | oMyPlugin.command('Toaster.open', { | ||
Line 112: | Line 120: | ||
{{!}}{{!}}type | {{!}}{{!}}type | ||
{{!}}{{!}}string | {{!}}{{!}}string | ||
− | {{!}}{{!}}Specifies the type of body content that can be provided to | + | {{!}}{{!}}Specifies the type of body content that can be provided to Toaster window. Generic type shows the default body content and custom type overrides the default html body content. |
{{!}}- | {{!}}- | ||
{{!}}{{!}}title | {{!}}{{!}}title | ||
{{!}}{{!}}string | {{!}}{{!}}string | ||
− | {{!}}{{!}}Heading title to display on the | + | {{!}}{{!}}Heading title to display on the Toaster window. |
{{!}}- | {{!}}- | ||
{{!}}{{!}}body | {{!}}{{!}}body | ||
{{!}}{{!}}string | {{!}}{{!}}string | ||
− | {{!}}{{!}}Holds text value for Generic | + | {{!}}{{!}}Holds text value for Generic Toaster type and html string template for Custom Toaster type. |
{{!}}- | {{!}}- | ||
{{!}}{{!}}icon | {{!}}{{!}}icon | ||
Line 128: | Line 136: | ||
{{!}}{{!}}controls | {{!}}{{!}}controls | ||
{{!}}{{!}}string | {{!}}{{!}}string | ||
− | {{!}}{{!}}Show close and minimize controls on | + | {{!}}{{!}}Show close and minimize controls on Toaster window. |
{{!}}- | {{!}}- | ||
{{!}}{{!}}buttons | {{!}}{{!}}buttons | ||
Line 136: | Line 144: | ||
{{!}}{{!}}buttons.type | {{!}}{{!}}buttons.type | ||
{{!}}{{!}}string | {{!}}{{!}}string | ||
− | {{!}}{{!}}Shows two buttons on the | + | {{!}}{{!}}Shows two buttons on the Toaster . |
{{!}}- | {{!}}- | ||
{{!}}{{!}}buttons.primary | {{!}}{{!}}buttons.primary | ||
Line 148: | Line 156: | ||
{{!}}{{!}}immutable | {{!}}{{!}}immutable | ||
{{!}}{{!}}boolean | {{!}}{{!}}boolean | ||
− | {{!}}{{!}}When set to true, | + | {{!}}{{!}}When set to true, Toaster cannot be closed by other plugins. |
{{!}}} | {{!}}} | ||
Line 165: | Line 173: | ||
{{!}}- | {{!}}- | ||
{{!}}{{!}}rejected | {{!}}{{!}}rejected | ||
− | {{!}}{{!}}When no | + | {{!}}{{!}}When no Toaster type is specified |
{{!}}{{!}}'No content was provided. Toaster has ignored your command' | {{!}}{{!}}'No content was provided. Toaster has ignored your command' | ||
{{!}}- | {{!}}- | ||
{{!}}{{!}}rejected | {{!}}{{!}}rejected | ||
− | {{!}}{{!}}When | + | {{!}}{{!}}When Toaster is already opened |
{{!}}{{!}}'Toaster view is currently reserved' | {{!}}{{!}}'Toaster view is currently reserved' | ||
{{!}}} | {{!}}} | ||
Line 177: | Line 185: | ||
Closes the Toaster UI. | Closes the Toaster UI. | ||
====Example==== | ====Example==== | ||
− | <source lang= | + | <source lang="javascript"> |
oMyPlugin.command('Toaster.close').done(function(e){ | oMyPlugin.command('Toaster.close').done(function(e){ | ||
Line 197: | Line 205: | ||
{{!}}- | {{!}}- | ||
{{!}}{{!}}resolved | {{!}}{{!}}resolved | ||
− | {{!}}{{!}}When | + | {{!}}{{!}}When Toaster is successfully closed. |
{{!}}{{!}}n/a | {{!}}{{!}}n/a | ||
{{!}}- | {{!}}- | ||
Line 208: | Line 216: | ||
{{!}}{{!}}'Toaster view is currently reserved' | {{!}}{{!}}'Toaster view is currently reserved' | ||
{{!}}} | {{!}}} | ||
− | | | + | |structuredtextwide= |
+ | |FAQHeading= | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
|sectionHeading=API Events | |sectionHeading=API Events | ||
|anchor=events | |anchor=events | ||
− | |||
− | |||
|alignment=Vertical | |alignment=Vertical | ||
+ | |Media= | ||
+ | |image= | ||
|structuredtext=Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus. | |structuredtext=Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus. | ||
Line 221: | Line 230: | ||
− | <source lang= | + | <source lang="javascript">var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin'); |
oMyPlugin.subscribe('Toaster.ready', function(e){});</source> | oMyPlugin.subscribe('Toaster.ready', function(e){});</source> | ||
Line 238: | Line 247: | ||
{{!}}{{!}}n/a | {{!}}{{!}}n/a | ||
{{!}}} | {{!}}} | ||
− | | | + | |structuredtextwide= |
+ | |FAQHeading= | ||
|Status=No | |Status=No | ||
}} | }} | ||
}} | }} |
Revision as of 15:48, May 22, 2020
Contents
Learn how to use a toast view control that widgets can inject their UI into.
Overview
The Toaster plugin provides a toast view control that widgets can inject their UI into, accepting the HTML UI, placing it inside a toast view, and displaying the UI onscreen in the lower-bottom-right of the screen. When it is opened, it slides up from the bottom. When it is closed, it slides down until it is offscreen.
Toaster provides these benefits:
- Shows UI as a slide-up toast view in the lower-bottom-right of the screen.
- Open and close transition animations.
- No overlapping toasts, only one at a time. Automatically managed by the Toaster plugin.
Usage
Toaster is easy to use; you simply open and close it. When you call Toaster.open, you pass in the HTML content you want to show. If you call Toaster.open again while a toast is already open, it will automatically close the previous toast before showing yours (unless the previous toast has reserved the view to prevent new toasts).
Namespace
The Toaster plugin has the following namespaces tied up with each of the following types.
Type | Namespace |
---|---|
CXBus—API commands & API events | Toaster |
CSS | .cx-toaster |
Customization
Toaster does not have customization options.
Mobile Support
Toaster does not have mobile-specific styles at this time.
Configuration
Toaster does not have configuration options.
Localization
Toaster does not have localization options.
API Commands
Once you've registered your plugin on the bus, you can call commands on other registered plugins. Here's how to use the global bus object to register a new plugin on the bus.
var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');
oMyPlugin.command('Toaster.close');
open
Opens the Toaster UI.
Example
oMyPlugin.command('Toaster.open', {
type: 'generic',
title: 'Toaster Title',
body: 'Toaster Body',
icon: 'chat',
controls: 'close',
immutable: false,
buttons:{
type: 'binary',
primary: 'Accept',
secondary: 'Decline'
}
}).done(function(e){
// Toaster opened successfully
}).fail(function(e){
// Toaster failed to open properly
});
Options
Option | Type | Description |
---|---|---|
type | string | Specifies the type of body content that can be provided to Toaster window. Generic type shows the default body content and custom type overrides the default html body content. |
title | string | Heading title to display on the Toaster window. |
body | string | Holds text value for Generic Toaster type and html string template for Custom Toaster type. |
icon | string | The CSS class name for an icon. |
controls | string | Show close and minimize controls on Toaster window. |
buttons | object | Define the type of buttons. |
buttons.type | string | Shows two buttons on the Toaster . |
buttons.primary | string | Text to be shown on primary button. |
buttons.secondary | string | Text to be shown on secondary button. |
immutable | boolean | When set to true, Toaster cannot be closed by other plugins. |
Resolutions
Status | When | Returns |
---|---|---|
resolved | When Toaster is successfully opened | n/a |
rejected | When no Toaster type is specified | 'No content was provided. Toaster has ignored your command' |
rejected | When Toaster is already opened | 'Toaster view is currently reserved' |
close
Closes the Toaster UI.
Example
oMyPlugin.command('Toaster.close').done(function(e){
// Toaster closed successfully
}).fail(function(e){
// Toaster failed to close
});
Resolutions
Status | When | Returns |
---|---|---|
resolved | When Toaster is successfully closed. | n/a |
rejected | When Toaster is already closed. | 'Toaster view is already closed' |
rejected | When Toaster view is immutable. | 'Toaster view is currently reserved' |
API Events
Once you've registered your plugin on the bus, you can subscribe to and listen for published events. Here's how to use the global bus object to register a new plugin on the bus.
var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');
oMyPlugin.subscribe('Toaster.ready', function(e){});
Name | Description | Data |
---|---|---|
ready | The Toaster plugin is initialized and ready to accept commands | n/a |
closed | The Toaster plugin has been removed from the screen | n/a |