- Add the Zotero icon to the add-on bar instead of the status bar in Fx4

- Make the add-on bar visible if the Zotero icon isn't set to hidden, which is an annoying way of dealing with https://bugzilla.mozilla.org/show_bug.cgi?id=616419 not yet landing -- people who use an upper toolbar button and don't want the add-on bar to show will need to set the Zotero icon to hidden

Addresses #1726, Firefox 4 Compatibility
This commit is contained in:
Dan Stillman 2011-01-07 06:36:31 +00:00
parent 5ceb3f4cf7
commit 78a92255d8
4 changed files with 94 additions and 54 deletions

View file

@ -44,6 +44,7 @@ locale zotero zh-TW chrome/locale/zh-TW/zotero/
skin zotero default chrome/skin/default/zotero/
overlay chrome://browser/content/browser.xul chrome://zotero/content/statusBarOverlay.xul appversion<4.0
overlay chrome://browser/content/browser.xul chrome://zotero/content/overlay.xul
overlay chrome://browser/content/browser.xul chrome://zotero/content/itemPane.xul

View file

@ -467,62 +467,85 @@
<image src="chrome://zotero/skin/treeitem-book.png" id="zotero-status-image" onclick="Zotero_Browser.scrapeThisPage(ZoteroPane.getSelectedLibraryID(), ZoteroPane.getSelectedCollection(true))" position="1" hidden="true"/>
</hbox>
<statusbar id="status-bar">
<statusbarpanel id="zotero-status-bar-icon" hidden="true"
class="statusbarpanel-iconic" onclick="ZoteroPane.toggleDisplay();"/>
</statusbar>
<script>
<![CDATA[
window.addEventListener('load', function(e){
var icon = document.getElementById('zotero-status-bar-icon');
if(icon) {
if (Zotero && Zotero.initialized){
switch (Zotero.Prefs.get('statusBarIcon')) {
case 2:
icon.setAttribute('hidden', false);
break;
case 1:
icon.setAttribute('hidden', false);
icon.setAttribute('compact', true);
break;
var iconPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch('extensions.zotero.').getIntPref('statusBarIcon');
var isFx36 = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo)
.platformVersion.indexOf('1.9') === 0;
// Status bar in Fx3.6
if (isFx36) {
var icon = document.getElementById('zotero-status-bar-icon');
}
// In >=Fx4, add to add-on bar
else {
var icon = document.createElement('toolbarbutton');
icon.id = 'zotero-addon-bar-icon';
icon.setAttribute('oncommand', 'ZoteroPane.toggleDisplay()');
icon.setAttribute('hidden', true);
var addonBar = document.getElementById('addon-bar');
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);
}
// Set "Report Errors..." label via property rather than DTD entity,
// since we need to reference it in script elsewhere
document.getElementById('zotero-tb-actions-reportErrors').setAttribute('label',
Zotero.getString('errorReport.reportErrors'));
}
else {
if (Zotero) {
var errMsg = Zotero.startupError;
}
// Use defaults if necessary
if (!errMsg) {
// Get the stringbundle manually
var src = 'chrome://zotero/locale/zotero.properties';
var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
getService(Components.interfaces.nsILocaleService);
var appLocale = localeService.getApplicationLocale();
var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var stringBundle = stringBundleService.createBundle(src, appLocale);
var errMsg = stringBundle.GetStringFromName('startupError');
}
if(icon) {
icon.setAttribute('tooltiptext', errMsg);
icon.setAttribute('error', 'true');
}
if (!icon) {
return;
}
if (Zotero && Zotero.initialized){
switch (iconPref) {
case 2:
icon.setAttribute('hidden', false);
}
break;
case 1:
icon.setAttribute('hidden', false);
icon.setAttribute('compact', true);
break;
}
// Used for loading pages from upgrade wizard
if (Zotero.initialURL) {
setTimeout("gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL); Zotero.initialURL = null;", 1);
// Set "Report Errors..." label via property rather than DTD entity,
// since we need to reference it in script elsewhere
document.getElementById('zotero-tb-actions-reportErrors').setAttribute('label',
Zotero.getString('errorReport.reportErrors'));
}
else {
if (Zotero) {
var errMsg = Zotero.startupError;
}
// Use defaults if necessary
if (!errMsg) {
// Get the stringbundle manually
var src = 'chrome://zotero/locale/zotero.properties';
var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
getService(Components.interfaces.nsILocaleService);
var appLocale = localeService.getApplicationLocale();
var stringBundleService = Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
var stringBundle = stringBundleService.createBundle(src, appLocale);
var errMsg = stringBundle.GetStringFromName('startupError');
}
if(icon) {
icon.setAttribute('tooltiptext', errMsg);
icon.setAttribute('error', 'true');
icon.setAttribute('hidden', false);
}
}
// Used for loading pages from upgrade wizard
if (Zotero.initialURL) {
setTimeout("gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL); Zotero.initialURL = null;", 1);
}
}, false);

View file

@ -0,0 +1,9 @@
<?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="ZoteroPane.toggleDisplay();"/>
</statusbar>
</overlay>

View file

@ -1,18 +1,25 @@
#zotero-status-bar-icon
#zotero-status-bar-icon, #zotero-addon-bar-icon
{
width: 55px;
margin: 0 0 -1px; /* For Fitts's law (on OS X, at least) */
padding: 0 0 1px;
list-style-image: url(chrome://zotero/skin/zotero_status_bar.png);
}
#zotero-status-bar-icon[compact="true"]
#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-bottom: 4px;
}
#zotero-status-bar-icon[compact="true"], #zotero-addon-bar-icon[compact="true"]
{
width: 20px;
margin: 0 0 -1px;
padding: 0 0 1px;
list-style-image: url(chrome://zotero/skin/zotero_status_bar_compact.png);
}
#zotero-status-bar-icon[error="true"]
#zotero-status-bar-icon[error="true"], #zotero-addon-bar-icon[error="true"]
{
list-style-image: url(chrome://zotero/skin/zotero_status_bar_error.png);
}