The Weavy Widget API

With the widget javascript API you can add your own buttons and controls for interacting with the Weavy widget. This is the most advanced and powerful way to take full control of how you want the Weavy widget to look and behave. If you haven’t already, take a look at the configuration options for basic control of the Weavy widget.

var widget = new WeavyWidget(widget_options); 

// get the current options
var options = widget.options;

// The main node for the widget
var container = widget.container;

// initializes the weavy instance
// should be used together with widget options { init: false; }
widget.init();

// open a bubble in the weavy widget
widget.open(bubbleId, destination);

// close all bubbles in the weavy widget
widget.close();

// open/close a bubble in the weavy widget
widget.toggle(bubbleId);

// expand/collapse the weavy widget
widget.resize();

// expand the weavy widget
widget.maximize();

// reload the weavy widget with new options 
widget.reload(options);

// Sign in a user to Weavy. Only available when a custom authentication url over https (SSL) has been set up
widget.signIn(username, password);

// Sign out the current user. Only available when a custom authentication url over https (SSL) has been set up
widget.signOut();

// hook onto an event (see below for a list of available events)
widget.on([event], callback);

// hook onto an event once (see below for a list of available events)
widget.one([event], callback);

// Trigger any existing or custom weavy widget event
widget.triggerEvent([event], data);

// Returns an url with https protocol according to options for https
widget.httpsUrl(url)

// Clean up everything except the ShadowDOM node, which you have to remove from outside Weavy
widget.destroy();

Widget events

The following javascript events are available.

var widget = new WeavyWidget(widget_options);

widget.on("init", function(e) {
  // When widget is initializing
});

widget.on("load", function(e) {
  // Called when widget is fully loaded and widget DOM is ready
  var widgetDOM = widget.root;
  var container = widget.container;
});

widget.on("open", function(e, open){
  // called when a bubble is opened
  var bubbleId = open.target;
});

widget.on("close", function(e){
  // called when the bubbles are is closed
});

widget.on("resize", function(e){
  // called when the weavy widget is resized
});

widget.on("reload", function(e, options){
  // called when the weavy widget reloads
  var weavyOptions = options;
});

widget.on("badge", function(e, badge){
  // called when the weavy badge number is updated
  var total = badge.total;
  var unreadConversations = badge.conversations;
  var unreadNotifications = badge.notifications;
});

widget.on("notification", function(e, notification){
  // called when a new notification arrives
  var notificationText = notification.text;  
});