1

I wanted to migrate my existing add-on for firefox and chrome to crossrider in order to have it also with safari and IE, but i've a few doubts that mayble Schlomo (or any Crossrider developercan) can help me to solve them.

Questions :

  1. Can i add a popup pane when someone clicks on the add-on button showing some kind of options inside it?

  2. Can i add a blinking icon to the actual icon showing some kind of event happened like incoming chat or so?

  3. Is there a way to add the red text box like in chrome showing at the bottom right of the icon some kind of text?

Thanks a lot!

Tony
  • 3,425
  • 10
  • 30
  • 46

1 Answers1

3

When you pose the question like that, I can only hope the following answers will serve to allay your doubts and enlighten :)

First off, I would recommend familiarizing yourself with How to add a browser button to your Crossrider extension in general and the button popup feature specifically.

In answer to your specific questions:

  1. You can use the button popup feature and build the required options in there. Take a look at the Button Popup Menu demo extension to get you started.
  2. Whilst you can't make the button blink, you can alternate the button icon to make it look like blinking (see example).
  3. In short, yes. Simply use the appAPI.browserAction.setBadgeText and appAPI.browserAction.setBadgeBackgroundColor methods (see example).

The following example bring together the key elements in the background.js code required to achieve the solutions mentioned. Look at the popup.html file in the Button Popup Menu for an example of how to build the options page.

appAPI.ready(function() {
    var sid, // Blink interval id
        alt=0, // Blink alternation state
        icon = { // Blink icons
            0: 'icons/icon0.png',
            1: 'icons/icon1.png'
        };

    // Set the initial icon for the button
    appAPI.browserAction.setResourceIcon(icon[0]);
    // Sets the popup for the button
    appAPI.browserAction.setPopup({
        resourcePath:'html/popup.html',
        height: 300,
        width: 300
    });

    if (true) { // blink condition, set to true for this example
        // Blink icon
        sid = appAPI.setInterval(function() {
            alt = 1 - alt;
            appAPI.browserAction.setResourceIcon(icon[alt]);
        }, 1 * 1000);
    } else {
        appAPI.clearInterval(sid);
    }

    if (true) { // show button text condition, set to true for this example
        // Add red text box to icon
        appAPI.browserAction.setBadgeText('ext', [255,0,0,255]);
    }
});

[Disclosure: I am a crossrider employee]

Shlomo
  • 3,763
  • 11
  • 16