Merge [3617-3838] from branch to trunk
This commit is contained in:
parent
51e11b9071
commit
337b16361a
|
@ -60,9 +60,6 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
document.getElementById("multiple-sources-button").label = Zotero.getString("citation.multipleSources");
|
document.getElementById("multiple-sources-button").label = Zotero.getString("citation.multipleSources");
|
||||||
document.getElementById("show-editor-button").label = Zotero.getString("citation.showEditor");
|
document.getElementById("show-editor-button").label = Zotero.getString("citation.showEditor");
|
||||||
|
|
||||||
if(Zotero.isWin) {
|
|
||||||
document.getElementById("zotero-select-items-container").style.border = "1px solid black";
|
|
||||||
}
|
|
||||||
io = window.arguments[0].wrappedJSObject;
|
io = window.arguments[0].wrappedJSObject;
|
||||||
|
|
||||||
// find accept button
|
// find accept button
|
||||||
|
@ -135,6 +132,15 @@ var Zotero_Citation_Dialog = new function () {
|
||||||
|
|
||||||
_updateAccept();
|
_updateAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Center citation popups manually after a delay when using a popup, since
|
||||||
|
// popups aren't resizable and there might be persisted positions
|
||||||
|
if (Zotero.Integration.usePopup) {
|
||||||
|
document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
||||||
|
setTimeout(function () {
|
||||||
|
window.centerWindowOnScreen();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -124,6 +124,15 @@ var ZoteroAdvancedSearch = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.startDrag = function (event, element) {
|
||||||
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
||||||
|
nsDragAndDrop.startDrag(event, element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.onDragStart(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function onUnload() {
|
function onUnload() {
|
||||||
// Unregister search from Notifier
|
// Unregister search from Notifier
|
||||||
if (this.itemsView) {
|
if (this.itemsView) {
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
<tree id="zotero-items-tree" flex="1" hidecolumnpicker="true" seltype="multiple"
|
<tree id="zotero-items-tree" flex="1" hidecolumnpicker="true" seltype="multiple"
|
||||||
ondblclick="ZoteroAdvancedSearch.onDblClick(event, this)"
|
ondblclick="ZoteroAdvancedSearch.onDblClick(event, this)"
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') { nsDragAndDrop.startDrag(event, ZoteroAdvancedSearch.itemsView); }">
|
ondraggesture="if (event.target.localName == 'treechildren') { Zotero.debug('starting'); ZoteroAdvancedSearch.startDrag(event, ZoteroAdvancedSearch.itemsView); }">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
id="zotero-items-column-title" primary="true"
|
id="zotero-items-column-title" primary="true"
|
||||||
|
|
|
@ -112,16 +112,12 @@ var Zotero_File_Interface_Bibliography = new function() {
|
||||||
}
|
}
|
||||||
document.getElementById("fields").label = Zotero.getString("integration."+formatOption+".label");
|
document.getElementById("fields").label = Zotero.getString("integration."+formatOption+".label");
|
||||||
document.getElementById("fields-caption").textContent = Zotero.getString("integration."+formatOption+".caption");
|
document.getElementById("fields-caption").textContent = Zotero.getString("integration."+formatOption+".caption");
|
||||||
|
|
||||||
if(Zotero.isWin) {
|
|
||||||
// add border on Windows
|
|
||||||
document.getElementById("zotero-doc-prefs-dialog").style.border = "1px solid black";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center popup manually after a delay on Windows, since window
|
// Center citation popups manually after a delay when using a popup, since
|
||||||
// isn't resizable and there might be a persisted position
|
// popups aren't resizable and there might be persisted positions
|
||||||
if (Zotero.isWin) {
|
if (Zotero.Integration.usePopup) {
|
||||||
|
document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.centerWindowOnScreen();
|
window.centerWindowOnScreen();
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
|
@ -39,9 +39,6 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
function load() {
|
function load() {
|
||||||
document.getElementById('editor').format = "Integration";
|
document.getElementById('editor').format = "Integration";
|
||||||
|
|
||||||
if(Zotero.isWin) {
|
|
||||||
document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
|
||||||
}
|
|
||||||
bibEditInterface = window.arguments[0].wrappedJSObject;
|
bibEditInterface = window.arguments[0].wrappedJSObject;
|
||||||
itemSet = bibEditInterface.getItemSet();
|
itemSet = bibEditInterface.getItemSet();
|
||||||
|
|
||||||
|
@ -50,6 +47,15 @@ var Zotero_Bibliography_Dialog = new function () {
|
||||||
|
|
||||||
// load bibliography entires
|
// load bibliography entires
|
||||||
_loadItems();
|
_loadItems();
|
||||||
|
|
||||||
|
// Center citation popups manually after a delay when using a popup, since
|
||||||
|
// popups aren't resizable and there might be persisted positions
|
||||||
|
if (Zotero.Integration.usePopup) {
|
||||||
|
document.getElementsByTagName("dialog")[0].style.border = "1px solid black";
|
||||||
|
setTimeout(function () {
|
||||||
|
window.centerWindowOnScreen();
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1728,6 +1728,39 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.startDrag = function (event, element) {
|
||||||
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
||||||
|
nsDragAndDrop.startDrag(event, element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
element.onDragStart(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.dragEnter = function (event, element) {
|
||||||
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return element.onDragEnter(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.dragOver = function (event, element) {
|
||||||
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
||||||
|
return nsDragAndDrop.dragOver(event, element);
|
||||||
|
}
|
||||||
|
return element.onDragOver(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.dragDrop = function (event, element) {
|
||||||
|
if (Zotero.isFx2 || Zotero.isFx30) {
|
||||||
|
return nsDragAndDrop.drop(event, element);
|
||||||
|
}
|
||||||
|
return element.onDrop(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loads a URL following the standard modifier key behavior
|
* Loads a URL following the standard modifier key behavior
|
||||||
* (e.g. meta-click == new background tab, meta-shift-click == new front tab,
|
* (e.g. meta-click == new background tab, meta-shift-click == new front tab,
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
<script src="timelineInterface.js"/>
|
<script src="timelineInterface.js"/>
|
||||||
<script src="recognizePDF.js"/>
|
<script src="recognizePDF.js"/>
|
||||||
<script src="browser.js"/>
|
<script src="browser.js"/>
|
||||||
<script src="chrome://global/content/nsDragAndDrop.js"/>
|
|
||||||
<script src="chrome://global/content/nsTransferable.js"/>
|
|
||||||
|
|
||||||
<commandset id="mainCommandSet">
|
<commandset id="mainCommandSet">
|
||||||
<command id="cmd_zotero_search" oncommand="ZoteroPane.search();"/>
|
<command id="cmd_zotero_search" oncommand="ZoteroPane.search();"/>
|
||||||
|
@ -150,10 +148,12 @@
|
||||||
<tree id="zotero-collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu"
|
<tree id="zotero-collections-tree" hidecolumnpicker="true" context="zotero-collectionmenu"
|
||||||
onmouseover="ZoteroPane.collectionsView.setHighlightedRows();"
|
onmouseover="ZoteroPane.collectionsView.setHighlightedRows();"
|
||||||
ondblclick="ZoteroPane.onDoubleClick(event, this);"
|
ondblclick="ZoteroPane.onDoubleClick(event, this);"
|
||||||
onselect="ZoteroPane.onCollectionSelected();" seltype="single"
|
|
||||||
ondragdrop="nsDragAndDrop.drop(event, ZoteroPane.collectionsView)"
|
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event, ZoteroPane.collectionsView);"
|
|
||||||
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
||||||
|
onselect="ZoteroPane.onCollectionSelected();" seltype="single"
|
||||||
|
ondraggesture="if (event.target.localName == 'treechildren') { ZoteroPane.startDrag(event, ZoteroPane.collectionsView); }"
|
||||||
|
ondragenter="return ZoteroPane.dragEnter(event, ZoteroPane.collectionsView)"
|
||||||
|
ondragover="return ZoteroPane.dragOver(event, ZoteroPane.collectionsView)"
|
||||||
|
ondragdrop="return ZoteroPane.dragDrop(event, ZoteroPane.collectionsView)"
|
||||||
flex="1">
|
flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
|
@ -213,9 +213,10 @@
|
||||||
onfocus="if (ZoteroPane.itemsView.rowCount && !ZoteroPane.itemsView.selection.count) { ZoteroPane.itemsView.selection.select(0); }"
|
onfocus="if (ZoteroPane.itemsView.rowCount && !ZoteroPane.itemsView.selection.count) { ZoteroPane.itemsView.selection.select(0); }"
|
||||||
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
||||||
onselect="ZoteroPane.itemSelected();"
|
onselect="ZoteroPane.itemSelected();"
|
||||||
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ZoteroPane.itemsView);"
|
ondraggesture="if (event.target.localName == 'treechildren') { ZoteroPane.startDrag(event, ZoteroPane.itemsView); }"
|
||||||
ondragover="nsDragAndDrop.dragOver(event, ZoteroPane.itemsView)"
|
ondragenter="return ZoteroPane.dragEnter(event, ZoteroPane.itemsView)"
|
||||||
ondragdrop="nsDragAndDrop.drop(event, ZoteroPane.itemsView)"
|
ondragover="return ZoteroPane.dragOver(event, ZoteroPane.itemsView)"
|
||||||
|
ondragdrop="return ZoteroPane.dragDrop(event, ZoteroPane.itemsView)"
|
||||||
flex="1">
|
flex="1">
|
||||||
<treecols>
|
<treecols>
|
||||||
<treecol
|
<treecol
|
||||||
|
|
|
@ -42,15 +42,6 @@ function doLoad()
|
||||||
|
|
||||||
collectionsView = new Zotero.CollectionTreeView();
|
collectionsView = new Zotero.CollectionTreeView();
|
||||||
document.getElementById('zotero-collections-tree').view = collectionsView;
|
document.getElementById('zotero-collections-tree').view = collectionsView;
|
||||||
|
|
||||||
// Center citation popups manually after a delay on Windows, since windows
|
|
||||||
// aren't resizable and there might be persisted positions
|
|
||||||
if (Zotero.isWin &&
|
|
||||||
window.document.documentURI != 'chrome://zotero/content/selectItemsDialog.xul') {
|
|
||||||
setTimeout(function () {
|
|
||||||
window.centerWindowOnScreen();
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function doUnload()
|
function doUnload()
|
||||||
|
|
|
@ -48,6 +48,10 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
var title = file.leafName;
|
var title = file.leafName;
|
||||||
|
|
||||||
|
if (!file.isFile()) {
|
||||||
|
throw ("'" + title + "' must be a file in Zotero.Attachments.importFromFile()");
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.DB.beginTransaction();
|
Zotero.DB.beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -61,13 +65,10 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
// Create directory for attachment files within storage directory
|
// Create directory for attachment files within storage directory
|
||||||
var destDir = this.createDirectoryForItem(itemID);
|
var destDir = this.createDirectoryForItem(itemID);
|
||||||
|
|
||||||
file.copyTo(destDir, null);
|
file.copyTo(destDir, null);
|
||||||
|
|
||||||
// Point to copied file
|
// Point to copied file
|
||||||
var newFile = Components.classes["@mozilla.org/file/local;1"]
|
var newFile = destDir.clone();
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
newFile.initWithFile(destDir);
|
|
||||||
newFile.append(title);
|
newFile.append(title);
|
||||||
|
|
||||||
var mimeType = Zotero.MIME.getMIMETypeFromFile(newFile);
|
var mimeType = Zotero.MIME.getMIMETypeFromFile(newFile);
|
||||||
|
@ -141,13 +142,13 @@ Zotero.Attachments = new function(){
|
||||||
var itemID = attachmentItem.save();
|
var itemID = attachmentItem.save();
|
||||||
attachmentItem = Zotero.Items.get(itemID)
|
attachmentItem = Zotero.Items.get(itemID)
|
||||||
|
|
||||||
var newFile = this.getStorageDirectory(itemID);
|
|
||||||
var newName = newFile.leafName;
|
|
||||||
|
|
||||||
var storageDir = Zotero.getStorageDirectory();
|
var storageDir = Zotero.getStorageDirectory();
|
||||||
file.parent.copyTo(storageDir, newName);
|
var destDir = this.getStorageDirectory(itemID);
|
||||||
|
_moveOrphanedDirectory(destDir);
|
||||||
|
file.parent.copyTo(storageDir, destDir.leafName);
|
||||||
|
|
||||||
// Point to copied file
|
// Point to copied file
|
||||||
|
var newFile = destDir.clone();
|
||||||
newFile.append(file.leafName);
|
newFile.append(file.leafName);
|
||||||
|
|
||||||
attachmentItem.attachmentPath = this.getPath(newFile, this.LINK_MODE_IMPORTED_URL);
|
attachmentItem.attachmentPath = this.getPath(newFile, this.LINK_MODE_IMPORTED_URL);
|
||||||
|
@ -182,6 +183,8 @@ Zotero.Attachments = new function(){
|
||||||
Zotero.debug('Importing attachment from URL');
|
Zotero.debug('Importing attachment from URL');
|
||||||
|
|
||||||
// Throw error on invalid URLs
|
// Throw error on invalid URLs
|
||||||
|
//
|
||||||
|
// TODO: allow other schemes
|
||||||
var urlRe = /^https?:\/\/[^\s]*$/;
|
var urlRe = /^https?:\/\/[^\s]*$/;
|
||||||
var matches = urlRe.exec(url);
|
var matches = urlRe.exec(url);
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
|
@ -274,9 +277,7 @@ Zotero.Attachments = new function(){
|
||||||
// Create a new folder for this item in the storage directory
|
// Create a new folder for this item in the storage directory
|
||||||
var destDir = Zotero.Attachments.createDirectoryForItem(itemID);
|
var destDir = Zotero.Attachments.createDirectoryForItem(itemID);
|
||||||
|
|
||||||
var file = Components.classes["@mozilla.org/file/local;1"].
|
var file = destDir.clone();
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
file.initWithFile(destDir);
|
|
||||||
file.append(fileName);
|
file.append(fileName);
|
||||||
|
|
||||||
wbp.progressListener = new Zotero.WebProgressFinishListener(function(){
|
wbp.progressListener = new Zotero.WebProgressFinishListener(function(){
|
||||||
|
@ -890,9 +891,12 @@ Zotero.Attachments = new function(){
|
||||||
* Create directory for attachment files within storage directory
|
* Create directory for attachment files within storage directory
|
||||||
*
|
*
|
||||||
* @param integer itemID Item id
|
* @param integer itemID Item id
|
||||||
|
*
|
||||||
|
* If a directory exists with the same name, move it to orphaned-files
|
||||||
*/
|
*/
|
||||||
function createDirectoryForItem(itemID) {
|
function createDirectoryForItem(itemID) {
|
||||||
var dir = this.getStorageDirectory(itemID);
|
var dir = this.getStorageDirectory(itemID);
|
||||||
|
_moveOrphanedDirectory(dir);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||||
}
|
}
|
||||||
|
@ -1040,6 +1044,63 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If directory exists and is non-empty, move it to orphaned-files directory
|
||||||
|
*
|
||||||
|
* If empty, just remove it
|
||||||
|
*/
|
||||||
|
function _moveOrphanedDirectory(dir) {
|
||||||
|
if (!dir.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = dir.clone();
|
||||||
|
|
||||||
|
var files = dir.directoryEntries;
|
||||||
|
files.QueryInterface(Components.interfaces.nsIDirectoryEnumerator);
|
||||||
|
if (!files.hasMoreElements()) {
|
||||||
|
dir.remove(false);
|
||||||
|
}
|
||||||
|
files.close();
|
||||||
|
|
||||||
|
// Create orphaned-files directory if it doesn't exist
|
||||||
|
var orphaned = Zotero.getZoteroDirectory();
|
||||||
|
orphaned.append('orphaned-files');
|
||||||
|
if (!orphaned.exists()) {
|
||||||
|
orphaned.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find unique filename for orphaned file
|
||||||
|
var orphanTarget = orphaned.clone();
|
||||||
|
orphanTarget.append(dir.leafName);
|
||||||
|
var newName = null;
|
||||||
|
if (orphanTarget.exists()) {
|
||||||
|
try {
|
||||||
|
orphanTarget.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
||||||
|
newName = orphanTarget.leafName;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// DEBUG: Work around createUnique() brokenness on Windows
|
||||||
|
// as of Fx3.0.3 (https://bugzilla.mozilla.org/show_bug.cgi?id=452217)
|
||||||
|
//
|
||||||
|
// We just delete the conflicting file
|
||||||
|
if (Zotero.isWin && e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
|
||||||
|
orphanTarget.remove(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newName) {
|
||||||
|
orphanTarget.remove(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move target to orphaned files directory
|
||||||
|
dir.moveTo(orphaned, newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new item of type 'attachment' and add to the itemAttachments table
|
* Create a new item of type 'attachment' and add to the itemAttachments table
|
||||||
*
|
*
|
||||||
|
|
|
@ -74,9 +74,59 @@ Zotero.CollectionTreeView.prototype.setTree = function(treebox)
|
||||||
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
|
var matches = lastViewedFolder.match(/^(?:(C|S)([0-9]+)|L)$/);
|
||||||
var select = 0;
|
var select = 0;
|
||||||
if (matches) {
|
if (matches) {
|
||||||
if (matches[1] == 'C' && this._collectionRowMap[matches[2]]) {
|
if (matches[1] == 'C') {
|
||||||
|
if (this._collectionRowMap[matches[2]]) {
|
||||||
select = this._collectionRowMap[matches[2]];
|
select = this._collectionRowMap[matches[2]];
|
||||||
}
|
}
|
||||||
|
// Search recursively
|
||||||
|
else {
|
||||||
|
var path = [];
|
||||||
|
var failsafe = 10; // Only go up ten levels
|
||||||
|
var lastCol = matches[2];
|
||||||
|
do {
|
||||||
|
failsafe--;
|
||||||
|
var col = Zotero.Collections.get(lastCol);
|
||||||
|
if (!col) {
|
||||||
|
var msg = "Last-viewed collection not found";
|
||||||
|
Zotero.debug(msg);
|
||||||
|
path = [];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var par = col.getParent();
|
||||||
|
if (!par) {
|
||||||
|
var msg = "Parent collection not found in "
|
||||||
|
+ "Zotero.CollectionTreeView.setTree()";
|
||||||
|
Zotero.debug(msg, 1);
|
||||||
|
Components.utils.reportError(msg);
|
||||||
|
path = [];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
lastCol = par;
|
||||||
|
path.push(lastCol);
|
||||||
|
}
|
||||||
|
while (!this._collectionRowMap[lastCol] && failsafe > 0)
|
||||||
|
if (path.length) {
|
||||||
|
for (var i=path.length-1; i>=0; i--) {
|
||||||
|
var id = path[i];
|
||||||
|
var row = this._collectionRowMap[id];
|
||||||
|
if (!row) {
|
||||||
|
var msg = "Collection not found in tree in "
|
||||||
|
+ "Zotero.CollectionTreeView.setTree()";
|
||||||
|
Zotero.debug(msg, 1);
|
||||||
|
Components.utils.reportError(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!this.isContainerOpen(row)) {
|
||||||
|
this.toggleOpenState(row);
|
||||||
|
if (this._collectionRowMap[matches[2]]) {
|
||||||
|
select = this._collectionRowMap[matches[2]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (matches[1] == 'S' && this._searchRowMap[matches[2]]) {
|
else if (matches[1] == 'S' && this._searchRowMap[matches[2]]) {
|
||||||
select = this._searchRowMap[matches[2]];
|
select = this._searchRowMap[matches[2]];
|
||||||
}
|
}
|
||||||
|
@ -622,39 +672,67 @@ Zotero.CollectionTreeCommandController.prototype.onEvent = function(evt)
|
||||||
///
|
///
|
||||||
/// Drag-and-drop functions:
|
/// Drag-and-drop functions:
|
||||||
/// canDrop() and drop() are for nsITreeView
|
/// canDrop() and drop() are for nsITreeView
|
||||||
/// onDragStart(), getSupportedFlavours(), and onDrop() for nsDragAndDrop.js + nsTransferable.js
|
/// onDragStart(), getSupportedFlavours(), and onDrop() for nsDragAndDrop.js
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a drag using nsDragAndDrop.js or HTML 5 Drag and Drop
|
||||||
|
*/
|
||||||
|
Zotero.CollectionTreeView.prototype.onDragStart = function(event, transferData, action) {
|
||||||
|
var collectionID = this._getItemAtRow(this.selection.currentIndex).ref.id;
|
||||||
|
|
||||||
|
// Use nsDragAndDrop.js interface for Firefox 2 and Firefox 3.0
|
||||||
|
var oldMethod = Zotero.isFx2 || Zotero.isFx30;
|
||||||
|
|
||||||
|
if (oldMethod) {
|
||||||
|
transferData.data = new TransferData();
|
||||||
|
transferData.data.addDataForFlavour("zotero/collection", collectionID);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.dataTransfer.setData("zotero/collection", collectionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the supported drag flavors
|
||||||
|
*
|
||||||
|
* Called by nsDragAndDrop.js
|
||||||
|
*/
|
||||||
|
Zotero.CollectionTreeView.prototype.getSupportedFlavours = function () {
|
||||||
|
var flavors = new FlavourSet();
|
||||||
|
flavors.appendFlavour("zotero/collection");
|
||||||
|
flavors.appendFlavour("zotero/item");
|
||||||
|
flavors.appendFlavour("zotero/item-xml");
|
||||||
|
flavors.appendFlavour("text/x-moz-url");
|
||||||
|
flavors.appendFlavour("application/x-moz-file", "nsIFile");
|
||||||
|
return flavors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called while a drag is over the tree.
|
* Called while a drag is over the tree.
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.canDrop = function(row, orient)
|
Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
|
||||||
{
|
{
|
||||||
// workaround... two different services call canDrop
|
//Zotero.debug("Row is " + row + "; orient is " + orient);
|
||||||
// (nsDragAndDrop, and the tree) -- this is for the former,
|
|
||||||
// used when dragging between windows
|
// Two different services call canDrop, nsDragAndDrop and the tree
|
||||||
|
// This is for the former, used when dragging between windows
|
||||||
if (typeof row == 'object') {
|
if (typeof row == 'object') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zotero.debug('Row is ' + row);
|
if (!dragData) {
|
||||||
//Zotero.debug('Orient is ' + orient);
|
var dragData = Zotero.DragDrop.getDragData(this);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dataSet = nsTransferable.get(this.getSupportedFlavours(),nsDragAndDrop.getDragData, true);
|
|
||||||
}
|
}
|
||||||
catch (e)
|
if (!dragData) {
|
||||||
{
|
|
||||||
//a work around a limitation in nsDragAndDrop.js -- the mDragSession is not set until the drag moves over another control.
|
|
||||||
//(this will only happen if the first drag is from the collection list)
|
|
||||||
nsDragAndDrop.mDragSession = nsDragAndDrop.mDragService.getCurrentSession();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
var dataType = dragData.dataType;
|
||||||
var data = dataSet.first.first;
|
var data = dragData.data;
|
||||||
var dataType = data.flavour.contentType;
|
|
||||||
|
|
||||||
// For dropping collections onto root level
|
// For dropping collections onto root level
|
||||||
if (orient == 1 && row == 0 && dataType == 'zotero/collection') {
|
if (orient == 1 && row == 0 && dataType == 'zotero/collection') {
|
||||||
|
@ -665,7 +743,7 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient)
|
||||||
var rowCollection = this._getItemAtRow(row).ref; //the collection we are dragging over
|
var rowCollection = this._getItemAtRow(row).ref; //the collection we are dragging over
|
||||||
|
|
||||||
if (dataType == 'zotero/item') {
|
if (dataType == 'zotero/item') {
|
||||||
var ids = data.data.split(',');
|
var ids = data;
|
||||||
for each(var id in ids)
|
for each(var id in ids)
|
||||||
{
|
{
|
||||||
var item = Zotero.Items.get(id);
|
var item = Zotero.Items.get(id);
|
||||||
|
@ -698,15 +776,16 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Don't allow folder drag
|
// Don't allow folder drag
|
||||||
if (dataType == 'application/x-moz-file' && data.data.isDirectory()) {
|
if (dataType == 'application/x-moz-file' && data[0].isDirectory()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (dataType == 'zotero/collection'
|
else if (dataType == 'zotero/collection'
|
||||||
&& data.data != rowCollection.id
|
// Collections cannot be dropped on themselves, nor in their children
|
||||||
&& !Zotero.Collections.get(data.data).hasDescendent('collection', rowCollection.id)) {
|
&& data[0] != rowCollection.id
|
||||||
return true;//collections cannot be dropped on themselves, nor in their children
|
&& !Zotero.Collections.get(data[0]).hasDescendent('collection', rowCollection.id)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -717,25 +796,26 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient)
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
||||||
{
|
{
|
||||||
var dataSet = nsTransferable.get(this.getSupportedFlavours(),nsDragAndDrop.getDragData, true);
|
var dragData = Zotero.DragDrop.getDragData(this);
|
||||||
var data = dataSet.first.first;
|
|
||||||
var dataType = data.flavour.contentType;
|
|
||||||
|
|
||||||
if (!this.canDrop(row, orient)) {
|
if (!this.canDrop(row, orient, dragData)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dataType = dragData.dataType;
|
||||||
|
var data = dragData.data;
|
||||||
|
|
||||||
if(dataType == 'zotero/collection')
|
if(dataType == 'zotero/collection')
|
||||||
{
|
{
|
||||||
var targetCollectionID;
|
var targetCollectionID;
|
||||||
if(this._getItemAtRow(row).isCollection())
|
if(this._getItemAtRow(row).isCollection())
|
||||||
targetCollectionID = this._getItemAtRow(row).ref.id;
|
targetCollectionID = this._getItemAtRow(row).ref.id;
|
||||||
var droppedCollection = Zotero.Collections.get(data.data);
|
var droppedCollection = Zotero.Collections.get(data[0]);
|
||||||
droppedCollection.parent = targetCollectionID;
|
droppedCollection.parent = targetCollectionID;
|
||||||
droppedCollection.save();
|
droppedCollection.save();
|
||||||
}
|
}
|
||||||
else if (dataType == 'zotero/item') {
|
else if (dataType == 'zotero/item') {
|
||||||
var ids = data.data.split(',');
|
var ids = data;
|
||||||
if (ids.length < 1) {
|
if (ids.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -769,7 +849,6 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') {
|
else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') {
|
||||||
|
@ -782,12 +861,11 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
||||||
|
|
||||||
var unlock = Zotero.Notifier.begin(true);
|
var unlock = Zotero.Notifier.begin(true);
|
||||||
try {
|
try {
|
||||||
var dataList = dataSet.dataList;
|
for (var i=0; i<data.length; i++) {
|
||||||
for (var i=0, len=dataList.length; i<len; i++) {
|
var file = data[i];
|
||||||
var file = dataList[i].first.data;
|
|
||||||
|
|
||||||
if (dataType == 'text/x-moz-url') {
|
if (dataType == 'text/x-moz-url') {
|
||||||
var url = file.split("\n")[0];
|
var url = data[i];
|
||||||
|
|
||||||
if (url.indexOf('file:///') == 0) {
|
if (url.indexOf('file:///') == 0) {
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
|
@ -840,35 +918,38 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Begin a drag
|
|
||||||
*/
|
|
||||||
Zotero.CollectionTreeView.prototype.onDragStart = function(evt,transferData,action)
|
|
||||||
{
|
|
||||||
transferData.data=new TransferData();
|
|
||||||
|
|
||||||
//attach ID
|
/*
|
||||||
transferData.data.addDataForFlavour("zotero/collection",this._getItemAtRow(this.selection.currentIndex).ref.id);
|
* Called by HTML 5 Drag and Drop when dragging over the tree
|
||||||
|
*/
|
||||||
|
Zotero.CollectionTreeView.prototype.onDragEnter = function (event) {
|
||||||
|
Zotero.debug("Storing current drag data");
|
||||||
|
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the supported drag flavors
|
|
||||||
*/
|
|
||||||
Zotero.CollectionTreeView.prototype.getSupportedFlavours = function ()
|
|
||||||
{
|
|
||||||
var flavors = new FlavourSet();
|
|
||||||
flavors.appendFlavour("zotero/collection");
|
|
||||||
flavors.appendFlavour("zotero/item");
|
|
||||||
flavors.appendFlavour("zotero/item-xml");
|
|
||||||
flavors.appendFlavour("text/x-moz-url");
|
|
||||||
flavors.appendFlavour("application/x-moz-file", "nsIFile");
|
|
||||||
return flavors;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called by nsDragAndDrop.js for any sort of drop on the tree
|
* Called by nsDragAndDrop.js and HTML 5 Drag and Drop when dragging over the tree
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.onDrop = function (evt,dropdata,session) { }
|
Zotero.CollectionTreeView.prototype.onDragOver = function (event, dropdata, session) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by nsDragAndDrop.js and HTML 5 Drag and Drop when dropping onto the tree
|
||||||
|
*/
|
||||||
|
Zotero.CollectionTreeView.prototype.onDrop = function (event, dropdata, session) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zotero.CollectionTreeView.prototype.onDragExit = function (event) {
|
||||||
|
Zotero.debug("Clearing drag data");
|
||||||
|
Zotero.DragDrop.currentDataTransfer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
|
|
|
@ -776,7 +776,7 @@ Zotero.DBConnection.prototype.backupDatabase = function (suffix) {
|
||||||
Zotero.DBConnection.prototype.startDummyStatement = function () {
|
Zotero.DBConnection.prototype.startDummyStatement = function () {
|
||||||
try {
|
try {
|
||||||
if (!this._dummyConnection) {
|
if (!this._dummyConnection) {
|
||||||
this._debug("Opening database '" + this._dbName + " for dummy statement");
|
this._debug("Opening database '" + this._dbName + "' for dummy statement");
|
||||||
// Get the storage service
|
// Get the storage service
|
||||||
var store = Components.classes["@mozilla.org/storage/service;1"].
|
var store = Components.classes["@mozilla.org/storage/service;1"].
|
||||||
getService(Components.interfaces.mozIStorageService);
|
getService(Components.interfaces.mozIStorageService);
|
||||||
|
|
|
@ -414,10 +414,14 @@ Zotero.Fulltext = new function(){
|
||||||
proc.init(_pdfInfo);
|
proc.init(_pdfInfo);
|
||||||
|
|
||||||
var args = [file.path, infoFile.path];
|
var args = [file.path, infoFile.path];
|
||||||
|
try {
|
||||||
proc.run(true, args, args.length);
|
proc.run(true, args, args.length);
|
||||||
|
|
||||||
var totalPages = this.getTotalPagesFromFile(itemID);
|
var totalPages = this.getTotalPagesFromFile(itemID);
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.debug("Error running pdfinfo");
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
Zotero.debug(this.pdfInfoName + " is not available");
|
Zotero.debug(this.pdfInfoName + " is not available");
|
||||||
}
|
}
|
||||||
|
@ -443,7 +447,13 @@ Zotero.Fulltext = new function(){
|
||||||
var pagesIndexed = Math.min(maxPages, totalPages);
|
var pagesIndexed = Math.min(maxPages, totalPages);
|
||||||
}
|
}
|
||||||
args.push(file.path, cacheFile.path);
|
args.push(file.path, cacheFile.path);
|
||||||
|
try {
|
||||||
proc.run(true, args, args.length);
|
proc.run(true, args, args.length);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.debug("Error running pdftotext");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!cacheFile.exists()) {
|
if (!cacheFile.exists()) {
|
||||||
Zotero.debug("Cache file doesn't exist!");
|
Zotero.debug("Cache file doesn't exist!");
|
||||||
|
|
|
@ -37,6 +37,10 @@ Zotero.Integration = new function() {
|
||||||
this.handleHeader = handleHeader;
|
this.handleHeader = handleHeader;
|
||||||
this.handleEnvelope = handleEnvelope;
|
this.handleEnvelope = handleEnvelope;
|
||||||
|
|
||||||
|
this.__defineGetter__("usePopup", function () {
|
||||||
|
return !Zotero.isMac && !Zotero.Prefs.get("integration.realWindow");
|
||||||
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initializes a very rudimentary web server used for SOAP RPC
|
* initializes a very rudimentary web server used for SOAP RPC
|
||||||
*/
|
*/
|
||||||
|
@ -795,10 +799,12 @@ Zotero.Integration.SOAP_Compat = new function() {
|
||||||
io.useBookmarks = session.prefs.fieldType;
|
io.useBookmarks = session.prefs.fieldType;
|
||||||
}
|
}
|
||||||
|
|
||||||
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
watcher.openWindow(
|
||||||
.getService(Components.interfaces.nsIWindowWatcher)
|
null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
||||||
.openWindow(null, 'chrome://zotero/content/integrationDocPrefs.xul', '',
|
'chrome,modal,centerscreen'
|
||||||
'chrome,modal,centerscreen' + (Zotero.isWin ? ',popup' : ''), io, true);
|
+ (Zotero.Integration.usePopup ? ',popup' : ''),
|
||||||
|
io, true
|
||||||
|
);
|
||||||
session.prefs.useEndnotes = io.useEndnotes;
|
session.prefs.useEndnotes = io.useEndnotes;
|
||||||
session.prefs.fieldType = io.useBookmarks;
|
session.prefs.fieldType = io.useBookmarks;
|
||||||
session.setStyle(io.style, session.prefs);
|
session.setStyle(io.style, session.prefs);
|
||||||
|
@ -1163,8 +1169,12 @@ Zotero.Integration.Session.prototype.editCitation = function(index, citation) {
|
||||||
|
|
||||||
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||||
.getService(Components.interfaces.nsIWindowWatcher)
|
.getService(Components.interfaces.nsIWindowWatcher)
|
||||||
.openWindow(null, 'chrome://zotero/content/addCitationDialog.xul', '',
|
.openWindow(
|
||||||
'chrome,modal,centerscreen,resizable=yes' + (Zotero.isWin ? ',popup' : ''), io);
|
null, 'chrome://zotero/content/addCitationDialog.xul', '',
|
||||||
|
'chrome,modal,centerscreen,resizable=yes'
|
||||||
|
+ (Zotero.Integration.usePopup ? ',popup' : ''),
|
||||||
|
io
|
||||||
|
);
|
||||||
|
|
||||||
if(citation && !io.citation.citationItems.length) {
|
if(citation && !io.citation.citationItems.length) {
|
||||||
io.citation = citation;
|
io.citation = citation;
|
||||||
|
@ -1331,9 +1341,13 @@ Zotero.Integration.Session.prototype.editBibliography = function() {
|
||||||
|
|
||||||
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||||
.getService(Components.interfaces.nsIWindowWatcher)
|
.getService(Components.interfaces.nsIWindowWatcher)
|
||||||
.openWindow(null, 'chrome://zotero/content/editBibliographyDialog.xul', '',
|
.openWindow(
|
||||||
'chrome,modal,centerscreen,resizable=yes' + (Zotero.isWin ? ',popup' : ''), io, true);
|
null, 'chrome://zotero/content/editBibliographyDialog.xul', '',
|
||||||
|
'chrome,modal,centerscreen,resizable=yes'
|
||||||
|
+ (Zotero.Integration.usePopup ? ',popup' : ''),
|
||||||
|
io,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView = function(itemGroup, sourcesOnly)
|
Zotero.ItemTreeView = function(itemGroup, sourcesOnly)
|
||||||
{
|
{
|
||||||
|
this.wrappedJSObject = this;
|
||||||
|
|
||||||
this._initialized = false;
|
this._initialized = false;
|
||||||
|
|
||||||
this._itemGroup = itemGroup;
|
this._itemGroup = itemGroup;
|
||||||
|
@ -1347,6 +1349,20 @@ Zotero.ItemTreeView.prototype.rememberSelection = function(selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.ItemTreeView.prototype.selectSearchMatches = function () {
|
||||||
|
if (this._searchMode) {
|
||||||
|
var ids = [];
|
||||||
|
for (var id in this._searchItemIDs) {
|
||||||
|
ids.push(id);
|
||||||
|
}
|
||||||
|
this.rememberSelection(ids);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.selection.clearSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.saveOpenState = function() {
|
Zotero.ItemTreeView.prototype.saveOpenState = function() {
|
||||||
var ids = [];
|
var ids = [];
|
||||||
for (var i=0, len=this.rowCount; i<len; i++) {
|
for (var i=0, len=this.rowCount; i<len; i++) {
|
||||||
|
@ -1521,9 +1537,15 @@ Zotero.ItemTreeCommandController.prototype.isCommandEnabled = function(cmd)
|
||||||
|
|
||||||
Zotero.ItemTreeCommandController.prototype.doCommand = function(cmd)
|
Zotero.ItemTreeCommandController.prototype.doCommand = function(cmd)
|
||||||
{
|
{
|
||||||
if(cmd == 'cmd_selectAll')
|
if (cmd == 'cmd_selectAll') {
|
||||||
|
if (this.tree.view.wrappedJSObject._itemGroup.isSearchMode()) {
|
||||||
|
this.tree.view.wrappedJSObject.selectSearchMatches();
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.tree.view.selection.selectAll();
|
this.tree.view.selection.selectAll();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
|
Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
|
||||||
{
|
{
|
||||||
|
@ -1532,16 +1554,17 @@ Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
/// Drag-and-drop functions:
|
/// Drag-and-drop functions
|
||||||
/// for nsDragAndDrop.js + nsTransferable.js
|
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Begin a drag
|
* Start a drag using nsDragAndDrop.js or HTML 5 Drag and Drop
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
|
Zotero.ItemTreeView.prototype.onDragStart = function (event, transferData, action) {
|
||||||
{
|
// Use nsDragAndDrop.js interface for Firefox 2 and Firefox 3.0
|
||||||
|
var oldMethod = Zotero.isFx2 || Zotero.isFx30;
|
||||||
|
|
||||||
// Quick implementation of dragging of XML item format
|
// Quick implementation of dragging of XML item format
|
||||||
if (this.readOnly) {
|
if (this.readOnly) {
|
||||||
var items = this.getSelectedItems();
|
var items = this.getSelectedItems();
|
||||||
|
@ -1552,30 +1575,93 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
|
||||||
xml.items.item += xmlNode;
|
xml.items.item += xmlNode;
|
||||||
}
|
}
|
||||||
Zotero.debug(xml.toXMLString());
|
Zotero.debug(xml.toXMLString());
|
||||||
|
if (oldMethod) {
|
||||||
transferData.data = new TransferData();
|
transferData.data = new TransferData();
|
||||||
transferData.data.addDataForFlavour("zotero/item-xml", xml.toXMLString());
|
transferData.data.addDataForFlavour("zotero/item-xml", xml.toXMLString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.dataTransfer.setData("zotero/item-xml", xml.toXMLString());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var itemIDs = this.saveSelection();
|
||||||
|
var items = Zotero.Items.get(itemIDs);
|
||||||
|
|
||||||
|
if (oldMethod) {
|
||||||
transferData.data = new TransferData();
|
transferData.data = new TransferData();
|
||||||
transferData.data.addDataForFlavour("zotero/item", this.saveSelection());
|
transferData.data.addDataForFlavour("zotero/item", itemIDs.join());
|
||||||
|
}
|
||||||
var items = Zotero.Items.get(this.saveSelection());
|
else {
|
||||||
|
event.dataTransfer.setData("zotero/item", itemIDs.join());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multi-file drag
|
||||||
|
// - Doesn't work on Firefox >=3.0/Windows
|
||||||
|
if (Zotero.isFx2 || !Zotero.isWin) {
|
||||||
// If at least one file is a non-web-link attachment and can be found,
|
// If at least one file is a non-web-link attachment and can be found,
|
||||||
// enable dragging to file system
|
// enable dragging to file system
|
||||||
for (var i=0; i<items.length; i++) {
|
for (var i=0; i<items.length; i++) {
|
||||||
if (items[i].isAttachment() &&
|
if (items[i].isAttachment()
|
||||||
items[i].attachmentLinkMode != Zotero.Attachments.LINK_MODE_LINKED_URL
|
&& items[i].attachmentLinkMode
|
||||||
|
!= Zotero.Attachments.LINK_MODE_LINKED_URL
|
||||||
&& items[i].getFile()) {
|
&& items[i].getFile()) {
|
||||||
transferData.data.addDataForFlavour("application/x-moz-file-promise",
|
Zotero.debug("Adding file via x-moz-file-promise");
|
||||||
new Zotero.ItemTreeView.fileDragDataProvider(), 0, Components.interfaces.nsISupports);
|
if (oldMethod) {
|
||||||
|
transferData.data.addDataForFlavour(
|
||||||
|
"application/x-moz-file-promise",
|
||||||
|
new Zotero.ItemTreeView.fileDragDataProvider(),
|
||||||
|
0,
|
||||||
|
Components.interfaces.nsISupports
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.dataTransfer.mozSetDataAt(
|
||||||
|
"application/x-moz-file-promise",
|
||||||
|
new Zotero.ItemTreeView.fileDragDataProvider(),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// Copy first file on Firefox >=3.0 Windows
|
||||||
|
else {
|
||||||
|
var index = 0;
|
||||||
|
for (var i=0; i<items.length; i++) {
|
||||||
|
if (items[i].isAttachment() &&
|
||||||
|
items[i].getAttachmentLinkMode() != Zotero.Attachments.LINK_MODE_LINKED_URL) {
|
||||||
|
var file = items[i].getFile();
|
||||||
|
if (!file) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fph = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||||
|
.createInstance(Components.interfaces.nsIFileProtocolHandler);
|
||||||
|
var uri = fph.getURLSpecFromFile(file);
|
||||||
|
|
||||||
|
if (oldMethod) {
|
||||||
|
transferData.data.addDataForFlavour("text/x-moz-url", uri + "\n" + file.leafName);
|
||||||
|
transferData.data.addDataForFlavour("application/x-moz-file", file);
|
||||||
|
transferData.data.addDataForFlavour("application/x-moz-file-promise-url", uri);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.dataTransfer.mozSetDataAt("text/x-moz-url", uri + "\n" + file.leafName, index);
|
||||||
|
event.dataTransfer.mozSetDataAt("application/x-moz-file", file, index);
|
||||||
|
event.dataTransfer.mozSetDataAt("application/x-moz-file-promise-url", uri, index);
|
||||||
|
// DEBUG: possible to drag multiple files without x-moz-file-promise?
|
||||||
|
break;
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get Quick Copy format for current URL
|
// Get Quick Copy format for current URL
|
||||||
var url = this._ownerDocument.defaultView.content.location.href;
|
var url = this._ownerDocument.defaultView.content ?
|
||||||
|
this._ownerDocument.defaultView.content.location.href : null;
|
||||||
var format = Zotero.QuickCopy.getFormatFromURL(url);
|
var format = Zotero.QuickCopy.getFormatFromURL(url);
|
||||||
|
|
||||||
Zotero.debug("Dragging with format " + Zotero.QuickCopy.getFormattedNameFromSetting(format));
|
Zotero.debug("Dragging with format " + Zotero.QuickCopy.getFormattedNameFromSetting(format));
|
||||||
|
@ -1587,8 +1673,13 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = obj.output.replace(/\r\n/g, "\n");
|
var text = obj.output.replace(/\r\n/g, "\n");
|
||||||
|
if (oldMethod) {
|
||||||
transferData.data.addDataForFlavour("text/unicode", text);
|
transferData.data.addDataForFlavour("text/unicode", text);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
event.dataTransfer.setData("text/plain", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var [mode, ] = format.split('=');
|
var [mode, ] = format.split('=');
|
||||||
|
@ -1596,11 +1687,19 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
|
||||||
Zotero.QuickCopy.getContentFromItems(items, format, exportCallback);
|
Zotero.QuickCopy.getContentFromItems(items, format, exportCallback);
|
||||||
}
|
}
|
||||||
else if (mode.indexOf('bibliography') == 0) {
|
else if (mode.indexOf('bibliography') == 0) {
|
||||||
var content = Zotero.QuickCopy.getContentFromItems(items, format, null, evt.shiftKey);
|
var content = Zotero.QuickCopy.getContentFromItems(items, format, null, event.shiftKey);
|
||||||
transferData.data.addDataForFlavour("text/unicode", content.text);
|
if (oldMethod) {
|
||||||
if (content.html) {
|
if (content.html) {
|
||||||
transferData.data.addDataForFlavour("text/html", content.html);
|
transferData.data.addDataForFlavour("text/html", content.html);
|
||||||
}
|
}
|
||||||
|
transferData.data.addDataForFlavour("text/unicode", content.text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (content.html) {
|
||||||
|
event.dataTransfer.setData("text/html", content.html);
|
||||||
|
}
|
||||||
|
event.dataTransfer.setData("text/plain", content.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Components.utils.reportError("Invalid Quick Copy mode '" + mode + "'");
|
Components.utils.reportError("Invalid Quick Copy mode '" + mode + "'");
|
||||||
|
@ -1613,6 +1712,8 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
|
||||||
|
|
||||||
|
|
||||||
// Implements nsIFlavorDataProvider for dragging attachment files to OS
|
// Implements nsIFlavorDataProvider for dragging attachment files to OS
|
||||||
|
//
|
||||||
|
// Not used on Windows in Firefox 3 or higher
|
||||||
Zotero.ItemTreeView.fileDragDataProvider = function() { };
|
Zotero.ItemTreeView.fileDragDataProvider = function() { };
|
||||||
|
|
||||||
Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
|
@ -1641,6 +1742,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
var items = {};
|
var items = {};
|
||||||
transferable.getTransferData("zotero/item", items, dataSize);
|
transferable.getTransferData("zotero/item", items, dataSize);
|
||||||
items.value.QueryInterface(Components.interfaces.nsISupportsString);
|
items.value.QueryInterface(Components.interfaces.nsISupportsString);
|
||||||
|
|
||||||
var draggedItems = Zotero.Items.get(items.value.data.split(','));
|
var draggedItems = Zotero.Items.get(items.value.data.split(','));
|
||||||
|
|
||||||
var items = [];
|
var items = [];
|
||||||
|
@ -1832,11 +1934,12 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Called by nsDragAndDrop.js for any sort of drop on the tree
|
* Returns the supported drag flavours
|
||||||
|
*
|
||||||
|
* Called by nsDragAndDrop.js
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.getSupportedFlavours = function ()
|
Zotero.ItemTreeView.prototype.getSupportedFlavours = function () {
|
||||||
{
|
|
||||||
var flavors = new FlavourSet();
|
var flavors = new FlavourSet();
|
||||||
flavors.appendFlavour("zotero/item");
|
flavors.appendFlavour("zotero/item");
|
||||||
flavors.appendFlavour("zotero/item-xml");
|
flavors.appendFlavour("zotero/item-xml");
|
||||||
|
@ -1845,47 +1948,26 @@ Zotero.ItemTreeView.prototype.getSupportedFlavours = function ()
|
||||||
return flavors;
|
return flavors;
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
|
|
||||||
|
Zotero.ItemTreeView.prototype.canDrop = function(row, orient, dragData)
|
||||||
{
|
{
|
||||||
|
//Zotero.debug("Row is " + row + "; orient is " + orient);
|
||||||
|
|
||||||
if (row == -1 && orient == -1) {
|
if (row == -1 && orient == -1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
if (!dragData) {
|
||||||
{
|
var dragData = Zotero.DragDrop.getDragData(this);
|
||||||
var dataSet = nsTransferable.get(this.getSupportedFlavours(),
|
|
||||||
nsDragAndDrop.getDragData, true);
|
|
||||||
}
|
}
|
||||||
catch (e)
|
if (!dragData) {
|
||||||
{
|
|
||||||
// A work around a limitation in nsDragAndDrop.js -- the mDragSession
|
|
||||||
// is not set until the drag moves over another control.
|
|
||||||
// (This will only happen if the first drag is from the item list.)
|
|
||||||
nsDragAndDrop.mDragSession = nsDragAndDrop.mDragService.getCurrentSession();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
var dataType = dragData.dataType;
|
||||||
|
var data = dragData.data;
|
||||||
|
|
||||||
var data = dataSet.first.first;
|
if (dataType == 'zotero/item') {
|
||||||
var dataType = data.flavour.contentType;
|
var ids = data;
|
||||||
|
|
||||||
//Zotero.debug("Drag data type is " + dataType);
|
|
||||||
|
|
||||||
switch (dataType) {
|
|
||||||
case 'zotero/item':
|
|
||||||
var ids = data.data.split(','); // ids of rows we are dragging in
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'text/x-moz-url':
|
|
||||||
var url = data.data.split("\n")[0];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'application/x-moz-file':
|
|
||||||
var file = data.data;
|
|
||||||
// Don't allow folder drag
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround... two different services call canDrop
|
// workaround... two different services call canDrop
|
||||||
|
@ -1929,9 +2011,6 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zotero.debug('row is ' + row);
|
|
||||||
//Zotero.debug('orient is ' + orient);
|
|
||||||
|
|
||||||
// Highlight the rows correctly on drag
|
// Highlight the rows correctly on drag
|
||||||
|
|
||||||
var rowItem = this._getItemAtRow(row).ref; //the item we are dragging over
|
var rowItem = this._getItemAtRow(row).ref; //the item we are dragging over
|
||||||
|
@ -1997,30 +2076,17 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
|
||||||
*/
|
*/
|
||||||
Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
||||||
{
|
{
|
||||||
try
|
var dragData = Zotero.DragDrop.getDragData(this);
|
||||||
{
|
|
||||||
var dataSet = nsTransferable.get(this.getSupportedFlavours(),
|
|
||||||
nsDragAndDrop.getDragData, true);
|
|
||||||
}
|
|
||||||
catch (e)
|
|
||||||
{
|
|
||||||
// A work around a limitation in nsDragAndDrop.js -- the mDragSession
|
|
||||||
// is not set until the drag moves over another control.
|
|
||||||
// (This will only happen if the first drag is from the item list.)
|
|
||||||
nsDragAndDrop.mDragSession = nsDragAndDrop.mDragService.getCurrentSession();
|
|
||||||
var dataSet = nsTransferable.get(this.getSupportedFlavours(),
|
|
||||||
nsDragAndDrop.getDragData, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = dataSet.first.first;
|
if (!this.canDrop(row, orient, dragData)) {
|
||||||
var dataType = data.flavour.contentType;
|
|
||||||
|
|
||||||
if (!this.canDrop(row, orient)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dataType = dragData.dataType;
|
||||||
|
var data = dragData.data;
|
||||||
|
|
||||||
if (dataType == 'zotero/item') {
|
if (dataType == 'zotero/item') {
|
||||||
var ids = data.data.split(','); // ids of rows we are dragging in
|
var ids = data;
|
||||||
|
|
||||||
// Dropped directly on a row
|
// Dropped directly on a row
|
||||||
if (orient == 0)
|
if (orient == 0)
|
||||||
|
@ -2083,12 +2149,11 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
||||||
|
|
||||||
var unlock = Zotero.Notifier.begin(true);
|
var unlock = Zotero.Notifier.begin(true);
|
||||||
try {
|
try {
|
||||||
var dataList = dataSet.dataList;
|
for (var i=0; i<data.length; i++) {
|
||||||
for (var i=0, len=dataList.length; i<len; i++) {
|
var file = data[i];
|
||||||
var file = dataList[i].first.data;
|
|
||||||
|
|
||||||
if (dataType == 'text/x-moz-url') {
|
if (dataType == 'text/x-moz-url') {
|
||||||
var url = file.split("\n")[0];
|
var url = data[i];
|
||||||
|
|
||||||
if (url.indexOf('file:///') == 0) {
|
if (url.indexOf('file:///') == 0) {
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
|
@ -2141,12 +2206,30 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Zotero.ItemTreeView.prototype.onDragEnter = function (event) {
|
||||||
* Called by nsDragAndDrop.js for any sort of drop on the tree
|
Zotero.debug("Storing current drag data");
|
||||||
*/
|
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||||
Zotero.ItemTreeView.prototype.onDrop = function (evt,dropdata,session){ }
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by nsDragAndDrop.js and HTML 5 Drag and Drop when dragging over the tree
|
||||||
|
*/
|
||||||
|
Zotero.ItemTreeView.prototype.onDragOver = function (event, dropdata, session) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called by nsDragAndDrop.js and HTML 5 Drag and Drop when dropping onto the tree
|
||||||
|
*/
|
||||||
|
Zotero.ItemTreeView.prototype.onDrop = function (event, dropdata, session) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Zotero.ItemTreeView.prototype.onDragExit = function (event) {
|
||||||
|
Zotero.debug("Clearing drag data");
|
||||||
|
Zotero.DragDrop.currentDataTransfer = null;
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.ItemTreeView.prototype.onDragOver = function (evt,dropdata,session) { }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
///
|
///
|
||||||
|
|
|
@ -31,19 +31,21 @@ Zotero.Report = new function() {
|
||||||
/^http:\/\/([^\.]*\.)?nytimes\.com/
|
/^http:\/\/([^\.]*\.)?nytimes\.com/
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var escapeXML = function (str) {
|
||||||
|
str = str.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/g, '\u2B1A');
|
||||||
|
return Zotero.Utilities.prototype.htmlSpecialChars(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function generateHTMLDetails(items, combineChildItems) {
|
function generateHTMLDetails(items, combineChildItems) {
|
||||||
var ZU = new Zotero.Utilities();
|
|
||||||
var escapeXML = ZU.htmlSpecialChars;
|
|
||||||
|
|
||||||
var content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ';
|
var content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ';
|
||||||
content += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
|
content += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
|
||||||
content += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
|
content += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
|
||||||
content += '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
|
content += '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n';
|
||||||
content += '<title>' + Zotero.getString('report.title.default') + '</title>\n';
|
content += '<title>' + Zotero.getString('report.title.default') + '</title>\n';
|
||||||
content += '<link rel="stylesheet" type="text/css" href="chrome://zotero/skin/report/detail.css"/>\n';
|
content += '<link rel="stylesheet" type="text/css" href="zotero://report/detail.css"/>\n';
|
||||||
content += '<link rel="stylesheet" type="text/css" media="screen,projection" href="chrome://zotero/skin/report/detail_screen.css"/>\n';
|
content += '<link rel="stylesheet" type="text/css" media="screen,projection" href="zotero://report/detail_screen.css"/>\n';
|
||||||
content += '<link rel="stylesheet" type="text/css" media="print" href="chrome://zotero/skin/report/detail_print.css"/>\n';
|
content += '<link rel="stylesheet" type="text/css" media="print" href="zotero://report/detail_print.css"/>\n';
|
||||||
content += '</head>\n\n<body>\n';
|
content += '</head>\n\n<body>\n';
|
||||||
|
|
||||||
content += '<ul class="report' + (combineChildItems ? ' combineChildItems' : '') + '">\n';
|
content += '<ul class="report' + (combineChildItems ? ' combineChildItems' : '') + '">\n';
|
||||||
|
@ -142,9 +144,6 @@ Zotero.Report = new function() {
|
||||||
|
|
||||||
|
|
||||||
function _generateMetadataTable(arr) {
|
function _generateMetadataTable(arr) {
|
||||||
var ZU = new Zotero.Utilities();
|
|
||||||
var escapeXML = ZU.htmlSpecialChars;
|
|
||||||
|
|
||||||
var table = false;
|
var table = false;
|
||||||
var content = '<table>\n';
|
var content = '<table>\n';
|
||||||
|
|
||||||
|
@ -220,7 +219,7 @@ Zotero.Report = new function() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
arr[i] = ZU.trim(arr[i] + '');
|
arr[i] = Zotero.Utilities.prototype.trim(arr[i] + '');
|
||||||
|
|
||||||
// Skip empty fields
|
// Skip empty fields
|
||||||
if (!arr[i]) {
|
if (!arr[i]) {
|
||||||
|
@ -303,9 +302,6 @@ Zotero.Report = new function() {
|
||||||
|
|
||||||
|
|
||||||
function _generateTagsList(arr) {
|
function _generateTagsList(arr) {
|
||||||
var ZU = new Zotero.Utilities();
|
|
||||||
var escapeXML = ZU.htmlSpecialChars;
|
|
||||||
|
|
||||||
var content = '';
|
var content = '';
|
||||||
if (arr['tags'] && arr['tags'].length) {
|
if (arr['tags'] && arr['tags'].length) {
|
||||||
var str = Zotero.getString('report.tags');
|
var str = Zotero.getString('report.tags');
|
||||||
|
@ -321,9 +317,6 @@ Zotero.Report = new function() {
|
||||||
|
|
||||||
|
|
||||||
function _generateAttachmentsList(arr) {
|
function _generateAttachmentsList(arr) {
|
||||||
var ZU = new Zotero.Utilities();
|
|
||||||
var escapeXML = ZU.htmlSpecialChars;
|
|
||||||
|
|
||||||
var content = '';
|
var content = '';
|
||||||
if (arr.attachments && arr.attachments.length) {
|
if (arr.attachments && arr.attachments.length) {
|
||||||
content += '<h3 class="attachments">' + escapeXML(Zotero.getString('itemFields.attachments')) + '</h3>\n';
|
content += '<h3 class="attachments">' + escapeXML(Zotero.getString('itemFields.attachments')) + '</h3>\n';
|
||||||
|
|
|
@ -1204,6 +1204,11 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
|
||||||
var uri = IOService.newURI(item.path, "", null);
|
var uri = IOService.newURI(item.path, "", null);
|
||||||
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
|
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
|
||||||
|
|
||||||
|
if (file.path == '/') {
|
||||||
|
Zotero.debug("Translate: Ignoring attachment '" + item.path + "': error parsing path", 2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
// use item title if possible, or else file leaf name
|
// use item title if possible, or else file leaf name
|
||||||
var title = item.title;
|
var title = item.title;
|
||||||
|
|
|
@ -123,6 +123,8 @@ var Zotero = new function(){
|
||||||
getService(Components.interfaces.nsIXULAppInfo)
|
getService(Components.interfaces.nsIXULAppInfo)
|
||||||
this.isFx2 = appInfo.platformVersion.indexOf('1.8') === 0; // TODO: remove
|
this.isFx2 = appInfo.platformVersion.indexOf('1.8') === 0; // TODO: remove
|
||||||
this.isFx3 = appInfo.platformVersion.indexOf('1.9') === 0;
|
this.isFx3 = appInfo.platformVersion.indexOf('1.9') === 0;
|
||||||
|
this.isFx30 = appInfo.platformVersion.indexOf('1.9.0') === 0;
|
||||||
|
this.isFx31 = appInfo.platformVersion.indexOf('1.9.1') === 0;
|
||||||
|
|
||||||
// OS platform
|
// OS platform
|
||||||
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
var win = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
||||||
|
@ -1903,6 +1905,122 @@ Zotero.Date = new function(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.DragDrop = {
|
||||||
|
currentDataTransfer: null,
|
||||||
|
|
||||||
|
getDragData: function (element, firstOnly) {
|
||||||
|
var dragData = {
|
||||||
|
dataType: '',
|
||||||
|
data: []
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use nsDragAndDrop.js interface for Firefox 2 and Firefox 3.0
|
||||||
|
var oldMethod = Zotero.isFx2 || Zotero.isFx30;
|
||||||
|
if (oldMethod) {
|
||||||
|
try {
|
||||||
|
var dataSet = nsTransferable.get(
|
||||||
|
element.getSupportedFlavours(),
|
||||||
|
nsDragAndDrop.getDragData,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// A work around a limitation in nsDragAndDrop.js -- the mDragSession
|
||||||
|
// is not set until the drag moves over another control.
|
||||||
|
// (This will only happen if the first drag is from the item list.)
|
||||||
|
nsDragAndDrop.mDragSession = nsDragAndDrop.mDragService.getCurrentSession();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var firstData = dataSet.first.first;
|
||||||
|
dragData.dataType = firstData.flavour.contentType;
|
||||||
|
|
||||||
|
var dataList = dataSet.dataList;
|
||||||
|
var len = firstOnly ? 1 : dataList.length;
|
||||||
|
|
||||||
|
//Zotero.debug("Drag data type is " + dragData.dataType);
|
||||||
|
|
||||||
|
switch (dragData.dataType) {
|
||||||
|
case 'zotero/collection':
|
||||||
|
case 'zotero/item':
|
||||||
|
var ids = firstData.data.split(','); // ids of rows we are dragging in
|
||||||
|
dragData.data = ids;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'text/x-moz-url':
|
||||||
|
var urls = [];
|
||||||
|
for (var i=0; i<len; i++) {
|
||||||
|
var url = dataList[i].first.data.split("\n")[0];
|
||||||
|
urls.push(url);
|
||||||
|
}
|
||||||
|
dragData.data = urls;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'application/x-moz-file':
|
||||||
|
var files = [];
|
||||||
|
for (var i=0; i<len; i++) {
|
||||||
|
var file = dataList[i].first.data;
|
||||||
|
file.QueryInterface(Components.interfaces.nsIFile);
|
||||||
|
// Don't allow folder drag
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
dragData.data = files;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Firefox 3.1 and higher
|
||||||
|
else {
|
||||||
|
var dt = this.currentDataTransfer;
|
||||||
|
if (!dt) {
|
||||||
|
Zotero.debug("Drag data not available");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var len = firstOnly ? 1 : dt.mozItemCount;
|
||||||
|
|
||||||
|
if (dt.types.contains('zotero/collection')) {
|
||||||
|
dragData.dataType = 'zotero/collection';
|
||||||
|
var ids = dt.getData('zotero/collection').split(",");
|
||||||
|
dragData.data = ids;
|
||||||
|
}
|
||||||
|
else if (dt.types.contains('zotero/item')) {
|
||||||
|
dragData.dataType = 'zotero/item';
|
||||||
|
var ids = dt.getData('zotero/item').split(",");
|
||||||
|
dragData.data = ids;
|
||||||
|
}
|
||||||
|
else if (dt.types.contains('application/x-moz-file')) {
|
||||||
|
dragData.dataType = 'application/x-moz-file';
|
||||||
|
var files = [];
|
||||||
|
for (var i=0; i<len; i++) {
|
||||||
|
var file = dt.mozGetDataAt("application/x-moz-file", i);
|
||||||
|
file.QueryInterface(Components.interfaces.nsIFile);
|
||||||
|
// Don't allow folder drag
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
files.push(file);
|
||||||
|
}
|
||||||
|
dragData.data = files;
|
||||||
|
}
|
||||||
|
else if (dt.types.contains('text/x-moz-url')) {
|
||||||
|
dragData.dataType = 'text/x-moz-url';
|
||||||
|
var urls = [];
|
||||||
|
for (var i=0; i<len; i++) {
|
||||||
|
var url = dt.getData("application/x-moz-url", i).split("\n")[0];
|
||||||
|
urls.push(url);
|
||||||
|
}
|
||||||
|
dragData.data = urls;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dragData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions for creating and destroying hidden browser objects
|
* Functions for creating and destroying hidden browser objects
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -73,7 +73,7 @@ function ChromeExtensionHandler() {
|
||||||
var ReportExtension = new function(){
|
var ReportExtension = new function(){
|
||||||
this.newChannel = newChannel;
|
this.newChannel = newChannel;
|
||||||
|
|
||||||
this.__defineGetter__('loadAsChrome', function () { return true; });
|
this.__defineGetter__('loadAsChrome', function () { return false; });
|
||||||
|
|
||||||
function newChannel(uri){
|
function newChannel(uri){
|
||||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
|
@ -119,6 +119,22 @@ function ChromeExtensionHandler() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
// Proxy CSS files
|
||||||
|
if (type.match(/^detail.*\.css$/)) {
|
||||||
|
var chromeURL = 'chrome://zotero/skin/report/' + type;
|
||||||
|
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIIOService);
|
||||||
|
var uri = ios.newURI(chromeURL, null, null);
|
||||||
|
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||||
|
.getService(Components.interfaces.nsIChromeRegistry);
|
||||||
|
var fileURI = chromeReg.convertChromeURL(uri);
|
||||||
|
var ph = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||||
|
.createInstance(Components.interfaces.nsIFileProtocolHandler);
|
||||||
|
var channel = ioService.newChannelFromURI(fileURI);
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display all items
|
||||||
var type = 'library';
|
var type = 'library';
|
||||||
var s = new Zotero.Search();
|
var s = new Zotero.Search();
|
||||||
s.addCondition('noChildren', 'true');
|
s.addCondition('noChildren', 'true');
|
||||||
|
@ -753,7 +769,6 @@ function ChromeExtensionHandler() {
|
||||||
|
|
||||||
var SelectExtensionSpec = ZOTERO_SCHEME + "://select"
|
var SelectExtensionSpec = ZOTERO_SCHEME + "://select"
|
||||||
this._extensions[SelectExtensionSpec] = SelectExtension;
|
this._extensions[SelectExtensionSpec] = SelectExtension;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -768,7 +783,12 @@ ChromeExtensionHandler.prototype = {
|
||||||
protocolFlags :
|
protocolFlags :
|
||||||
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE |
|
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE |
|
||||||
Components.interfaces.nsIProtocolHandler.URI_NOAUTH |
|
Components.interfaces.nsIProtocolHandler.URI_NOAUTH |
|
||||||
Components.interfaces.nsIProtocolHandler.URI_IS_LOCAL_FILE,
|
// DEBUG: This should be URI_IS_LOCAL_FILE, and MUST be if any
|
||||||
|
// extensions that modify data are added
|
||||||
|
// - https://www.zotero.org/trac/ticket/1156
|
||||||
|
//
|
||||||
|
//Components.interfaces.nsIProtocolHandler.URI_IS_LOCAL_FILE,
|
||||||
|
Components.interfaces.nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,
|
||||||
|
|
||||||
allowPort : function(port, scheme) {
|
allowPort : function(port, scheme) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -78,6 +78,7 @@ pref("extensions.zotero.export.quickCopy.setting", 'bibliography=http://www.zote
|
||||||
// Integration settings
|
// Integration settings
|
||||||
pref("extensions.zotero.integration.port", 50001);
|
pref("extensions.zotero.integration.port", 50001);
|
||||||
pref("extensions.zotero.integration.autoRegenerate", -1); // -1 = ask; 0 = no; 1 = yes
|
pref("extensions.zotero.integration.autoRegenerate", -1); // -1 = ask; 0 = no; 1 = yes
|
||||||
|
pref("extensions.zotero.integration.realWindow", false);
|
||||||
|
|
||||||
// Zeroconf
|
// Zeroconf
|
||||||
pref("extensions.zotero.zeroconf.server.enabled", false);
|
pref("extensions.zotero.zeroconf.server.enabled", false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user