Add tooltip ("Save to Zotero") to the scrape icon, with the translator used in parentheses (e.g. "Save to Zotero (Library Catalog (Voyager))" to help with user debugging

Also added a few things to help with right-to-left languages:

- chromedir attribute on zotero-pane
- Zotero.dir property containing 'ltr' or 'rtl'
- Zotero.localeJoin(arr, separator=' ') to join an array into a string in the proper locale order
This commit is contained in:
Dan Stillman 2007-09-17 20:33:23 +00:00
parent 4a4577ff5a
commit f749e5272c
4 changed files with 53 additions and 2 deletions

View File

@ -420,6 +420,7 @@ var Zotero_Browser = new function() {
var captureIcon = tab.getCaptureIcon();
if(captureIcon) {
Zotero_Browser.statusImage.src = captureIcon;
Zotero_Browser.statusImage.tooltipText = tab.getCaptureTooltip();
Zotero_Browser.statusImage.hidden = false;
} else {
Zotero_Browser.statusImage.hidden = true;
@ -664,6 +665,19 @@ Zotero_Browser.Tab.prototype.getCaptureIcon = function() {
return false;
}
Zotero_Browser.Tab.prototype.getCaptureTooltip = function() {
if (this.page.translators && this.page.translators.length) {
var arr = [Zotero.getString('ingester.saveToZotero')];
if (this.page.translators[0].itemType == 'multiple') {
arr.push('...');
}
arr.push (' ' , '(' + this.page.translators[0].label + ')');
return Zotero.localeJoin(arr, '');
}
return '';
}
/**********CALLBACKS**********/
/*

View File

@ -21,7 +21,13 @@
***** END LICENSE BLOCK *****
-->
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<!DOCTYPE window [
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd">
%zoteroDTD;
]>
<overlay id="zotero"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@ -73,7 +79,8 @@
onmouseup="ZoteroPane.updateTagSelectorSize()"/>
<hbox id="zotero-pane" persist="savedHeight" hidden="true"
onkeydown="ZoteroPane.handleKeyDown(event, this.id)"
onkeyup="ZoteroPane.handleKeyUp(event, this.id)">
onkeyup="ZoteroPane.handleKeyUp(event, this.id)"
chromedir="&locale.dir;">
<popupset>
<popup id="zotero-collectionmenu" onpopupshowing="ZoteroPane.buildCollectionContextMenu();">
<menuitem label="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane.newCollection()"/>

View File

@ -48,6 +48,7 @@ var Zotero = new function(){
this.varDump = varDump;
this.safeDebug = safeDebug;
this.getString = getString;
this.localeJoin = localeJoin;
this.getLocaleCollation = getLocaleCollation;
this.setFontSize = setFontSize;
this.flattenArguments = flattenArguments;
@ -69,6 +70,7 @@ var Zotero = new function(){
this.version;
this.platform;
this.locale;
this.dir; // locale direction: 'ltr' or 'rtl'
this.isMac;
this.isWin;
this.initialURL; // used by Schema to show the changelog on upgrades
@ -143,8 +145,17 @@ var Zotero = new function(){
var stringBundleService =
Components.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService);
_localizedStringBundle = stringBundleService.createBundle(src, appLocale);
// Set the locale direction to Zotero.dir
// DEBUG: is there a better way to get the entity from JS?
var xmlhttp = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance();
xmlhttp.open('GET', 'chrome://global/locale/global.dtd', false);
xmlhttp.send(null);
this.dir = xmlhttp.responseText.match(/(ltr|rtl)/)[0];
try {
this.getZoteroDirectory();
}
@ -589,6 +600,24 @@ var Zotero = new function(){
}
/*
* Join the elements of an array into a string using the appropriate
* locale direction
*
* |separator| defaults to a space (not a comma like Array.join()) if
* not specified
*/
function localeJoin(arr, separator) {
if (typeof separator == 'undefined') {
separator = ' ';
}
if (this.dir == 'rtl') {
str.reverse();
}
return arr.join(separator);
}
function getLocaleCollation() {
var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"]
.getService(Components.interfaces.nsILocaleService);

View File

@ -316,6 +316,7 @@ fileTypes.document = Document
save.attachment = Saving Snapshot...
save.link = Saving Link...
ingester.saveToZotero = Save to Zotero
ingester.scraping = Saving Item...
ingester.scrapeComplete = Item Saved
ingester.scrapeError = Could Not Save Item