Jump to: navigation, search

API Commands

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.

Important
The global bus object is a debug tool. When implementing Widgets on your own site, do not use the global bus object to register your custom plugins. Instead, see Widgets Extensions for more information about extending Genesys Widgets.


var oMyPlugin = window._genesys.widgets.bus.registerPlugin('MyPlugin');
 
oMyPlugin.command('App.themeDemo');

setTheme

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.

Example

oMyPlugin.command('App.setTheme', {theme: 'light'}).done(function(e){
 
	// App set theme successfully
 
}).fail(function(e){
 
	// App failed to set theme
});


Options

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'.


Resolutions

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'

getTheme

Get the CSS classname for the currently selected theme.

Example

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
});


Resolutions

Status When Returns
resolved Always CSS classname for the currently selected theme. e.g. 'cx-theme-light'
rejected Never

reTheme

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.

Example

oMyPlugin.command('App.reTheme', {html: '<div>Test Theme</div>'}).done(function(e){
 
	// App set theme successfully
 
}).fail(function(e){
 
	// App failed to set theme
});


Options

Option Type Description
html string or jQuery Wrapped Set HTML string or jQuery Wrapped Set you want to have modified.


Resolutions

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]'

themeDemo

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.

Example

oMyPlugin.command('App.themeDemo', {delay: 1000}).done(function(e){
 
	// App demo successfully started
 
}).fail(function(e){
 
	// App failed to start demo
});


Options

Option Type Description
delay number Number of milliseconds between theme changes. Default value is 2000 milliseconds.


Resolutions

Status When Returns
resolved Always
rejected Never

setLanguage

Changes the language

Example

oMyPlugin.command('App.setLanguage', {lang: 'eng'}).done(function(e){
 
	// App set language successfully started
 
}).fail(function(e){
 
	// App failed to set language
});


Options

Option Type Description
lang string Change the language of Genesys Widgets. Switches all strings in Widgets to selected language.


Resolutions

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

closeAll

Publishes the 'App.closeAll' event that requests all widgets to close.

Example

oMyPlugin.command('App.closeAll').done(function(e){
 
	// App closed all successfully
 
}).fail(function(e){
 
	// App failed to close all
});


Resolutions

Status When Returns
resolved Always
rejected Never

Feedback

Comment on this article:

blog comments powered by Disqus
This page was last modified on 10 August 2017, at 06:39.