Difference between revisions of "WID/Current/SDK/Common"
(Published) |
|||
Line 8: | Line 8: | ||
|Context=Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets. | |Context=Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets. | ||
|Section={{Section | |Section={{Section | ||
− | | | + | |Standalone=No |
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Common is a utility object available for import into Plugins/Widgets and Extensions. It is also accessible directly from the path '''window._genesys.widgets.common'''. | |structuredtext=Common is a utility object available for import into Plugins/Widgets and Extensions. It is also accessible directly from the path '''window._genesys.widgets.common'''. | ||
Line 20: | Line 21: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.Generate.Container({options}) | |sectionHeading=Common.Generate.Container({options}) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Dynamically generates a new HTML Container in matching the style of Genesys Widgets with the selected components you request in your options object. Returns the generated container HTML as a jQuery wrapped set. | |structuredtext=Dynamically generates a new HTML Container in matching the style of Genesys Widgets with the selected components you request in your options object. Returns the generated container HTML as a jQuery wrapped set. | ||
Line 110: | Line 112: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.Generate.Buttons({options}) | |sectionHeading=Common.Generate.Buttons({options}) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Dynamically generates a new HTML Binary Button set in matching the style of Genesys Widgets with the selected options in your options object. Returns the buttons as a jQuery wrapped set. | |structuredtext=Dynamically generates a new HTML Binary Button set in matching the style of Genesys Widgets with the selected options in your options object. Returns the buttons as a jQuery wrapped set. | ||
Line 155: | Line 158: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.Generate.Icon(name) | |sectionHeading=Common.Generate.Icon(name) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Dynamically generates an icon from the included icon set. Icons are in SVG format. | |structuredtext=Dynamically generates an icon from the included icon set. Icons are in SVG format. | ||
Line 191: | Line 195: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.Generate.Scrollbar(element, {options}) | |sectionHeading=Common.Generate.Scrollbar(element, {options}) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Dynamically generates a widget scrollbar for selected DOM element. | |structuredtext=Dynamically generates a widget scrollbar for selected DOM element. | ||
Line 223: | Line 228: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.config(object) | |sectionHeading=Common.config(object) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Configure some debug options for Common at runtime. | |structuredtext=Configure some debug options for Common at runtime. | ||
Line 251: | Line 257: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.checkPath(object, path) | |sectionHeading=Common.checkPath(object, path) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Check for the existence of a sub-property of an object at any depth. Returns the value of that property if found otherwise it returns false. Useful for checking configuration object paths without having to check each sub-property level individually. | |structuredtext=Check for the existence of a sub-property of an object at any depth. Returns the value of that property if found otherwise it returns false. Useful for checking configuration object paths without having to check each sub-property level individually. | ||
Line 287: | Line 294: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.createPath(object, path, value) | |sectionHeading=Common.createPath(object, path, value) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Related to checkPath, createPath lets you specify a target object and path string but lets you create the path and set a value for it. This saves you the pain of defining each node in the path individually. All nodes in your path will be created as objects. Your final node, the property you are trying to create, will be whatever value you assign it. | |structuredtext=Related to checkPath, createPath lets you specify a target object and path string but lets you create the path and set a value for it. This saves you the pain of defining each node in the path individually. All nodes in your path will be created as objects. Your final node, the property you are trying to create, will be whatever value you assign it. | ||
Line 327: | Line 335: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.linkify(string, options) | |sectionHeading=Common.linkify(string, options) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Search for and convert URLs within a string into HTML links. Returns transformed string. | |structuredtext=Search for and convert URLs within a string into HTML links. Returns transformed string. | ||
Line 365: | Line 374: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.log(mixed, type) | |sectionHeading=Common.log(mixed, type) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Log something to the browser's console. When using Common.log, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.log. | |structuredtext=Log something to the browser's console. When using Common.log, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.log. | ||
Line 402: | Line 412: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.sanitizeHTML(string) | |sectionHeading=Common.sanitizeHTML(string) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Search for and escape < and > characters within a string. Returns transformed string. Useful for escaping HTML. | |structuredtext=Search for and escape < and > characters within a string. Returns transformed string. Useful for escaping HTML. | ||
Line 435: | Line 446: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.updateTemplateI18n(element, object) | |sectionHeading=Common.updateTemplateI18n(element, object) | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Searches through an element's contents for i18n string elements to update with new strings. Used when updating the language in real-time. Works by searching for elements with the CSS classname 'i18n' and reading the custom attribute 'data-message' to match the string name in the language object. See example below. | |structuredtext=Searches through an element's contents for i18n string elements to update with new strings. Used when updating the language in real-time. Works by searching for elements with the CSS classname 'i18n' and reading the custom attribute 'data-message' to match the string name in the language object. See example below. | ||
Line 472: | Line 484: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.debugIcons | |sectionHeading=Common.debugIcons | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Returns the list of all the Icons with their names that Widgets support. | |structuredtext=Returns the list of all the Icons with their names that Widgets support. | ||
Line 488: | Line 501: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.debug | |sectionHeading=Common.debug | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Adds debug logs in to the browser's console. When using Common.debug, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.debug. | |structuredtext=Adds debug logs in to the browser's console. When using Common.debug, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.debug. | ||
Line 516: | Line 530: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.error | |sectionHeading=Common.error | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Adds error logs in to the browser's console. When using Common.error, _genesys.main.debug must be set to true to see your logs. This allows you to add error logging to your code without worrying about unwanted error messages in production. | |structuredtext=Adds error logs in to the browser's console. When using Common.error, _genesys.main.debug must be set to true to see your logs. This allows you to add error logging to your code without worrying about unwanted error messages in production. | ||
Line 544: | Line 559: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.populateAllPlaceholders | |sectionHeading=Common.populateAllPlaceholders | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Adds place holder content to the input elements in a form with the given text strings. | |structuredtext=Adds place holder content to the input elements in a form with the given text strings. | ||
Line 576: | Line 592: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.populateLanguageStrings | |sectionHeading=Common.populateLanguageStrings | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Adds the preferred language place holder text to the given input elements in a form. | |structuredtext=Adds the preferred language place holder text to the given input elements in a form. | ||
Line 608: | Line 625: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.populateIcons | |sectionHeading=Common.populateIcons | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Show all the Icons on a Widget. | |structuredtext=Show all the Icons on a Widget. | ||
Line 636: | Line 654: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.insertIcon | |sectionHeading=Common.insertIcon | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Adds an icon before the selected element. | |structuredtext=Adds an icon before the selected element. | ||
Line 668: | Line 687: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.injectScript | |sectionHeading=Common.injectScript | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Injects javascript code dynamically into widgets with the help of a script tag. | |structuredtext=Injects javascript code dynamically into widgets with the help of a script tag. | ||
Line 696: | Line 716: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.mobileScreenScale | |sectionHeading=Common.mobileScreenScale | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Re-sizes and fits Widget to any mobile screen. | |structuredtext=Re-sizes and fits Widget to any mobile screen. | ||
Line 724: | Line 745: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.showLoading | |sectionHeading=Common.showLoading | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Show loading spinner Icon. | |structuredtext=Show loading spinner Icon. | ||
Line 752: | Line 774: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.hideLoading | |sectionHeading=Common.hideLoading | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Remove loading spinner Icon. | |structuredtext=Remove loading spinner Icon. | ||
Line 780: | Line 803: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.showWaiting | |sectionHeading=Common.showWaiting | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Show waiting Icon. | |structuredtext=Show waiting Icon. | ||
Line 808: | Line 832: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.hideWaiting | |sectionHeading=Common.hideWaiting | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Remove waiting Icon. | |structuredtext=Remove waiting Icon. | ||
Line 836: | Line 861: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.watch | |sectionHeading=Common.watch | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Repeat your function execution for every 'x' milliseconds (default 1 second) up to a maximum number of times (default - infinite) or till your function returns true. | |structuredtext=Repeat your function execution for every 'x' milliseconds (default 1 second) up to a maximum number of times (default - infinite) or till your function returns true. | ||
Line 878: | Line 904: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.addDialog | |sectionHeading=Common.addDialog | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Create your own dialog box and append it in to the Widget. | |structuredtext=Create your own dialog box and append it in to the Widget. | ||
Line 914: | Line 941: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.showDialog | |sectionHeading=Common.showDialog | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Show the dialog box that you prefer, using the dialog box name created with Common.addDialog(). | |structuredtext=Show the dialog box that you prefer, using the dialog box name created with Common.addDialog(). | ||
Line 946: | Line 974: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.hideDialog | |sectionHeading=Common.hideDialog | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Hide the dialog box that you showed using Common.showDialog(). | |structuredtext=Hide the dialog box that you showed using Common.showDialog(). | ||
Line 978: | Line 1,007: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.hideDialogs | |sectionHeading=Common.hideDialogs | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Hide all the dialog boxes. Dialog box name is not needed here. | |structuredtext=Hide all the dialog boxes. Dialog box name is not needed here. | ||
Line 1,006: | Line 1,036: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.bytesToSize | |sectionHeading=Common.bytesToSize | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Convert any number in bytes to Kilobytes, Megabytes, Gigabytes and Terabytes. | |structuredtext=Convert any number in bytes to Kilobytes, Megabytes, Gigabytes and Terabytes. | ||
Line 1,034: | Line 1,065: | ||
|Status=No | |Status=No | ||
}}{{Section | }}{{Section | ||
− | |||
|sectionHeading=Common.getFormattedTime | |sectionHeading=Common.getFormattedTime | ||
+ | |Standalone=No | ||
+ | |ComingSoon=No | ||
|alignment=Vertical | |alignment=Vertical | ||
|structuredtext=Returns time in 12 hrs or 24 hrs format from the actual date timestamp. If no timestamp is provided, it uses current time. | |structuredtext=Returns time in 12 hrs or 24 hrs format from the actual date timestamp. If no timestamp is provided, it uses current time. |
Revision as of 13:48, January 17, 2020
Contents
- 1 Common.Generate.Container({options})
- 2 Common.Generate.Buttons({options})
- 3 Common.Generate.Icon(name)
- 4 Common.Generate.Scrollbar(element, {options})
- 5 Common.config(object)
- 6 Common.checkPath(object, path)
- 7 Common.createPath(object, path, value)
- 8 Common.linkify(string, options)
- 9 Common.log(mixed, type)
- 10 Common.sanitizeHTML(string)
- 11 Common.updateTemplateI18n(element, object)
- 12 Common.debugIcons
- 13 Common.debug
- 14 Common.error
- 15 Common.populateAllPlaceholders
- 16 Common.populateLanguageStrings
- 17 Common.populateIcons
- 18 Common.insertIcon
- 19 Common.injectScript
- 20 Common.mobileScreenScale
- 21 Common.showLoading
- 22 Common.hideLoading
- 23 Common.showWaiting
- 24 Common.hideWaiting
- 25 Common.watch
- 26 Common.addDialog
- 27 Common.showDialog
- 28 Common.hideDialog
- 29 Common.hideDialogs
- 30 Common.bytesToSize
- 31 Common.getFormattedTime
Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets.
Common is a utility object available for import into Plugins/Widgets and Extensions. It is also accessible directly from the path window._genesys.widgets.common.
Common provides utility functions and dynamically generates common HTML Containers used throughout Genesys Widgets.
For all examples below, assume that _genesys.widgets.common has been stored in a local variable named 'Common'.
var Common = _genesys.widgets.common;
Common.Generate.Container({options})
Dynamically generates a new HTML Container in matching the style of Genesys Widgets with the selected components you request in your options object. Returns the generated container HTML as a jQuery wrapped set.
Example
'Generate an Overlay Container'
var ndContainer = Common.Generate.Container({
type: 'overlay',
title: 'My Overlay',body: 'Some HTML here as a string or jQuery wrapped set',
icon: 'call-outgoing',
controls: 'close',
buttons: false
}),
'Generate a Toast Container'
var ndContainer = Common.Generate.Container({
type: 'generic',
title: 'My Toast',body: 'Some HTML here as a string or jQuery wrapped set',
icon: 'chat',
controls: '',
buttons: {
type:'binary',
primary: 'OK',
secondary:'cancel'
}
}),
Arguments
Argument | Type | Description |
---|---|---|
options | object | An object containing options to apply to the generated container. |
options.type | string | 'generic' or 'overlay'. Overlay containers have special CSS properties for appearing inside the Overlay widget. Default is 'generic'. |
options.title | string | Title to apply to the container's titlebar area. |
options.body | string or jQuery wrapped set | The HTML body you want the container to wrap. |
options.icon | string | CSS Classname of icon to use. |
options.controls | string | Select from a set of window control buttons to show at the top right. 'close' = Show only the close button. 'minimize' = Show only the minimize button. 'all' = Show both close and minimize buttons. |
options.buttons | object | Options for displaying action buttons at the bottom of the container, such as OK and Cancel buttons. |
options.buttons.type | string | Currently 'binary' is the only supported button set at this time. Additional sets and arrangements will be available in a later release. Please pass 'binary' as the type here if you wish to show typical 'accept' and 'dismiss' buttons. |
options.buttons.primary | string | Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc) |
options.buttons.secondary | string | Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc) |
Common.Generate.Buttons({options})
Dynamically generates a new HTML Binary Button set in matching the style of Genesys Widgets with the selected options in your options object. Returns the buttons as a jQuery wrapped set.
Example
'Generate Binary Buttons'
var ndButtons = Common.Generate.Buttons({
type: 'binary',
primary: 'OK',
secondary: 'Cancel'
}),
Arguments
Argument | Type | Description |
---|---|---|
options | object | Options for generating buttons, such as OK and Cancel buttons. |
options.type | string | Currently 'binary' is the only supported button set at this time. Additional sets and arrangements will be available in a later release. Please pass 'binary' as the type here if you wish to show typical 'accept' and 'dismiss' buttons. |
options.primary | string | Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc) |
options.secondary | string | Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc) |
Common.Generate.Icon(name)
Dynamically generates an icon from the included icon set. Icons are in SVG format.
Example
'Generate Chat Icon'
var ndChatIcon = Common.Generate.Icon('chat');
'Insert Chat Icon'
$('#your_icon_container').append(Common.Generate.Icon('chat'));
Arguments
Argument | Type | Description |
---|---|---|
name | string | Select the icon you want to generate by name. See the icon reference page for icon names. |
Common.Generate.Scrollbar(element, {options})
Dynamically generates a widget scrollbar for selected DOM element.
Example
'Generate Scrollbar for a container'
var scrollContainer = Common.Generate.Scrollbar($('#your_container'))
Arguments
Argument | Type | Description |
---|---|---|
element | DOM element or jQuery selector | Select the element to which you would like to apply scrollbar. |
options | object | This is an iScroll component. So, all the options that iScroll supports can be passed here. For more details, refer to: http://iscrolljs.com/#configuring |
Common.config(object)
Configure some debug options for Common at runtime.
Example
'Enable full debug logging'
Common.config({debug: true, debugTimestamps: true});
Arguments
Argument | Type | Description |
---|---|---|
object | object | Supported options are 'debug' and 'debugTimestamps'. Setting debug to true will enable debug messages created by Common.log(). Setting debugTimestamps to true will add timestamps to the front of each debug message created by Common.log(). Default value for both is false. |
Common.checkPath(object, path)
Check for the existence of a sub-property of an object at any depth. Returns the value of that property if found otherwise it returns false. Useful for checking configuration object paths without having to check each sub-property level individually.
Example
'Check for window._genesys.main'
var oMainConfig = false;
if(oMainConfig = Common.checkPath(window, '_genesys.main')){
//... Utilize oMainConfig
}
Arguments
Argument | Type | Description |
---|---|---|
object | object | An Object you want checked for a particular sub property at any depth. |
path | string | The object path in dot notation you wish to search for. |
Common.createPath(object, path, value)
Related to checkPath, createPath lets you specify a target object and path string but lets you create the path and set a value for it. This saves you the pain of defining each node in the path individually. All nodes in your path will be created as objects. Your final node, the property you are trying to create, will be whatever value you assign it.
Example
'Create window._genesys.main'
var oMainConfig = false;
if(oMainConfig = Common.createPath(window, '_genesys.main', {debug:true})){
//... Utilize oMainConfig
}
Arguments
Argument | Type | Description |
---|---|---|
object | object | An Object you want to add your new path to. |
path | string | The object path in dot notation you wish to create. |
value | any | The value you want to assign to the final node (property) in your path. |
Common.linkify(string, options)
Search for and convert URLs within a string into HTML links. Returns transformed string.
Example
'Check for window._genesys.main'
var sString = 'Please visit www.genesys.com';
sString = Common.linkify(sString, {target: 'self'});
// sString == 'Please visit <a href='www.genesys.com' target='_self'>www.genesys.com</a>
Arguments
Argument | Type | Description |
---|---|---|
string | string | Any string you want to check for URLs and have them converted. |
options | object | A list of options to apply to the linkify operation. |
options.target | string | Choose the HTML TARGET attribute to apply to the generated links. Default is '_blank'. Set this option to 'self' to apply the target '_self' to the generated links. |
Common.log(mixed, type)
Log something to the browser's console. When using Common.log, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.log.
Example
'Check the contents of window._genesys.main'
var Common = _genesys.widgets.common;
Common.log(window._genesys.main);
if(!window._genesys.main){
Common.log('window._genesys.main is not defined', 'error');
}
Arguments
Argument | Type | Description |
---|---|---|
mixed | Any | Any value or message you'd like to log. |
type | string | You can specify the log type, such as 'log', 'debug' and 'error'. Default type is 'log'. Note, if your browser doesn't support the 'debug' or 'error' log type, use 'log' instead. |
Common.sanitizeHTML(string)
Search for and escape < and > characters within a string. Returns transformed string. Useful for escaping HTML.
Example
'Check for window._genesys.main'
var sString = 'Please visit <a href='www.genesys.com'
target='_self'>www.genesys.com</a>';
sString = Common.sanitizeHTML(sString);
// sString == 'Please visit <a href='www.genesys.com' target='_self'>www.genesys.com</a>''
Arguments
Argument | Type | Description |
---|---|---|
string | string | Any string you want to be transformed. |
Common.updateTemplateI18n(element, object)
Searches through an element's contents for i18n string elements to update with new strings. Used when updating the language in real-time. Works by searching for elements with the CSS classname 'i18n' and reading the custom attribute 'data-message' to match the string name in the language object. See example below.
Example
'Check for window._genesys.main'
var ndContainer = $('<div><button class='i18n' data-message='CustomButton001'>
</button></div>');
Common.updateTemplateI18n(ndContainer, {CustomButton001: 'Accept'});
// ndContainer == <div><button class='i18n' data-message='CustomButton001'>Accept</button></div>
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery wrapped set | Element you want to search within to replace i18n strings. |
object | Object of i18n Strings | The list of languages strings you want to update your UI with. This object comes from the App.i18n event or you can define your own custom object inline or using some other system. Object format is a simple name:value pair format. the 'data-message' attribute on your HTML element must match one of these property names to be updated. |
Common.debugIcons
Returns the list of all the Icons with their names that Widgets support.
Example
'Fetch and Display list of icons present in Widgets'
Common.debugIcons()
Common.debug
Adds debug logs in to the browser's console. When using Common.debug, _genesys.main.debug must be set to true to see your logs. This allows you to add debug logging to your code without worrying about unwanted debug messages in production. If timestamps are enabled, they will be prefixed to all messages printed through Common.debug.
Example
'Check the File upload limits in WebChatService'
Common.debug(data_server_returned_file_limits);
Arguments
Argument | Type | Description |
---|---|---|
mixed | Any | Any value or message you'd like to add debug log. Note: This is only supported if your browser supports debug log type. |
Common.error
Adds error logs in to the browser's console. When using Common.error, _genesys.main.debug must be set to true to see your logs. This allows you to add error logging to your code without worrying about unwanted error messages in production.
Example
'Logging error messages'
Common.error('A widget plugin did not receive the following config: ....');
Arguments
Argument | Type | Description |
---|---|---|
mixed | Any | Any value or message you'd like to add error log. Note: This is only supported if your browser supports error log type. |
Common.populateAllPlaceholders
Adds place holder content to the input elements in a form with the given text strings.
Example
'Show placeholders strings in a form'
Common.populateAllPlaceholders($('#your_form'), {strings})
Arguments
Argument | Type | Description |
---|---|---|
Form Selector | jQuery DOM selector for a form | Form containing input elements. Note: Input elements should contain i18n class name and data attribute 'data-message-type' with value 'placeholder' for the place holder details to appear. |
Key/Value pairs | object | Placeholder messages that needs to be displayed. This is an object with key-value pairs where, key should be equal to the 'data-message' attribute value of an input element and value can be any text that you would like to display. |
Common.populateLanguageStrings
Adds the preferred language place holder text to the given input elements in a form.
Example
'Show placeholders strings in a form'
Common.populateLanguageStrings($('#your_form'), {strings})
Arguments
Argument | Type | Description |
---|---|---|
Form Selector | jQuery DOM selector for a form | Form containing input elements. Note: Input elements should contain i18n class name and data attribute 'data-message-type' with value 'placeholder' for the place holder details to appear. |
Key/Value pairs | object | Placeholder messages that needs to be displayed. This is an object with key-value pairs where, key should be equal to the 'data-message' attribute value of an input element and value can be any text that you would like to display. |
Common.populateIcons
Show all the Icons on a Widget.
Example
'Populate all Widget Icons'
Common.populateIcons($('#your_continer'));
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM selector | Specify the Widget container for which all the Icons have to be displayed. |
Common.insertIcon
Adds an icon before the selected element.
Example
'Insert a check mark icon to an element you desire.'
Common.insertIcon($('#your_element'), 'alert-checkmark')
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM selector | An html element to which Icon is to be displayed. |
Icon name | string | Name of the Icon that you would like to display. Note: Refer to Common.debugIcons method to find out all the icons names that widgets supports. |
Common.injectScript
Injects javascript code dynamically into widgets with the help of a script tag.
Example
'Inject your Widget WebChat extension plugin.'
Common.injectScript('path/to/LoadWebChat.ext.js')
Arguments
Argument | Type | Description |
---|---|---|
Script file name | string path to JavaScript file | JavaScript file name that needs to be injected into widgets. |
Common.mobileScreenScale
Re-sizes and fits Widget to any mobile screen.
Example
'Fit your widget to any mobile screen.'
var mobileScaledWidget = Common.mobileScreenScale($('#your_widget'));
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM Selector | Your main Widget wrapper container selector that contains the entire Widget with 'cx-titlebar', 'cx-body', 'cx-footer', 'cx-button-container' and 'cx-message-container' classes in it. |
Common.showLoading
Show loading spinner Icon.
Example
'Show loading spinner during an Ajax request'
Common.showLoading($('#your_container'))
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM Selector | An html container where loading spinner should appear. This adds a class name 'cx-loading'. |
Common.hideLoading
Remove loading spinner Icon.
Example
'Remove loading spinner after the Ajax request'
Common.hideLoading($('#your_container'))
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM Selector | An html container which contains the loading spinner. |
Common.showWaiting
Show waiting Icon.
Example
'Show waiting Icon when uploading a file.'
Common.showWaiting($('#your_container'))
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM Selector | An html container where waiting symbol should appear. This adds a class name 'cx-waiting'. |
Common.hideWaiting
Remove waiting Icon.
Example
'Remove waiting Icon after file upload is done.'
Common.hideWaiting($('#your_container'))
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery DOM Selector | An html container which contains the waiting symbol. |
Common.watch
Repeat your function execution for every 'x' milliseconds (default 1 second) up to a maximum number of times (default - infinite) or till your function returns true.
Example
'Make Request Notifications till none are pending.'
Common.watch(function(iteration, maxIterations){
if(bRequestNotificationsPending){
// ..POST Request
}
return !bRequestNotificationsPending;
}, 3000, 30)
Arguments
Argument | Type | Description |
---|---|---|
function name | function | The function that you would like to execute. It should return true/false. |
frequency | milliseconds | Execute the function for every 'x' milliseconds till the it returns true. |
limit | number | The maximum number of times function is executed. |
Common.addDialog
Create your own dialog box and append it in to the Widget.
Example
'Add a dialog box on your preferred container div
Common.addDialog($('#your_container'), $('#your_dialog_box'), 'my_warning')
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery selector | The parent container that holds the dialog box. |
element | jQuery selector | The actual dialog box that you would like to display. This should contain the data-dialog attribute with the value equal to the dialog box name. |
name | string | Dialog box name. |
Common.showDialog
Show the dialog box that you prefer, using the dialog box name created with Common.addDialog().
Example
'Show the dialog box created using Common.addDialog()'
Common.showDialog($('#your_container'), 'your_dialog_box_name');
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery Selector | The parent container which has the Dialog box appended in to it. |
name | string | The actual dialog box name. |
Common.hideDialog
Hide the dialog box that you showed using Common.showDialog().
Example
'Hide dialog box'
Common.hideDialog($('#your_container'), 'your_dialog_box_name);
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery Selector | The parent container which is showing the dialog box. |
name | string | The actual dialog box name. |
Common.hideDialogs
Hide all the dialog boxes. Dialog box name is not needed here.
Example
'Hide all dialog boxes.'
Common.hideDialogs($('#your_container'));
Arguments
Argument | Type | Description |
---|---|---|
element | jQuery Selector | The parent container which is showing all the dialog boxes. |
Common.bytesToSize
Convert any number in bytes to Kilobytes, Megabytes, Gigabytes and Terabytes.
Example
'bytes to KB, MB, GB or TB.'
var fileSize = Common.bytesToSize(parseInt(fileSizeInBytes));
Arguments
Argument | Type | Description |
---|---|---|
bytes | number | Number in bytes size. |
Common.getFormattedTime
Returns time in 12 hrs or 24 hrs format from the actual date timestamp. If no timestamp is provided, it uses current time.
Example
'convert date timestamp to return time in 12 hrs format'
var formattedTime = Common.getFormattedTime(timestamp, 12);
Arguments
Argument | Type | Description |
---|---|---|
timestamp | Date | JavaScript Date timestamp object. |
format | number | Time format with value 12 or 24. |