kango.ui.browserButton

Summary

Name Description
addEventListener Registers an event handler for the specified event type
removeEventListener Removes an event handler that the addEventListener method registered
setTooltipText Changes tooltip (hint) for the button
setIcon Sets Icon for button
setBadgeValue Sets badge text
setBadgeBackgroundColor Sets badge background color
setPopup Sets popup details associated with button

Methods

addEventListener

kango.ui.browserButton.addEventListener(name, callback)

Registers an event handler for the specified event type.

Arguments:
  • name (string) – event name
  • callback (function(event)) – callback function

Events list:

COMMAND // Fired on browser action icon clicked

Note

COMMAND event will not fire if browserButton has a popup.

Example:

// Handle button click
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, function(event) {
    kango.console.log('Button clicked');
});

removeEventListener

kango.ui.browserButton.removeEventListener(name, callback)

Removes an event handler that the kango.ui.browserButton.addEventListener() method registered.

Arguments:
  • name (string) – event name
  • callback (function(event)) – callback function

Example:

// event handler
var onCommand = function(event) {
    kango.console.log('Button clicked');
};

// add event handler
kango.ui.browserButton.addEventListener(kango.ui.browserButton.event.COMMAND, onCommand);

// remove event handler
kango.ui.browserButton.removeEventListener(kango.ui.browserButton.event.COMMAND, onCommand);

setTooltipText

kango.ui.browserButton.setTooltipText(text)

Sets the tooltip text (hint) to be shown for browser button.

Arguments:
  • text (string) – Text to show as tooltip

Note

It’s impossible to remove tooltip in Safari.

Example:

kango.ui.browserButton.setTooltipText('Test')

setIcon

kango.ui.browserButton.setIcon(path)

Sets or changes icon for browser button. Url must point to local file, path must be relative to extension_info.json file.

Arguments:
  • path (string) – Path to the icon

Note

Icon must be in .png file, supported sizes are 16x16 to 19x19, all browsers except Safari supporting full color transparent PNG. Safari however can only use black and white icons. Please refer Apple docs to find out how to prepare an Icon for Safari.

Example:

kango.ui.browserButton.setIcon('icons/online.png');

setBadgeValue

kango.ui.browserButton.setBadgeValue(value)

Sets number (badge) to show on browser button.

Arguments:
  • value (string|number) – An value to show on the button

Note

Safari supports only number values.

Example:

kango.ui.browserButton.setBadgeValue(27);
kango.ui.browserButton.setBadgeValue('+12');

setBadgeBackgroundColor

kango.ui.browserButton.setBadgeBackgroundColor(color)

Sets badge background color.

Arguments:
  • color (array) – An array of four integers in the range [0,255] that make up the RGBA color of the badge

Note

Not supported in Safari.

Example:

// opaque red
kango.ui.browserButton.setBadgeBackgroundColor([255, 0, 0, 255]);

setPopup

kango.ui.browserButton.setPopup(details)

Specifies all the information about popup to open on browser button click.

Note

Kango API available only for local pages.

See Popup API section for more details.

Details object:

details = {
    string url,   // URL to open in popup
    number width, // Width of popup
    number height // Height of popup
}

Example:

kango.ui.browserButton.setPopup({
    url: 'weather.html',
    width: 200,
    height: 300
});

Table Of Contents

Previous topic

kango.browser.windows

Next topic

kango.ui.optionsPage