- Only call Zotero.wait() in translate.js if it is defined

- Don't try to use Zotero.getString() in strToDate if it is not defined
- Add getBaseIDFromTypeAndField to connector/cachedTypes.js and fix getItemTypeFields
This commit is contained in:
Simon Kornblith 2011-07-08 04:20:05 +00:00
parent ed3bc7d1f7
commit 5cf6a1cff3
3 changed files with 17 additions and 9 deletions

View file

@ -140,7 +140,17 @@ Zotero.ItemFields = new function() {
return false;
};
this.getItemTypeFields = function(idOrName) {
this.getBaseIDFromTypeAndField = function(itemType, fieldIdOrName) {
if(!Zotero.Connector_Types["fields"][fieldIdOrName]
|| !Zotero.Connector_Types["itemTypes"][itemType]) throw new Error("Invalid field or type ID");
fieldIdOrName = Zotero.Connector_Types["fields"][fieldIdOrName].id;
var baseField = Zotero.Connector_Types["itemTypes"][itemType]["baseFields"][fieldIdOrName];
return baseField ? baseField : false;
};
this.getItemTypeFields = function(typeIdOrName) {
return Zotero.Connector_Types["itemTypes"][typeIdOrName].fields.slice();
};
}

View file

@ -234,13 +234,13 @@ Zotero.Date = new function(){
function strToDate(string) {
// Parse 'yesterday'/'today'/'tomorrow'
var lc = (string + '').toLowerCase();
if (lc == 'yesterday' || lc == Zotero.getString('date.yesterday')) {
if (lc == 'yesterday' || (Zotero.getString && lc === Zotero.getString('date.yesterday'))) {
string = Zotero.Date.dateToSQL(new Date(new Date().getTime() - 86400000)).substr(0, 10);
}
else if (lc == 'today' || lc == Zotero.getString('date.today')) {
else if (lc == 'today' || (Zotero.getString && lc == Zotero.getString('date.today'))) {
string = Zotero.Date.dateToSQL(new Date()).substr(0, 10);
}
else if (lc == 'tomorrow' || lc == Zotero.getString('date.tomorrow')) {
else if (lc == 'tomorrow' || (Zotero.getString && lc == Zotero.getString('date.tomorrow'))) {
string = Zotero.Date.dateToSQL(new Date(new Date().getTime() + 86400000)).substr(0, 10);
}
@ -367,7 +367,7 @@ Zotero.Date = new function(){
if(!date.day) {
// compile day regular expression
if(!_dayRe) {
var daySuffixes = Zotero.getString("date.daySuffixes").replace(/, ?/g, "|");
var daySuffixes = Zotero.getString ? Zotero.getString("date.daySuffixes").replace(/, ?/g, "|") : "";
_dayRe = new RegExp("\\b([0-9]{1,2})(?:"+daySuffixes+")?\\b(.*)", "i");
}

View file

@ -137,7 +137,7 @@ Zotero.Translate.Sandbox = {
});
// Allow progress meter to update
if(!translate.noWait) Zotero.wait();
if(!translate.noWait && Zotero.wait) Zotero.wait();
translate._runHandler("itemSaving", item);
// pass both the saved item and the original JS array item
@ -590,9 +590,7 @@ Zotero.Translate.Sandbox = {
translate._runHandler("itemDone", item);
// Update progress bar
if(!translate.noWait) {
Zotero.wait();
}
if(!translate.noWait && Zotero.wait) Zotero.wait();
return item;
},