Badge.display

By Opera Software

Description:

Determines whether the badge should be displayed; allowed values: "block" and "none"; it is set to "none" by default.

Example:

//
// The background process (e.g. index.html)
//

// Set the button's properties
var properties = {
  disabled: false,
  title: "My Test Extension",
  icon: "icon.18x18.png",
  badge: {
    backgroundColor: '#CC5555',
    color: 'white',
    textContent: '!',
    display: 'none'
  }
};	

// Add the button to the browser UI
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);

// Listen for injected script messages
opera.extension.onmessage = function(event) {
  // Show the badge if we get a warning from the injected script
  if (event.data === 'warning') {
    button.badge.display = 'block';
  } else {
    button.badge.display = 'none';
  }
}

This article is licensed under a Creative Commons Attribution 3.0 Unported license.

Comments

No new comments accepted.