From ca994fd22b595b742697d7a3a533490bf630c183 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 14 Feb 2012 22:55:35 -0500 Subject: [PATCH 01/27] Prevent accept from being called twice --- chrome/content/zotero/xpcom/integration.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index b4d4c7d06..02eab1599 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -1768,9 +1768,15 @@ Zotero.Integration.CitationEditInterface.prototype = { * Accept changes to the citation * @param {Function} [progressCallback] A callback to be run when progress has changed. * Receives a number from 0 to 100 indicating current status. + * @param {Boolean} [force] Whether to run accept even if it has been run previously. */ - "accept":function(progressCallback) { + "accept":function(progressCallback, force) { var me = this; + + // Don't allow accept to be called multiple times + if(!force && this._haveAccepted) return; + this._haveAccepted = true; + this._fields.progressCallback = progressCallback; if(this._errorOccurred) { @@ -1779,7 +1785,7 @@ Zotero.Integration.CitationEditInterface.prototype = { Zotero.setTimeout(function() { me._fields.updateSession(function() { me._errorOccurred = false; - me.accept(progressCallback); + me.accept(progressCallback, true); }) }, 0); return; From 9b76f4b5b8162fe9e309f204c563455f23f96d7c Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Tue, 14 Feb 2012 23:01:44 -0500 Subject: [PATCH 02/27] Hack to open PDFs in pdf.js when available --- chrome/content/zotero/xpcom/mime.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chrome/content/zotero/xpcom/mime.js b/chrome/content/zotero/xpcom/mime.js index 87866fe09..7a64e5f24 100644 --- a/chrome/content/zotero/xpcom/mime.js +++ b/chrome/content/zotero/xpcom/mime.js @@ -355,6 +355,12 @@ Zotero.MIME = new function(){ return isNative; } + if(mimeType === "application/pdf" + && "@mozilla.org/streamconv;1?from=application/pdf&to=*/*" in Components.classes) { + // PDF can be handled internally if pdf.js is installed + return true; + } + // Is there a better way to get to navigator? var types = Components.classes["@mozilla.org/appshell/appShellService;1"] .getService(Components.interfaces.nsIAppShellService) From 645bbf92b80a7a95c31253a5905ac731adf6a532 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 15 Feb 2012 02:43:08 -0500 Subject: [PATCH 03/27] More hacks for pdf.js --- chrome/content/zotero/xpcom/attachments.js | 22 ++++++++++++++++++++++ chrome/content/zotero/zoteroPane.js | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index a7ab63212..a7ae4ec87 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -504,6 +504,10 @@ Zotero.Attachments = new function(){ var url = document.location.href; var title = forceTitle ? forceTitle : document.title; var mimeType = document.contentType; + if(Zotero.Attachments.isPDFJS(document)) { + mimeType = "application/pdf"; + } + var charsetID = Zotero.CharacterSets.getID(document.characterSet); if (!forceTitle) { @@ -1358,4 +1362,22 @@ Zotero.Attachments = new function(){ .getURLSpecFromFile(file); browser.loadURI(url); } + + /** + * Determines if a given document is an instance of PDFJS + * @return {Boolean} + */ + this.isPDFJS = function(doc) { + // pdf.js HACK + if(doc.contentType === "text/html") { + var win = doc.defaultView; + if(win) { + win = win.wrappedJSObject; + if(win && "PDFJS" in win && win.PDFJS.isFirefoxExtension) { + return true; + } + } + } + return false; + } } diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index f76d62855..3e85897ce 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -3082,7 +3082,7 @@ var ZoteroPane = new function() if (itemType == 'temporaryPDFHack') { itemType = null; var isPDF = false; - if (doc.title.indexOf('application/pdf') != -1) { + if (doc.title.indexOf('application/pdf') != -1 || Zotero.Attachments.isPDFJS(doc)) { isPDF = true; } else { From 1e5bde6a541c6df6716a4f3f77ab4fde1463e5cf Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 15 Feb 2012 13:07:12 -0500 Subject: [PATCH 04/27] Fix an inconsequential error --- chrome/content/zotero/xpcom/locateManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/locateManager.js b/chrome/content/zotero/xpcom/locateManager.js index 7f3c93b4e..eda39bf3b 100644 --- a/chrome/content/zotero/xpcom/locateManager.js +++ b/chrome/content/zotero/xpcom/locateManager.js @@ -519,7 +519,7 @@ Zotero.LocateManager = new function() { false) return this; - throw Cr.NS_ERROR_NO_INTERFACE; + throw Components.results.NS_ERROR_NO_INTERFACE; }, // nsIRequestObserver From 5d78e3cfe8dbe6dea1033471a182e32f4416cc66 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 02:59:02 -0500 Subject: [PATCH 05/27] Update to citeproc-js 1.0.283 --- chrome/content/zotero/xpcom/citeproc.js | 81 ++++++++++++++----------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index be9a00e22..9f93f2728 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -736,16 +736,31 @@ CSL_CHROME.prototype.insertChildNodeAfter = function (parent,node,pos,datexml) { myxml = this.importNode(node.ownerDocument, datexml); parent.replaceChild(myxml, node); return parent; - }; +}; CSL_CHROME.prototype.insertPublisherAndPlace = function(myxml) { var group = myxml.getElementsByTagName("group"); for (var i = 0, ilen = group.length; i < ilen; i += 1) { var node = group.item(i); - if (node.childNodes.length === 2) { + var skippers = []; + for (var j = 0, jlen = node.childNodes.length; j < jlen; j += 1) { + if (node.childNodes.item(j).nodeType !== 1) { + skippers.push(j); + } + } + if (node.childNodes.length - skippers.length === 2) { var twovars = []; for (var j = 0, jlen = 2; j < jlen; j += 1) { - var child = node.childNodes.item(j); - if (child.childNodes.length === 0) { + if (skippers.indexOf(j) > -1) { + continue; + } + var child = node.childNodes.item(j); + var subskippers = []; + for (var k = 0, klen = child.childNodes.length; k < klen; k += 1) { + if (child.childNodes.item(k).nodeType !== 1) { + subskippers.push(k); + } + } + if (child.childNodes.length - subskippers.length === 0) { twovars.push(child.getAttribute('variable')); if (child.getAttribute('suffix') || child.getAttribute('prefix')) { @@ -2133,7 +2148,7 @@ CSL.DateParser = function () { }; CSL.Engine = function (sys, style, lang, forceLang) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.280"; + this.processor_version = "1.0.283"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -7500,15 +7515,8 @@ CSL.Node.text = { func = function (state, Item, item) { if (item && item[this.variables[0]]) { var locator = "" + item[this.variables[0]]; - locator = locator.replace(/--*/g,"\u2013"); - var m = locator.match(/^([0-9]+)\s*\u2013\s*([0-9]+)$/) - if (m) { - if (parseInt(m[1]) >= parseInt(m[2])) { - locator = m[1] + "-" + m[2]; - } - } else { - locator = locator.replace(/\u2013/g,"-"); - } + locator = locator.replace(/([^\\])--*/g,"$1\u2013"); + locator = locator.replace(/\\-/g,"-"); state.output.append(locator, this, false, false, true); } }; @@ -7529,15 +7537,8 @@ CSL.Node.text = { func = function (state, Item) { var value = state.getVariable(Item, "page", form); if (value) { - value = value.replace(/--*/g,"\u2013"); - var m = value.match(/^([0-9]+)\s*\u2013\s*([0-9]+)$/) - if (m) { - if (parseInt(m[1]) >= parseInt(m[2])) { - value = m[1] + "-" + m[2]; - } - } else { - value = value.replace(/\u2013/g,"-"); - } + value = value.replace(/([^\\])--*/g,"$1\u2013"); + value = value.replace(/\\-/g,"-"); value = state.fun.page_mangler(value); state.output.append(value, this, false, false, true); } @@ -8839,11 +8840,15 @@ CSL.Transform = function (state) { if (Item.type) { hereinafter_metadata.push("type:" + Item.type); } - if (Item.issued) { + var date_segment = Item.issued + if (["legal_case", "bill", "legislation"].indexOf(Item.type) > -1) { + date_segment = Item["original-date"]; + } + if (date_segment) { var date = []; for (var j = 0, jlen = CSL.DATE_PARTS.length; j < jlen; j += 1) { - if (Item.issued[CSL.DATE_PARTS[j]]) { - var element = Item.issued[CSL.DATE_PARTS[j]]; + if (date_segment[CSL.DATE_PARTS[j]]) { + var element = date_segment[CSL.DATE_PARTS[j]]; while (element.length < 2) { element = "0" + element; } @@ -9016,14 +9021,14 @@ CSL.Parallel.prototype.CloseVariable = function (hello) { this.cite[this.variable] = this.data; if (this.sets.value().length > 0) { var prev = this.sets.value()[(this.sets.value().length - 1)]; - if (this.target === "front" && this.variable === "issued") { + if (this.target === "front" && this.variable === "original-date") { if (this.data.value && this.master_was_neutral_cite) { this.target = "mid"; } } if (this.target === "front") { if ((prev[this.variable] || this.data.value) && (!prev[this.variable] || this.data.value !== prev[this.variable].value)) { - if ("issued" !== this.variable) { + if ("original-date" !== this.variable) { this.in_series = false; } } @@ -9089,25 +9094,25 @@ CSL.Parallel.prototype.CloseCite = function () { this.ComposeSet(true); } if (this.sets.value().length === 0) { - has_issued = false; + has_date = false; for (pos = 0, len = this.cite.back.length; pos < len; pos += 1) { x = this.cite.back[pos]; - if (x === "issued" && this.cite.issued && this.cite.issued.value) { - has_issued = true; + if (x === "original-date" && this.cite["original-date"] && this.cite["original-date"].value) { + has_date = true; break; } } - if (!has_issued) { - this.cite.back_forceme.push("issued"); + if (!has_date) { + this.cite.back_forceme.push("original-date"); } } else { - var idx = this.cite.front.indexOf("issued"); + var idx = this.cite.front.indexOf("original-date"); if (idx === -1 || this.master_was_neutral_cite) { this.cite.back_forceme = this.sets.value().slice(-1)[0].back_forceme; } if (idx > -1) { var prev = this.sets.value()[this.sets.value().length - 1]; - if (!prev.issued) { + if (!prev["original-date"]) { this.cite.front = this.cite.front.slice(0, idx).concat(this.cite.front.slice(idx + 1)); } } @@ -10402,7 +10407,11 @@ CSL.Util.FlipFlopper.prototype._normalizeString = function (str) { if (str.indexOf(this.quotechars[1]) > -1) { for (var i = 0, ilen = 2; i < ilen; i += 1) { if (this.quotechars[i + 4]) { - str = str.replace(this.quotechars[i + 4], this.quotechars[1]); + if (i === 0) { + str = str.replace(this.quotechars[i + 4], " " + this.quotechars[1]); + } else { + str = str.replace(this.quotechars[i + 4], this.quotechars[1]); + } } } } From bfa7b5b1533cda86e2f092961e42e60e440d05c0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 16 Feb 2012 03:45:25 -0500 Subject: [PATCH 06/27] Add some storage filename debugging --- chrome/content/zotero/xpcom/storage.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index 543621fd1..c6b117a8e 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1115,11 +1115,14 @@ Zotero.Sync.Storage = new function () { destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); } catch (e) { + Zotero.debug(e, 1); + var windowsLength = false; var nameLength = false; // Windows API only allows paths of 260 characters if (e.name == "NS_ERROR_FILE_NOT_FOUND" && destFile.path.length > 255) { + Zotero.debug("Path is " + destFile.path); windowsLength = true; } // ext3/ext4/HFS+ have a filename length limit of ~254 bytes @@ -1127,19 +1130,22 @@ Zotero.Sync.Storage = new function () { // These filenames will almost always be ASCII ad files, // but allow an extra 10 bytes anyway else if (e.name == "NS_ERROR_FAILURE" && destFile.leafName.length >= 244) { + Zotero.debug("Filename is " + destFile.leafName); nameLength = true; } // Filesystem encryption (or, more specifically, filename encryption) // can result in a lower limit -- not much we can do about this, // but log a warning and skip the file else if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) { - Zotero.debug(e); // TODO: localize var msg = "Error creating file '" + destFile.leafName + "'. " + "See http://www.zotero.org/support/kb/encrypted_filenames for more information."; Components.utils.reportError(msg); continue; } + else { + Zotero.debug("Path is " + destFile.path); + } if (windowsLength || nameLength) { // Preserve extension @@ -1148,7 +1154,7 @@ Zotero.Sync.Storage = new function () { if (windowsLength) { var pathLength = destFile.path.length - destFile.leafName.length; - var newLength = 255 - pathLength; + var newLength = 254 - pathLength; // Require 40 available characters in path -- this is arbitrary, // but otherwise filenames are going to end up being cut off if (newLength < 40) { From 6a68139591e18447ea7f1e99c59c0a9e07f6d585 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 03:50:26 -0500 Subject: [PATCH 07/27] charset is a complex value in newer Fx versions probably fixes http://forums.zotero.org/discussion/21956/zotero-wont-accept-ris-file/#Item_2 --- .../xpcom/translation/translate_firefox.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 835b3b100..392238ba8 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -332,10 +332,22 @@ Zotero.Translate.IO.Read = function(file, mode) { // if the regexp continues to fail, this is not UTF-8 if(!isUTF8) { // Can't be UTF-8; see if a default charset is defined - this._charset = Zotero.Prefs.get("intl.charset.default", true); + var prefs = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefBranch); + try { + this._charset = prefs.getComplexValue("intl.charset.default", + Components.interfaces.nsIPrefLocalizedString).toString(); + } catch(e) {} - // ISO-8859-1 by default - if(!this._charset) this._charset = "ISO-8859-1"; + if(!this._charset) { + try { + this._charset = prefs.getCharPref("intl.charset.default"); + } catch(e) {} + + + // ISO-8859-1 by default + if(!this._charset) this._charset = "ISO-8859-1"; + } break; } From c99a7d37f044549fbeaf03fd331a6b53255ece43 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 04:05:12 -0500 Subject: [PATCH 08/27] Zotero toolbar should always be visible --- chrome/skin/default/zotero/overlay.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index cd08a1d74..c7186b995 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -517,4 +517,9 @@ #zotero-annotate-tb-unhighlight[tool-active=true] { list-style-image: url('chrome://zotero/skin/annotate-unhighlight-selected.png'); +} + +#zotero-toolbar +{ + visibility: visible !important; } \ No newline at end of file From 54b2916f7eea28d5353853a80daa330cfb20f36a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 04:13:47 -0500 Subject: [PATCH 09/27] Don't let Firefox hide our toolbars --- chrome/content/zotero/zoteroPane.xul | 2 +- chrome/skin/default/zotero/overlay.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/zoteroPane.xul b/chrome/content/zotero/zoteroPane.xul index 124056f28..41b6a76e3 100644 --- a/chrome/content/zotero/zoteroPane.xul +++ b/chrome/content/zotero/zoteroPane.xul @@ -97,7 +97,7 @@ onkeyup="ZoteroPane_Local.handleKeyUp(event, this.id)" chromedir="&locale.dir;"> - + diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index c7186b995..f0f5813c0 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -522,4 +522,5 @@ #zotero-toolbar { visibility: visible !important; + display: block !important; } \ No newline at end of file From c62c229e6fe75b1ed8053130e1f5a9495c7394fb Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 04:17:51 -0500 Subject: [PATCH 10/27] Don't screw up toolbar styling --- chrome/skin/default/zotero/overlay.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index f0f5813c0..99888a5f2 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -522,5 +522,5 @@ #zotero-toolbar { visibility: visible !important; - display: block !important; + display: inherit !important; } \ No newline at end of file From 10d23e76bf73dd272f7e76f9402af7ae5bd07440 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 16 Feb 2012 04:50:51 -0500 Subject: [PATCH 11/27] Fix "Please restart undefined" in WebDAV error message And a little other weirdness --- chrome/content/zotero/xpcom/storage/webdav.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index feae35979..6e13eeea3 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -49,7 +49,7 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.includeGroupItems = false; // TEMP // TODO: localize Zotero.Sync.Storage.Session.WebDAV.prototype.defaultError = "A WebDAV file sync error occurred. Please try syncing again.\n\nIf you receive this message repeatedly, check your WebDAV server settings in the Sync pane of the Zotero preferences."; -Zotero.Sync.Storage.Session.WebDAV.prototype.defaultErrorRestart = "A WebDAV file sync error occurred. Please restart " + Zotero.appName + " and try syncing again.\n\nIf you receive this message repeatedly, check your WebDAV server settings in the Sync pane of the Zotero preferences."; +Zotero.Sync.Storage.Session.WebDAV.prototype.__defineGetter__('defaultErrorRestart', function () "A WebDAV file sync error occurred. Please restart " + Zotero.appName + " and try syncing again.\n\nIf you receive this message repeatedly, check your WebDAV server settings in the Sync pane of the Zotero preferences."); Zotero.Sync.Storage.Session.WebDAV.prototype.__defineGetter__('enabled', function () { @@ -703,10 +703,10 @@ Zotero.Sync.Storage.Session.WebDAV.prototype._onUploadCancel = function (httpReq Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callback) { + var self = this; + // Cache the credentials at the root URI if (!this._cachedCredentials) { - var self = this; - Zotero.HTTP.doOptions(this.rootURI, function (req) { self._checkResponse(req, self); @@ -729,7 +729,6 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callbac var successFileURI = uri.clone(); successFileURI.spec += "lastsync"; Zotero.HTTP.doGet(successFileURI, function (req) { - var ts = undefined; try { if (req.responseText) { Zotero.debug(req.responseText); @@ -744,10 +743,7 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callbac if (req.status != 200 && req.status != 404) { var msg = "Unexpected status code " + req.status + " for HEAD request " + "in Zotero.Sync.Storage.Session.WebDAV.getLastSyncTime()"; - Zotero.debug(msg, 1); - Components.utils.reportError(msg); - self.onError(); - return; + throw (msg); } if (req.status == 200) { @@ -759,17 +755,21 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callbac else { ts = null; } - } - finally { + callback(ts); } + catch (e) { + Zotero.debug(e, 1); + Components.utils.reportError(e); + self.onError(); + } }); return; } catch (e) { Zotero.debug(e); Components.utils.reportError(e); - callback(); + self.onError(); return; } } From eeacdc7391c1d8e468548898e7f8534399428358 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 06:34:08 -0500 Subject: [PATCH 12/27] Fix issues saving attachments from another translator --- chrome/content/zotero/xpcom/translation/translate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index f2e37a3f6..d2f050d2b 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -240,10 +240,10 @@ Zotero.Translate.Sandbox = { if(attachments) { for(var i=0; i Date: Thu, 16 Feb 2012 07:44:02 -0500 Subject: [PATCH 13/27] Don't throw if the user types before the window finishes initializing --- chrome/content/zotero/integration/quickFormat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 1b4308781..5a509109b 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -978,7 +978,7 @@ var Zotero_QuickFormat = new function () { * Handle return or escape */ function _onQuickSearchKeyPress(event) { - qfGuidance.hide(); + if(qfGuidance) qfGuidance.hide(); var keyCode = event.keyCode; if(keyCode === event.DOM_VK_RETURN || keyCode === event.DOM_VK_ENTER) { From a47174748ec5bfb64747bd2274d59ad2b90506ad Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 07:56:40 -0500 Subject: [PATCH 14/27] Update to citeproc-js 1.0.285 --- chrome/content/zotero/xpcom/citeproc.js | 43 +++++++++++++++++-------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/chrome/content/zotero/xpcom/citeproc.js b/chrome/content/zotero/xpcom/citeproc.js index 9f93f2728..3dee989b5 100644 --- a/chrome/content/zotero/xpcom/citeproc.js +++ b/chrome/content/zotero/xpcom/citeproc.js @@ -2148,7 +2148,7 @@ CSL.DateParser = function () { }; CSL.Engine = function (sys, style, lang, forceLang) { var attrs, langspec, localexml, locale; - this.processor_version = "1.0.283"; + this.processor_version = "1.0.285"; this.csl_version = "1.0"; this.sys = sys; this.sys.xml = new CSL.System.Xml.Parsing(); @@ -7500,6 +7500,9 @@ CSL.Node.text = { } else { state.transform.setTransformFallback(true); state.transform.setAbbreviationFallback(true); + if (this.variables_real[0] === "subjurisdiction") { + state.transform.setSuppressMonitor("container-title"); + } func = state.transform.getOutputFunction(this.variables); } if (this.variables_real[0] === "container-title") { @@ -7554,14 +7557,16 @@ CSL.Node.text = { } }; } else if (this.variables_real[0] === "hereinafter") { - func = function (state, Item) { - var hereinafter_info = state.transform.getHereinafter(Item); - var value = state.transform.abbrevs[hereinafter_info[0]].hereinafter[hereinafter_info[1]]; - if (value) { - state.tmp.group_context.value()[2] = true; - state.output.append(value, this); - } - }; + if (state.sys.getAbbreviation) { + func = function (state, Item) { + var hereinafter_info = state.transform.getHereinafter(Item); + var value = state.transform.abbrevs[hereinafter_info[0]].hereinafter[hereinafter_info[1]]; + if (value) { + state.tmp.group_context.value()[2] = true; + state.output.append(value, this); + } + }; + } } else if (this.variables_real[0] === "URL") { func = function (state, Item) { var value; @@ -8585,7 +8590,8 @@ CSL.Transform = function (state) { opt = { abbreviation_fallback: false, alternative_varname: false, - transform_fallback: false + transform_fallback: false, + suppress_monitor: false }; } this.init = init; @@ -8661,6 +8667,10 @@ CSL.Transform = function (state) { opt.abbreviation_fallback = b; } this.setAbbreviationFallback = setAbbreviationFallback; + function setSuppressMonitor(b) { + opt.suppress_monitor = b; + } + this.setSuppressMonitor = setSuppressMonitor; function setAlternativeVariableName(s) { opt.alternative_varname = s; } @@ -8731,9 +8741,10 @@ CSL.Transform = function (state) { var myabbrev_family, myfieldname, abbreviation_fallback, alternative_varname, transform_locale, transform_fallback, getTextSubfield; myabbrev_family = abbrev_family; myfieldname = fieldname; - abbreviation_fallback = opt.abbreviation_fallback; - alternative_varname = opt.alternative_varname; - transform_fallback = opt.transform_fallback; + var abbreviation_fallback = opt.abbreviation_fallback; + var alternative_varname = opt.alternative_varname; + var transform_fallback = opt.transform_fallback; + var suppress_monitor = opt.suppress_monitor; var localesets; var langPrefs = CSL.LangPrefsMap[myfieldname]; if (!langPrefs) { @@ -8797,6 +8808,12 @@ CSL.Transform = function (state) { } if (myabbrev_family) { primary = abbreviate(state, Item, alternative_varname, primary, myabbrev_family, true); + if (suppress_monitor && primary) { + suppressing_partner = abbreviate(state, Item, false, Item["container-title"], "container-title", true); + if (suppressing_partner && suppressing_partner.slice(0, primary.length) === primary) { + return null; + } + } secondary = abbreviate(state, Item, false, secondary, myabbrev_family, true); tertiary = abbreviate(state, Item, false, tertiary, myabbrev_family, true); } From 95fa3bc5547a44cea5ec90e49f102191f1d2ac7e Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 07:59:42 -0500 Subject: [PATCH 15/27] Fix an error spotted in an error report --- chrome/content/zotero/xpcom/itemTreeView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index a312e5fa4..5a3c5f10a 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -2054,7 +2054,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (event) { } // Get Quick Copy format for current URL - var url = this._ownerDocument.defaultView.content ? + var url = this._ownerDocument.defaultView.content && this._ownerDocument.defaultView.content.location ? this._ownerDocument.defaultView.content.location.href : null; var format = Zotero.QuickCopy.getFormatFromURL(url); From a402350cda13f6da7508b507af568b5cf66bb4a6 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 13:29:32 -0500 Subject: [PATCH 16/27] Better error handling in addStatement --- chrome/content/zotero/xpcom/translation/translate.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index d2f050d2b..72c1e2721 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2155,6 +2155,16 @@ Zotero.Translate.IO._RDFSandbox.prototype = { * (false) */ "addStatement":function(about, relation, value, literal) { + if(about === null || about === undefined) { + throw new Error("about must be defined in Zotero.RDF.addStatement"); + } + if(relation === null || relation === undefined) { + throw new Error("relation must be defined in Zotero.RDF.addStatement"); + } + if(value === null || value === undefined) { + throw new Error("value must be defined in Zotero.RDF.addStatement"); + } + if(literal) { // zap chars that Mozilla will mangle value = value.toString().replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ''); From 1c83646212b482a2d37fbcba82d0455b6f07cab7 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 14:22:50 -0500 Subject: [PATCH 17/27] Avoid throwing if attempt to catch startup errors somehow fails? --- chrome/content/zotero/xpcom/zotero.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 89cd65a9e..03105b345 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -434,9 +434,13 @@ const ZOTERO_CONFIG = { var cs = Components.classes["@mozilla.org/consoleservice;1"]. getService(Components.interfaces.nsIConsoleService); // Get startup errors - var messages = {}; - cs.getMessageArray(messages, {}); - _startupErrors = [msg for each(msg in messages.value) if(_shouldKeepError(msg))]; + try { + var messages = {}; + cs.getMessageArray(messages, {}); + _startupErrors = [msg for each(msg in messages.value) if(_shouldKeepError(msg))]; + } catch(e) { + Zotero.logError(e); + } // Register error observer cs.registerListener(ConsoleListener); From d94b4683b3100be8e2b2368101cc4a460c0e922f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 14:42:21 -0500 Subject: [PATCH 18/27] Force ZSA into online mode on startup --- chrome/content/zotero/xpcom/standalone.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chrome/content/zotero/xpcom/standalone.js b/chrome/content/zotero/xpcom/standalone.js index c47bee904..c6f654a9e 100644 --- a/chrome/content/zotero/xpcom/standalone.js +++ b/chrome/content/zotero/xpcom/standalone.js @@ -22,6 +22,7 @@ ***** END LICENSE BLOCK ***** */ +Components.utils.import("resource://gre/modules/Services.jsm"); Zotero.Standalone = new function() { /** @@ -70,6 +71,9 @@ Zotero.Standalone = new function() { }; this.init = function() { + // Set not offline + Services.io.offline = false; + // Add an observer to handle AMO requests Components.classes["@mozilla.org/observer-service;1"]. getService(Components.interfaces.nsIObserverService). From 6aedc8bff5dbee318146c64fa153cbe4af845ff0 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 16:03:07 -0500 Subject: [PATCH 19/27] Prevent inconsequential error --- chrome/content/zotero/xpcom/standalone.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/standalone.js b/chrome/content/zotero/xpcom/standalone.js index c6f654a9e..9e60fd244 100644 --- a/chrome/content/zotero/xpcom/standalone.js +++ b/chrome/content/zotero/xpcom/standalone.js @@ -79,8 +79,12 @@ Zotero.Standalone = new function() { getService(Components.interfaces.nsIObserverService). addObserver({ "observe":function(ch) { - if(ch.QueryInterface(Components.interfaces.nsIRequest).URI.host - !== "versioncheck.addons.mozilla.org") return; + try { + if(ch.QueryInterface(Components.interfaces.nsIRequest).URI.host + !== "versioncheck.addons.mozilla.org") return; + } catch(e) { + return; + } var newListener = new AMOStreamListener; newListener.oldListener = ch. QueryInterface(Components.interfaces.nsITraceableChannel). From 02d6ca1058cd648e2e806cd074efdb6b514494ca Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 16 Feb 2012 19:22:35 -0500 Subject: [PATCH 20/27] Don't support Firefox 13 to please AMO --- install.rdf | 2 +- update.rdf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.rdf b/install.rdf index fb3c1cbbe..e8e2fd402 100644 --- a/install.rdf +++ b/install.rdf @@ -26,7 +26,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 3.6 - 13.* + 13.0a1 diff --git a/update.rdf b/update.rdf index 18219ff11..cb49b1eaf 100644 --- a/update.rdf +++ b/update.rdf @@ -12,7 +12,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 3.6 - 13.* + 13.0a1 http://download.zotero.org/extension/zotero.xpi sha1: From 75dd27bf5b4f3b26f19ad17111f3842d57729e5f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 16 Feb 2012 19:43:38 -0500 Subject: [PATCH 21/27] Remove setAttribute('onclick'...) with embedded id for AMO --- chrome/content/zotero/itemPane.js | 6 ++++-- chrome/content/zotero/itemPane.xul | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index 90a275bcc..53bdee643 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -98,6 +98,8 @@ var ZoteroItemPane = new function() { var notes = Zotero.Items.get(item.getNotes()); if (notes.length) { for(var i = 0; i < notes.length; i++) { + let id = notes[i].id; + var icon = document.createElement('image'); icon.setAttribute('src','chrome://zotero/skin/treeitem-note.png'); @@ -109,8 +111,8 @@ var ZoteroItemPane = new function() { label.setAttribute('crop','end'); var box = document.createElement('box'); - box.setAttribute('onclick',"ZoteroPane_Local.selectItem(" + notes[i].id + ");"); box.setAttribute('class','zotero-clicky'); + box.addEventListener('click', function () { ZoteroPane_Local.selectItem(id); }); box.appendChild(icon); box.appendChild(label); @@ -118,7 +120,7 @@ var ZoteroItemPane = new function() { var removeButton = document.createElement('label'); removeButton.setAttribute("value","-"); removeButton.setAttribute("class","zotero-clicky zotero-clicky-minus"); - removeButton.setAttribute("onclick","ZoteroItemPane.removeNote(" + notes[i].id + ")"); + removeButton.addEventListener('click', function () { ZoteroItemPane.removeNote(id); }); } var row = document.createElement('row'); diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul index c9facea7d..38af4e645 100644 --- a/chrome/content/zotero/itemPane.xul +++ b/chrome/content/zotero/itemPane.xul @@ -30,7 +30,7 @@