Remove all references to deprecated nsDragAndDrop, and remove some obsolete drag code
This commit is contained in:
parent
642a857a29
commit
3f28260507
7 changed files with 21 additions and 124 deletions
|
@ -163,11 +163,6 @@ var ZoteroAdvancedSearch = new function() {
|
|||
}
|
||||
|
||||
|
||||
this.startDrag = function (event, element) {
|
||||
element.onDragStart(event);
|
||||
}
|
||||
|
||||
|
||||
function onUnload() {
|
||||
// Unregister search from Notifier
|
||||
if (this.itemsView) {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
<tree id="zotero-items-tree" flex="1" hidecolumnpicker="true" seltype="multiple"
|
||||
ondblclick="ZoteroAdvancedSearch.onDblClick(event, this)"
|
||||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroAdvancedSearch.startDrag(event, ZoteroAdvancedSearch.itemsView); }">
|
||||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroAdvancedSearch.itemsView.onDragStart(event); }">
|
||||
<treecols>
|
||||
<treecol
|
||||
id="zotero-items-column-title" primary="true"
|
||||
|
|
|
@ -2532,26 +2532,6 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
|
||||
this.startDrag = function (event, element) {
|
||||
element.onDragStart(event);
|
||||
}
|
||||
|
||||
|
||||
this.dragEnter = function (event, element) {
|
||||
return element.onDragEnter(event);
|
||||
}
|
||||
|
||||
|
||||
this.dragOver = function (event, element) {
|
||||
return element.onDragOver(event);
|
||||
}
|
||||
|
||||
|
||||
this.dragDrop = function (event, element) {
|
||||
return element.onDrop(event);
|
||||
}
|
||||
|
||||
|
||||
this.openPreferences = function (paneID, action) {
|
||||
var io = {
|
||||
pane: paneID,
|
||||
|
|
|
@ -176,10 +176,10 @@
|
|||
onmouseover="ZoteroPane.collectionsView.setHighlightedRows();"
|
||||
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
||||
onselect="ZoteroPane.onCollectionSelected();" seltype="cell"
|
||||
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)"
|
||||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane.collectionsView.onDragStart(event); }"
|
||||
ondragenter="return ZoteroPane.collectionsView.onDragEnter(event)"
|
||||
ondragover="return ZoteroPane.collectionsView.onDragOver(event)"
|
||||
ondrop="return ZoteroPane.collectionsView.onDrop(event)"
|
||||
flex="1">
|
||||
<treecols>
|
||||
<treecol
|
||||
|
@ -250,10 +250,10 @@
|
|||
onfocus="if (ZoteroPane.itemsView.rowCount && !ZoteroPane.itemsView.selection.count) { ZoteroPane.itemsView.selection.select(0); }"
|
||||
onkeypress="ZoteroPane.handleKeyPress(event, this.id)"
|
||||
onselect="ZoteroPane.itemSelected();"
|
||||
ondraggesture="if (event.target.localName == 'treechildren') { ZoteroPane.startDrag(event, ZoteroPane.itemsView); }"
|
||||
ondragenter="return ZoteroPane.dragEnter(event, ZoteroPane.itemsView)"
|
||||
ondragover="return ZoteroPane.dragOver(event, ZoteroPane.itemsView)"
|
||||
ondragdrop="return ZoteroPane.dragDrop(event, ZoteroPane.itemsView)"
|
||||
ondragstart="if (event.target.localName == 'treechildren') { ZoteroPane.itemsView.onDragStart(event); }"
|
||||
ondragenter="return ZoteroPane.itemsView.onDragEnter(event)"
|
||||
ondragover="return ZoteroPane.itemsView.onDragOver(event)"
|
||||
ondragdrop="return ZoteroPane.itemsView.onDrop(event)"
|
||||
flex="1">
|
||||
<treecols>
|
||||
<treecol
|
||||
|
|
|
@ -216,7 +216,6 @@
|
|||
contentcontextmenu="contentAreaContextMenu"
|
||||
onnewtab="BrowserOpenTab();"
|
||||
autocompletepopup="PopupAutoComplete"
|
||||
ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
|
||||
onclick="return contentAreaClick(event, false);"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
|
|
@ -1021,38 +1021,20 @@ Zotero.CollectionTreeCommandController.prototype.onEvent = function(evt)
|
|||
///
|
||||
/// Drag-and-drop functions:
|
||||
/// canDrop() and drop() are for nsITreeView
|
||||
/// onDragStart(), getSupportedFlavours(), and onDrop() for nsDragAndDrop.js
|
||||
/// onDragStart() and onDrop() are for HTML 5 Drag and Drop
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
/*
|
||||
* Start a drag using HTML 5 Drag and Drop
|
||||
*/
|
||||
Zotero.CollectionTreeView.prototype.onDragStart = function(event, transferData, action) {
|
||||
Zotero.CollectionTreeView.prototype.onDragStart = function(event) {
|
||||
var itemGroup = this._getItemAtRow(this.selection.currentIndex);
|
||||
if (!itemGroup.isCollection()) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
var collectionID = itemGroup.ref.id;
|
||||
|
||||
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;
|
||||
event.dataTransfer.setData("zotero/collection", itemGroup.ref.id);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1063,12 +1045,6 @@ Zotero.CollectionTreeView.prototype.canDrop = function(row, orient, dragData)
|
|||
{
|
||||
//Zotero.debug("Row is " + row + "; orient is " + orient);
|
||||
|
||||
// Two different services call canDrop, nsDragAndDrop and the tree
|
||||
// This is for the former, used when dragging between windows
|
||||
if (typeof row == 'object') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!dragData || !dragData.data) {
|
||||
var dragData = Zotero.DragDrop.getDragData(this);
|
||||
}
|
||||
|
|
|
@ -1775,7 +1775,7 @@ Zotero.ItemTreeCommandController.prototype.onEvent = function(evt)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Start a drag using nsDragAndDrop.js or HTML 5 Drag and Drop
|
||||
* Start a drag using HTML 5 Drag and Drop
|
||||
*/
|
||||
Zotero.ItemTreeView.prototype.onDragStart = function (event) {
|
||||
// Quick implementation of dragging of XML item format
|
||||
|
@ -2106,24 +2106,9 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the supported drag flavours
|
||||
*
|
||||
* Called by nsDragAndDrop.js
|
||||
*/
|
||||
Zotero.ItemTreeView.prototype.getSupportedFlavours = function () {
|
||||
var flavors = new FlavourSet();
|
||||
flavors.appendFlavour("zotero/item");
|
||||
flavors.appendFlavour("zotero/item-xml");
|
||||
flavors.appendFlavour("text/x-moz-url");
|
||||
flavors.appendFlavour("application/x-moz-file", "nsIFile");
|
||||
return flavors;
|
||||
}
|
||||
|
||||
|
||||
Zotero.ItemTreeView.prototype.canDrop = function(row, orient, dragData)
|
||||
{
|
||||
//Zotero.debug("Row is " + row + "; orient is " + orient);
|
||||
Zotero.debug("Row is " + row + "; orient is " + orient);
|
||||
|
||||
if (row == -1 && orient == -1) {
|
||||
//return true;
|
||||
|
@ -2133,6 +2118,7 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient, dragData)
|
|||
var dragData = Zotero.DragDrop.getDragData(this);
|
||||
}
|
||||
if (!dragData) {
|
||||
Zotero.debug("No drag data");
|
||||
return false;
|
||||
}
|
||||
var dataType = dragData.dataType;
|
||||
|
@ -2144,45 +2130,6 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient, dragData)
|
|||
|
||||
var itemGroup = this._itemGroup;
|
||||
|
||||
// workaround... two different services call canDrop
|
||||
// (nsDragAndDrop, and the tree) -- this is for the former,
|
||||
// used when dragging between windows
|
||||
if (typeof row == 'object')
|
||||
{
|
||||
// If drag to different window
|
||||
if (nsDragAndDrop.mDragSession.sourceNode!=row.target)
|
||||
{
|
||||
if (dataType == 'zotero/item') {
|
||||
var items = Zotero.Items.get(ids);
|
||||
|
||||
// Check if at least one item (or parent item for children) doesn't
|
||||
// already exist in target
|
||||
for each(var item in items) {
|
||||
// Skip non-top-level items
|
||||
if (!item.isTopLevelItem()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: For now, disable cross-window cross-library drag
|
||||
if (itemGroup.ref.libraryID != item.libraryID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemGroup.ref && !itemGroup.ref.hasItem(item.id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') {
|
||||
if (itemGroup.isSearch()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (orient == 0) {
|
||||
var rowItem = this._getItemAtRow(row).ref; // the item we are dragging over
|
||||
}
|
||||
|
@ -2423,26 +2370,26 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient)
|
|||
}
|
||||
|
||||
Zotero.ItemTreeView.prototype.onDragEnter = function (event) {
|
||||
Zotero.debug("Storing current drag data");
|
||||
//Zotero.debug("Storing current drag data");
|
||||
Zotero.DragDrop.currentDataTransfer = event.dataTransfer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by nsDragAndDrop.js and HTML 5 Drag and Drop when dragging over the tree
|
||||
* Called by 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
|
||||
* Called by 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.debug("Clearing drag data");
|
||||
Zotero.DragDrop.currentDataTransfer = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue