- 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/ 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/overlay.xul
overlay chrome://browser/content/browser.xul chrome://zotero/content/itemPane.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"/> <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> </hbox>
<statusbar id="status-bar">
<statusbarpanel id="zotero-status-bar-icon" hidden="true"
class="statusbarpanel-iconic" onclick="ZoteroPane.toggleDisplay();"/>
</statusbar>
<script> <script>
<![CDATA[ <![CDATA[
window.addEventListener('load', function(e){ window.addEventListener('load', function(e){
var icon = document.getElementById('zotero-status-bar-icon'); var iconPref = Components.classes["@mozilla.org/preferences-service;1"]
if(icon) { .getService(Components.interfaces.nsIPrefService)
if (Zotero && Zotero.initialized){ .getBranch('extensions.zotero.').getIntPref('statusBarIcon');
switch (Zotero.Prefs.get('statusBarIcon')) { var isFx36 = Components.classes["@mozilla.org/xre/app-info;1"]
case 2: .getService(Components.interfaces.nsIXULAppInfo)
icon.setAttribute('hidden', false); .platformVersion.indexOf('1.9') === 0;
break;
case 1: // Status bar in Fx3.6
icon.setAttribute('hidden', false); if (isFx36) {
icon.setAttribute('compact', true); var icon = document.getElementById('zotero-status-bar-icon');
break; }
// 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; if (!icon) {
} return;
}
// Use defaults if necessary
if (!errMsg) { if (Zotero && Zotero.initialized){
// Get the stringbundle manually switch (iconPref) {
var src = 'chrome://zotero/locale/zotero.properties'; case 2:
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); icon.setAttribute('hidden', false);
} break;
case 1:
icon.setAttribute('hidden', false);
icon.setAttribute('compact', true);
break;
} }
// Used for loading pages from upgrade wizard // Set "Report Errors..." label via property rather than DTD entity,
if (Zotero.initialURL) { // since we need to reference it in script elsewhere
setTimeout("gBrowser.selectedTab = gBrowser.addTab(Zotero.initialURL); Zotero.initialURL = null;", 1); 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); }, 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; 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); 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; width: 20px;
margin: 0 0 -1px;
padding: 0 0 1px;
list-style-image: url(chrome://zotero/skin/zotero_status_bar_compact.png); 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); list-style-image: url(chrome://zotero/skin/zotero_status_bar_error.png);
} }