Switch to regular add-on bar button
Can be moved/removed via Customize as well as via Zotero prefs. The icon can be in the toolbar or in the add-on bar, but not both, because it's now the same button with different styling depending on where it is. If the icon does not exist in the UI and the pref is set to show (as it is by default), the icon is added to the add-on bar and the add-on bar is persisted open. This has the effect of showing the icon/bar on first run. If the icon is removed or the bar is hidden, they remain that way.
This commit is contained in:
parent
fe29fb7985
commit
4ef7c94374
8 changed files with 161 additions and 92 deletions
|
@ -36,6 +36,8 @@ var ZoteroOverlay = new function()
|
|||
this.isTab = false;
|
||||
|
||||
this.onLoad = function() {
|
||||
try {
|
||||
|
||||
zoteroPane = document.getElementById('zotero-pane-stack');
|
||||
zoteroSplitter = document.getElementById('zotero-splitter');
|
||||
|
||||
|
@ -74,43 +76,45 @@ var ZoteroOverlay = new function()
|
|||
}
|
||||
|
||||
// Make Zotero icon visible, if requested
|
||||
var iconPref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService)
|
||||
.getBranch('extensions.zotero.').getIntPref('statusBarIcon');
|
||||
.getBranch('extensions.zotero.');
|
||||
|
||||
var fx36Icon = document.getElementById('zotero-status-bar-icon');
|
||||
var addonBar = document.getElementById('addon-bar');
|
||||
|
||||
// Status bar in Fx3.6
|
||||
if (isFx36) {
|
||||
var icon = fx36Icon;
|
||||
}
|
||||
// In >=Fx4, add to add-on bar
|
||||
else {
|
||||
// add Zotero icon
|
||||
var icon = document.createElement('toolbarbutton');
|
||||
icon.id = 'zotero-addon-bar-icon';
|
||||
icon.setAttribute('oncommand', 'ZoteroOverlay.toggleDisplay()');
|
||||
icon.setAttribute('hidden', true);
|
||||
addonBar.appendChild(icon);
|
||||
if (addonBar.collapsed) {
|
||||
// If no Zotero or icon isn't set to hidden, show add-on bar
|
||||
if (iconPref != 0) {
|
||||
setToolbarVisibility(addonBar, true);
|
||||
}
|
||||
}
|
||||
var iconPref = prefBranch.getIntPref('statusBarIcon');
|
||||
|
||||
// If this is the first run, add icon to add-on bar if not
|
||||
// in the window already and not hidden by the Zotero prefs
|
||||
if (!document.getElementById("zotero-toolbar-button") && iconPref != 0) {
|
||||
addonBar.insertItem("zotero-toolbar-button");
|
||||
addonBar.setAttribute("currentset", addonBar.currentSet);
|
||||
document.persist(addonBar.id, "currentset");
|
||||
addonBar.setAttribute("collapsed", false);
|
||||
document.persist(addonBar.id, "collapsed");
|
||||
}
|
||||
|
||||
var icon = document.getElementById('zotero-toolbar-button');
|
||||
|
||||
// Add a listener for toolbar change events
|
||||
window.addEventListener("customizationchange", onToolbarChange, false);
|
||||
|
||||
if (Zotero && Zotero.initialized){
|
||||
document.getElementById('appcontent').addEventListener('mousemove', Zotero.ProgressWindowSet.updateTimers, false);
|
||||
switch (iconPref) {
|
||||
case 2:
|
||||
icon.setAttribute('hidden', false);
|
||||
break;
|
||||
case 1:
|
||||
icon.setAttribute('hidden', false);
|
||||
if (icon) {
|
||||
if (iconPref == 1) {
|
||||
icon.setAttribute('compact', true);
|
||||
break;
|
||||
}
|
||||
// If hidden in prefs, remove from add-on bar
|
||||
else if (iconPref == 0) {
|
||||
var toolbar = icon.parentNode;
|
||||
if (toolbar.id == 'addon-bar') {
|
||||
var palette = doc.getElementById("navigator-toolbox").palette;
|
||||
palette.appendChild(icon);
|
||||
toolbar.setAttribute("currentset", toolbar.currentSet);
|
||||
document.persist(toolbar.id, "currentset");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -134,7 +138,6 @@ var ZoteroOverlay = new function()
|
|||
|
||||
icon.setAttribute('tooltiptext', errMsg);
|
||||
icon.setAttribute('error', 'true');
|
||||
icon.setAttribute('hidden', false);
|
||||
}
|
||||
|
||||
// Used for loading pages from upgrade wizard
|
||||
|
@ -162,9 +165,39 @@ var ZoteroOverlay = new function()
|
|||
ZoteroOverlay.toggleDisplay(_stateBeforeReload);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onToolbarChange(e) {
|
||||
// e.target seems to be navigator-toolbox in all cases,
|
||||
// so check the addon-bar directly
|
||||
var addonBar = document.getElementById("addon-bar");
|
||||
var icon = document.getElementById("zotero-toolbar-button");
|
||||
if (icon) {
|
||||
// If dragged to add-on bar
|
||||
if (addonBar.getElementsByAttribute("id", "zotero-toolbar-button").length) {
|
||||
var statusBarPref = Zotero.Prefs.get("statusBarIcon");
|
||||
// If pref set to hide, force to full
|
||||
if (statusBarPref == 0) {
|
||||
Zotero.Prefs.set("statusBarIcon", 2)
|
||||
}
|
||||
else if (statusBarPref == 1) {
|
||||
icon.setAttribute("compact", true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
Zotero.Prefs.set("statusBarIcon", 0);
|
||||
}
|
||||
|
||||
|
||||
this.onUnload = function() {
|
||||
window.removeEventListener("customizationchange", onToolbarChange, false);
|
||||
ZoteroPane.destroy();
|
||||
}
|
||||
|
||||
|
|
|
@ -1853,19 +1853,17 @@ function updateWordProcessorInstructions() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets "Status bar icon" to "None" if Zotero is set to load in separate tab on Fx 4
|
||||
* Sets "Status bar icon" to "None" if Zotero is set to load in separate tab
|
||||
*/
|
||||
function handleShowInPreferenceChange() {
|
||||
var showInSeparateTab = document.getElementById("zotero-prefpane-general-showIn-separateTab");
|
||||
var showInAppTab = document.getElementById("zotero-prefpane-general-showIn-appTab");
|
||||
if(Zotero.isFx4) {
|
||||
if(showInAppTab.selected) {
|
||||
document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-none');
|
||||
Zotero.Prefs.set("statusBarIcon", 0);
|
||||
} else if(Zotero.isFx4) {
|
||||
document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-full');
|
||||
Zotero.Prefs.set("statusBarIcon", 2);
|
||||
}
|
||||
if(showInAppTab.selected) {
|
||||
document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-none');
|
||||
Zotero.Prefs.set("statusBarIcon", 0);
|
||||
} else {
|
||||
document.getElementById('statusBarIcon').selectedItem = document.getElementById('statusBarIcon-full');
|
||||
Zotero.Prefs.set("statusBarIcon", 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<overlay id="zotero-status-bar"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<statusbar id="status-bar">
|
||||
<statusbarpanel id="zotero-status-bar-icon" hidden="true"
|
||||
class="statusbarpanel-iconic" onclick="ZoteroOverlay.toggleDisplay();"/>
|
||||
</statusbar>
|
||||
</overlay>
|
|
@ -2033,9 +2033,74 @@ Zotero.Prefs = new function(){
|
|||
if(topic!="nsPref:changed"){
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// subject is the nsIPrefBranch we're observing (after appropriate QI)
|
||||
// data is the name of the pref that's been changed (relative to subject)
|
||||
switch (data){
|
||||
switch (data) {
|
||||
case "statusBarIcon":
|
||||
var doc = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator)
|
||||
.getMostRecentWindow("navigator:browser").document;
|
||||
|
||||
var addonBar = doc.getElementById("addon-bar");
|
||||
var icon = doc.getElementById("zotero-toolbar-button");
|
||||
// When the customize window is open, toolbar buttons seem to
|
||||
// become wrapped in toolbarpaletteitems, which we need to remove
|
||||
// manually if we change the pref to hidden or else the customize
|
||||
// window doesn't close.
|
||||
var wrapper = doc.getElementById("wrapper-zotero-toolbar-button");
|
||||
var palette = doc.getElementById("navigator-toolbox").palette;
|
||||
var inAddonBar = false;
|
||||
if (icon) {
|
||||
// Because of the potential wrapper, don't just use .parentNode
|
||||
var toolbar = Zotero.getAncestorByTagName(icon, "toolbar");
|
||||
inAddonBar = toolbar == addonBar;
|
||||
}
|
||||
var val = this.get("statusBarIcon");
|
||||
if (val == 0) {
|
||||
// If showing in add-on bar, hide
|
||||
if (!icon || !inAddonBar) {
|
||||
return;
|
||||
}
|
||||
palette.appendChild(icon);
|
||||
if (wrapper) {
|
||||
addonBar.removeChild(wrapper);
|
||||
}
|
||||
addonBar.setAttribute("currentset", addonBar.currentSet);
|
||||
doc.persist(addonBar.id, "currentset");
|
||||
}
|
||||
else {
|
||||
// If showing somewhere else, remove it from there
|
||||
if (icon && !inAddonBar) {
|
||||
palette.appendChild(icon);
|
||||
if (wrapper) {
|
||||
toolbar.removeChild(wrapper);
|
||||
}
|
||||
toolbar.setAttribute("currentset", toolbar.currentSet);
|
||||
doc.persist(toolbar.id, "currentset");
|
||||
}
|
||||
|
||||
// If not showing in add-on bar, add
|
||||
if (!inAddonBar) {
|
||||
var icon = addonBar.insertItem("zotero-toolbar-button");
|
||||
addonBar.setAttribute("currentset", addonBar.currentSet);
|
||||
doc.persist(addonBar.id, "currentset");
|
||||
addonBar.setAttribute("collapsed", false);
|
||||
doc.persist(addonBar.id, "collapsed");
|
||||
}
|
||||
// And make small
|
||||
if (val == 1) {
|
||||
icon.setAttribute("compact", true);
|
||||
}
|
||||
// Or large
|
||||
else if (val == 2) {
|
||||
icon.removeAttribute("compact");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "automaticScraperUpdates":
|
||||
if (this.get('automaticScraperUpdates')){
|
||||
Zotero.Schema.updateFromRepository();
|
||||
|
@ -2081,6 +2146,12 @@ Zotero.Prefs = new function(){
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
Zotero.debug(e);
|
||||
throw (e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,32 +3,6 @@
|
|||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
#zotero-status-bar-icon, #zotero-addon-bar-icon
|
||||
{
|
||||
width: 55px;
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar.png);
|
||||
}
|
||||
#zotero-status-bar-icon
|
||||
{
|
||||
margin: 0 0 -1px; /* For Fitts's law (on OS X, at least) */
|
||||
padding: 0 0 1px;
|
||||
}
|
||||
#zotero-addon-bar-icon
|
||||
{
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
padding: 0 0 1px 0;
|
||||
-moz-appearance: none;
|
||||
}
|
||||
#zotero-status-bar-icon[compact="true"], #zotero-addon-bar-icon[compact="true"]
|
||||
{
|
||||
width: 20px;
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar_compact.png);
|
||||
}
|
||||
#zotero-status-bar-icon[error="true"], #zotero-addon-bar-icon[error="true"]
|
||||
{
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar_error.png);
|
||||
}
|
||||
|
||||
#zotero-pane
|
||||
{
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1,011 B |
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB |
|
@ -21,34 +21,36 @@
|
|||
padding:0;
|
||||
}
|
||||
|
||||
#zotero-toolbar-button
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-24px.png');
|
||||
/*
|
||||
Add-on bar and toolbar icon
|
||||
*/
|
||||
#zotero-toolbar-button {
|
||||
list-style-image: url(chrome://zotero/skin/zotero-z-24px.png);
|
||||
}
|
||||
|
||||
#zotero-toolbar-button:hover
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-24px-hover.png');
|
||||
#zotero-toolbar-button:active {
|
||||
list-style-image: url(chrome://zotero/skin/zotero-z-24px-active.png);
|
||||
}
|
||||
|
||||
#zotero-toolbar-button:active
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-24px-active.png');
|
||||
toolbar[iconsize="small"] #zotero-toolbar-button {
|
||||
list-style-image: url(chrome://zotero/skin/zotero-z-16px.png);
|
||||
}
|
||||
|
||||
toolbar[iconsize="small"] #zotero-toolbar-button
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-16px.png');
|
||||
toolbar[iconsize="small"] #zotero-toolbar-button:active {
|
||||
list-style-image: url(chrome://zotero/skin/zotero-z-16px-active.png);
|
||||
}
|
||||
|
||||
toolbar[iconsize="small"] #zotero-toolbar-button:hover
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-16px-hover.png');
|
||||
#addon-bar #zotero-toolbar-button {
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar.png);
|
||||
}
|
||||
|
||||
toolbar[iconsize="small"] #zotero-toolbar-button:active
|
||||
{
|
||||
list-style-image: url('chrome://zotero/skin/zotero-z-16px-active.png');
|
||||
#addon-bar #zotero-toolbar-button[compact="true"] {
|
||||
width: 20px;
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar_compact.png);
|
||||
}
|
||||
|
||||
#addon-bar #zotero-toolbar-button[error="true"] {
|
||||
list-style-image: url(chrome://zotero/skin/zotero_status_bar_error.png);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue