xylar
xylar

Reputation: 7663

Toggle Toolbar in Firefox extension

I have a toolbarbutton and I want it to toggle a toolbox > toolbar when it is clicked. I thought there might be an internal function similar to toggleSidebar(id) but I cannot find it.

Upvotes: 2

Views: 1134

Answers (1)

xylar
xylar

Reputation: 7663

Well there is no function, however there is a simple solution for anyone looking for it.

First on the toolbarbutton add the following attribute:

oncommand="extName.toggleToolbar(event);"

then in the javascript:

toggleToolbar: function(e) {
    var toolbar = document.getElementById('uniqueName-toolbar');

    if(toolbar.getAttribute('hidden')== 'true'){
        toolbar.setAttribute('hidden', false);
    }
    else{
        toolbar.setAttribute('hidden', true);
    }
}

Upvotes: 3

Related Questions