2011-02-09 03:22:06 +00:00
|
|
|
/*
|
|
|
|
***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
|
|
|
Copyright © 2009 Center for History and New Media
|
|
|
|
George Mason University, Fairfax, Virginia, USA
|
|
|
|
http://zotero.org
|
|
|
|
|
|
|
|
This file is part of Zotero.
|
|
|
|
|
|
|
|
Zotero is free software: you can redistribute it and/or modify
|
2011-05-18 18:34:22 +00:00
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
2011-02-09 03:22:06 +00:00
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Zotero is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-05-18 18:34:22 +00:00
|
|
|
GNU Affero General Public License for more details.
|
2011-02-09 03:22:06 +00:00
|
|
|
|
2011-05-18 18:34:22 +00:00
|
|
|
You should have received a copy of the GNU Affero General Public License
|
2011-02-09 03:22:06 +00:00
|
|
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
***** END LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This object contains the various functions for the interface
|
|
|
|
*/
|
|
|
|
var Zotero_LocateMenu = new function() {
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "ios", "@mozilla.org/network/io-service;1", "nsIIOService");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear and build the locate menu
|
|
|
|
*/
|
2011-02-19 04:19:22 +00:00
|
|
|
this.buildLocateMenu = function() {
|
2011-02-09 03:22:06 +00:00
|
|
|
var locateMenu = document.getElementById('zotero-tb-locate-menu');
|
|
|
|
|
|
|
|
// clear menu
|
|
|
|
while(locateMenu.childElementCount > 0) {
|
|
|
|
locateMenu.removeChild(locateMenu.firstChild);
|
|
|
|
}
|
|
|
|
|
2011-06-06 04:30:06 +00:00
|
|
|
var selectedItems = _getSelectedItems();
|
2011-02-09 03:22:06 +00:00
|
|
|
|
|
|
|
if(selectedItems.length) {
|
2011-03-01 22:40:56 +00:00
|
|
|
_addViewOptions(locateMenu, selectedItems, true, true);
|
2011-02-11 21:55:48 +00:00
|
|
|
|
2011-02-22 00:02:05 +00:00
|
|
|
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
2011-02-11 21:55:48 +00:00
|
|
|
// add engines that are available for selected items
|
|
|
|
if(availableEngines.length) {
|
2011-08-28 20:12:08 +00:00
|
|
|
Zotero_LocateMenu.addLocateEngines(locateMenu, availableEngines, null, true);
|
2011-02-11 21:55:48 +00:00
|
|
|
}
|
2011-02-09 03:22:06 +00:00
|
|
|
} else {
|
|
|
|
// add "no items selected"
|
|
|
|
menuitem = _createMenuItem(Zotero.getString("pane.item.selected.zero"), "no-items-selected");
|
|
|
|
locateMenu.appendChild(menuitem);
|
|
|
|
menuitem.disabled = true;
|
|
|
|
}
|
2011-03-26 21:55:23 +00:00
|
|
|
|
|
|
|
// add separator at end if necessary
|
|
|
|
if(locateMenu.lastChild.tagName !== "menuseparator") {
|
|
|
|
locateMenu.appendChild(document.createElement("menuseparator"));
|
|
|
|
}
|
2011-02-09 03:22:06 +00:00
|
|
|
|
|
|
|
// add installable locate menus, if there are any
|
|
|
|
if(window.Zotero_Browser) {
|
|
|
|
var installableLocateEngines = _getInstallableLocateEngines();
|
|
|
|
} else {
|
|
|
|
var installableLocateEngines = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(installableLocateEngines.length) {
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let locateEngine of installableLocateEngines) {
|
2011-02-09 03:22:06 +00:00
|
|
|
var menuitem = document.createElement("menuitem");
|
|
|
|
menuitem.setAttribute("label", locateEngine.label);
|
2011-02-11 08:07:20 +00:00
|
|
|
menuitem.setAttribute("class", "menuitem-iconic");
|
2011-02-09 03:22:06 +00:00
|
|
|
menuitem.setAttribute("image", locateEngine.image);
|
|
|
|
menuitem.zoteroLocateInfo = locateEngine;
|
2011-02-11 08:07:20 +00:00
|
|
|
menuitem.addEventListener("command", _addLocateEngine, false);
|
2011-02-09 03:22:06 +00:00
|
|
|
|
|
|
|
locateMenu.appendChild(menuitem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuitem = document.createElement("menuitem");
|
|
|
|
menuitem = _createMenuItem(Zotero.getString("locate.manageLocateEngines"), "zotero-manage-locate-menu");
|
2011-02-11 08:07:20 +00:00
|
|
|
menuitem.addEventListener("command", _openLocateEngineManager, false);
|
2011-02-09 03:22:06 +00:00
|
|
|
locateMenu.appendChild(menuitem);
|
|
|
|
}
|
|
|
|
|
2011-02-22 00:02:05 +00:00
|
|
|
/**
|
|
|
|
* Clear the bottom part of the context menu and add locate options
|
|
|
|
* @param {menupopup} menu The menu to add context menu items to
|
2013-04-13 06:53:02 +00:00
|
|
|
* @param {Boolean} showIcons Whether menu items should have associated icons
|
2015-10-31 07:46:47 +00:00
|
|
|
* @return {Promise}
|
2011-02-22 00:02:05 +00:00
|
|
|
*/
|
2015-10-31 07:46:47 +00:00
|
|
|
this.buildContextMenu = Zotero.Promise.coroutine(function* (menu, showIcons) {
|
2011-02-22 00:02:05 +00:00
|
|
|
// get selected items
|
2011-06-06 04:30:06 +00:00
|
|
|
var selectedItems = _getSelectedItems();
|
2011-02-22 00:02:05 +00:00
|
|
|
|
2011-07-11 22:19:10 +00:00
|
|
|
// if no items selected or >20 items selected, stop now
|
|
|
|
if(!selectedItems.length || selectedItems.length > 20) return;
|
2011-02-22 00:02:05 +00:00
|
|
|
|
|
|
|
// add view options
|
2015-10-31 07:46:47 +00:00
|
|
|
yield _addViewOptions(menu, selectedItems, showIcons);
|
2011-02-22 00:02:05 +00:00
|
|
|
|
|
|
|
/*// look for locate engines
|
|
|
|
var availableEngines = _getAvailableLocateEngines(selectedItems);
|
|
|
|
if(availableEngines.length) {
|
|
|
|
// if locate engines are available, make a new submenu
|
|
|
|
var submenu = document.createElement("menu");
|
|
|
|
submenu.setAttribute("zotero-locate", "true");
|
|
|
|
submenu.setAttribute("label", Zotero.getString("locate.locateEngines"));
|
|
|
|
|
|
|
|
// add locate engines to the submenu
|
|
|
|
_addLocateEngines(submenuPopup, availableEngines, true);
|
|
|
|
|
|
|
|
submenu.appendChild(submenuPopup);
|
|
|
|
menu.appendChild(submenu);
|
|
|
|
}*/
|
2015-10-31 07:46:47 +00:00
|
|
|
});
|
2011-02-22 00:02:05 +00:00
|
|
|
|
2011-03-01 22:40:56 +00:00
|
|
|
function _addViewOption(selectedItems, optionName, optionObject, showIcons) {
|
|
|
|
var menuitem = _createMenuItem(Zotero.getString("locate."+optionName+".label"),
|
|
|
|
null, Zotero.getString("locate."+optionName+".tooltip"));
|
|
|
|
if(showIcons) {
|
|
|
|
menuitem.setAttribute("class", "menuitem-iconic");
|
2013-04-14 05:47:05 +00:00
|
|
|
menuitem.style.listStyleImage = "url('"+optionObject.icon+"')";
|
2011-03-01 22:40:56 +00:00
|
|
|
}
|
|
|
|
menuitem.setAttribute("zotero-locate", "true");
|
|
|
|
|
|
|
|
menuitem.addEventListener("command", function(event) {
|
|
|
|
optionObject.handleItems(selectedItems, event);
|
|
|
|
}, false)
|
|
|
|
return menuitem;
|
|
|
|
}
|
|
|
|
|
2011-02-22 00:02:05 +00:00
|
|
|
/**
|
|
|
|
* Add view options to a menu
|
|
|
|
* @param {menupopup} locateMenu The menu to add menu items to
|
|
|
|
* @param {Zotero.Item[]} selectedItems The items to create view options based upon
|
|
|
|
* @param {Boolean} showIcons Whether menu items should have associated icons
|
2011-03-01 22:40:56 +00:00
|
|
|
* @param {Boolean} addExtraOptions Whether to add options that start with "_" below the separator
|
2011-02-22 00:02:05 +00:00
|
|
|
*/
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _addViewOptions = Zotero.Promise.coroutine(function* (locateMenu, selectedItems, showIcons, addExtraOptions) {
|
2011-02-22 00:02:05 +00:00
|
|
|
var optionsToShow = {};
|
|
|
|
|
|
|
|
// check which view options are available
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of selectedItems) {
|
2011-02-22 00:02:05 +00:00
|
|
|
for(var viewOption in ViewOptions) {
|
|
|
|
if(!optionsToShow[viewOption]) {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
optionsToShow[viewOption] = yield ViewOptions[viewOption].canHandleItem(item);
|
2011-02-22 00:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-01 22:40:56 +00:00
|
|
|
// add available view options to menu
|
|
|
|
var lastNode = locateMenu.hasChildNodes() ? locateMenu.firstChild : null;
|
|
|
|
var haveOptions = false;
|
|
|
|
for(var viewOption in optionsToShow) {
|
|
|
|
if(viewOption[0] === "_" || !optionsToShow[viewOption]) continue;
|
|
|
|
locateMenu.insertBefore(_addViewOption(selectedItems, viewOption,
|
|
|
|
ViewOptions[viewOption], showIcons), lastNode);
|
|
|
|
haveOptions = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(haveOptions) {
|
2011-02-22 00:02:05 +00:00
|
|
|
var sep = document.createElement("menuseparator");
|
|
|
|
sep.setAttribute("zotero-locate", "true");
|
2011-03-01 22:40:56 +00:00
|
|
|
locateMenu.insertBefore(sep, lastNode);
|
2011-02-22 00:02:05 +00:00
|
|
|
}
|
|
|
|
|
2011-03-01 22:40:56 +00:00
|
|
|
if(addExtraOptions) {
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let viewOption in optionsToShow) {
|
2011-03-01 22:40:56 +00:00
|
|
|
if(viewOption[0] !== "_" || !optionsToShow[viewOption]) continue;
|
|
|
|
locateMenu.insertBefore(_addViewOption(selectedItems, viewOption.substr(1),
|
|
|
|
ViewOptions[viewOption], showIcons), lastNode);
|
2011-02-22 00:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-22 00:02:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get available locate engines that can handle a set of items
|
|
|
|
* @param {Zotero.Item[]} selectedItems The items to look or locate engines for
|
|
|
|
* @return {Zotero.LocateManater.LocateEngine[]} An array of locate engines capable of handling
|
|
|
|
* the given items
|
|
|
|
*/
|
|
|
|
function _getAvailableLocateEngines(selectedItems) {
|
|
|
|
// check for custom locate engines
|
|
|
|
var customEngines = Zotero.LocateManager.getVisibleEngines();
|
|
|
|
var availableEngines = [];
|
|
|
|
|
|
|
|
// check which engines can translate an item
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let engine of customEngines) {
|
2011-02-22 00:02:05 +00:00
|
|
|
// require a submission for at least one selected item
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of selectedItems) {
|
2011-02-22 00:02:05 +00:00
|
|
|
if(engine.getItemSubmission(item)) {
|
|
|
|
availableEngines.push(engine);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return availableEngines;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add locate engine options to a menu
|
|
|
|
* @param {menupopup} menu The menu to add menu items to
|
2011-08-28 20:12:08 +00:00
|
|
|
* @param {Zotero.LocateManager.LocateEngine[]} engines The list of engines to add to the menu
|
|
|
|
* @param {Function|null} items Function to call to locate items
|
2011-02-22 00:02:05 +00:00
|
|
|
* @param {Boolean} showIcons Whether menu items should have associated icons
|
|
|
|
*/
|
2011-08-28 20:12:08 +00:00
|
|
|
this.addLocateEngines = function(menu, engines, locateFn, showIcons) {
|
|
|
|
if(!locateFn) {
|
|
|
|
locateFn = this.locateItem;
|
|
|
|
}
|
|
|
|
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let engine of engines) {
|
2011-02-22 00:02:05 +00:00
|
|
|
var menuitem = _createMenuItem(engine.name, null, engine.description);
|
|
|
|
menuitem.setAttribute("class", "menuitem-iconic");
|
|
|
|
menuitem.setAttribute("image", engine.icon);
|
|
|
|
menu.appendChild(menuitem);
|
2011-08-28 20:12:08 +00:00
|
|
|
menuitem.addEventListener("command", locateFn, false);
|
2011-02-22 00:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-09 03:22:06 +00:00
|
|
|
/**
|
2011-02-11 08:07:20 +00:00
|
|
|
* Create a new menuitem XUL element
|
2011-02-09 03:22:06 +00:00
|
|
|
*/
|
2011-02-11 08:07:20 +00:00
|
|
|
function _createMenuItem( label, id, tooltiptext ) {
|
|
|
|
var menuitem = document.createElement("menuitem");
|
|
|
|
menuitem.setAttribute("label", label);
|
|
|
|
if(id) menuitem.setAttribute("id", id);
|
|
|
|
if(tooltiptext) menuitem.setAttribute("tooltiptext", tooltiptext);
|
|
|
|
|
|
|
|
return menuitem;
|
2011-02-09 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-02-11 08:07:20 +00:00
|
|
|
* Get any locate engines that can be installed from the current page
|
2011-02-09 03:22:06 +00:00
|
|
|
*/
|
2011-02-11 08:07:20 +00:00
|
|
|
function _getInstallableLocateEngines() {
|
|
|
|
var locateEngines = [];
|
|
|
|
if(!window.Zotero_Browser || !window.Zotero_Browser.tabbrowser) return locateEngines;
|
|
|
|
|
|
|
|
var links = Zotero_Browser.tabbrowser.selectedBrowser.contentDocument.getElementsByTagName("link");
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let link of links) {
|
2011-02-11 08:07:20 +00:00
|
|
|
if(!link.getAttribute) continue;
|
|
|
|
var rel = link.getAttribute("rel");
|
|
|
|
if(rel && rel === "search") {
|
|
|
|
var type = link.getAttribute("type");
|
|
|
|
if(type && type === "application/x-openurl-opensearchdescription+xml") {
|
|
|
|
var label = link.getAttribute("title");
|
|
|
|
if(label) {
|
|
|
|
if(Zotero.LocateManager.getEngineByName(label)) {
|
|
|
|
label = 'Update "'+label+'"';
|
|
|
|
} else {
|
|
|
|
label = 'Add "'+label+'"';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
label = 'Add Locate Engine';
|
|
|
|
}
|
|
|
|
|
|
|
|
locateEngines.push({'label':label,
|
|
|
|
'href':link.getAttribute("href"),
|
|
|
|
'image':Zotero_Browser.tabbrowser.selectedTab.image});
|
|
|
|
}
|
|
|
|
}
|
2011-02-09 03:22:06 +00:00
|
|
|
}
|
2011-02-11 08:07:20 +00:00
|
|
|
|
|
|
|
return locateEngines;
|
2011-02-09 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Locate selected items
|
|
|
|
*/
|
2011-08-28 20:12:08 +00:00
|
|
|
this.locateItem = function(event, selectedItems) {
|
|
|
|
if(!selectedItems) {
|
|
|
|
selectedItems = _getSelectedItems();
|
|
|
|
}
|
2011-02-09 03:22:06 +00:00
|
|
|
|
|
|
|
// find selected engine
|
|
|
|
var selectedEngine = Zotero.LocateManager.getEngineByName(event.target.label);
|
|
|
|
if(!selectedEngine) throw "Selected locate engine not found";
|
|
|
|
|
|
|
|
var urls = [];
|
|
|
|
var postDatas = [];
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of selectedItems) {
|
2011-02-09 03:22:06 +00:00
|
|
|
var submission = selectedEngine.getItemSubmission(item);
|
2011-02-24 04:28:17 +00:00
|
|
|
if(submission) {
|
|
|
|
urls.push(submission.uri.spec);
|
|
|
|
postDatas.push(submission.postData);
|
|
|
|
}
|
2011-02-09 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Zotero.debug("Loading using "+selectedEngine.name);
|
|
|
|
Zotero.debug(urls);
|
2011-03-24 23:23:11 +00:00
|
|
|
ZoteroPane_Local.loadURI(urls, event, postDatas);
|
2011-02-09 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a new locate engine
|
|
|
|
*/
|
2011-02-11 08:07:20 +00:00
|
|
|
function _addLocateEngine(event) {
|
2011-02-09 03:22:06 +00:00
|
|
|
Zotero.LocateManager.addEngine(event.target.zoteroLocateInfo.href,
|
|
|
|
Components.interfaces.nsISearchEngine.TYPE_OPENSEARCH,
|
|
|
|
event.target.zoteroLocateInfo.image, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the locate manager
|
|
|
|
*/
|
2011-02-11 08:07:20 +00:00
|
|
|
function _openLocateEngineManager(event) {
|
2011-02-09 03:22:06 +00:00
|
|
|
window.openDialog('chrome://zotero/content/locateManager.xul',
|
|
|
|
'Zotero Locate Engine Manager',
|
|
|
|
'chrome,centerscreen'
|
|
|
|
);
|
|
|
|
}
|
2011-02-11 08:07:20 +00:00
|
|
|
|
2011-06-06 04:30:06 +00:00
|
|
|
/**
|
|
|
|
* Get the first 50 selected items
|
|
|
|
*/
|
|
|
|
function _getSelectedItems() {
|
|
|
|
var allSelectedItems = ZoteroPane_Local.getSelectedItems();
|
|
|
|
var selectedItems = [];
|
|
|
|
while(selectedItems.length < 50 && allSelectedItems.length) {
|
|
|
|
var item = allSelectedItems.shift();
|
|
|
|
if(!item.isNote()) selectedItems.push(item);
|
|
|
|
}
|
|
|
|
return selectedItems;
|
|
|
|
}
|
|
|
|
|
2011-02-11 08:07:20 +00:00
|
|
|
var ViewOptions = {};
|
|
|
|
|
2011-02-12 21:09:41 +00:00
|
|
|
/**
|
|
|
|
* "View PDF" option
|
|
|
|
*
|
|
|
|
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
|
|
|
* a PDF
|
|
|
|
*/
|
|
|
|
ViewOptions.pdf = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/treeitem-attachment-pdf.png";
|
|
|
|
this._mimeTypes = ["application/pdf"];
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.canHandleItem = function (item) {
|
|
|
|
return _getFirstAttachmentWithMIMEType(item, this._mimeTypes).then((item) => !!item);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
2011-07-11 22:19:10 +00:00
|
|
|
var attachments = [];
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of items) {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var attachment = yield _getFirstAttachmentWithMIMEType(item, this._mimeTypes);
|
2011-07-11 22:19:10 +00:00
|
|
|
if(attachment) attachments.push(attachment.id);
|
2011-02-12 21:09:41 +00:00
|
|
|
}
|
2011-07-11 22:19:10 +00:00
|
|
|
|
|
|
|
ZoteroPane_Local.viewAttachment(attachments, event);
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-12 21:09:41 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _getFirstAttachmentWithMIMEType = Zotero.Promise.coroutine(function* (item, mimeTypes) {
|
2015-03-22 23:51:29 +00:00
|
|
|
var attachments = item.isAttachment() ? [item] : (yield item.getBestAttachments());
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let i = 0; i < attachments.length; i++) {
|
|
|
|
let attachment = attachments[i];
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
if (mimeTypes.indexOf(attachment.attachmentContentType) !== -1
|
2015-03-17 19:14:17 +00:00
|
|
|
&& attachment.attachmentLinkMode !== Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
|
|
|
return attachment;
|
|
|
|
}
|
2011-02-12 21:09:41 +00:00
|
|
|
}
|
|
|
|
return false;
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-12 21:09:41 +00:00
|
|
|
};
|
|
|
|
|
2011-02-11 08:07:20 +00:00
|
|
|
/**
|
|
|
|
* "View Online" option
|
|
|
|
*
|
|
|
|
* Should appear only when an item or an attachment has a URL
|
|
|
|
*/
|
|
|
|
ViewOptions.online = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/locate-view-online.png";
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.canHandleItem = function (item) {
|
|
|
|
return _getURL(item).then((val) => val !== false);
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
2016-10-16 14:24:04 +00:00
|
|
|
var urls = yield Zotero.Promise.all(items.map(item => _getURL(item)));
|
|
|
|
ZoteroPane_Local.loadURI(urls.filter(url => !!url), event);
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _getURL = Zotero.Promise.coroutine(function* (item) {
|
2011-02-11 08:07:20 +00:00
|
|
|
// try url field for item and for attachments
|
2011-02-21 22:27:39 +00:00
|
|
|
var urlField = item.getField('url');
|
|
|
|
if(urlField) {
|
2011-03-26 21:16:07 +00:00
|
|
|
var uri;
|
|
|
|
try {
|
|
|
|
uri = Zotero_LocateMenu.ios.newURI(urlField, null, null);
|
2011-03-29 01:32:22 +00:00
|
|
|
if(uri && uri.host && uri.scheme !== 'file') return urlField;
|
2011-03-26 21:16:07 +00:00
|
|
|
} catch(e) {};
|
2011-02-21 22:27:39 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 08:07:20 +00:00
|
|
|
if(item.isRegularItem()) {
|
|
|
|
var attachments = item.getAttachments();
|
|
|
|
if(attachments) {
|
2011-02-21 22:27:39 +00:00
|
|
|
// look through url fields for non-file:/// attachments
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let attachment of Zotero.Items.get(attachments)) {
|
2011-02-21 22:27:39 +00:00
|
|
|
var urlField = attachment.getField('url');
|
|
|
|
if(urlField) return urlField;
|
2011-02-19 01:48:24 +00:00
|
|
|
}
|
2011-02-21 22:27:39 +00:00
|
|
|
|
|
|
|
}
|
2011-02-19 01:48:24 +00:00
|
|
|
}
|
|
|
|
|
2011-02-11 08:07:20 +00:00
|
|
|
// if no url field, try DOI field
|
|
|
|
var doi = item.getField('DOI');
|
|
|
|
if(doi && typeof doi === "string") {
|
|
|
|
doi = Zotero.Utilities.cleanDOI(doi);
|
|
|
|
if(doi) {
|
|
|
|
return "http://dx.doi.org/" + encodeURIComponent(doi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "View Snapshot" option
|
|
|
|
*
|
|
|
|
* Should appear only when the item is a PDF, or a linked or attached file or web attachment is
|
|
|
|
* a snapshot
|
|
|
|
*/
|
|
|
|
ViewOptions.snapshot = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/treeitem-attachment-snapshot.png";
|
|
|
|
this._mimeTypes = ["text/html", "application/xhtml+xml"];
|
|
|
|
this.canHandleItem = ViewOptions.pdf.canHandleItem;
|
|
|
|
this.handleItems = ViewOptions.pdf.handleItems;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "View File" option
|
|
|
|
*
|
|
|
|
* Should appear only when an item or a linked or attached file or web attachment does not
|
|
|
|
* satisfy the conditions for "View PDF" or "View Snapshot"
|
|
|
|
*/
|
|
|
|
ViewOptions.file = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/treeitem-attachment-file.png";
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.canHandleItem = function (item) {
|
|
|
|
return _getFile(item).then((item) => !!item);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
2011-07-11 22:19:10 +00:00
|
|
|
var attachments = [];
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of items) {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var attachment = yield _getFile(item);
|
2011-07-11 22:19:10 +00:00
|
|
|
if(attachment) attachments.push(attachment.id);
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
2011-07-11 22:19:10 +00:00
|
|
|
|
|
|
|
ZoteroPane_Local.viewAttachment(attachments, event);
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _getFile = Zotero.Promise.coroutine(function* (item) {
|
|
|
|
var attachments = item.isAttachment() ? [item] : (yield item.getBestAttachments());
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let i = 0; i < attachments.length; i++) {
|
|
|
|
let attachment = attachments[i];
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
if (!(yield ViewOptions.snapshot.canHandleItem(attachment))
|
|
|
|
&& !(yield ViewOptions.pdf.canHandleItem(attachment))
|
2011-03-01 22:40:56 +00:00
|
|
|
&& attachment.attachmentLinkMode !== Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
2011-02-11 08:07:20 +00:00
|
|
|
return attachment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Open in External Viewer" option
|
|
|
|
*
|
|
|
|
* Should appear only when an item or a linked or attached file or web attachment can be
|
|
|
|
* viewed by an internal non-native handler and "launchNonNativeFiles" pref is disabled
|
|
|
|
*/
|
|
|
|
ViewOptions.externalViewer = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/locate-external-viewer.png";
|
|
|
|
this.useExternalViewer = true;
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.canHandleItem = Zotero.Promise.coroutine(function* (item) {
|
2011-02-11 08:07:20 +00:00
|
|
|
return (this.useExternalViewer ^ Zotero.Prefs.get('launchNonNativeFiles'))
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
&& (yield _getBestNonNativeAttachment(item));
|
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
2011-07-11 22:19:10 +00:00
|
|
|
var attachments = [];
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of items) {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var attachment = yield _getBestNonNativeAttachment(item);
|
2011-07-11 22:19:10 +00:00
|
|
|
if(attachment) attachments.push(attachment.id);
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
2011-07-11 22:19:10 +00:00
|
|
|
|
|
|
|
ZoteroPane_Local.viewAttachment(attachments, event, false, this.useExternalViewer);
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _getBestNonNativeAttachment = Zotero.Promise.coroutine(function* (item) {
|
|
|
|
var attachments = item.isAttachment() ? [item] : (yield item.getBestAttachments());
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let i = 0; i < attachments.length; i++) {
|
|
|
|
let attachment = attachments[i];
|
2011-03-01 22:40:56 +00:00
|
|
|
if(attachment.attachmentLinkMode !== Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
2014-08-07 22:35:12 +00:00
|
|
|
var path = yield attachment.getFilePathAsync();
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
if (path) {
|
|
|
|
var ext = Zotero.File.getExtension(Zotero.File.pathToFile(path));
|
2016-05-13 19:46:19 +00:00
|
|
|
if(!attachment.attachmentContentType ||
|
|
|
|
Zotero.MIME.hasNativeHandler(attachment.attachmentContentType, ext) ||
|
|
|
|
!Zotero.MIME.hasInternalHandler(attachment.attachmentContentType, ext)) {
|
2011-03-01 22:40:56 +00:00
|
|
|
return false;
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
2011-03-01 22:40:56 +00:00
|
|
|
return attachment;
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Open in Internal Viewer" option
|
|
|
|
*
|
|
|
|
* Should appear only when an item or a linked or attached file or web attachment can be
|
|
|
|
* viewed by an internal non-native handler and "launchNonNativeFiles" pref is enabled
|
|
|
|
*/
|
|
|
|
ViewOptions.internalViewer = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/locate-internal-viewer.png";
|
|
|
|
this.useExternalViewer = false;
|
|
|
|
this.canHandleItem = ViewOptions.externalViewer.canHandleItem;
|
|
|
|
this.handleItems = ViewOptions.externalViewer.handleItems;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Show File" option
|
|
|
|
*
|
|
|
|
* Should appear only when an item is a file or web attachment, or has a linked or attached
|
|
|
|
* file or web attachment
|
|
|
|
*/
|
|
|
|
ViewOptions.showFile = new function() {
|
|
|
|
this.icon = "chrome://zotero/skin/locate-show-file.png";
|
|
|
|
this.useExternalViewer = true;
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.canHandleItem = function (item) {
|
2016-10-15 19:20:09 +00:00
|
|
|
return _getBestFile(item).then(item => !!item);
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.handleItems = Zotero.Promise.coroutine(function* (items, event) {
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of items) {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var attachment = yield _getBestFile(item);
|
2011-02-11 08:07:20 +00:00
|
|
|
if(attachment) {
|
2011-03-24 23:23:11 +00:00
|
|
|
ZoteroPane_Local.showAttachmentInFilesystem(attachment.id);
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
var _getBestFile = Zotero.Promise.coroutine(function* (item) {
|
2011-02-11 08:07:20 +00:00
|
|
|
if(item.isAttachment()) {
|
2011-03-01 22:40:56 +00:00
|
|
|
if(item.attachmentLinkMode === Zotero.Attachments.LINK_MODE_LINKED_URL) return false;
|
2011-02-11 08:07:20 +00:00
|
|
|
return item;
|
|
|
|
} else {
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
return yield item.getBestAttachment();
|
2011-02-11 08:07:20 +00:00
|
|
|
}
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Library Lookup" Option
|
|
|
|
*
|
|
|
|
* Should appear only for regular items
|
|
|
|
*/
|
2011-03-01 22:40:56 +00:00
|
|
|
ViewOptions._libraryLookup = new function() {
|
2011-02-11 08:07:20 +00:00
|
|
|
this.icon = "chrome://zotero/skin/locate-library-lookup.png";
|
2016-10-15 19:20:09 +00:00
|
|
|
this.canHandleItem = function (item) { return Zotero.Promise.resolve(item.isRegularItem()); };
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
this.handleItems = Zotero.Promise.method(function (items, event) {
|
2011-02-11 08:07:20 +00:00
|
|
|
var urls = [];
|
2015-03-17 19:14:17 +00:00
|
|
|
for (let item of items) {
|
2011-02-11 08:07:20 +00:00
|
|
|
if(!item.isRegularItem()) continue;
|
|
|
|
var url = Zotero.OpenURL.resolve(item);
|
|
|
|
if(url) urls.push(url);
|
|
|
|
}
|
2011-03-24 23:23:11 +00:00
|
|
|
ZoteroPane_Local.loadURI(urls, event);
|
Async DB megacommit
Promise-based rewrite of most of the codebase, with asynchronous database and file access -- see https://github.com/zotero/zotero/issues/518 for details.
WARNING: This includes backwards-incompatible schema changes.
An incomplete list of other changes:
- Schema overhaul
- Replace main tables with new versions with updated schema
- Enable real foreign key support and remove previous triggers
- Don't use NULLs for local libraryID, which broke the UNIQUE index
preventing object key duplication. All code (Zotero and third-party)
using NULL for the local library will need to be updated to use 0
instead (already done for Zotero code)
- Add 'compatibility' DB version that can be incremented manually to break DB
compatibility with previous versions. 'userdata' upgrades will no longer
automatically break compatibility.
- Demote creators and tags from first-class objects to item properties
- New API syncing properties
- 'synced'/'version' properties to data objects
- 'etag' to groups
- 'version' to libraries
- Create Zotero.DataObject that other objects inherit from
- Consolidate data object loading into Zotero.DataObjects
- Change object reloading so that only the loaded and changed parts of objects are reloaded, instead of reloading all data from the database (with some exceptions, including item primary data)
- Items and collections now have .parentItem and .parentKey properties, replacing item.getSource() and item.getSourceKey()
- New function Zotero.serial(fn), to wrap an async function such that all calls are run serially
- New function Zotero.Utilities.Internal.forEachChunkAsync(arr, chunkSize, func)
- Add tag selector loading message
- Various API and name changes, since everything was breaking anyway
Known broken things:
- Syncing (will be completely rewritten for API syncing)
- Translation architecture (needs promise-based rewrite)
- Duplicates view
- DB integrity check (from schema changes)
- Dragging (may be difficult to fix)
Lots of other big and little things are certainly broken, particularly with the UI, which can be affected by async code in all sorts of subtle ways.
2014-08-06 21:38:05 +00:00
|
|
|
});
|
2011-02-11 08:07:20 +00:00
|
|
|
};
|
|
|
|
}
|