What is flock.js?
Widgets can use flock.js to communicate with their host Flock client. flock.js can only be used from within widgets inside Flock. It is not supported independently inside a browser
It is available at: https://apps-static.flock.co/js-sdk/0.1.0/flock.js
Some of the things that you can do with flock.js are:
- Use the currently opened widget to open another widget. For eg launch a modal widget from a sidebar widget
- Launch the browser
- Close the current widget (only applicable for modal widgets)
How do I use it?
Include flock.js in your widget via a script
tag in the HTML.
<html> <head> <script src="/path/to/flock.js"></script> </head> <body> ... </body> </html>
flock.js provides a global object, flock
, whose methods can be invoked by your widget app to be able to talk to the Flock host client.
Methods
The following methods are available on the flock
object.
flock.openWidget(url, desktopType[, moblileType])
This method opens a widget.
url
. The URL that should be opened.desktopType
. Can be either'modal'
or'sidebar'
.mobileType
. Can only be'modal'
, which is also the default.
Note: When opening a widget using this method, the assoicated event that is passed to the URL is client.widgetAction.
flock.openBrowser(url[, sendContext])
This method launches a browser.
url
. The URL that should be opened.sendContext
. Iffalse
, then Flock just opens the link in the browser without passing any context to it.
Note: When launching the browser with context using this method, the assoicated event that is passed to the URL is client.widgetAction.
flock.close()
Closes the widget within which this method was called.