Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Persist the location of the toolbar button.
Browse files Browse the repository at this point in the history
This doesn’t, however, persist the toolbar, and always assumes it’s the
navigation bar, making the button impossible to remove for now.
  • Loading branch information
charmander committed Jan 18, 2015
1 parent 7cf08ec commit 4ea2066
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
23 changes: 14 additions & 9 deletions bootstrap.js
Expand Up @@ -21,20 +21,25 @@ function addButton(window) {

const navigationBar = window.document.getElementById('nav-bar');

let button = window.document.getElementById('safeguard-button');
let button = window.document.createElement('toolbarbutton');
button.setAttribute('id', 'safeguard-button');
button.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
button.setAttribute('label', 'Safeguard');

if (!button) {
button = window.document.createElement('toolbarbutton');
button.setAttribute('id', 'safeguard-button');
button.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
button.setAttribute('label', 'Safeguard');
button.addEventListener('command', reloadWhitelist, false);

button.addEventListener('command', reloadWhitelist, false);
toolbox.palette.appendChild(button);

toolbox.palette.appendChild(button);
var currentSet = navigationBar.getAttribute('currentset').split(',');
var i = currentSet.indexOf('safeguard-button');
var next = null;

if (i !== -1 && i !== currentSet.length - 1) {
next = window.document.getElementById(currentSet[i + 1]);
}

navigationBar.insertItem('safeguard-button');
navigationBar.insertItem('safeguard-button', next);
window.document.persist('safeguard-button', 'currentset');
}

function removeButton(window) {
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Expand Up @@ -3,7 +3,7 @@
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description RDF:about="urn:mozilla:install-manifest">
<em:id>safeguard@charmander.me</em:id>
<em:version>0.1.2</em:version>
<em:version>0.1.3</em:version>
<em:type>2</em:type>
<em:targetApplication>
<RDF:Description>
Expand Down

0 comments on commit 4ea2066

Please sign in to comment.