Skip to content

Commit

Permalink
Move the F1 button to the URL bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
philikon committed Mar 19, 2011
1 parent 9ed38db commit 3314146
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 85 deletions.
12 changes: 4 additions & 8 deletions extensions/firefox-share/src/chrome/skin/overlay.css
Expand Up @@ -22,23 +22,19 @@
* */
@namespace xul url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);

#ffshare-toolbar-button > label {
display: none;
}

#ffshare-toolbar-button > image {
#share-button {
list-style-image: url("resource://ffshare/chrome/skin/toolbar-button.png");
width: auto;
height: auto;
}
#ffshare-toolbar-button[firstRun] > image {
#share-button[firstRun] {
list-style-image: url("resource://ffshare/chrome/skin/toolbar-button-glow.png");
}

#ffshare-toolbar-button[status="start"] > image {
#share-button[status="start"] {
list-style-image: url("resource://ffshare/chrome/skin/status-sharing.png");
}

#ffshare-toolbar-button[status="finished"] > image {
#share-button[status="finished"] {
list-style-image: url("resource://ffshare/chrome/skin/status-shared.png");
}
12 changes: 4 additions & 8 deletions extensions/firefox-share/src/chrome/skin/windows/overlay.css
Expand Up @@ -21,24 +21,20 @@
* Contributor(s):
* */

#ffshare-toolbar-button > label {
display: none;
}

#ffshare-toolbar-button > image {
#share-button {
list-style-image: url("resource://ffshare/chrome/skin/windows/toolbar-button.png");
width: auto;
height: auto;
}
#ffshare-toolbar-button[firstRun] > image {
#share-button[firstRun] {
list-style-image: url("resource://ffshare/chrome/skin/windows/toolbar-button-glow.png");
}

#ffshare-toolbar-button[status="start"] > image {
#share-button[status="start"] {
list-style-image: url("resource://ffshare/chrome/skin/windows/status-sharing.png");
}

#ffshare-toolbar-button[status="finished"] > image {
#share-button[status="finished"] {
list-style-image: url("resource://ffshare/chrome/skin/windows/status-shared.png");
}

Expand Down
9 changes: 6 additions & 3 deletions extensions/firefox-share/src/modules/main.js
Expand Up @@ -44,7 +44,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://ffshare/modules/progress.js");

const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const buttonId = 'ffshare-toolbar-button';
const SHARE_BUTTON_ID = "share-button";

const EXPORTED_SYMBOLS = ["installFFShareIntoWindow"];

Expand Down Expand Up @@ -73,7 +73,7 @@ function error(msg) {
}

function sendJustInstalledEvent(win, url) {
var buttonNode = win.document.getElementById(buttonId);
var buttonNode = win.document.getElementById(SHARE_BUTTON_ID);
//Button may not be there if customized and removed from toolbar.
if (buttonNode) {
var tab = win.gBrowser.loadOneTab(url, { referrerURI: null,
Expand Down Expand Up @@ -125,7 +125,7 @@ function openAndReuseOneTabPerURL(url) {
// Focus *this* browser-window
browserWin.focus();

buttonNode = browserWin.document.getElementById(buttonId);
buttonNode = browserWin.document.getElementById(SHARE_BUTTON_ID);
//Button may not be there if customized and removed from toolbar.
if (buttonNode) {
buttonNode.setAttribute("firstRun", "true");
Expand Down Expand Up @@ -219,11 +219,14 @@ FFShare.prototype = {

canShareURI: function (aURI) {
var command = this.window.document.getElementById("cmd_toggleSharePage");
let button = this.window.document.getElementById(SHARE_BUTTON_ID);
try {
if (this.isValidURI(aURI)) {
command.removeAttribute("disabled");
button.hidden = false;
} else {
command.setAttribute("disabled", "true");
button.hidden = true;
}
} catch (e) {
throw e;
Expand Down
76 changes: 11 additions & 65 deletions extensions/firefox-share/src/modules/overlay.js
Expand Up @@ -44,7 +44,7 @@ Cu.import("resource://gre/modules/AddonManager.jsm");
Cu.import("resource://ffshare/modules/addonutils.js");

const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const buttonId = 'ffshare-toolbar-button';
const SHARE_BUTTON_ID = 'share-button';

const EXPORTED_SYMBOLS = ["installOverlay"];

Expand Down Expand Up @@ -194,71 +194,17 @@ function installOverlay(win) {


// ********************************************************************
// create the toolbar button, this gets fancy, should be easier



// We clone an existing button because creating a new one from scratch
// does not seem to work (perhaps some missing properties?)
let button = document.createElementNS(NS_XUL, 'toolbarbutton');

let toolbox = document.getElementById("navigator-toolbox");
// at startup, we must modify BrowserToolbarPalette, after load, we must
// use toolbox.palette
let palette = document.getElementById('BrowserToolbarPalette') || toolbox.palette;

// Setup label and tooltip
button.setAttribute("id", buttonId);
button.setAttribute("type", "checkbox");
button.setAttribute("label", getString("ffshareToolbarButton.label"));
button.setAttribute("tooltipText", getString("ffshareToolbarButton.tooltip"));
button.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional");
button.setAttribute("command", "cmd_toggleSharePage");

palette.appendChild(button);

// move to location specified in prefs
let toolbarId = Application.prefs.getValue("extensions." + FFSHARE_EXT_ID + ".toolbarid", "nav-bar");
let beforeId = Application.prefs.getValue("extensions." + FFSHARE_EXT_ID + ".toolbarbefore", "urlbar-container");
let toolbar = toolbarId && document.getElementById(toolbarId);
if (toolbar) {
let curSet = toolbar.currentSet.split(",");

if (curSet.indexOf(buttonId) === -1) {
//Insert our ID before the URL bar ID.
let pos = curSet.indexOf(beforeId) || curSet.length;
curSet.splice(pos, 0, buttonId);
let set = curSet.join(",");

toolbar.setAttribute("currentset", set);
toolbar.currentSet = set;
document.persist(toolbar.id, "currentset");
try {
BrowserToolboxCustomizeDone(true);
}
catch (e) {}
}

}

// we must redeclare our vars in the unload...
// create the urlbar button

let button = document.createElementNS(NS_XUL, "image");
button.id = SHARE_BUTTON_ID;
button.className = "urlbar-icon";
button.setAttribute("onclick", "ffshare.togglePanel();");
let urlbarIcons = document.getElementById("urlbar-icons");
urlbarIcons.insertBefore(button, urlbarIcons.firstChild);
unloaders.push(function() {
let toolbox = document.getElementById("navigator-toolbox");
let toolbarId = Application.prefs.getValue("extensions." + FFSHARE_EXT_ID + ".toolbarid", "nav-bar");
let toolbar = toolbarId && document.getElementById(toolbarId);

let curSet = toolbar.currentSet.split(",");
let pos = curSet.indexOf(buttonId);
if (pos !== -1) {
curSet.splice(pos, 1);
let set = curSet.join(",");

toolbar.setAttribute("currentset", set);
toolbar.currentSet = set;
document.persist(toolbar.id, "currentset");
}
let palette = document.getElementById('BrowserToolbarPalette') || toolbox.palette;
palette.removeChild(button);
urlbarIcons.removeChild(button);
});

return unloaders;
}
2 changes: 1 addition & 1 deletion extensions/firefox-share/src/modules/panel.js
Expand Up @@ -81,7 +81,7 @@ function sharePanel(window, ffshare) {
this.document = window.document;
this.ffshare = ffshare;

this.button = this.document.getElementById('ffshare-toolbar-button');
this.button = this.document.getElementById('share-button');
this.browser = this.document.getElementById('share-browser');
this.panel = this.document.getElementById('share-popup');

Expand Down

0 comments on commit 3314146

Please sign in to comment.