Comments or questions about this documentation? Contact us for support!
Once you've registered your own plugin on the bus, you can call commands on other registered plugins. Below we'll quickly register a new plugin on the bus using the global bus object.
var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');
oMyPlugin.command('App.themeDemo');
Sets the theme for Genesys Widgets from the list of registered themes. Default themes are 'light' and 'dark'. You can register as many new themes as you need.
oMyPlugin.command('App.setTheme', {theme: 'light'}).done(function(e){
// App set theme successfully
}).fail(function(e){
// App failed to set theme
});
Option | Type | Description |
---|---|---|
theme | string | Name of the theme you want to use. This name is specified in window._genesys.main.themes. Default themes are 'light' and 'dark'. |
Status | When | Returns |
---|---|---|
resolved | Theme exists and is successfully changed | The name of the theme that was chosen. e.g. 'light' |
rejected | 'Invalid theme specified' |
Get the CSS classname for the currently selected theme.
oMyPlugin.command('App.getTheme').done(function(e){
// App got theme successfully
// e == CSS classname for current theme
}).fail(function(e){
// App failed to get theme
});
Status | When | Returns |
---|---|---|
resolved | Always | CSS classname for the currently selected theme. e.g. 'cx-theme-light' |
rejected | Never |
Accepts an HTML reference (either string or jQuery wrapped set) and applies the proper CSS Theme Classname to that HTML and returns it back. When widgets receive the 'theme' event from App, they pass-in their UI containers into App.reTheme to have the old theme classname stripped and new classname applied.
oMyPlugin.command('App.reTheme', {html: '<div>Test Theme</div>'}).done(function(e){
// App set theme successfully
}).fail(function(e){
// App failed to set theme
});
Option | Type | Description |
---|---|---|
html | string or jQuery Wrapped Set | HTML string or jQuery Wrapped Set you want to have modified. |
Status | When | Returns |
---|---|---|
resolved | When HTML is provided and theme is updated | HTML that was passed-in and modified |
rejected | When no HTML is provided | 'No HTML provided by [plugin name]' |
Start an automated demo of each theme. All registered themes will be applied with a default delay between themes of 2 seconds. You can override this delay. This command is useful for comparing themes or testing themes with official or custom widgets.
oMyPlugin.command('App.themeDemo', {delay: 1000}).done(function(e){
// App demo successfully started
}).fail(function(e){
// App failed to start demo
});
Option | Type | Description |
---|---|---|
delay | number | Number of milliseconds between theme changes. Default value is 2000 milliseconds. |
Status | When | Returns |
---|---|---|
resolved | Always | |
rejected | Never |
Changes the language
oMyPlugin.command('App.setLanguage', {lang: 'eng'}).done(function(e){
// App set language successfully started
}).fail(function(e){
// App failed to set language
});
Option | Type | Description |
---|---|---|
lang | string | Change the language of Genesys Widgets. Switches all strings in Widgets to selected language. |
Status | When | Returns |
---|---|---|
resolved | When language successfully changed | |
rejected | When no language code is provided | No language code provided |
rejected | When no matching language code is specified in your language pack | No matching language code found in language pack |
Publishes the 'App.closeAll' event that requests all widgets to close.
oMyPlugin.command('App.closeAll').done(function(e){
// App closed all successfully
}).fail(function(e){
// App failed to close all
});
Status | When | Returns |
---|---|---|
resolved | Always | |
rejected | Never |