From 7022379a87ecf22bd9978e7ab33df9c837f6990f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Mon, 29 Oct 2012 19:31:10 -0400 Subject: [PATCH 01/12] Fix RDF for Firefox 17 --- .../zotero/xpcom/translation/translate.js | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index f9f419769..e931be4d2 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2465,7 +2465,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { } } - return containerElements; + return this._expose(containerElements); }, /** @@ -2498,7 +2498,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { for(var i in this._dataStore.subjectIndex) { returnArray.push(this._dataStore.subjectIndex[i][0].subject); } - return returnArray; + return this._expose(returnArray); }, /** @@ -2514,7 +2514,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { for(var i=0; i Date: Tue, 30 Oct 2012 02:01:45 -0400 Subject: [PATCH 02/12] Revert "Fix RDF for Firefox 17" This reverts commit 7022379a87ecf22bd9978e7ab33df9c837f6990f. --- .../zotero/xpcom/translation/translate.js | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index e931be4d2..f9f419769 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2465,7 +2465,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { } } - return this._expose(containerElements); + return containerElements; }, /** @@ -2498,7 +2498,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { for(var i in this._dataStore.subjectIndex) { returnArray.push(this._dataStore.subjectIndex[i][0].subject); } - return this._expose(returnArray); + return returnArray; }, /** @@ -2514,7 +2514,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = { for(var i=0; i Date: Tue, 30 Oct 2012 02:06:06 -0400 Subject: [PATCH 03/12] Fix passing all arrays to sandbox --- .../xpcom/translation/translate_firefox.js | 35 ++++++------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index c9cc2acfe..abb66c8dd 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -149,7 +149,8 @@ Zotero.Translate.SandboxManager.prototype = { */ "importObject":function(object, passAsFirstArgument, attachTo) { if(!attachTo) attachTo = this.sandbox.Zotero; - var newExposedProps = false; + var newExposedProps = false, + sandbox = this.sandbox; if(!object.__exposedProps__) newExposedProps = {}; for(var key in (newExposedProps ? object : object.__exposedProps__)) { let localKey = key; @@ -160,30 +161,16 @@ Zotero.Translate.SandboxManager.prototype = { var isObject = typeof object[localKey] === "object"; if(isFunction || isObject) { if(isFunction) { - if(Zotero.isFx4) { - if(passAsFirstArgument) { - attachTo[localKey] = object[localKey].bind(object, passAsFirstArgument); - } else { - attachTo[localKey] = object[localKey].bind(object); + attachTo[localKey] = function() { + var args = Array.prototype.slice.apply(arguments); + if(passAsFirstArgument) args.unshift(passAsFirstArgument); + var out = object[localKey].apply(object, args); + if(out instanceof Array) { + // Copy to sandbox + out = sandbox.Array.prototype.slice.apply(out); } - } else { - attachTo[localKey] = function() { - if(passAsFirstArgument) { - var args = new Array(arguments.length+1); - args[0] = passAsFirstArgument; - var offset = 1; - } else { - var args = new Array(arguments.length); - var offset = 0; - } - - for(var i=0, nArgs=arguments.length; i Date: Tue, 30 Oct 2012 04:46:19 -0400 Subject: [PATCH 04/12] Fix XPI note loading in Fx17 due to navigator.userAgent error --- chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js | 4 +++- chrome/content/zotero/tinymce/tiny_mce.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) mode change 100755 => 100644 chrome/content/zotero/tinymce/tiny_mce.js diff --git a/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js b/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js index ad9740f3f..f96099af4 100644 --- a/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js +++ b/chrome/content/zotero/tinymce/plugins/paste/editor_plugin.js @@ -255,7 +255,9 @@ // Check if we should use the new auto process method if (getParam(ed, "paste_auto_cleanup_on_paste")) { // Is it's Opera or older FF use key handler - if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) { + // Modified by Dan S./Zotero + //if (tinymce.isOpera || /Firefox\/2/.test(navigator.userAgent)) { + if (false) { ed.onKeyDown.add(function(ed, e) { if (((tinymce.isMac ? e.metaKey : e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) grabContent(e); diff --git a/chrome/content/zotero/tinymce/tiny_mce.js b/chrome/content/zotero/tinymce/tiny_mce.js old mode 100755 new mode 100644 index 5092334fe..33c6cf691 --- a/chrome/content/zotero/tinymce/tiny_mce.js +++ b/chrome/content/zotero/tinymce/tiny_mce.js @@ -12,7 +12,9 @@ releaseDate : '2010-09-29', _init : function() { - var t = this, d = document, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; + // Modified by Dan S./Zotero + //var t = this, d = document, na = navigator, ua = na.userAgent, i, nl, n, base, p, v; + var t = this, d = document, na = navigator, ua = "Gecko " + na.platform, i, nl, n, base, p, v; t.isOpera = win.opera && opera.buildNumber; From 21bf3000cbe64ad5345bb731b0e8396aa004b13f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 31 Oct 2012 04:38:45 -0400 Subject: [PATCH 05/12] Better method for determining valid XHTML notes in reports Previously looked for

tag. Now just check if it's valid XML. --- chrome/content/zotero/xpcom/report.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/chrome/content/zotero/xpcom/report.js b/chrome/content/zotero/xpcom/report.js index ae6fc360a..fd4039ee4 100644 --- a/chrome/content/zotero/xpcom/report.js +++ b/chrome/content/zotero/xpcom/report.js @@ -76,12 +76,17 @@ Zotero.Report = new function() { // Independent note if (arr['note']) { content += '\n'; - if (arr.note.substr(0, 1024).match(/]*>/)) { - content += arr.note + '\n'; + + // If not valid XML, display notes with entities encoded + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var doc = parser.parseFromString(arr.note, "application/xml"); + if (doc.documentElement.tagName == 'parsererror') { + content += '

' + escapeXML(arr.note) + '

\n'; } - // Wrap plaintext notes in

+ // Otherwise render markup normally else { - content += '

' + arr.note + '

\n'; + content += arr.note + '\n'; } } } @@ -98,13 +103,17 @@ Zotero.Report = new function() { for each(var note in arr.reportChildren.notes) { content += '
  • \n'; - if (note.note.substr(0, 1024).match(/]*>/)) { - content += note.note + '\n'; - } - // Wrap plaintext notes in

    - else { + // If not valid XML, display notes with entities encoded + var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"] + .createInstance(Components.interfaces.nsIDOMParser); + var doc = parser.parseFromString(note.note, "application/xml"); + if (doc.documentElement.tagName == 'parsererror') { content += '

    ' + escapeXML(note.note) + '

    \n'; } + // Otherwise render markup normally + else { + content += note.note + '\n'; + } // Child note tags content += _generateTagsList(note); From 81bfb5c327c86f0e0c52939c824acc96d0d592af Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 31 Oct 2012 05:22:58 -0400 Subject: [PATCH 06/12] Keep New Collection button enabled on Trash if library is editable Fixes #28 --- chrome/content/zotero/zoteroPane.js | 48 +++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 7dc0f032e..9d3d3b05a 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -745,7 +745,7 @@ var ZoteroPane = new function() return false; } - if (!this.canEdit()) { + if (!this.canEditLibrary()) { this.displayCannotEditLibraryMessage(); return; } @@ -1088,7 +1088,24 @@ var ZoteroPane = new function() ]; for(var i=0; i Date: Thu, 1 Nov 2012 01:53:31 -0400 Subject: [PATCH 07/12] Closes #49, Open attachments with Return/Enter Standard Firefox modifier keys also work --- chrome/content/zotero/xpcom/itemTreeView.js | 4 + chrome/content/zotero/zoteroPane.js | 135 +++++++++++--------- 2 files changed, 79 insertions(+), 60 deletions(-) diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index cbb3a34a6..ffab65cda 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -174,6 +174,10 @@ Zotero.ItemTreeView.prototype._setTreeGenerator = function(treebox) // in overlay.js::onCollectionSelected() this.listener = listener; tree.addEventListener('keypress', listener, false); + // This seems to be the only way to prevent Enter/Return + // from toggle row open/close. The event is handled by + // handleKeyPress() in zoteroPane.js. + tree._handleEnter = function () {}; this.sort(); diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 9d3d3b05a..62e55501e 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -664,6 +664,19 @@ var ZoteroPane = new function() event.preventDefault(); return; } + else if (event.keyCode == event.DOM_VK_RETURN) { + var items = this.itemsView.getSelectedItems(); + // Don't do anything if more than 20 items selected + if (!items.length || items.length > 20) { + return; + } + ZoteroPane_Local.viewItems(items, event); + // These don't seem to do anything. Instead we override + // the tree binding's _handleEnter method in itemTreeView.js. + //event.preventDefault(); + //event.stopPropagation(); + return; + } } } @@ -2607,72 +2620,23 @@ var ZoteroPane = new function() } } else if (tree.id == 'zotero-items-tree') { - var viewOnDoubleClick = Zotero.Prefs.get('viewOnDoubleClick'); - // Expand/collapse on triple-click - if (viewOnDoubleClick) { - if (event.detail == 3) { - tree.view.toggleOpenState(tree.view.selection.currentIndex); - return; - } - - // Don't expand/collapse on double-click - event.stopPropagation(); + if (!Zotero.Prefs.get('viewOnDoubleClick')) { + return; } + if (event.detail == 3) { + tree.view.toggleOpenState(tree.view.selection.currentIndex); + return; + } + + // Don't expand/collapse on double-click + event.stopPropagation(); + if (tree.view && tree.view.selection.currentIndex > -1) { var item = ZoteroPane_Local.getSelectedItems()[0]; if (item) { - if (item.isRegularItem()) { - if (itemGroup.isBucket()) { - var uri = itemGroup.ref.getItemURI(item); - ZoteroPane_Local.loadURI(uri); - event.stopPropagation(); - return; - } - - if (!viewOnDoubleClick) { - return; - } - - var uri = Components.classes["@mozilla.org/network/standard-url;1"]. - createInstance(Components.interfaces.nsIURI); - var snapID = item.getBestAttachment(); - if (snapID) { - spec = Zotero.Items.get(snapID).getLocalFileURL(); - if (spec) { - uri.spec = spec; - if (uri.scheme && uri.scheme == 'file') { - ZoteroPane_Local.viewAttachment(snapID, event); - return; - } - } - } - - var uri = item.getField('url'); - if (!uri) { - var doi = item.getField('DOI'); - if (doi) { - // Pull out DOI, in case there's a prefix - doi = Zotero.Utilities.cleanDOI(doi); - if (doi) { - uri = "http://dx.doi.org/" + encodeURIComponent(doi); - } - } - } - if (uri) { - ZoteroPane_Local.loadURI(uri); - } - } - else if (item.isNote()) { - if (!ZoteroPane_Local.collectionsView.editable) { - return; - } - document.getElementById('zotero-view-note-button').doCommand(); - } - else if (item.isAttachment()) { - ZoteroPane_Local.viewSelectedAttachment(event); - } + ZoteroPane_Local.viewItems([item], event); } } } @@ -3379,6 +3343,57 @@ var ZoteroPane = new function() } + this.viewItems = function (items, event) { + if (items.length > 1) { + if (!event || (!event.metaKey && !event.shiftKey)) { + event = { metaKey: true, shiftKey: true }; + } + } + + for each(var item in items) { + if (item.isRegularItem()) { + var uri = Components.classes["@mozilla.org/network/standard-url;1"] + .createInstance(Components.interfaces.nsIURI); + var snapID = item.getBestAttachment(); + if (snapID) { + spec = Zotero.Items.get(snapID).getLocalFileURL(); + if (spec) { + uri.spec = spec; + if (uri.scheme && uri.scheme == 'file') { + ZoteroPane_Local.viewAttachment(snapID, event); + continue; + } + } + } + + var uri = item.getField('url'); + if (!uri) { + var doi = item.getField('DOI'); + if (doi) { + // Pull out DOI, in case there's a prefix + doi = Zotero.Utilities.cleanDOI(doi); + if (doi) { + uri = "http://dx.doi.org/" + encodeURIComponent(doi); + } + } + } + if (uri) { + ZoteroPane_Local.loadURI(uri, event); + } + } + else if (item.isNote()) { + if (!ZoteroPane_Local.collectionsView.editable) { + continue; + } + document.getElementById('zotero-view-note-button').doCommand(); + } + else if (item.isAttachment()) { + ZoteroPane_Local.viewAttachment(item.id, event); + } + } + } + + function viewAttachment(itemIDs, event, noLocateOnMissing, forceExternalViewer) { // If view isn't editable, don't show Locate button, since the updated // path couldn't be sent back up From 0d0585b2172c643ddbcd5441c95b5fc124a7055a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 1 Nov 2012 01:59:09 -0400 Subject: [PATCH 08/12] Update versions --- chrome/content/zotero/xpcom/zotero.js | 2 +- install.rdf | 4 ++-- update.rdf | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index bcca8a99f..77e146dea 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -35,7 +35,7 @@ const ZOTERO_CONFIG = { API_URL: 'https://api.zotero.org/', PREF_BRANCH: 'extensions.zotero.', BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/', - VERSION: "3.0.8.SOURCE" + VERSION: "3.0.9.SOURCE" }; /* diff --git a/install.rdf b/install.rdf index 71bdaf0a7..ac3d3f50f 100644 --- a/install.rdf +++ b/install.rdf @@ -6,7 +6,7 @@ zotero@chnm.gmu.edu Zotero - 3.0.8.SOURCE + 3.0.9.SOURCE Center for History and New Media
    George Mason University
    Dan Cohen Sean Takats @@ -26,7 +26,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 5.0 - 19.0a1 + 17.* diff --git a/update.rdf b/update.rdf index b7f16c249..b4e3150cd 100644 --- a/update.rdf +++ b/update.rdf @@ -7,12 +7,12 @@ - 3.0.8.SOURCE + 3.0.9.SOURCE {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 5.0 - 19.0a1 + 17.* http://download.zotero.org/extension/zotero.xpi sha1: From 9d7cc849cdd924901dd491e067f11086f93d0f58 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 1 Nov 2012 03:32:07 -0400 Subject: [PATCH 09/12] Fixes #151, Allow Tab and Shift-Tab into and out of notes --- chrome/content/zotero/bindings/noteeditor.xml | 24 +++++++++++++++---- chrome/content/zotero/itemPane.xul | 2 +- chrome/content/zotero/zoteroPane.js | 13 ++++++++++ chrome/content/zotero/zoteroPane.xul | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml index 32308e9de..b9377ad18 100644 --- a/chrome/content/zotero/bindings/noteeditor.xml +++ b/chrome/content/zotero/bindings/noteeditor.xml @@ -268,11 +268,28 @@ - +