Web Widget API
moin web widget API provides handy API to control the widget based on your special business requirement.
The API separates to two parts - Setting and Command.
- Setting: Setting is used to control the UI, text, etc..
- Command: Command is used to control the action or receive the action from the widget
#
SettingThe Web Widget has the following core settings:
parameter | type | default value | description |
---|---|---|---|
hideButtonOnMobileDevice | boolean | false | Show/Hide the message button on mobile device |
Example
<script type="text/javascript"> window.moinSetting = { hideButtonOnMobileDevice: true };</script>
#
Execute commandmoin web widget API exposes the function to let developers execute some commands. Below will elaborate all eligible commands.
The format is
window.moinWidget.exec(<label>, <event>, callback);
form
show
#
Will show the web widget form
window.moinWidget.exec('form', 'show')
form
hide
#
Will hide the web widget form
window.moinWidget.exec('form', 'hide')
#
Subscribe Commandmoin web widget API exposes the listen function to let developers subscribe the event. Below will elaborate all eligible commands.
The format is
window.moinWidget.listen(<label>, <event>, callback);
messageButton
is clicked
#
execute the callback function when the message button is clicked
window.moinWidget.listen('messageButton', 'click', () => );
form
is show
#
execute the callback function when the form is shown
window.moinWidget.listen('form', 'show', () => );
form
is hide
#
execute the callback function when the form is hidden
window.moinWidget.listen('form', 'hide', () => );
form
is submit
#
execute the callback function when the form is submitted. The callback function will include the form data
window.moinWidget.listen('form', 'submit', (event, formData) => );
form
is sent
#
execute the callback function when the form is sent
window.moinWidget.listen('form', 'sent', () => );