diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul index fe9198be48..3c2a7a124c 100644 --- a/chrome/content/zotero/preferences/preferences.xul +++ b/chrome/content/zotero/preferences/preferences.xul @@ -64,6 +64,7 @@ To add a new preference: + @@ -148,6 +149,7 @@ To add a new preference: + diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 5fbc9ddc2a..04cbb2022d 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1431,7 +1431,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient) // DEBUG: save here because clone() doesn't currently work on unsaved tagged items var id = newItem.save(); newItem = Zotero.Items.get(id); - item.clone(false, newItem); + item.clone(false, newItem, false, !Zotero.Prefs.get('groups.copyTags')); newItem.save(); //var id = newItem.save(); //var newItem = Zotero.Items.get(id); diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index af66f03576..9ad3a5e850 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -4018,18 +4018,23 @@ Zotero.Item.prototype.multiDiff = function (otherItems, ignoreFields) { /** * Returns an unsaved copy of the item * - * @param {Boolean} [includePrimary=false] - * @param {Zotero.Item} [newItem=null] Target item for clone (used to pass a saved - * item for duplicating items with tags) - * @param {Boolean} [unsaved=false] Skip properties that require a saved object (e.g., tags) + * @param {Boolean} [includePrimary=false] + * @param {Zotero.Item} [newItem=null] Target item for clone (used to pass a saved + * item for duplicating items with tags) + * @param {Boolean} [unsaved=false] Skip properties that require a saved object (e.g., tags) + * @param {Boolean} [skipTags=false] Skip tags (implied by 'unsaved') */ -Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved) { +Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved, skipTags) { Zotero.debug('Cloning item ' + this.id); if (includePrimary && newItem) { throw ("includePrimary and newItem parameters are mutually exclusive in Zotero.Item.clone()"); } + if (unsaved) { + skipTags = true; + } + Zotero.DB.beginTransaction(); // TODO: get rid of serialize() call @@ -4169,7 +4174,7 @@ Zotero.Item.prototype.clone = function(includePrimary, newItem, unsaved) { } } - if (!unsaved && obj.tags) { + if (!skipTags && obj.tags) { for each(var tag in obj.tags) { if (sameLibrary) { newItem.addTagByID(tag.primary.tagID); diff --git a/chrome/content/zotero/xpcom/http.js b/chrome/content/zotero/xpcom/http.js index aea72cefe0..f332fb6b6d 100644 --- a/chrome/content/zotero/xpcom/http.js +++ b/chrome/content/zotero/xpcom/http.js @@ -626,38 +626,33 @@ Zotero.HTTP = new function() { // (Approximately) how many seconds to wait if the document is left in the loading state and // pageshow is called before we call pageshow with an incomplete document const LOADING_STATE_TIMEOUT = 120; - - var firedLoadEvent; - /** - * Removes event listener for the load event and deletes the hidden browser - */ - var removeListeners = function() { - hiddenBrowser.removeEventListener(loadEvent, onLoad, true); - if(!dontDelete) Zotero.Browser.deleteHiddenBrowser(hiddenBrowser); - } + var firedLoadEvent = 0; /** * Loads the next page * @inner */ var doLoad = function() { - if(urls.length) { - var url = urls.shift(); + if(currentURL < urls.length) { + var url = urls[currentURL], + hiddenBrowser = hiddenBrowsers[currentURL]; firedLoadEvent = 0; + currentURL++; try { - Zotero.debug("loading "+url); + Zotero.debug("Zotero.HTTP.processDocuments: Loading "+url); hiddenBrowser.loadURI(url); } catch(e) { - removeListeners(); if(exception) { exception(e); return; } else { throw(e); } + } finally { + doLoad(); } } else { - removeListeners(); + if(!dontDelete) Zotero.Browser.deleteHiddenBrowser(hiddenBrowsers); if(done) done(); } }; @@ -666,46 +661,49 @@ Zotero.HTTP = new function() { * Callback to be executed when a page load completes * @inner */ - var onLoad = function() { - var doc = hiddenBrowser.contentDocument; - if(!doc) return; + var onLoad = function(e) { + var hiddenBrowser = e.currentTarget, + doc = hiddenBrowser.contentDocument; + if(!doc || doc !== e.target) return; var url = doc.location.href.toString(); - if(url == "about:blank") return; - if(doc.readyState === "loading" && firedLoadEvent < 120) { - // Try again in a second - firedLoadEvent++; - Zotero.setTimeout(onLoad, 1000); + if(url === "about:blank") return; + if(doc.readyState === "loading" && (firedLoadEvent++) < 120) { + // Try again in a second + Zotero.setTimeout(onLoad.bind(this, e), 1000); return; } - if(url !== prevUrl) { // Just in case it fires too many times - prevUrl = url; - try { - processor(doc); - } catch(e) { - removeListeners(); - if(exception) { - exception(e); - return; - } else { - throw(e); - } + + Zotero.debug("Zotero.HTTP.processDocuments: "+url+" loaded"); + hiddenBrowser.removeEventListener("pageshow", onLoad, true); + + try { + processor(doc); + } catch(e) { + if(exception) { + exception(e); + return; + } else { + throw(e); } + } finally { doLoad(); } }; if(typeof(urls) == "string") urls = [urls]; - var prevUrl; - var loadEvent = "pageshow"; - - var hiddenBrowser = Zotero.Browser.createHiddenBrowser(); - hiddenBrowser.addEventListener(loadEvent, onLoad, true); - if(cookieSandbox) cookieSandbox.attachToBrowser(hiddenBrowser); + var hiddenBrowsers = [], + currentURL = 0; + for(var i=0; i