Closes #518, Support drag and drop in advanced search window
Also fix occasional throw error when first dragging to a collection
This commit is contained in:
parent
fb22bd04ba
commit
5313aff1a2
|
@ -6,8 +6,9 @@ var ZoteroAdvancedSearch = new function() {
|
|||
this.onDblClick = onDblClick;
|
||||
this.onUnload = onUnload;
|
||||
|
||||
this.itemsView = false;
|
||||
|
||||
var _searchBox;
|
||||
var _itemsView;
|
||||
|
||||
function onLoad() {
|
||||
_searchBox = document.getElementById('zotero-search-box');
|
||||
|
@ -31,18 +32,18 @@ var ZoteroAdvancedSearch = new function() {
|
|||
isSearch: function () { return true; }
|
||||
}
|
||||
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
if (this.itemsView) {
|
||||
this.itemsView.unregister();
|
||||
}
|
||||
|
||||
_itemsView = new Zotero.ItemTreeView(itemGroup, false);
|
||||
document.getElementById('zotero-items-tree').view = _itemsView;
|
||||
this.itemsView = new Zotero.ItemTreeView(itemGroup, false);
|
||||
document.getElementById('zotero-items-tree').view = this.itemsView;
|
||||
}
|
||||
|
||||
|
||||
function clear() {
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
if (this.itemsView) {
|
||||
this.itemsView.unregister();
|
||||
}
|
||||
document.getElementById('zotero-items-tree').view = null;
|
||||
|
||||
|
@ -90,9 +91,9 @@ var ZoteroAdvancedSearch = new function() {
|
|||
tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
|
||||
// obj.value == cell/text/image
|
||||
// TODO: handle collection double-click
|
||||
if (obj.value && _itemsView && _itemsView.selection.currentIndex > -1)
|
||||
if (obj.value && this.itemsView && this.itemsView.selection.currentIndex > -1)
|
||||
{
|
||||
var item = _itemsView.getSelectedItems()[0];
|
||||
var item = this.itemsView.getSelectedItems()[0];
|
||||
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
@ -118,8 +119,8 @@ var ZoteroAdvancedSearch = new function() {
|
|||
|
||||
function onUnload() {
|
||||
// Unregister search from Notifier
|
||||
if (_itemsView) {
|
||||
_itemsView.unregister();
|
||||
if (this.itemsView) {
|
||||
this.itemsView.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
<script src="include.js"/>
|
||||
<script src="advancedSearch.js"/>
|
||||
<script src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script src="chrome://global/content/nsTransferable.js"/>
|
||||
|
||||
<hbox>
|
||||
<zoterosearch id="zotero-search-box" oncommand="ZoteroAdvancedSearch.search()" flex="1"/>
|
||||
|
@ -33,7 +35,8 @@
|
|||
</hbox>
|
||||
|
||||
<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); }">
|
||||
<treecols>
|
||||
<treecol
|
||||
id="zotero-items-column-title" primary="true"
|
||||
|
|
|
@ -1046,7 +1046,7 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
|
|||
// DISABLED: move parent on child drag
|
||||
//var source = item.isRegularItem() ? false : item.getSource();
|
||||
//if (!this._itemGroup.ref.hasItem(source ? source : id))
|
||||
if (!this._itemGroup.ref.hasItem(id))
|
||||
if (this._itemGroup.ref && !this._itemGroup.ref.hasItem(id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user