Difference between revisions of "WID/Current/SDK/Common"

From Genesys Documentation
Jump to: navigation, search
(Published)
 
(Published)
 
(7 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
|Standalone=No
 
|Standalone=No
 
|DisplayName=Common
 
|DisplayName=Common
|Role=Developer
 
 
|TocName=Common
 
|TocName=Common
|Platform=PureEngage
+
|Context=Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets.
 
|ComingSoon=No
 
|ComingSoon=No
|Context=Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets.
+
|Platform=GenesysEngage-cloud
 +
|Role=Developer
 
|Section={{Section
 
|Section={{Section
|Type=Structured
 
 
|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 16: Line 15:
 
For all examples below, assume that _genesys.widgets.common has been stored in a local variable named 'Common'.
 
For all examples below, assume that _genesys.widgets.common has been stored in a local variable named 'Common'.
  
<source lang='javascript'>var Common = _genesys.widgets.common;</source>
+
<source lang="javascript">var Common = _genesys.widgets.common;</source>
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.Generate.Container({options})
 
|sectionHeading=Common.Generate.Container({options})
 
|alignment=Vertical
 
|alignment=Vertical
Line 28: Line 25:
 
'Generate an Overlay Container'
 
'Generate an Overlay Container'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var ndContainer = Common.Generate.Container({
 
var ndContainer = Common.Generate.Container({
  
Line 43: Line 40:
 
'Generate a Toast Container'
 
'Generate a Toast Container'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var ndContainer = Common.Generate.Container({
 
var ndContainer = Common.Generate.Container({
  
Line 101: Line 98:
 
{{!}}{{!}}options.buttons.primary
 
{{!}}{{!}}options.buttons.primary
 
{{!}}{{!}}string
 
{{!}}{{!}}string
{{!}}{{!}}Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc)
+
{{!}}{{!}}Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc.)
 
{{!}}-
 
{{!}}-
 
{{!}}{{!}}options.buttons.secondary
 
{{!}}{{!}}options.buttons.secondary
 
{{!}}{{!}}string
 
{{!}}{{!}}string
{{!}}{{!}}Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc)
+
{{!}}{{!}}Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc.)
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.Generate.Buttons({options})
 
|sectionHeading=Common.Generate.Buttons({options})
 
|alignment=Vertical
 
|alignment=Vertical
Line 118: Line 113:
 
'Generate Binary Buttons'
 
'Generate Binary Buttons'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var ndButtons = Common.Generate.Buttons({
 
var ndButtons = Common.Generate.Buttons({
  
Line 146: Line 141:
 
{{!}}{{!}}options.primary
 
{{!}}{{!}}options.primary
 
{{!}}{{!}}string
 
{{!}}{{!}}string
{{!}}{{!}}Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc)
+
{{!}}{{!}}Display name on the primary button. (for example 'OK', 'Yes', 'Accept', 'Continue', etc.)
 
{{!}}-
 
{{!}}-
 
{{!}}{{!}}options.secondary
 
{{!}}{{!}}options.secondary
 
{{!}}{{!}}string
 
{{!}}{{!}}string
{{!}}{{!}}Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc)
+
{{!}}{{!}}Display name on the secondary button. (for example 'Cancel', 'No', 'Dismiss', 'Reject', etc.)
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.Generate.Icon(name)
 
|sectionHeading=Common.Generate.Icon(name)
 
|alignment=Vertical
 
|alignment=Vertical
Line 163: Line 156:
 
'Generate Chat Icon'
 
'Generate Chat Icon'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var ndChatIcon = Common.Generate.Icon('chat');
 
var ndChatIcon = Common.Generate.Icon('chat');
 
</source>
 
</source>
Line 171: Line 164:
 
'Insert Chat Icon'
 
'Insert Chat Icon'
  
<source lang='javascript'>
+
<source lang="javascript">
 
$('#your_icon_container').append(Common.Generate.Icon('chat'));
 
$('#your_icon_container').append(Common.Generate.Icon('chat'));
 
</source>
 
</source>
Line 188: Line 181:
 
{{!}}{{!}}Select the icon you want to generate by name. See the icon reference page for icon names.
 
{{!}}{{!}}Select the icon you want to generate by name. See the icon reference page for icon names.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.Generate.Scrollbar(element, {options})
 
|sectionHeading=Common.Generate.Scrollbar(element, {options})
 
|alignment=Vertical
 
|alignment=Vertical
Line 199: Line 190:
 
'Generate Scrollbar for a container'
 
'Generate Scrollbar for a container'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var scrollContainer = Common.Generate.Scrollbar($('#your_container'))
 
var scrollContainer = Common.Generate.Scrollbar($('#your_container'))
 
</source>
 
</source>
Line 218: Line 209:
 
{{!}}{{!}}options
 
{{!}}{{!}}options
 
{{!}}{{!}}object
 
{{!}}{{!}}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 http://iscrolljs.com/#configuring]
+
{{!}}{{!}}This is an iScroll component. So, all the options that iScroll supports can be passed here.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.config(object)
 
|sectionHeading=Common.config(object)
 
|alignment=Vertical
 
|alignment=Vertical
Line 231: Line 220:
 
'Enable full debug logging'
 
'Enable full debug logging'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.config({debug: true, debugTimestamps: true});
 
Common.config({debug: true, debugTimestamps: true});
 
</source>
 
</source>
Line 248: Line 237:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.checkPath(object, path)
 
|sectionHeading=Common.checkPath(object, path)
 
|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 '''undefined'''. Useful for checking configuration object paths without having to check each sub-property level individually.
 
<br /><br />
 
<br /><br />
 
===Example===
 
===Example===
 
'Check for window._genesys.main'
 
'Check for window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var oMainConfig = false;
 
var oMainConfig = false;
  
Line 284: Line 271:
 
{{!}}{{!}}The object path in dot notation you wish to search for.
 
{{!}}{{!}}The object path in dot notation you wish to search for.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.createPath(object, path, value)
 
|sectionHeading=Common.createPath(object, path, value)
 
|alignment=Vertical
 
|alignment=Vertical
Line 295: Line 280:
 
'Create window._genesys.main'
 
'Create window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var oMainConfig = false;
 
var oMainConfig = false;
  
Line 314: Line 299:
 
{{!}}{{!}}object
 
{{!}}{{!}}object
 
{{!}}{{!}}object
 
{{!}}{{!}}object
{{!}}{{!}}An Object you want to add your new path to.
+
{{!}}{{!}}An object you want to add your new path to.
 
{{!}}-
 
{{!}}-
 
{{!}}{{!}}path
 
{{!}}{{!}}path
Line 324: Line 309:
 
{{!}}{{!}}The value you want to assign to the final node (property) in your path.
 
{{!}}{{!}}The value you want to assign to the final node (property) in your path.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.linkify(string, options)
 
|sectionHeading=Common.linkify(string, options)
 
|alignment=Vertical
 
|alignment=Vertical
Line 335: Line 318:
 
'Check for window._genesys.main'
 
'Check for window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var sString = 'Please visit www.genesys.com';
 
var sString = 'Please visit www.genesys.com';
 
sString = Common.linkify(sString, {target: 'self'});
 
sString = Common.linkify(sString, {target: 'self'});
Line 362: Line 345:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.log(mixed, type)
 
|sectionHeading=Common.log(mixed, type)
 
|alignment=Vertical
 
|alignment=Vertical
Line 373: Line 354:
 
'Check the contents of window._genesys.main'
 
'Check the contents of window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var Common = _genesys.widgets.common;  
 
var Common = _genesys.widgets.common;  
 
Common.log(window._genesys.main);
 
Common.log(window._genesys.main);
Line 399: Line 380:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.sanitizeHTML(string)
 
|sectionHeading=Common.sanitizeHTML(string)
 
|alignment=Vertical
 
|alignment=Vertical
Line 410: Line 389:
 
'Check for window._genesys.main'
 
'Check for window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var sString = 'Please visit <a href='www.genesys.com'
 
var sString = 'Please visit <a href='www.genesys.com'
 
target='_self'>www.genesys.com</a>';
 
target='_self'>www.genesys.com</a>';
Line 432: Line 411:
 
{{!}}{{!}}Any string you want to be transformed.
 
{{!}}{{!}}Any string you want to be transformed.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.updateTemplateI18n(element, object)
 
|sectionHeading=Common.updateTemplateI18n(element, object)
 
|alignment=Vertical
 
|alignment=Vertical
Line 443: Line 420:
 
'Check for window._genesys.main'
 
'Check for window._genesys.main'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var ndContainer = $('<div><button class='i18n' data-message='CustomButton001'>
 
var ndContainer = $('<div><button class='i18n' data-message='CustomButton001'>
 
</button></div>');
 
</button></div>');
Line 469: Line 446:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.debugIcons
 
|sectionHeading=Common.debugIcons
 
|alignment=Vertical
 
|alignment=Vertical
Line 480: Line 455:
 
'Fetch and Display list of icons present in Widgets'
 
'Fetch and Display list of icons present in Widgets'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.debugIcons()
 
Common.debugIcons()
 
</source>
 
</source>
  
 
<br />
 
<br />
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.debug
 
|sectionHeading=Common.debug
 
|alignment=Vertical
 
|alignment=Vertical
Line 496: Line 469:
 
'Check the File upload limits in WebChatService'
 
'Check the File upload limits in WebChatService'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.debug(data_server_returned_file_limits);
 
Common.debug(data_server_returned_file_limits);
 
</source>
 
</source>
Line 513: Line 486:
 
{{!}}{{!}}Any value or message you'd like to add debug log. Note: This is only supported if your browser supports debug log type.
 
{{!}}{{!}}Any value or message you'd like to add debug log. Note: This is only supported if your browser supports debug log type.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.error
 
|sectionHeading=Common.error
 
|alignment=Vertical
 
|alignment=Vertical
Line 524: Line 495:
 
'Logging error messages'
 
'Logging error messages'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.error('A widget plugin did not receive the following config: ....');
 
Common.error('A widget plugin did not receive the following config: ....');
 
</source>
 
</source>
Line 541: Line 512:
 
{{!}}{{!}}Any value or message you'd like to add error log. Note: This is only supported if your browser supports error log type.
 
{{!}}{{!}}Any value or message you'd like to add error log. Note: This is only supported if your browser supports error log type.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.populateAllPlaceholders
 
|sectionHeading=Common.populateAllPlaceholders
 
|alignment=Vertical
 
|alignment=Vertical
Line 552: Line 521:
 
'Show placeholders strings in a form'
 
'Show placeholders strings in a form'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.populateAllPlaceholders($('#your_form'), {strings})
 
Common.populateAllPlaceholders($('#your_form'), {strings})
 
</source>
 
</source>
Line 558: Line 527:
 
<br />
 
<br />
 
===Arguments===
 
===Arguments===
 
 
{{{!}} class="wikitable"
 
{{{!}} class="wikitable"
 
{{!}}-
 
{{!}}-
Line 573: Line 541:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.populateLanguageStrings
 
|sectionHeading=Common.populateLanguageStrings
 
|alignment=Vertical
 
|alignment=Vertical
Line 584: Line 550:
 
'Show placeholders strings in a form'
 
'Show placeholders strings in a form'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.populateLanguageStrings($('#your_form'), {strings})
 
Common.populateLanguageStrings($('#your_form'), {strings})
 
</source>
 
</source>
Line 605: Line 571:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.populateIcons
 
|sectionHeading=Common.populateIcons
 
|alignment=Vertical
 
|alignment=Vertical
Line 616: Line 580:
 
'Populate all Widget Icons'
 
'Populate all Widget Icons'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.populateIcons($('#your_continer'));
 
Common.populateIcons($('#your_continer'));
 
</source>
 
</source>
Line 633: Line 597:
 
{{!}}{{!}}Specify the Widget container for which all the Icons have to be displayed.
 
{{!}}{{!}}Specify the Widget container for which all the Icons have to be displayed.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.insertIcon
 
|sectionHeading=Common.insertIcon
 
|alignment=Vertical
 
|alignment=Vertical
Line 644: Line 606:
 
'Insert a check mark icon to an element you desire.'
 
'Insert a check mark icon to an element you desire.'
  
<source lang='javascript'>
+
<source lang="javascript">
Common.insertIcon($('#your_element'), 'alert-checkmark')
+
Common.insertIcon($('#your_element'), 'alert-checkmark', 'alert')
 
</source>
 
</source>
  
 
<br />
 
<br />
 
===Arguments===
 
===Arguments===
 
 
{{{!}} class="wikitable"
 
{{{!}} class="wikitable"
 
{{!}}-
 
{{!}}-
Line 661: Line 622:
 
{{!}}{{!}}An html element to which Icon is to be displayed.
 
{{!}}{{!}}An html element to which Icon is to be displayed.
 
{{!}}-
 
{{!}}-
{{!}}{{!}}Icon name
+
{{!}}{{!}}icon name
 
{{!}}{{!}}string
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 +
{{!}}-
 +
{{!}}{{!}}icon Aria Name
 +
{{!}}{{!}}string
 +
{{!}}{{!}}Name for the icon to be read by screen readers.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.injectScript
 
|sectionHeading=Common.injectScript
 
|alignment=Vertical
 
|alignment=Vertical
Line 676: Line 639:
 
'Inject your Widget WebChat extension plugin.'
 
'Inject your Widget WebChat extension plugin.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.injectScript('path/to/LoadWebChat.ext.js')
 
Common.injectScript('path/to/LoadWebChat.ext.js')
 
</source>
 
</source>
Line 693: Line 656:
 
{{!}}{{!}}JavaScript file name that needs to be injected into widgets.
 
{{!}}{{!}}JavaScript file name that needs to be injected into widgets.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.mobileScreenScale
 
|sectionHeading=Common.mobileScreenScale
 
|alignment=Vertical
 
|alignment=Vertical
Line 704: Line 665:
 
'Fit your widget to any mobile screen.'
 
'Fit your widget to any mobile screen.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var mobileScaledWidget = Common.mobileScreenScale($('#your_widget'));
 
var mobileScaledWidget = Common.mobileScreenScale($('#your_widget'));
 
</source>
 
</source>
Line 721: Line 682:
 
{{!}}{{!}}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.
 
{{!}}{{!}}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.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.showLoading
 
|sectionHeading=Common.showLoading
 
|alignment=Vertical
 
|alignment=Vertical
Line 732: Line 691:
 
'Show loading spinner during an Ajax request'
 
'Show loading spinner during an Ajax request'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.showLoading($('#your_container'))
 
Common.showLoading($('#your_container'))
 
</source>
 
</source>
Line 749: Line 708:
 
{{!}}{{!}}An html container where loading spinner should appear. This adds a class name 'cx-loading'.
 
{{!}}{{!}}An html container where loading spinner should appear. This adds a class name 'cx-loading'.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.hideLoading
 
|sectionHeading=Common.hideLoading
 
|alignment=Vertical
 
|alignment=Vertical
Line 760: Line 717:
 
'Remove loading spinner after the Ajax request'
 
'Remove loading spinner after the Ajax request'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.hideLoading($('#your_container'))
 
Common.hideLoading($('#your_container'))
 
</source>
 
</source>
Line 777: Line 734:
 
{{!}}{{!}}An html container which contains the loading spinner.
 
{{!}}{{!}}An html container which contains the loading spinner.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.showWaiting
 
|sectionHeading=Common.showWaiting
 
|alignment=Vertical
 
|alignment=Vertical
Line 788: Line 743:
 
'Show waiting Icon when uploading a file.'
 
'Show waiting Icon when uploading a file.'
  
<source lang='javascript'>
+
<source lang="javascript">
Common.showWaiting($('#your_container'))
+
Common.showWaiting($('#your_container'),'waiting'))
 
</source>
 
</source>
  
Line 804: Line 759:
 
{{!}}{{!}}jQuery DOM Selector
 
{{!}}{{!}}jQuery DOM Selector
 
{{!}}{{!}}An html container where waiting symbol should appear. This adds a class name 'cx-waiting'.
 
{{!}}{{!}}An html container where waiting symbol should appear. This adds a class name 'cx-waiting'.
 +
{{!}}-
 +
{{!}}{{!}}Aria Label
 +
{{!}}{{!}}string
 +
{{!}}{{!}}The value of the aria-label attribute for the loading screen icon. The default value is ‘waiting’
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.hideWaiting
 
|sectionHeading=Common.hideWaiting
 
|alignment=Vertical
 
|alignment=Vertical
Line 816: Line 773:
 
'Remove waiting Icon after file upload is done.'
 
'Remove waiting Icon after file upload is done.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.hideWaiting($('#your_container'))
 
Common.hideWaiting($('#your_container'))
 
</source>
 
</source>
Line 833: Line 790:
 
{{!}}{{!}}An html container which contains the waiting symbol.
 
{{!}}{{!}}An html container which contains the waiting symbol.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.watch
 
|sectionHeading=Common.watch
 
|alignment=Vertical
 
|alignment=Vertical
Line 844: Line 799:
 
'Make Request Notifications till none are pending.'
 
'Make Request Notifications till none are pending.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.watch(function(iteration, maxIterations){
 
Common.watch(function(iteration, maxIterations){
  
Line 869: Line 824:
 
{{!}}{{!}}frequency
 
{{!}}{{!}}frequency
 
{{!}}{{!}}milliseconds
 
{{!}}{{!}}milliseconds
{{!}}{{!}}Execute the function for every 'x' milliseconds till the it returns true.
+
{{!}}{{!}}Execute the function for every 'x' milliseconds until it returns true.
 
{{!}}-
 
{{!}}-
 
{{!}}{{!}}limit
 
{{!}}{{!}}limit
Line 875: Line 830:
 
{{!}}{{!}}The maximum number of times function is executed.
 
{{!}}{{!}}The maximum number of times function is executed.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.addDialog
 
|sectionHeading=Common.addDialog
 
|alignment=Vertical
 
|alignment=Vertical
Line 884: Line 837:
 
<br /><br />
 
<br /><br />
 
===Example===
 
===Example===
'Add a dialog box on your preferred container div''
+
'Add a dialog box on your preferred container div
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.addDialog($('#your_container'), $('#your_dialog_box'), 'my_warning')
 
Common.addDialog($('#your_container'), $('#your_dialog_box'), 'my_warning')
 
</source>
 
</source>
Line 911: Line 864:
 
{{!}}{{!}}Dialog box name.
 
{{!}}{{!}}Dialog box name.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.showDialog
 
|sectionHeading=Common.showDialog
 
|alignment=Vertical
 
|alignment=Vertical
Line 922: Line 873:
 
'Show the dialog box created using Common.addDialog()'
 
'Show the dialog box created using Common.addDialog()'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.showDialog($('#your_container'), 'your_dialog_box_name');
 
Common.showDialog($('#your_container'), 'your_dialog_box_name');
 
</source>
 
</source>
Line 943: Line 894:
 
{{!}}{{!}}The actual dialog box name.
 
{{!}}{{!}}The actual dialog box name.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.hideDialog
 
|sectionHeading=Common.hideDialog
 
|alignment=Vertical
 
|alignment=Vertical
Line 954: Line 903:
 
'Hide dialog box'
 
'Hide dialog box'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.hideDialog($('#your_container'), 'your_dialog_box_name);
 
Common.hideDialog($('#your_container'), 'your_dialog_box_name);
 
</source>
 
</source>
Line 975: Line 924:
 
{{!}}{{!}}The actual dialog box name.
 
{{!}}{{!}}The actual dialog box name.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.hideDialogs
 
|sectionHeading=Common.hideDialogs
 
|alignment=Vertical
 
|alignment=Vertical
Line 986: Line 933:
 
'Hide all dialog boxes.'
 
'Hide all dialog boxes.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
Common.hideDialogs($('#your_container'));
 
Common.hideDialogs($('#your_container'));
 
</source>
 
</source>
Line 1,003: Line 950:
 
{{!}}{{!}}The parent container which is showing all the dialog boxes.
 
{{!}}{{!}}The parent container which is showing all the dialog boxes.
 
{{!}}}
 
{{!}}}
|advanced=No
+
==Common.showAlert==
 +
Show a native alert dialog box on the Widget you prefer with your own text message. By default, a primary button is added to dismiss the alert dialog.
 +
===Example===
 +
Show an alert dialog box on the Widget you prefer. But default it adds the dismiss button.
 +
 +
<source lang="javascript">
 +
Common.showAlert($('.cx-widget.cx-webchat'), {text: 'your alert message', buttonText: 'Ok'})
 +
</source>
 +
===Arguments===
 +
{{{!}} class="wikitable"
 +
{{!}}-
 +
!{{!}}Argument
 +
!{{!}}Type
 +
!{{!}}Description
 +
{{!}}-
 +
{{!}}element
 +
{{!}}jQuery selector
 +
{{!}}The Widget plugin container that should display the alert dialog. This should be the top level container wrapper holding the Widget.
 +
{{!}}-
 +
{{!}}options
 +
{{!}}object
 +
{{!}}The data options containing the text to be shown on the Alert dialog box.
 +
{{!}}-
 +
{{!}}options.text
 +
{{!}}string
 +
{{!}}Display text on the Alert dialog box.
 +
{{!}}-
 +
{{!}}options.buttonText
 +
{{!}}string
 +
{{!}}Display text on the primary button. (for example 'OK')
 +
{{!}}}
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.bytesToSize
 
|sectionHeading=Common.bytesToSize
 
|alignment=Vertical
 
|alignment=Vertical
Line 1,014: Line 990:
 
'bytes to KB, MB, GB or TB.'
 
'bytes to KB, MB, GB or TB.'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var fileSize = Common.bytesToSize(parseInt(fileSizeInBytes));
 
var fileSize = Common.bytesToSize(parseInt(fileSizeInBytes));
 
</source>
 
</source>
Line 1,031: Line 1,007:
 
{{!}}{{!}}Number in bytes size.
 
{{!}}{{!}}Number in bytes size.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}{{Section
 
}}{{Section
|Type=Structured
 
 
|sectionHeading=Common.getFormattedTime
 
|sectionHeading=Common.getFormattedTime
 
|alignment=Vertical
 
|alignment=Vertical
Line 1,042: Line 1,016:
 
'convert date timestamp to return time in 12 hrs format'
 
'convert date timestamp to return time in 12 hrs format'
  
<source lang='javascript'>
+
<source lang="javascript">
 
var formattedTime = Common.getFormattedTime(timestamp, 12);
 
var formattedTime = Common.getFormattedTime(timestamp, 12);
 
</source>
 
</source>
Line 1,063: Line 1,037:
 
{{!}}{{!}}Time format with value 12 or 24.
 
{{!}}{{!}}Time format with value 12 or 24.
 
{{!}}}
 
{{!}}}
|advanced=No
 
 
|Status=No
 
|Status=No
 
}}
 
}}
 
}}
 
}}

Latest revision as of 20:56, February 3, 2021

This topic is part of the manual Widgets API Reference for version Current of Widgets.

Contents

Learn how to access Widgets utility functions and dynamically generate the common HTML containers used throughout Genesys Widgets.

Related documentation:

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.

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 undefined. 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 &lt;a href='www.genesys.com' target='_self'&gt;www.genesys.com&lt;/a&gt;''


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', 'alert')


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.
icon Aria Name string Name for the icon to be read by screen readers.

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'),'waiting'))


Arguments

Argument Type Description
element jQuery DOM Selector An html container where waiting symbol should appear. This adds a class name 'cx-waiting'.
Aria Label string The value of the aria-label attribute for the loading screen icon. The default value is ‘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 until 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.showAlert

Show a native alert dialog box on the Widget you prefer with your own text message. By default, a primary button is added to dismiss the alert dialog.

Example

Show an alert dialog box on the Widget you prefer. But default it adds the dismiss button.

Common.showAlert($('.cx-widget.cx-webchat'), {text: 'your alert message', buttonText: 'Ok'})

Arguments

Argument Type Description
element jQuery selector The Widget plugin container that should display the alert dialog. This should be the top level container wrapper holding the Widget.
options object The data options containing the text to be shown on the Alert dialog box.
options.text string Display text on the Alert dialog box.
options.buttonText string Display text on the primary button. (for example 'OK')

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.
Retrieved from "https://all.docs.genesys.com/WID/Current/SDK/Common (2025-06-20 07:15:01)"
Comments or questions about this documentation? Contact us for support!