commit e0e84bc22a6743ba14b381bb5db14fccef774546
parent e61dd6002456543b26869da7030b49bb054d461b
Author: Simon Kornblith <simon@simonster.com>
Date: Wed, 27 Oct 2010 02:10:45 +0000
- eliminate for each in future cross-browser code
- move itemTypeExists, getCreatorsForType, and getLocalizedCreatorType back under ZU
- modify OpenURL code to use ZU.itemTypeExists
Diffstat:
4 files changed, 94 insertions(+), 74 deletions(-)
diff --git a/chrome/content/zotero-platform/mac/overlay.css b/chrome/content/zotero-platform/mac/overlay.css
@@ -174,13 +174,24 @@
-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 > * {
- color: #7C7C7C !important; /* remove this when we support click-through */
+#zotero-view-tabbox:-moz-window-inactive > 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-view-tabbox > tabs > tab[selected=true] {
- color: #C5C5C5 !important; /* remove this when we support click-through */
+#zotero-view-tabbox:-moz-window-inactive > 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;
+}
+
+/* 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;
}
@@ -220,6 +231,15 @@
-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-visible][selected=true],
:root:not([active]) #zotero-view-tabbox > tabs[chromedir=rtl] > tab:last-child[selected=true],
diff --git a/chrome/content/zotero/xpcom/openurl.js b/chrome/content/zotero/xpcom/openurl.js
@@ -109,15 +109,15 @@ Zotero.OpenURL = new function() {
if(version == "0.1") {
var co = "sid=Zotero:"+encodeURIComponent(Zotero.version);
- for each(identifier in identifiers) {
- co += "&id="+encodeURIComponent(identifier);
+ for(var i=0; i<identifiers.length; i++) {
+ co += "&id="+encodeURIComponent(identifiers[i]);
}
} else {
var co = "url_ver=Z39.88-2004&ctx_ver=Z39.88-2004"+
"&rfr_id="+encodeURIComponent("info:sid/zotero.org:"+Zotero.version);
- for each(identifier in identifiers) {
- co += "&rft_id="+encodeURIComponent(identifier)
+ for(var i=0; i<identifiers.length; i++) {
+ co += "&rft_id="+encodeURIComponent(identifiers[i])
}
}
@@ -189,8 +189,8 @@ Zotero.OpenURL = new function() {
}
// encode subsequent creators as au
- for each(creator in item.creators) {
- co += _mapTag((creator.firstName ? creator.firstName+" " : "")+creator.lastName, (item.itemType == "patent" ? "inventor" : "au"), version);
+ for(var i=0; i<identifiers.length; i++) {
+ 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("&");
// get type
- for each(var part in coParts) {
- if(part.substr(0, 12) == "rft_val_fmt=") {
- var format = decodeURIComponent(part.substr(12));
+ for(var i=0; i<coParts.length; i++) {
+ if(coParts[i].substr(0, 12) == "rft_val_fmt=") {
+ var format = decodeURIComponent(coParts[i].substr(12));
if(format == "info:ofi/fmt:kev:mtx:journal") {
item.itemType = "journalArticle";
break;
@@ -257,8 +257,8 @@ Zotero.OpenURL = new function() {
// keep track of "aucorp," "aufirst," "aulast"
var complexAu = new Array();
- for each(var part in coParts) {
- var keyVal = part.split("=");
+ for(var i=0; i<coParts.length; i++) {
+ var keyVal = coParts[i].split("=");
var key = keyVal[0];
var value = decodeURIComponent(keyVal[1].replace(/\+|%2[bB]/g, " "));
if(!value) {
@@ -411,7 +411,7 @@ Zotero.OpenURL = new function() {
} else if(key == "rft.subject") {
item.tags.push(value);
} 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") {
item.publicationTitle = value;
}
@@ -419,16 +419,16 @@ Zotero.OpenURL = new function() {
}
// combine two lists of authors, eliminating duplicates
- for each(var au in complexAu) {
+ for(var i=0; i<complexAu.length; i++) {
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
// same last name, and the same first name up to a point), keep
// the plain author, since it might have a middle initial
- if(pAu.lastName == au.lastName &&
- (pAu.firstName == au.firstName == "" ||
- (pAu.firstName.length >= au.firstName.length &&
- pAu.firstName.substr(0, au.firstName.length) == au.firstName))) {
+ if(item.creators[j].lastName == complexAu[i].lastName &&
+ (item.creators[j].firstName == complexAu[i].firstName == "" ||
+ (item.creators[j].firstName.length >= complexAu[i].firstName.length &&
+ item.creators[j].firstName.substr(0, complexAu[i].firstName.length) == complexAu[i].firstName))) {
pushMe = false;
break;
}
diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js
@@ -939,8 +939,8 @@ Zotero.Translate.prototype._generateSandbox = function() {
var m = searchSandboxRe.exec(tempURL);
if(m) sandboxLocation = m[0];
}
- //} else if(this._sandboxLocation) {
- // sandboxLocation = this._sandboxLocation;
+ } else if(this._sandboxLocation) {
+ sandboxLocation = this._sandboxLocation;
}
Zotero.debug("Translate: Binding sandbox to "+(typeof sandboxLocation == "object" ? sandboxLocation.document.location : sandboxLocation), 4);
diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js
@@ -261,17 +261,17 @@ Zotero.Utilities = {
var parts = [];
var splits = str.split(/(<a [^>]+>[^<]*<\/a>)/);
- for each(var split in splits) {
+ for(var i=0; i<splits.length; i++) {
// Link
- if (split.indexOf('<a ') == 0) {
- var matches = split.match(/<a ([^>]+)>([^<]*)<\/a>/);
+ if (splits[i].indexOf('<a ') == 0) {
+ var matches = splits[i].match(/<a ([^>]+)>([^<]*)<\/a>/);
if (matches) {
// Attribute pairs
var attributes = {};
var pairs = matches[1].match(/([^ =]+)="([^"]+")/g);
- for each (var pair in pairs) {
- var [key, val] = pair.split(/=/);
- attributes[key] = val.substr(1, val.length - 2);
+ for(var j=0; j<pairs.length; j++) {
+ var keyVal = pairs[j].split(/=/);
+ attributes[keyVal[0]] = val.substr(1, keyVal[1].length - 2);
}
parts.push({
@@ -503,6 +503,50 @@ Zotero.Utilities = {
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;
+ }
}
}
@@ -811,50 +855,6 @@ Zotero.Utilities.Translate.prototype.doPost = function(url, body, onDone, header
}
/**
- * 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
* an absolute one
*