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:
Dan Stillman 2007-01-30 21:35:58 +00:00
parent fb22bd04ba
commit 5313aff1a2
3 changed files with 17 additions and 13 deletions

View File

@ -6,8 +6,9 @@ var ZoteroAdvancedSearch = new function() {
this.onDblClick = onDblClick; this.onDblClick = onDblClick;
this.onUnload = onUnload; this.onUnload = onUnload;
this.itemsView = false;
var _searchBox; var _searchBox;
var _itemsView;
function onLoad() { function onLoad() {
_searchBox = document.getElementById('zotero-search-box'); _searchBox = document.getElementById('zotero-search-box');
@ -31,18 +32,18 @@ var ZoteroAdvancedSearch = new function() {
isSearch: function () { return true; } isSearch: function () { return true; }
} }
if (_itemsView) { if (this.itemsView) {
_itemsView.unregister(); this.itemsView.unregister();
} }
_itemsView = new Zotero.ItemTreeView(itemGroup, false); this.itemsView = new Zotero.ItemTreeView(itemGroup, false);
document.getElementById('zotero-items-tree').view = _itemsView; document.getElementById('zotero-items-tree').view = this.itemsView;
} }
function clear() { function clear() {
if (_itemsView) { if (this.itemsView) {
_itemsView.unregister(); this.itemsView.unregister();
} }
document.getElementById('zotero-items-tree').view = null; 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); tree.treeBoxObject.getCellAt(event.clientX, event.clientY, row, col, obj);
// obj.value == cell/text/image // obj.value == cell/text/image
// TODO: handle collection double-click // 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"] var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
@ -118,8 +119,8 @@ var ZoteroAdvancedSearch = new function() {
function onUnload() { function onUnload() {
// Unregister search from Notifier // Unregister search from Notifier
if (_itemsView) { if (this.itemsView) {
_itemsView.unregister(); this.itemsView.unregister();
} }
} }
} }

View File

@ -21,6 +21,8 @@
<script src="include.js"/> <script src="include.js"/>
<script src="advancedSearch.js"/> <script src="advancedSearch.js"/>
<script src="chrome://global/content/nsDragAndDrop.js"/>
<script src="chrome://global/content/nsTransferable.js"/>
<hbox> <hbox>
<zoterosearch id="zotero-search-box" oncommand="ZoteroAdvancedSearch.search()" flex="1"/> <zoterosearch id="zotero-search-box" oncommand="ZoteroAdvancedSearch.search()" flex="1"/>
@ -33,7 +35,8 @@
</hbox> </hbox>
<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); }">
<treecols> <treecols>
<treecol <treecol
id="zotero-items-column-title" primary="true" id="zotero-items-column-title" primary="true"

View File

@ -1046,7 +1046,7 @@ Zotero.ItemTreeView.prototype.canDrop = function(row, orient)
// DISABLED: move parent on child drag // DISABLED: move parent on child drag
//var source = item.isRegularItem() ? false : item.getSource(); //var source = item.isRegularItem() ? false : item.getSource();
//if (!this._itemGroup.ref.hasItem(source ? source : id)) //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; return true;
} }