Badge.display

By Opera Software

From Opera 15 onward, Opera 11 & 12’s extension format is no longer supported, and instead, we’ve switched to Chromium’s extension model. Check out our new documentation for developing extensions for Opera 15 and higher and start building your own extensions.

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.