Functions
Functions are special methods that come with SDK which allow you to control the state of the beacon window.
Takes no arguments Returnsundefined
This function is used to open the beacon window. It is useful when you want to use a button on your webpage to directly open the beacon window. Follow the examples below on how it should be implemented.
var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.open();
/** Using a button on webpage to open the beacon window **/
document.getElementById('my-button').addEventListener('click', function() {
var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.open();
});
Takes no arguments Returnsundefined
This function is used to close the beacon window. Usage is similar to
open
function. Follow the examples below on how it should be implemented.var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.close();
/** Using a button on webpage to close the beacon window **/
document.getElementById('my-button').addEventListener('click', function() {
var beacon = document.getElementsByTagName('beacon-app')[0];
beacon.close();
});
Takes 1String
argument which is a valid hex color code ReturnsString
This function returns a contrasting text color for the color passed as argument. It is the same function that is used to set the text color of beacon window based on the primary color.
This function does not modify beacon window's state. It is provided just for your reference to follow the same color styles.
var beacon = document.getElementsByTagName('beacon-app')[0];
console.log(beacon.getTextColor("#5CB1DB"));
// #ffffff
console.log(beacon.getTextColor("#6DDAD0"));
// #2c3e50
Last modified 4yr ago