- eliminate for each in future cross-browser code
- move itemTypeExists, getCreatorsForType, and getLocalizedCreatorType back under ZU - modify OpenURL code to use ZU.itemTypeExists
This commit is contained in:
parent
e61dd60024
commit
e0e84bc22a
4 changed files with 94 additions and 74 deletions
|
@ -174,13 +174,24 @@
|
||||||
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-selected-down.png") 0 4 0 5 repeat stretch;
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-selected-down.png") 0 4 0 5 repeat stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:not([active]) #zotero-view-tabbox > tabs > * {
|
#zotero-view-tabbox:-moz-window-inactive > tabs > * {
|
||||||
color: #7C7C7C !important; /* remove this when we support click-through */
|
color: #7C7C7C !important;
|
||||||
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-inactive.png") 0 4 0 5 repeat stretch;
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-inactive.png") 0 4 0 5 repeat stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:not([active]) #zotero-view-tabbox > tabs > tab[selected=true] {
|
#zotero-view-tabbox:-moz-window-inactive > tabs > tab[selected=true] {
|
||||||
color: #C5C5C5 !important; /* remove this when we support click-through */
|
color: #C5C5C5 !important;
|
||||||
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-selected-inactive.png") 0 4 0 5 repeat stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Since Fx4 doesn't recognize the -moz-window-inactive pseudoclass as valid, these have to be separate (duplicate) rules to be parsed */
|
||||||
|
:root:not([active]) #zotero-pane:not([isFx4]) > #zotero-item-pane > #zotero-item-pane-content > #zotero-view-tabbox > tabs > * {
|
||||||
|
color: #7C7C7C !important;
|
||||||
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-inactive.png") 0 4 0 5 repeat stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
:root:not([active]) #zotero-pane:not([isFx4]) > #zotero-item-pane > #zotero-item-pane-content > #zotero-view-tabbox > tabs > tab[selected=true] {
|
||||||
|
color: #C5C5C5 !important;
|
||||||
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-selected-inactive.png") 0 4 0 5 repeat stretch;
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-middle-selected-inactive.png") 0 4 0 5 repeat stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +231,15 @@
|
||||||
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-left-inactive.png") 0 4 0 6 repeat stretch;
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-left-inactive.png") 0 4 0 6 repeat stretch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Since Fx4 doesn't recognize the -moz-window-inactive pseudoclass as valid, these have to be separate (duplicate) rules to be parsed */
|
||||||
|
|
||||||
|
:root:not([active]) #zotero-view-tabbox > tabs > :first-child,
|
||||||
|
:root:not([active]) #zotero-view-tabbox > tabs > [first-visible],
|
||||||
|
:root:not([active]) #zotero-view-tabbox > tabs[chromedir=rtl] > :last-child,
|
||||||
|
:root:not([active]) #zotero-view-tabbox > tabs[chromedir=rtl] > [last-visible] {
|
||||||
|
-moz-border-image: url("chrome://zotero/skin/mac/viewbutton-left-inactive.png") 0 4 0 6 repeat stretch;
|
||||||
|
}
|
||||||
|
|
||||||
:root:not([active]) #zotero-view-tabbox > tabs > tab:first-child[selected=true],
|
:root:not([active]) #zotero-view-tabbox > tabs > tab:first-child[selected=true],
|
||||||
:root:not([active]) #zotero-view-tabbox > tabs > tab[first-visible][selected=true],
|
:root:not([active]) #zotero-view-tabbox > tabs > tab[first-visible][selected=true],
|
||||||
:root:not([active]) #zotero-view-tabbox > tabs[chromedir=rtl] > tab:last-child[selected=true],
|
:root:not([active]) #zotero-view-tabbox > tabs[chromedir=rtl] > tab:last-child[selected=true],
|
||||||
|
|
|
@ -109,15 +109,15 @@ Zotero.OpenURL = new function() {
|
||||||
if(version == "0.1") {
|
if(version == "0.1") {
|
||||||
var co = "sid=Zotero:"+encodeURIComponent(Zotero.version);
|
var co = "sid=Zotero:"+encodeURIComponent(Zotero.version);
|
||||||
|
|
||||||
for each(identifier in identifiers) {
|
for(var i=0; i<identifiers.length; i++) {
|
||||||
co += "&id="+encodeURIComponent(identifier);
|
co += "&id="+encodeURIComponent(identifiers[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var co = "url_ver=Z39.88-2004&ctx_ver=Z39.88-2004"+
|
var co = "url_ver=Z39.88-2004&ctx_ver=Z39.88-2004"+
|
||||||
"&rfr_id="+encodeURIComponent("info:sid/zotero.org:"+Zotero.version);
|
"&rfr_id="+encodeURIComponent("info:sid/zotero.org:"+Zotero.version);
|
||||||
|
|
||||||
for each(identifier in identifiers) {
|
for(var i=0; i<identifiers.length; i++) {
|
||||||
co += "&rft_id="+encodeURIComponent(identifier)
|
co += "&rft_id="+encodeURIComponent(identifiers[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,8 +189,8 @@ Zotero.OpenURL = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// encode subsequent creators as au
|
// encode subsequent creators as au
|
||||||
for each(creator in item.creators) {
|
for(var i=0; i<identifiers.length; i++) {
|
||||||
co += _mapTag((creator.firstName ? creator.firstName+" " : "")+creator.lastName, (item.itemType == "patent" ? "inventor" : "au"), version);
|
co += _mapTag((creators[i].firstName ? creators[i].firstName+" " : "")+creators[i].lastName, (item.itemType == "patent" ? "inventor" : "au"), version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,9 +219,9 @@ Zotero.OpenURL = new function() {
|
||||||
var coParts = co.split("&");
|
var coParts = co.split("&");
|
||||||
|
|
||||||
// get type
|
// get type
|
||||||
for each(var part in coParts) {
|
for(var i=0; i<coParts.length; i++) {
|
||||||
if(part.substr(0, 12) == "rft_val_fmt=") {
|
if(coParts[i].substr(0, 12) == "rft_val_fmt=") {
|
||||||
var format = decodeURIComponent(part.substr(12));
|
var format = decodeURIComponent(coParts[i].substr(12));
|
||||||
if(format == "info:ofi/fmt:kev:mtx:journal") {
|
if(format == "info:ofi/fmt:kev:mtx:journal") {
|
||||||
item.itemType = "journalArticle";
|
item.itemType = "journalArticle";
|
||||||
break;
|
break;
|
||||||
|
@ -257,8 +257,8 @@ Zotero.OpenURL = new function() {
|
||||||
// keep track of "aucorp," "aufirst," "aulast"
|
// keep track of "aucorp," "aufirst," "aulast"
|
||||||
var complexAu = new Array();
|
var complexAu = new Array();
|
||||||
|
|
||||||
for each(var part in coParts) {
|
for(var i=0; i<coParts.length; i++) {
|
||||||
var keyVal = part.split("=");
|
var keyVal = coParts[i].split("=");
|
||||||
var key = keyVal[0];
|
var key = keyVal[0];
|
||||||
var value = decodeURIComponent(keyVal[1].replace(/\+|%2[bB]/g, " "));
|
var value = decodeURIComponent(keyVal[1].replace(/\+|%2[bB]/g, " "));
|
||||||
if(!value) {
|
if(!value) {
|
||||||
|
@ -411,7 +411,7 @@ Zotero.OpenURL = new function() {
|
||||||
} else if(key == "rft.subject") {
|
} else if(key == "rft.subject") {
|
||||||
item.tags.push(value);
|
item.tags.push(value);
|
||||||
} else if(key == "rft.type") {
|
} else if(key == "rft.type") {
|
||||||
if(Zotero.ItemTypes.getID(value)) item.itemType = value;
|
if(Zotero.Utilities.itemTypeExists(value)) item.itemType = value;
|
||||||
} else if(key == "rft.source") {
|
} else if(key == "rft.source") {
|
||||||
item.publicationTitle = value;
|
item.publicationTitle = value;
|
||||||
}
|
}
|
||||||
|
@ -419,16 +419,16 @@ Zotero.OpenURL = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// combine two lists of authors, eliminating duplicates
|
// combine two lists of authors, eliminating duplicates
|
||||||
for each(var au in complexAu) {
|
for(var i=0; i<complexAu.length; i++) {
|
||||||
var pushMe = true;
|
var pushMe = true;
|
||||||
for each(var pAu in item.creators) {
|
for(var j=0; j<item.creators.length; j++) {
|
||||||
// if there's a plain author that is close to this author (the
|
// if there's a plain author that is close to this author (the
|
||||||
// same last name, and the same first name up to a point), keep
|
// same last name, and the same first name up to a point), keep
|
||||||
// the plain author, since it might have a middle initial
|
// the plain author, since it might have a middle initial
|
||||||
if(pAu.lastName == au.lastName &&
|
if(item.creators[j].lastName == complexAu[i].lastName &&
|
||||||
(pAu.firstName == au.firstName == "" ||
|
(item.creators[j].firstName == complexAu[i].firstName == "" ||
|
||||||
(pAu.firstName.length >= au.firstName.length &&
|
(item.creators[j].firstName.length >= complexAu[i].firstName.length &&
|
||||||
pAu.firstName.substr(0, au.firstName.length) == au.firstName))) {
|
item.creators[j].firstName.substr(0, complexAu[i].firstName.length) == complexAu[i].firstName))) {
|
||||||
pushMe = false;
|
pushMe = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -939,8 +939,8 @@ Zotero.Translate.prototype._generateSandbox = function() {
|
||||||
var m = searchSandboxRe.exec(tempURL);
|
var m = searchSandboxRe.exec(tempURL);
|
||||||
if(m) sandboxLocation = m[0];
|
if(m) sandboxLocation = m[0];
|
||||||
}
|
}
|
||||||
//} else if(this._sandboxLocation) {
|
} else if(this._sandboxLocation) {
|
||||||
// sandboxLocation = this._sandboxLocation;
|
sandboxLocation = this._sandboxLocation;
|
||||||
}
|
}
|
||||||
Zotero.debug("Translate: Binding sandbox to "+(typeof sandboxLocation == "object" ? sandboxLocation.document.location : sandboxLocation), 4);
|
Zotero.debug("Translate: Binding sandbox to "+(typeof sandboxLocation == "object" ? sandboxLocation.document.location : sandboxLocation), 4);
|
||||||
|
|
||||||
|
|
|
@ -261,17 +261,17 @@ Zotero.Utilities = {
|
||||||
var parts = [];
|
var parts = [];
|
||||||
var splits = str.split(/(<a [^>]+>[^<]*<\/a>)/);
|
var splits = str.split(/(<a [^>]+>[^<]*<\/a>)/);
|
||||||
|
|
||||||
for each(var split in splits) {
|
for(var i=0; i<splits.length; i++) {
|
||||||
// Link
|
// Link
|
||||||
if (split.indexOf('<a ') == 0) {
|
if (splits[i].indexOf('<a ') == 0) {
|
||||||
var matches = split.match(/<a ([^>]+)>([^<]*)<\/a>/);
|
var matches = splits[i].match(/<a ([^>]+)>([^<]*)<\/a>/);
|
||||||
if (matches) {
|
if (matches) {
|
||||||
// Attribute pairs
|
// Attribute pairs
|
||||||
var attributes = {};
|
var attributes = {};
|
||||||
var pairs = matches[1].match(/([^ =]+)="([^"]+")/g);
|
var pairs = matches[1].match(/([^ =]+)="([^"]+")/g);
|
||||||
for each (var pair in pairs) {
|
for(var j=0; j<pairs.length; j++) {
|
||||||
var [key, val] = pair.split(/=/);
|
var keyVal = pairs[j].split(/=/);
|
||||||
attributes[key] = val.substr(1, val.length - 2);
|
attributes[keyVal[0]] = val.substr(1, keyVal[1].length - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push({
|
parts.push({
|
||||||
|
@ -503,6 +503,50 @@ Zotero.Utilities = {
|
||||||
nextSet();
|
nextSet();
|
||||||
}
|
}
|
||||||
nextSet();
|
nextSet();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if an item type exists
|
||||||
|
*
|
||||||
|
* @param {String} type Item type
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
"itemTypeExists":function(type) {
|
||||||
|
if(Zotero.ItemTypes.getID(type)) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find valid creator types for a given item type
|
||||||
|
*
|
||||||
|
* @param {String} type Item type
|
||||||
|
* @return {String[]} Creator types
|
||||||
|
*/
|
||||||
|
"getCreatorsForType":function(type) {
|
||||||
|
var types = Zotero.CreatorTypes.getTypesForItemType(Zotero.ItemTypes.getID(type));
|
||||||
|
var cleanTypes = new Array();
|
||||||
|
for(var i=0; i<types.length; i++) {
|
||||||
|
cleanTypes.push(types[i].name);
|
||||||
|
}
|
||||||
|
return cleanTypes;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a creator type name, localized to the current locale
|
||||||
|
*
|
||||||
|
* @param {String} type Creator type
|
||||||
|
* @param {String} Localized creator type
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
"getLocalizedCreatorType":function(type) {
|
||||||
|
try {
|
||||||
|
return Zotero.getString("creatorTypes."+type);
|
||||||
|
} catch(e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,50 +854,6 @@ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, header
|
||||||
}, headers, responseCharset);
|
}, headers, responseCharset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests if an item type exists
|
|
||||||
*
|
|
||||||
* @param {String} type Item type
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
Zotero.Utilities.Translate.prototype.itemTypeExists = function(type) {
|
|
||||||
if(Zotero.ItemTypes.getID(type)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find valid creator types for a given item type
|
|
||||||
*
|
|
||||||
* @param {String} type Item type
|
|
||||||
* @return {String[]} Creator types
|
|
||||||
*/
|
|
||||||
Zotero.Utilities.Translate.prototype.getCreatorsForType = function(type) {
|
|
||||||
var types = Zotero.CreatorTypes.getTypesForItemType(Zotero.ItemTypes.getID(type));
|
|
||||||
var cleanTypes = new Array();
|
|
||||||
for each(var type in types) {
|
|
||||||
cleanTypes.push(type.name);
|
|
||||||
}
|
|
||||||
return cleanTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a creator type name, localized to the current locale
|
|
||||||
*
|
|
||||||
* @param {String} type Creator type
|
|
||||||
* @param {String} Localized creator type
|
|
||||||
* @type Boolean
|
|
||||||
*/
|
|
||||||
Zotero.Utilities.Translate.prototype.getLocalizedCreatorType = function(type) {
|
|
||||||
try {
|
|
||||||
return Zotero.getString("creatorTypes."+type);
|
|
||||||
} catch(e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a URL to a form that goes through the appropriate proxy, or convert a relative URL to
|
* Translate a URL to a form that goes through the appropriate proxy, or convert a relative URL to
|
||||||
* an absolute one
|
* an absolute one
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue